From: Vladislav Timonin timoninvlad@yandex.ru
--- dlls/comdlg32/navbar.c | 46 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/dlls/comdlg32/navbar.c b/dlls/comdlg32/navbar.c index 77a73482a2a..81d88ff65d1 100644 --- a/dlls/comdlg32/navbar.c +++ b/dlls/comdlg32/navbar.c @@ -95,7 +95,7 @@ static void set_title_and_add_tooltip(NAVBAR_INFO *info, HWND window, UINT strin static void NAVBAR_CalcLayout(NAVBAR_INFO *info) { RECT container_rc, up_button_rc; - struct crumb *crumb1; + struct crumb *crumb1, *crumb2; INT padding, container_w, buttons_w, max_crumbs_w, w = 0, crumbs_visible_n = 0, prev_x; @@ -129,9 +129,11 @@ static void NAVBAR_CalcLayout(NAVBAR_INFO *info) crumbs_visible_n += 1; }
- /* always show at least 1 crumb */ - if (crumbs_visible_n < 1) + /* always show at least 2 crumbs */ + if (crumbs_visible_n < 2) { + w = 0; + crumb1 = (struct crumb *)list_tail(&info->crumbs); if (&crumb1->entry == &info->crumbs) { @@ -139,10 +141,42 @@ static void NAVBAR_CalcLayout(NAVBAR_INFO *info) return; }
- crumb1->current_w = max_crumbs_w; - crumbs_visible_n = 1; + crumb2 = (struct crumb *)list_tail(&crumb1->entry); + if (&crumb2->entry == &info->crumbs) /* only 1 crumb in the list */ + { + if (crumbs_visible_n == 0) /* that doesn't fit on screen */ + { + crumb1->current_w = max_crumbs_w; + crumbs_visible_n = 1; + }
- prev_x = buttons_w + crumb1->current_w; + prev_x = buttons_w + crumb1->current_w; + } + else + { + /* at least 2 crumbs in the list, 1 or 0 crumbs on screen */ + /* last crumb should take as much space as possible */ + INT min_crumb_w = MulDiv(56, info->dpi_x, USER_DEFAULT_SCREEN_DPI); + INT crumb2_size = crumb2->full_w; + + if (crumb2_size > min_crumb_w) + crumb2_size = min_crumb_w; + + /* calculate how much extra space is required to fit both crumbs */ + w = (crumb1->full_w + crumb2_size) - max_crumbs_w; + if (w > 0) + { + /* not enough space for last crumb, truncate it */ + crumb1->current_w = max(0, crumb1->full_w - w); + crumb2->current_w = crumb2_size; + } + else + /* enough space for last crumb, let the previous crumb take leftover space */ + crumb2->current_w = max_crumbs_w - crumb1->full_w; + + crumbs_visible_n = 2; + prev_x = buttons_w + crumb1->current_w + crumb2->current_w; + } } else prev_x = buttons_w + w;