Fixed the compatibility issue for the skins that are using MouseOverAction/MouseLeaveAction in Meters.

This commit is contained in:
spx 2010-08-13 23:20:20 +00:00
parent 8fe2a26a51
commit 20c3702501
4 changed files with 44 additions and 28 deletions

View File

@ -48,6 +48,7 @@ CMeterButton::CMeterButton(CMeterWindow* meterWindow) : CMeter(meterWindow)
m_Bitmap = NULL; m_Bitmap = NULL;
m_State = BUTTON_STATE_NORMAL; m_State = BUTTON_STATE_NORMAL;
m_Clicked = false; m_Clicked = false;
m_Executable = false;
} }
/* /*
@ -284,7 +285,7 @@ bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window)
{ {
if (m_State == BUTTON_STATE_DOWN) 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 // Do a delayed execute or ortherwise !RainmeterRefresh crashes
PostMessage(window->GetWindow(), WM_DELAYED_EXECUTE, (WPARAM)NULL, (LPARAM)m_Command.c_str()); 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) 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_State = BUTTON_STATE_DOWN;
m_Clicked = true; m_Clicked = true;

View File

@ -40,6 +40,9 @@ public:
bool MouseUp(POINT pos, CMeterWindow* window); bool MouseUp(POINT pos, CMeterWindow* window);
bool MouseDown(POINT pos); bool MouseDown(POINT pos);
void SetExecutable(bool exec) { m_Executable = exec; }
bool IsExecutable() { return m_Executable; }
private: private:
bool HitTest2(int px, int py, bool checkAlpha); bool HitTest2(int px, int py, bool checkAlpha);
@ -49,6 +52,7 @@ private:
std::wstring m_Command; // Command to be executed std::wstring m_Command; // Command to be executed
int m_State; int m_State;
bool m_Clicked; bool m_Clicked;
bool m_Executable;
}; };
#endif #endif

View File

@ -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. ** 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 // Check if the hitpoint was over some meter
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin(); std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
if (upperMeter)
{
for( ; j != m_Meters.rend(); ++j) for( ; j != m_Meters.rend(); ++j)
{ {
if ((*j) == upperMeter) if (!(*j)->IsHidden() && (*j)->HitTest(x, y))
{
++j;
break;
}
}
}
for( ; j != m_Meters.rend(); ++j)
{
if (!(*j)->IsHidden() && !upperMeter && (*j)->HitTest(x, y))
{ {
if (mouse == MOUSE_OVER) if (mouse == MOUSE_OVER)
{ {
@ -4032,28 +4023,41 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter)
} }
} }
// Handle button
CMeterButton* button = dynamic_cast<CMeterButton*>(*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)->IsMouseOver())
{ {
if (!((*j)->GetMouseOverAction().empty()) || if (!((*j)->GetMouseOverAction().empty()) ||
!((*j)->GetMouseLeaveAction().empty()) || !((*j)->GetMouseLeaveAction().empty()) ||
dynamic_cast<CMeterButton*>(*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()); //DebugLog(L"MeterEnter: %s - [%s]", m_SkinName.c_str(), (*j)->GetName());
(*j)->SetMouseOver(true); (*j)->SetMouseOver(true);
if (!((*j)->GetMouseOverAction().empty())) if (!((*j)->GetMouseOverAction().empty()))
{ {
m_Rainmeter->ExecuteCommand((*j)->GetMouseOverAction().c_str(), this); m_Rainmeter->ExecuteCommand((*j)->GetMouseOverAction().c_str(), this);
return true;
}
return false;
} }
} }
else
{
return false;
} }
} }
} }
@ -4061,6 +4065,16 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse, CMeter* upperMeter)
{ {
if ((*j)->IsMouseOver()) if ((*j)->IsMouseOver())
{ {
// Handle button
CMeterButton* button = dynamic_cast<CMeterButton*>(*j);
if (button)
{
if (button->IsExecutable())
{
button->SetExecutable(false);
}
}
//DebugLog(L"MeterLeave: %s - [%s]", m_SkinName.c_str(), (*j)->GetName()); //DebugLog(L"MeterLeave: %s - [%s]", m_SkinName.c_str(), (*j)->GetName());
(*j)->SetMouseOver(false); (*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); m_Rainmeter->ExecuteCommand((*j)->GetMouseLeaveAction().c_str(), this);
} }
return true;
} }
} }
} }
if (upperMeter) return false;
if (HitTest(x, y)) if (HitTest(x, y))
{ {
// If no meters caused actions, do the default actions // If no meters caused actions, do the default actions

View File

@ -254,7 +254,7 @@ private:
void ShowWindowIfAppropriate(); void ShowWindowIfAppropriate();
void HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meterWindow, bool changeCursor); void HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meterWindow, bool changeCursor);
bool DoAction(int x, int y, MOUSE mouse, bool test); 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); bool ResizeWindow(bool reset);
void IgnoreAeroPeek(); void IgnoreAeroPeek();