Make Tab Layout setting only accept predefined values (#3564)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2022-02-12 12:27:25 +00:00
committed by GitHub
parent 092f66dc15
commit b2fa7b1d94
3 changed files with 30 additions and 25 deletions
+27 -23
View File
@@ -144,30 +144,34 @@ void GeneralPage::initLayout(GeneralPageView &layout)
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addDropdown<int>(
"Tab layout", {"Horizontal", "Vertical"}, s.tabDirection,
[](auto val) {
switch (val)
{
case NotebookTabDirection::Horizontal:
return "Horizontal";
case NotebookTabDirection::Vertical:
return "Vertical";
}
ComboBox *tabDirectionDropdown =
layout.addDropdown<std::underlying_type<NotebookTabDirection>::type>(
"Tab layout", {"Horizontal", "Vertical"}, s.tabDirection,
[](auto val) {
switch (val)
{
case NotebookTabDirection::Horizontal:
return "Horizontal";
case NotebookTabDirection::Vertical:
return "Vertical";
}
return "";
},
[](auto args) {
if (args.value == "Vertical")
{
return NotebookTabDirection::Vertical;
}
else
{
// default to horizontal
return NotebookTabDirection::Horizontal;
}
});
return "";
},
[](auto args) {
if (args.value == "Vertical")
{
return NotebookTabDirection::Vertical;
}
else
{
// default to horizontal
return NotebookTabDirection::Horizontal;
}
},
false);
tabDirectionDropdown->setMinimumWidth(
tabDirectionDropdown->minimumSizeHint().width());
layout.addCheckbox("Show tab close button", s.showTabCloseButton);
layout.addCheckbox("Always on top", s.windowTopMost);