mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-04-02 10:42:14 -04:00
Merge 94846ac5b9
into b815744b4c
This commit is contained in:
commit
9c2c0c8813
4 changed files with 27 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace hiro {
|
||||
|
||||
static auto Application_keyboardProc(HWND, UINT, WPARAM, LPARAM) -> bool;
|
||||
static auto Application_processDeferred() -> void;
|
||||
static auto Application_processDialogMessage(MSG&) -> void;
|
||||
static auto CALLBACK Window_windowProc(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
|
||||
|
||||
|
@ -44,6 +45,14 @@ auto pApplication::processEvents() -> void {
|
|||
Application_processDialogMessage(msg);
|
||||
}
|
||||
}
|
||||
Application_processDeferred();
|
||||
}
|
||||
|
||||
auto Application_processDeferred() -> void {
|
||||
for (auto menu : pApplication::state().staleMenus) {
|
||||
menu->_updateDeferred();
|
||||
}
|
||||
pApplication::state().staleMenus.reset();
|
||||
}
|
||||
|
||||
auto Application_processDialogMessage(MSG& msg) -> void {
|
||||
|
|
|
@ -17,6 +17,7 @@ struct pApplication {
|
|||
int modalCount = 0; //number of modal loops
|
||||
Timer modalTimer; //to run Application during modal events
|
||||
pToolTip* toolTip = nullptr; //active toolTip
|
||||
vector<pMenuBar*> staleMenus; //menubars to update
|
||||
};
|
||||
static auto state() -> State&;
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@ auto pMenuBar::construct() -> void {
|
|||
}
|
||||
|
||||
auto pMenuBar::destruct() -> void {
|
||||
pApplication::state().staleMenus.removeByValue(this);
|
||||
if(hmenu) { DestroyMenu(hmenu); hmenu = nullptr; }
|
||||
if(auto parent = _parent()) {
|
||||
SetMenu(parent->hwnd, nullptr);
|
||||
|
@ -44,6 +45,20 @@ auto pMenuBar::_parent() -> maybe<pWindow&> {
|
|||
}
|
||||
|
||||
auto pMenuBar::_update() -> void {
|
||||
bool updateNow = false;
|
||||
if(auto parent = _parent()) {
|
||||
updateNow = GetMenu(parent->hwnd) == nullptr;
|
||||
}
|
||||
|
||||
if (updateNow) {
|
||||
_updateDeferred();
|
||||
} else {
|
||||
pApplication::state().staleMenus.removeByValue(this);
|
||||
pApplication::state().staleMenus.append(this);
|
||||
}
|
||||
}
|
||||
|
||||
auto pMenuBar::_updateDeferred() -> void {
|
||||
if(hmenu) DestroyMenu(hmenu);
|
||||
hmenu = CreateMenu();
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ struct pMenuBar : pObject {
|
|||
|
||||
auto _parent() -> maybe<pWindow&>;
|
||||
auto _update() -> void;
|
||||
|
||||
auto _updateDeferred() -> void;
|
||||
|
||||
HMENU hmenu = 0;
|
||||
vector<wObject> objects;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue