From 20c3702501b87be49f974cae565a278e1843662e Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 13 Aug 2010 23:20:20 +0000 Subject: [PATCH] Fixed the compatibility issue for the skins that are using MouseOverAction/MouseLeaveAction in Meters. --- Library/MeterButton.cpp | 5 ++-- Library/MeterButton.h | 4 +++ Library/MeterWindow.cpp | 61 ++++++++++++++++++++++++----------------- Library/MeterWindow.h | 2 +- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index c95d90aa..68c01120 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -48,6 +48,7 @@ CMeterButton::CMeterButton(CMeterWindow* meterWindow) : CMeter(meterWindow) m_Bitmap = NULL; m_State = BUTTON_STATE_NORMAL; m_Clicked = false; + m_Executable = false; } /* @@ -284,7 +285,7 @@ bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window) { if (m_State == BUTTON_STATE_DOWN) { - if (window && m_Clicked && HitTest2(pos.x, pos.y, true)) + if (window && m_Clicked && m_Executable && HitTest2(pos.x, pos.y, true)) { // Do a delayed execute or ortherwise !RainmeterRefresh crashes PostMessage(window->GetWindow(), WM_DELAYED_EXECUTE, (WPARAM)NULL, (LPARAM)m_Command.c_str()); @@ -300,7 +301,7 @@ bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window) bool CMeterButton::MouseDown(POINT pos) { - if (HitTest2(pos.x, pos.y, true)) + if (m_Executable && HitTest2(pos.x, pos.y, true)) { m_State = BUTTON_STATE_DOWN; m_Clicked = true; diff --git a/Library/MeterButton.h b/Library/MeterButton.h index 0c43ca40..6dd9beaf 100644 --- a/Library/MeterButton.h +++ b/Library/MeterButton.h @@ -40,6 +40,9 @@ public: bool MouseUp(POINT pos, CMeterWindow* window); bool MouseDown(POINT pos); + void SetExecutable(bool exec) { m_Executable = exec; } + bool IsExecutable() { return m_Executable; } + private: bool HitTest2(int px, int py, bool checkAlpha); @@ -49,6 +52,7 @@ private: std::wstring m_Command; // Command to be executed int m_State; bool m_Clicked; + bool m_Executable; }; #endif diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 74faccec..7568bdb9 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -3998,24 +3998,15 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test) ** Executes the action if such are defined. Returns true, if meter/window which should be processed still may exist. ** */ -bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter) +bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse) { + bool buttonFound = false; + // Check if the hitpoint was over some meter std::list::const_reverse_iterator j = m_Meters.rbegin(); - if (upperMeter) - { - for ( ; j != m_Meters.rend(); ++j) - { - if ((*j) == upperMeter) - { - ++j; - break; - } - } - } for( ; j != m_Meters.rend(); ++j) { - if (!(*j)->IsHidden() && !upperMeter && (*j)->HitTest(x, y)) + if (!(*j)->IsHidden() && (*j)->HitTest(x, y)) { if (mouse == MOUSE_OVER) { @@ -4032,35 +4023,58 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter) } } + // Handle button + CMeterButton* button = dynamic_cast(*j); + if (button) + { + if (!buttonFound) + { + if (!button->IsExecutable()) + { + button->SetExecutable(true); + } + buttonFound = true; + } + else + { + if (button->IsExecutable()) + { + button->SetExecutable(false); + } + } + } + if (!(*j)->IsMouseOver()) { if (!((*j)->GetMouseOverAction().empty()) || !((*j)->GetMouseLeaveAction().empty()) || - dynamic_cast(*j) != NULL) + button) { - while (DoMoveAction(x, y, MOUSE_LEAVE, (*j))) ; // Leave all lower meters - //DebugLog(L"MeterEnter: %s - [%s]", m_SkinName.c_str(), (*j)->GetName()); (*j)->SetMouseOver(true); if (!((*j)->GetMouseOverAction().empty())) { m_Rainmeter->ExecuteCommand((*j)->GetMouseOverAction().c_str(), this); - return true; } - return false; } } - else - { - return false; - } } } else { if ((*j)->IsMouseOver()) { + // Handle button + CMeterButton* button = dynamic_cast(*j); + if (button) + { + if (button->IsExecutable()) + { + button->SetExecutable(false); + } + } + //DebugLog(L"MeterLeave: %s - [%s]", m_SkinName.c_str(), (*j)->GetName()); (*j)->SetMouseOver(false); @@ -4068,13 +4082,10 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter) { m_Rainmeter->ExecuteCommand((*j)->GetMouseLeaveAction().c_str(), this); } - return true; } } } - if (upperMeter) return false; - if (HitTest(x, y)) { // If no meters caused actions, do the default actions diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 91788202..1913e014 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -254,7 +254,7 @@ private: void ShowWindowIfAppropriate(); void HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meterWindow, bool changeCursor); bool DoAction(int x, int y, MOUSE mouse, bool test); - bool DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter = NULL); + bool DoMoveAction(int x, int y, MOUSE mouse); bool ResizeWindow(bool reset); void IgnoreAeroPeek();