linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05688
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2942: improve menu bar hiding
------------------------------------------------------------
revno: 2942
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-06-08 15:56:39 +0200
message:
improve menu bar hiding
modified:
help/keyboard_commands.html
help/window_main.html
win32/MainWindow.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'help/keyboard_commands.html'
--- help/keyboard_commands.html 2012-06-03 17:22:16 +0000
+++ help/keyboard_commands.html 2012-06-08 13:56:39 +0000
@@ -23,7 +23,7 @@
<dt>Ctrl + 0</dt>
<dd>
Toggle the permanent visibility of the main menu bar. When it is hidden, the menu bar
- can be temporarily brought back into view with standard Windows shortcuts (Alt, F10).
+ can be temporarily brought back into view with standard Windows shortcuts (Alt or F10).
</dd>
<dt>Ctrl + 1</dt>
<dd>Enable or disable the toolbar.</dd>
=== modified file 'help/window_main.html'
--- help/window_main.html 2012-06-03 17:22:16 +0000
+++ help/window_main.html 2012-06-08 13:56:39 +0000
@@ -115,7 +115,7 @@
<dt>Menu bar</dt>
<dd>
Toggle the permanent visibility of the main menu bar. When it is hidden, the menu bar
- can be temporarily brought back into view with standard Windows shortcuts (Alt, F10).
+ can be temporarily brought back into view with standard Windows shortcuts (Alt or F10).
</dd>
<dt>Toolbar</dt>
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2012-06-03 17:22:16 +0000
+++ win32/MainWindow.cpp 2012-06-08 13:56:39 +0000
@@ -396,21 +396,13 @@
::SetMenu(handle(), nullptr);
}
- /* when the menu bar is hidden, catch WM_ENTERMENULOOP & WM_EXITMENULOOP to determine when it
- should be shown (such as when pressing Alt or F10).
- idea from Notepad++ <http://notepad-plus-plus.org/>. */
-
- auto updateMenuBar = [this](bool show) -> std::function<LRESULT (WPARAM, LPARAM)> {
- return [=](WPARAM wParam, LPARAM) -> LRESULT {
- if(!wParam && !BOOLSETTING(SHOW_MENU_BAR)) {
- ::SetMenu(handle(), show ? mainMenu->handle() : nullptr);
- }
- return 0;
- };
- };
-
- onRaw(updateMenuBar(true), dwt::Message(WM_ENTERMENULOOP));
- onRaw(updateMenuBar(false), dwt::Message(WM_EXITMENULOOP));
+ // hide the temporary menu bar on WM_EXITMENULOOP
+ onRaw([this](WPARAM wParam, LPARAM) -> LRESULT {
+ if(!wParam && !BOOLSETTING(SHOW_MENU_BAR) && ::GetMenu(handle())) {
+ ::SetMenu(handle(), nullptr);
+ }
+ return 0;
+ }, dwt::Message(WM_EXITMENULOOP));
}
void MainWindow::initToolbar() {
@@ -611,6 +603,24 @@
}
bool MainWindow::filter(MSG& msg) {
+ if(msg.message == WM_SYSKEYDOWN && (msg.wParam == VK_MENU || msg.wParam == VK_F10) &&
+ !BOOLSETTING(SHOW_MENU_BAR) && !::GetMenu(handle()) && !isShiftPressed())
+ {
+ // show the temporary menu bar when pressing Alt or F10
+ ::SetMenu(handle(), mainMenu->handle());
+
+ } else if((msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP) && (msg.wParam == VK_MENU || msg.wParam == VK_F10) &&
+ !BOOLSETTING(SHOW_MENU_BAR) && ::GetMenu(handle()))
+ {
+ // hide the temporary menu bar if when releasing Alt or F10, the menu bar isn't focused
+ callAsync([this] {
+ MENUBARINFO info = { sizeof(MENUBARINFO) };
+ if(!::GetMenuBarInfo(handle(), OBJID_MENU, 0, &info) || !info.fBarFocused) {
+ ::SetMenu(handle(), nullptr);
+ }
+ });
+ }
+
if(tabs && tabs->filter(msg)) {
return true;
}
@@ -1286,6 +1296,11 @@
}
void MainWindow::handleActivate(bool active) {
+ // hide the temporary menu bar when moving out of the main window
+ if(!active && !BOOLSETTING(SHOW_MENU_BAR) && ::GetMenu(handle())) {
+ ::SetMenu(handle(), nullptr);
+ }
+
// focus the active tab window
Container* w = getTabView()->getActive();
if(w) {
@@ -1547,9 +1562,15 @@
}
void MainWindow::switchMenuBar() {
- SettingsManager::getInstance()->set(SettingsManager::SHOW_MENU_BAR, !BOOLSETTING(SHOW_MENU_BAR));
- ::SetMenu(handle(), BOOLSETTING(SHOW_MENU_BAR) ? mainMenu->handle() : nullptr);
- viewMenu->checkItem(viewIndexes["Menu"], BOOLSETTING(SHOW_MENU_BAR));
+ auto show = !BOOLSETTING(SHOW_MENU_BAR);
+ SettingsManager::getInstance()->set(SettingsManager::SHOW_MENU_BAR, show);
+ ::SetMenu(handle(), show ? mainMenu->handle() : nullptr);
+ viewMenu->checkItem(viewIndexes["Menu"], show);
+
+ if(!show) {
+ dwt::MessageBox(this).show(T_("The menu bar is now hidden. Press Alt or F10 to temporarily bring it back into view."),
+ _T(APPNAME) _T(" ") _T(VERSIONSTRING), dwt::MessageBox::BOX_OK, dwt::MessageBox::BOX_ICONINFORMATION);
+ }
}
void MainWindow::switchToolbar() {