diff options
author | B. Stack <bgstack15@gmail.com> | 2021-12-06 07:57:52 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2021-12-06 07:57:52 -0500 |
commit | 226ac347c51e21440d1740d85b5e9912d1ce08e5 (patch) | |
tree | 2999df8f80b28d0f7f60a84b7f75d613e280bba1 /wx+/std_button_layout.h | |
parent | Merge branch 'b11.14' into 'master' (diff) | |
download | FreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.tar.gz FreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.tar.bz2 FreeFileSync-226ac347c51e21440d1740d85b5e9912d1ce08e5.zip |
add upstream 11.15
Diffstat (limited to 'wx+/std_button_layout.h')
-rw-r--r-- | wx+/std_button_layout.h | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/wx+/std_button_layout.h b/wx+/std_button_layout.h index 25745132..e84b0c78 100644 --- a/wx+/std_button_layout.h +++ b/wx+/std_button_layout.h @@ -47,6 +47,11 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) { assert(sizer.GetOrientation() == wxHORIZONTAL); + //GNOME Human Interface Guidelines: https://developer.gnome.org/hig-book/3.2/hig-book.html#alert-spacing + const int spaceH = fastFromDIP( 6); //OK + const int spaceRimH = fastFromDIP(12); //OK + const int spaceRimV = fastFromDIP(12); //OK + StdButtons buttonsTmp = buttons; auto detach = [&](wxButton*& btn) @@ -54,15 +59,11 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) if (btn) { assert(btn->GetContainingSizer() == &sizer); - if (btn->IsShown()) - { - bool rv = sizer.Detach(btn); - assert(rv); - if (!rv) - btn = nullptr; - } - else - btn = nullptr; + if (btn->IsShown() && sizer.Detach(btn)) + return; + + assert(false); //why is it hidden!? + btn = nullptr; } }; @@ -71,10 +72,30 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) detach(buttonsTmp.btnNo); detach(buttonsTmp.btnCancel); - //GNOME Human Interface Guidelines: https://developer.gnome.org/hig-book/3.2/hig-book.html#alert-spacing - const int spaceH = fastFromDIP( 6); //OK - const int spaceRimH = fastFromDIP(12); //OK - const int spaceRimV = fastFromDIP(12); //OK + + //"All your fixed-size spacers are belong to us!" => have a clean slate: consider repeated setStandardButtonLayout() calls + for (size_t pos = sizer.GetItemCount(); pos-- > 0;) + if (wxSizerItem& item = *sizer.GetItem(pos); + item.IsSpacer() && item.GetProportion() == 0 && item.GetSize().y == 0) + { + [[maybe_unused]] bool rv = sizer.Detach(pos); + assert(rv); + } + + //set border on left considering existing items + if (!sizer.IsEmpty()) //for yet another retarded reason wxWidgets will have wxSizer::GetItem(0) cause an assert rather than just return nullptr as documented + if (wxSizerItem& item = *sizer.GetItem(static_cast<size_t>(0)); + item.IsShown()) + { + assert(item.GetBorder() <= spaceRimV); //pragmatic check: other controls in the sizer should not have a larger border + + if (const int flag = item.GetFlag(); + flag & wxLEFT) + item.SetFlag(flag & ~wxLEFT); + + sizer.Prepend(spaceRimH, 0); + } + bool settingFirstButton = true; auto attach = [&](wxButton* btn) @@ -93,20 +114,6 @@ void setStandardButtonLayout(wxBoxSizer& sizer, const StdButtons& buttons) } }; - //set border on left considering existing items - if (sizer.GetChildren().GetCount() > 0) //for yet another retarded reason wxWidgets will have wxSizer::GetItem(0) cause an assert rather than just return nullptr as documented - if (wxSizerItem* item = sizer.GetItem(static_cast<size_t>(0))) - { - assert(item->GetBorder() <= spaceRimV); //pragmatic check: other controls in the sizer should not have a larger border - int flag = item->GetFlag(); - if (flag & wxLEFT) - { - flag &= ~wxLEFT; - item->SetFlag(flag); - } - sizer.Insert(static_cast<size_t>(0), spaceRimH, 0); - } - sizer.Add(spaceRimH, 0); attach(buttonsTmp.btnNo); attach(buttonsTmp.btnCancel); |