mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed Button meter behavior. Now ignores transparent area of the button when mouseover.
This commit is contained in:
parent
8bf1f6aec8
commit
ed9ea73e6b
@ -210,7 +210,7 @@ void MeterButton::BindMeasures(ConfigParser& parser, const WCHAR* section)
|
||||
** Checks if the given point is inside the button.
|
||||
**
|
||||
*/
|
||||
bool MeterButton::HitTest2(int px, int py, bool checkAlpha)
|
||||
bool MeterButton::HitTest2(int px, int py)
|
||||
{
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
@ -218,8 +218,6 @@ bool MeterButton::HitTest2(int px, int py, bool checkAlpha)
|
||||
if (m_MouseOver &&
|
||||
px >= x && px < x + m_W &&
|
||||
py >= y && py < y + m_H)
|
||||
{
|
||||
if (checkAlpha)
|
||||
{
|
||||
if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0)
|
||||
{
|
||||
@ -241,11 +239,6 @@ bool MeterButton::HitTest2(int px, int py, bool checkAlpha)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -253,7 +246,7 @@ bool MeterButton::MouseUp(POINT pos, bool execute)
|
||||
{
|
||||
if (m_State == BUTTON_STATE_DOWN)
|
||||
{
|
||||
if (execute && m_Clicked && m_Focus && HitTest2(pos.x, pos.y, true))
|
||||
if (execute && m_Clicked && m_Focus && HitTest2(pos.x, pos.y))
|
||||
{
|
||||
GetRainmeter().ExecuteCommand(m_Command.c_str(), m_MeterWindow);
|
||||
}
|
||||
@ -268,7 +261,7 @@ bool MeterButton::MouseUp(POINT pos, bool execute)
|
||||
|
||||
bool MeterButton::MouseDown(POINT pos)
|
||||
{
|
||||
if (m_Focus && HitTest2(pos.x, pos.y, true))
|
||||
if (m_Focus && HitTest2(pos.x, pos.y))
|
||||
{
|
||||
m_State = BUTTON_STATE_DOWN;
|
||||
m_Clicked = true;
|
||||
@ -281,7 +274,7 @@ bool MeterButton::MouseMove(POINT pos)
|
||||
{
|
||||
if (m_Clicked)
|
||||
{
|
||||
if (HitTest2(pos.x, pos.y, true))
|
||||
if (HitTest2(pos.x, pos.y))
|
||||
{
|
||||
if (m_State == BUTTON_STATE_NORMAL)
|
||||
{
|
||||
@ -306,7 +299,7 @@ bool MeterButton::MouseMove(POINT pos)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HitTest2(pos.x, pos.y, false))
|
||||
if (HitTest2(pos.x, pos.y))
|
||||
{
|
||||
if (m_State == BUTTON_STATE_NORMAL)
|
||||
{
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
|
||||
void SetFocus(bool f) { m_Focus = f; }
|
||||
|
||||
bool HitTest2(int px, int py);
|
||||
|
||||
protected:
|
||||
virtual void ReadOptions(ConfigParser& parser, const WCHAR* section);
|
||||
virtual void BindMeasures(ConfigParser& parser, const WCHAR* section);
|
||||
@ -49,8 +51,6 @@ protected:
|
||||
virtual bool IsFixedSize(bool overwrite = false) { return overwrite; }
|
||||
|
||||
private:
|
||||
bool HitTest2(int px, int py, bool checkAlpha);
|
||||
|
||||
TintedImage m_Image;
|
||||
std::wstring m_ImageName;
|
||||
bool m_NeedsReload;
|
||||
|
@ -3181,14 +3181,26 @@ void MeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, bool execute)
|
||||
}
|
||||
}
|
||||
|
||||
if (!cursor &&
|
||||
((*j)->HasMouseAction() || button) &&
|
||||
(*j)->GetMouse().GetCursorState() &&
|
||||
(*j)->HitTest(pos.x, pos.y))
|
||||
// Get cursor if required
|
||||
if (!cursor && (*j)->GetMouse().GetCursorState())
|
||||
{
|
||||
if ((*j)->HasMouseAction())
|
||||
{
|
||||
if ((*j)->HitTest(pos.x, pos.y))
|
||||
{
|
||||
cursor = (*j)->GetMouse().GetCursor();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Special case for Button meter: reacts only on valid pixel in button image
|
||||
if (button && button->HitTest2(pos.x, pos.y))
|
||||
{
|
||||
cursor = (*j)->GetMouse().GetCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (redraw)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user