Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide 'Show toolbars' menu item by default #410

Merged
merged 2 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Development version

### Features

* The 'View/Show toolbars' menu item is now only shown if the shift key is held down when opening the View menu. [[#410](https://github.com/reupen/columns_ui/pull/410)]

* A warning was added under the 'Show toolbars' option in preferences. [[#410](https://github.com/reupen/columns_ui/pull/410)]

### Internal changes

* The component is now compiled using Visual Studio 2022 17.0 and the /std:c++20 compiler option. [[#408](https://github.com/reupen/columns_ui/pull/408), [#409](https://github.com/reupen/columns_ui/pull/409)]
Expand Down
15 changes: 8 additions & 7 deletions foo_ui_columns/foo_ui_columns.rc
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@ BEGIN
PUSHBUTTON "Import configuration...",IDC_FCL_IMPORT,7,53,107,14
PUSHBUTTON "Export configuration...",IDC_FCL_EXPORT,7,77,107,14
LTEXT "Miscellaneous",IDC_TITLE2,7,107,313,14
CONTROL "Show toolbars",IDC_TOOLBARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,130,64,10
PUSHBUTTON "Reset toolbars",IDC_RESET_TOOLBARS,7,148,107,14
CONTROL "Use transparency, opacity",IDC_USE_TRANSPARENCY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,171,100,10
EDITTEXT IDC_TRANSPARENCY_LEVEL,108,170,31,12,ES_AUTOHSCROLL
CONTROL "",IDC_TRANSPARENCY_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,170,11,10
LTEXT "Main window title formatting script",IDC_STATIC,7,189,118,8
EDITTEXT IDC_STRING,7,199,313,65,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
CONTROL "Use transparency, opacity",IDC_USE_TRANSPARENCY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,130,100,10
EDITTEXT IDC_TRANSPARENCY_LEVEL,108,129,31,12,ES_AUTOHSCROLL
CONTROL "",IDC_TRANSPARENCY_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,129,11,10
LTEXT "Main window title formatting script",IDC_STATIC,7,148,118,8
EDITTEXT IDC_STRING,7,158,313,52,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
CONTROL "Show toolbars",IDC_TOOLBARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,219,64,10
LTEXT "Before hiding the toolbars, ensure you have an alternative way of accessing preferences.",IDC_STATIC,7,232,299,8
PUSHBUTTON "Reset toolbars",IDC_RESET_TOOLBARS,7,250,107,14
END

IDD_SPECTRUM_ANALYSER_OPTIONS DIALOGEX 0, 0, 202, 168
Expand Down
9 changes: 6 additions & 3 deletions foo_ui_columns/menu_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static const MainMenuCommand show_toolbars{
cfg_toolbars = !cfg_toolbars;
on_show_toolbars_change();
},
[] { return cfg_toolbars != 0; }};
[] { return cfg_toolbars != 0; }, true};

static const MainMenuCommand live_editing{toggle_live_editing_id, "Live editing",
"Enables or disables live editing of the Columns UI layout.",
Expand Down Expand Up @@ -132,11 +132,14 @@ class MainMenuCommands : public mainmenu_commands {

bool get_display(t_uint32 p_index, pfc::string_base& p_text, t_uint32& p_flags) override
{
auto& command = m_commands[p_index];
const auto& command = m_commands[p_index];
p_text = command.name;

if (command.is_ticked_callback && command.is_ticked_callback())
p_flags |= flag_checked;
return cui::main_window.get_wnd() != nullptr;

const bool shift_down = (GetKeyState(VK_SHIFT) < 0);
return main_window.get_wnd() != nullptr && (!command.hide_without_shift_key || shift_down);
}

void execute(t_uint32 p_index, service_ptr_t<service_base> p_callback) override
Expand Down
1 change: 1 addition & 0 deletions foo_ui_columns/menu_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct MainMenuCommand {
const char* description;
std::function<void()> execute_callback;
std::function<bool()> is_ticked_callback{};
bool hide_without_shift_key{};
};

namespace commands {
Expand Down