summaryrefslogtreecommitdiff
path: root/wx+/std_button_layout.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2021-12-06 13:37:35 +0000
committerB. Stack <bgstack15@gmail.com>2021-12-06 13:37:35 +0000
commitf142f32c8d2b53f305cb72cb5953e3394d6a6243 (patch)
tree2999df8f80b28d0f7f60a84b7f75d613e280bba1 /wx+/std_button_layout.h
parentMerge branch 'b11.14' into 'master' (diff)
parentadd upstream 11.15 (diff)
downloadFreeFileSync-f142f32c8d2b53f305cb72cb5953e3394d6a6243.tar.gz
FreeFileSync-f142f32c8d2b53f305cb72cb5953e3394d6a6243.tar.bz2
FreeFileSync-f142f32c8d2b53f305cb72cb5953e3394d6a6243.zip
Merge branch 'b11.15' into 'master'11.15
add upstream 11.15 See merge request opensource-tracking/FreeFileSync!39
Diffstat (limited to 'wx+/std_button_layout.h')
-rw-r--r--wx+/std_button_layout.h61
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);
bgstack15