mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed the compatibility issue for the skins that are using MouseOverAction/MouseLeaveAction in Meters.
This commit is contained in:
parent
8fe2a26a51
commit
20c3702501
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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<CMeter*>::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,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)->GetMouseOverAction().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());
|
||||
(*j)->SetMouseOver(true);
|
||||
|
||||
if (!((*j)->GetMouseOverAction().empty()))
|
||||
{
|
||||
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())
|
||||
{
|
||||
// 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());
|
||||
(*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
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user