mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup
This commit is contained in:
parent
9da869363d
commit
9375b5013c
@ -53,6 +53,7 @@ CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : CSection(meterWin
|
|||||||
m_ToolTipType(false),
|
m_ToolTipType(false),
|
||||||
m_ToolTipHidden(meterWindow->GetMeterToolTipHidden()),
|
m_ToolTipHidden(meterWindow->GetMeterToolTipHidden()),
|
||||||
m_ToolTipHandle(),
|
m_ToolTipHandle(),
|
||||||
|
m_Mouse(meterWindow, this),
|
||||||
m_HasMouseAction(false),
|
m_HasMouseAction(false),
|
||||||
m_MouseOver(false),
|
m_MouseOver(false),
|
||||||
m_RelativeX(POSITION_ABSOLUTE),
|
m_RelativeX(POSITION_ABSOLUTE),
|
||||||
@ -322,19 +323,8 @@ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
|||||||
|
|
||||||
m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false);
|
m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false);
|
||||||
|
|
||||||
m_Mouse.ReadOptions(parser, section, m_MeterWindow);
|
m_Mouse.ReadOptions(parser, section);
|
||||||
|
m_HasMouseAction = m_Mouse.HasButtonAction() || m_Mouse.HasScrollAction();
|
||||||
m_HasMouseAction =
|
|
||||||
!(m_Mouse.GetLeftUpAction().empty() && m_Mouse.GetLeftDownAction().empty() &&
|
|
||||||
m_Mouse.GetLeftDoubleClickAction().empty() && m_Mouse.GetMiddleUpAction().empty() &&
|
|
||||||
m_Mouse.GetMiddleDownAction().empty() && m_Mouse.GetMiddleDoubleClickAction().empty() &&
|
|
||||||
m_Mouse.GetRightUpAction().empty() && m_Mouse.GetRightDownAction().empty() &&
|
|
||||||
m_Mouse.GetRightDoubleClickAction().empty() && m_Mouse.GetX1UpAction().empty() &&
|
|
||||||
m_Mouse.GetX1DownAction().empty() && m_Mouse.GetX1DoubleClickAction().empty() &&
|
|
||||||
m_Mouse.GetX2UpAction().empty() && m_Mouse.GetX2DownAction().empty() &&
|
|
||||||
m_Mouse.GetX2DoubleClickAction().empty() && m_Mouse.GetMouseScrollDownAction().empty() &&
|
|
||||||
m_Mouse.GetMouseScrollLeftAction().empty() && m_Mouse.GetMouseScrollRightAction().empty() &&
|
|
||||||
m_Mouse.GetMouseScrollUpAction().empty());
|
|
||||||
|
|
||||||
m_ToolTipText = parser.ReadString(section, L"ToolTipText", L"");
|
m_ToolTipText = parser.ReadString(section, L"ToolTipText", L"");
|
||||||
m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L"");
|
m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L"");
|
||||||
|
@ -82,6 +82,7 @@ CMeterWindow::CMeterWindow(const std::wstring& folderPath, const std::wstring& f
|
|||||||
m_Background(),
|
m_Background(),
|
||||||
m_BackgroundSize(),
|
m_BackgroundSize(),
|
||||||
m_Window(),
|
m_Window(),
|
||||||
|
m_Mouse(this),
|
||||||
m_MouseOver(false),
|
m_MouseOver(false),
|
||||||
m_MouseInputRegistered(false),
|
m_MouseInputRegistered(false),
|
||||||
m_HasMouseScrollAction(false),
|
m_HasMouseScrollAction(false),
|
||||||
@ -215,6 +216,7 @@ void CMeterWindow::Dispose(bool refresh)
|
|||||||
KillTimer(m_Window, TIMER_TRANSITION);
|
KillTimer(m_Window, TIMER_TRANSITION);
|
||||||
|
|
||||||
UnregisterMouseInput();
|
UnregisterMouseInput();
|
||||||
|
m_HasMouseScrollAction = false;
|
||||||
|
|
||||||
m_ActiveTransition = false;
|
m_ActiveTransition = false;
|
||||||
|
|
||||||
@ -2043,7 +2045,7 @@ bool CMeterWindow::ReadSkin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Mouse.ReadOptions(m_Parser, L"Rainmeter", this);
|
m_Mouse.ReadOptions(m_Parser, L"Rainmeter");
|
||||||
|
|
||||||
m_OnRefreshAction = m_Parser.ReadString(L"Rainmeter", L"OnRefreshAction", L"", false);
|
m_OnRefreshAction = m_Parser.ReadString(L"Rainmeter", L"OnRefreshAction", L"", false);
|
||||||
m_OnCloseAction = m_Parser.ReadString(L"Rainmeter", L"OnCloseAction", L"", false);
|
m_OnCloseAction = m_Parser.ReadString(L"Rainmeter", L"OnCloseAction", L"", false);
|
||||||
@ -4300,7 +4302,7 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
*/
|
*/
|
||||||
bool CMeterWindow::DoAction(int x, int y, MOUSEACTION action, bool test)
|
bool CMeterWindow::DoAction(int x, int y, MOUSEACTION action, bool test)
|
||||||
{
|
{
|
||||||
std::wstring command = L"";
|
std::wstring command;
|
||||||
|
|
||||||
// Check if the hitpoint was over some meter
|
// Check if the hitpoint was over some meter
|
||||||
std::vector<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
|
std::vector<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
|
||||||
@ -4309,17 +4311,20 @@ bool CMeterWindow::DoAction(int x, int y, MOUSEACTION action, bool test)
|
|||||||
// Hidden meters are ignored
|
// Hidden meters are ignored
|
||||||
if ((*j)->IsHidden()) continue;
|
if ((*j)->IsHidden()) continue;
|
||||||
|
|
||||||
std::wstring meterCommand = (*j)->GetMouse().GetActionCommand(action);
|
const CMouse& mouse = (*j)->GetMouse();
|
||||||
if (!meterCommand.empty() && (*j)->HitTest(x, y))
|
if (mouse.HasActionCommand(action) && (*j)->HitTest(x, y))
|
||||||
{
|
{
|
||||||
command = meterCommand;
|
command = mouse.GetActionCommand(action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.empty() && HitTest(x, y))
|
if (command.empty())
|
||||||
{
|
{
|
||||||
command = m_Mouse.GetActionCommand(action).c_str();
|
if (m_Mouse.HasActionCommand(action) && HitTest(x, y))
|
||||||
|
{
|
||||||
|
command = m_Mouse.GetActionCommand(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.empty())
|
if (!command.empty())
|
||||||
@ -4388,17 +4393,18 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
|
|||||||
|
|
||||||
if (!(*j)->IsMouseOver())
|
if (!(*j)->IsMouseOver())
|
||||||
{
|
{
|
||||||
if (!((*j)->GetMouse().GetOverAction().empty()) ||
|
const CMouse& mouse = (*j)->GetMouse();
|
||||||
!((*j)->GetMouse().GetLeaveAction().empty()) ||
|
if (!mouse.GetOverAction().empty() ||
|
||||||
|
!mouse.GetLeaveAction().empty() ||
|
||||||
button)
|
button)
|
||||||
{
|
{
|
||||||
//LogWithArgs(LOG_DEBUG, L"MeterEnter: %s - [%s]", m_FolderPath.c_str(), (*j)->GetName());
|
//LogWithArgs(LOG_DEBUG, L"MeterEnter: %s - [%s]", m_FolderPath.c_str(), (*j)->GetName());
|
||||||
(*j)->SetMouseOver(true);
|
(*j)->SetMouseOver(true);
|
||||||
|
|
||||||
if (!((*j)->GetMouse().GetOverAction().empty()))
|
if (!mouse.GetOverAction().empty())
|
||||||
{
|
{
|
||||||
UINT currCounter = m_MouseMoveCounter;
|
UINT currCounter = m_MouseMoveCounter;
|
||||||
Rainmeter->ExecuteCommand((*j)->GetMouse().GetOverAction().c_str(), this);
|
Rainmeter->ExecuteCommand(mouse.GetOverAction().c_str(), this);
|
||||||
return (currCounter == m_MouseMoveCounter);
|
return (currCounter == m_MouseMoveCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4421,9 +4427,10 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
|
|||||||
//LogWithArgs(LOG_DEBUG, L"MeterLeave: %s - [%s]", m_FolderPath.c_str(), (*j)->GetName());
|
//LogWithArgs(LOG_DEBUG, L"MeterLeave: %s - [%s]", m_FolderPath.c_str(), (*j)->GetName());
|
||||||
(*j)->SetMouseOver(false);
|
(*j)->SetMouseOver(false);
|
||||||
|
|
||||||
if (!((*j)->GetMouse().GetLeaveAction().empty()))
|
const CMouse& mouse = (*j)->GetMouse();
|
||||||
|
if (!mouse.GetLeaveAction().empty())
|
||||||
{
|
{
|
||||||
Rainmeter->ExecuteCommand((*j)->GetMouse().GetLeaveAction().c_str(), this);
|
Rainmeter->ExecuteCommand(mouse.GetLeaveAction().c_str(), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,10 @@
|
|||||||
#include "Litestep.h"
|
#include "Litestep.h"
|
||||||
#include "Mouse.h"
|
#include "Mouse.h"
|
||||||
|
|
||||||
CMouse::CMouse() :
|
CMouse::CMouse(CMeterWindow* meterWindow, CMeter* meter) : m_MeterWindow(meterWindow), m_Meter(meter),
|
||||||
m_CursorType(MOUSECURSOR_HAND),
|
m_CursorType(MOUSECURSOR_HAND),
|
||||||
m_CustomCursor(),
|
m_CustomCursor(),
|
||||||
m_CursorState(true),
|
m_CursorState(true)
|
||||||
m_MeterWindow()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,43 +35,36 @@ CMouse::~CMouse()
|
|||||||
DestroyCustomCursor();
|
DestroyCustomCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWindow* meterWindow)
|
void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||||
{
|
{
|
||||||
m_MeterWindow = meterWindow;
|
|
||||||
m_MeterName = section;
|
|
||||||
|
|
||||||
DestroyCustomCursor();
|
DestroyCustomCursor();
|
||||||
|
|
||||||
m_LeftDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"", false);
|
m_MouseActions[MOUSE_LMB_UP] = parser.ReadString(section, L"LeftMouseUpAction", L"", false);
|
||||||
m_RightDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false);
|
m_MouseActions[MOUSE_LMB_DOWN] = parser.ReadString(section, L"LeftMouseDownAction", L"", false);
|
||||||
m_MiddleDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"", false);
|
m_MouseActions[MOUSE_LMB_DBLCLK] = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false);
|
||||||
m_X1DownAction = parser.ReadString(section, L"X1MouseDownAction", L"", false);
|
m_MouseActions[MOUSE_MMB_UP] = parser.ReadString(section, L"MiddleMouseUpAction", L"", false);
|
||||||
m_X2DownAction = parser.ReadString(section, L"X2MouseDownAction", L"", false);
|
m_MouseActions[MOUSE_MMB_DOWN] = parser.ReadString(section, L"MiddleMouseDownAction", L"", false);
|
||||||
m_LeftUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"", false);
|
m_MouseActions[MOUSE_MMB_DBLCLK] = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false);
|
||||||
m_RightUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false);
|
m_MouseActions[MOUSE_RMB_UP] = parser.ReadString(section, L"RightMouseUpAction", L"", false);
|
||||||
m_MiddleUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"", false);
|
m_MouseActions[MOUSE_RMB_DOWN] = parser.ReadString(section, L"RightMouseDownAction", L"", false);
|
||||||
m_X1UpAction = parser.ReadString(section, L"X1MouseUpAction", L"", false);
|
m_MouseActions[MOUSE_RMB_DBLCLK] = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false);
|
||||||
m_X2UpAction = parser.ReadString(section, L"X2MouseUpAction", L"", false);
|
m_MouseActions[MOUSE_X1MB_UP] = parser.ReadString(section, L"X1MouseUpAction", L"", false);
|
||||||
m_LeftDoubleClickAction = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false);
|
m_MouseActions[MOUSE_X1MB_DOWN] = parser.ReadString(section, L"X1MouseDownAction", L"", false);
|
||||||
m_RightDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false);
|
m_MouseActions[MOUSE_X1MB_DBLCLK] = parser.ReadString(section, L"X1MouseDoubleClickAction", L"", false);
|
||||||
m_MiddleDoubleClickAction = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false);
|
m_MouseActions[MOUSE_X2MB_UP] = parser.ReadString(section, L"X2MouseUpAction", L"", false);
|
||||||
m_X1DoubleClickAction = parser.ReadString(section, L"X1MouseDoubleClickAction", L"", false);
|
m_MouseActions[MOUSE_X2MB_DOWN] = parser.ReadString(section, L"X2MouseDownAction", L"", false);
|
||||||
m_X2DoubleClickAction = parser.ReadString(section, L"X2MouseDoubleClickAction", L"", false);
|
m_MouseActions[MOUSE_X2MB_DBLCLK] = parser.ReadString(section, L"X2MouseDoubleClickAction", L"", false);
|
||||||
|
|
||||||
m_OverAction = parser.ReadString(section, L"MouseOverAction", L"", false);
|
m_MouseActions[MOUSE_MW_UP] = parser.ReadString(section, L"MouseScrollUpAction", L"", false);
|
||||||
m_LeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
m_MouseActions[MOUSE_MW_DOWN] = parser.ReadString(section, L"MouseScrollDownAction", L"", false);
|
||||||
|
m_MouseActions[MOUSE_MW_LEFT] = parser.ReadString(section, L"MouseScrollLeftAction", L"", false);
|
||||||
|
m_MouseActions[MOUSE_MW_RIGHT] = parser.ReadString(section, L"MouseScrollRightAction", L"", false);
|
||||||
|
|
||||||
m_MouseScrollDownAction = parser.ReadString(section, L"MouseScrollDownAction", L"", false);
|
m_MouseActions[MOUSE_OVER] = parser.ReadString(section, L"MouseOverAction", L"", false);
|
||||||
m_MouseScrollUpAction = parser.ReadString(section, L"MouseScrollUpAction", L"", false);
|
m_MouseActions[MOUSE_LEAVE] = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
||||||
m_MouseScrollLeftAction = parser.ReadString(section, L"MouseScrollLeftAction", L"", false);
|
|
||||||
m_MouseScrollRightAction = parser.ReadString(section, L"MouseScrollRightAction", L"", false);
|
|
||||||
if (!m_MouseScrollDownAction.empty() || !m_MouseScrollUpAction.empty() ||
|
|
||||||
!m_MouseScrollLeftAction.empty() || !m_MouseScrollRightAction.empty())
|
|
||||||
{
|
|
||||||
meterWindow->SetHasMouseScrollAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool defaultState = (section == L"Rainmeter") ? true : meterWindow->GetMouse().GetCursorState();
|
if (HasScrollAction())
{
m_MeterWindow->SetHasMouseScrollAction();
}
|
||||||
|
const bool defaultState = (section == L"Rainmeter") ? true : m_MeterWindow->GetMouse().GetCursorState();
|
||||||
m_CursorState = 0!=parser.ReadInt(section, L"MouseActionCursor", defaultState);
|
m_CursorState = 0!=parser.ReadInt(section, L"MouseActionCursor", defaultState);
|
||||||
|
|
||||||
const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L"";
|
const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L"";
|
||||||
@ -108,16 +100,16 @@ void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWind
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Inherit from [Rainmeter].
|
// Inherit from [Rainmeter].
|
||||||
m_CursorType = meterWindow->GetMouse().GetCursorType();
|
m_CursorType = m_MeterWindow->GetMouse().GetCursorType();
|
||||||
if (m_CursorType == MOUSECURSOR_CUSTOM)
|
if (m_CursorType == MOUSECURSOR_CUSTOM)
|
||||||
{
|
{
|
||||||
mouseCursor = meterWindow->GetParser().ReadString(L"Rainmeter", L"MouseActionCursorName", L"").c_str();
|
mouseCursor = m_MeterWindow->GetParser().ReadString(L"Rainmeter", L"MouseActionCursorName", L"").c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CursorType == MOUSECURSOR_CUSTOM)
|
if (m_CursorType == MOUSECURSOR_CUSTOM)
|
||||||
{
|
{
|
||||||
std::wstring cursorPath = meterWindow->GetResourcesPath();
|
std::wstring cursorPath = m_MeterWindow->GetResourcesPath();
|
||||||
cursorPath += L"Cursors\\";
|
cursorPath += L"Cursors\\";
|
||||||
cursorPath += mouseCursor;
|
cursorPath += mouseCursor;
|
||||||
m_CustomCursor = LoadCursorFromFile(cursorPath.c_str());
|
m_CustomCursor = LoadCursorFromFile(cursorPath.c_str());
|
||||||
@ -173,89 +165,8 @@ HCURSOR CMouse::GetCursor() const
|
|||||||
|
|
||||||
std::wstring CMouse::GetActionCommand(MOUSEACTION action) const
|
std::wstring CMouse::GetActionCommand(MOUSEACTION action) const
|
||||||
{
|
{
|
||||||
std::wstring command = L"";
|
std::wstring command = m_MouseActions[action];
|
||||||
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case MOUSE_LMB_DOWN:
|
|
||||||
command = m_LeftDownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_LMB_UP:
|
|
||||||
command = m_LeftUpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_LMB_DBLCLK:
|
|
||||||
command = m_LeftDoubleClickAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_RMB_DOWN:
|
|
||||||
command = m_RightDownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_RMB_UP:
|
|
||||||
command = m_RightUpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_RMB_DBLCLK:
|
|
||||||
command = m_RightDoubleClickAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MMB_DOWN:
|
|
||||||
command = m_MiddleDownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MMB_UP:
|
|
||||||
command = m_MiddleUpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MMB_DBLCLK:
|
|
||||||
command = m_MiddleDoubleClickAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MW_DOWN:
|
|
||||||
command = m_MouseScrollDownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MW_UP:
|
|
||||||
command = m_MouseScrollUpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MW_LEFT:
|
|
||||||
command = m_MouseScrollLeftAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_MW_RIGHT:
|
|
||||||
command = m_MouseScrollRightAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X1MB_DOWN:
|
|
||||||
command = m_X1DownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X1MB_UP:
|
|
||||||
command = m_X1UpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X1MB_DBLCLK:
|
|
||||||
command = m_X1DoubleClickAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X2MB_DOWN:
|
|
||||||
command = m_X2DownAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X2MB_UP:
|
|
||||||
command = m_X2UpAction;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MOUSE_X2MB_DBLCLK:
|
|
||||||
command = m_X2DoubleClickAction;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplaceMouseVariables(command);
|
ReplaceMouseVariables(command);
|
||||||
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,21 +230,19 @@ void CMouse::ReplaceMouseVariables(std::wstring& result) const
|
|||||||
while (loop);
|
while (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CMouse::GetMouseVariable(std::wstring variable) const
|
std::wstring CMouse::GetMouseVariable(const std::wstring& variable) const
|
||||||
{
|
{
|
||||||
std::wstring result = L"";
|
std::wstring result;
|
||||||
|
|
||||||
POINT pt;
|
POINT pt;
|
||||||
GetCursorPos(&pt);
|
GetCursorPos(&pt);
|
||||||
|
|
||||||
CMeter* meter = m_MeterWindow->GetMeter(m_MeterName);
|
|
||||||
|
|
||||||
if (_wcsnicmp(variable.c_str(), L"MOUSEX", 6) == 0)
|
if (_wcsnicmp(variable.c_str(), L"MOUSEX", 6) == 0)
|
||||||
{
|
{
|
||||||
double xOffset = (double)(m_MeterWindow->GetX() + (meter ? meter->GetX() : 0) - 1);
|
double xOffset = (double)(m_MeterWindow->GetX() + (m_Meter ? m_Meter->GetX() : 0) - 1);
|
||||||
if (_wcsicmp(variable.c_str(), L"MOUSEX:%") == 0)
|
if (_wcsicmp(variable.c_str(), L"MOUSEX:%") == 0)
|
||||||
{
|
{
|
||||||
xOffset = ((pt.x - xOffset) / (meter ? meter->GetW() : m_MeterWindow->GetW())) * 100;
|
xOffset = ((pt.x - xOffset) / (m_Meter ? m_Meter->GetW() : m_MeterWindow->GetW())) * 100;
|
||||||
result = std::to_wstring((int)xOffset);
|
result = std::to_wstring((int)xOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -343,10 +252,10 @@ std::wstring CMouse::GetMouseVariable(std::wstring variable) const
|
|||||||
}
|
}
|
||||||
else if (_wcsnicmp(variable.c_str(), L"MOUSEY", 6) == 0)
|
else if (_wcsnicmp(variable.c_str(), L"MOUSEY", 6) == 0)
|
||||||
{
|
{
|
||||||
double yOffset = (double)(m_MeterWindow->GetY() + (meter ? meter->GetY() : 0) - 1);
|
double yOffset = (double)(m_MeterWindow->GetY() + (m_Meter ? m_Meter->GetY() : 0) - 1);
|
||||||
if (_wcsicmp(variable.c_str(), L"MOUSEY:%") == 0)
|
if (_wcsicmp(variable.c_str(), L"MOUSEY:%") == 0)
|
||||||
{
|
{
|
||||||
yOffset = ((pt.y - yOffset) / (meter ? meter->GetH() : m_MeterWindow->GetH())) * 100;
|
yOffset = ((pt.y - yOffset) / (m_Meter ? m_Meter->GetH() : m_MeterWindow->GetH())) * 100;
|
||||||
result = std::to_wstring((int)yOffset);
|
result = std::to_wstring((int)yOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
138
Library/Mouse.h
138
Library/Mouse.h
@ -21,27 +21,31 @@
|
|||||||
|
|
||||||
enum MOUSEACTION
|
enum MOUSEACTION
|
||||||
{
|
{
|
||||||
|
MOUSE_LMB_UP = 0,
|
||||||
MOUSE_LMB_DOWN,
|
MOUSE_LMB_DOWN,
|
||||||
MOUSE_LMB_UP,
|
|
||||||
MOUSE_LMB_DBLCLK,
|
MOUSE_LMB_DBLCLK,
|
||||||
MOUSE_RMB_DOWN,
|
|
||||||
MOUSE_RMB_UP,
|
|
||||||
MOUSE_RMB_DBLCLK,
|
|
||||||
MOUSE_MMB_DOWN,
|
|
||||||
MOUSE_MMB_UP,
|
MOUSE_MMB_UP,
|
||||||
|
MOUSE_MMB_DOWN,
|
||||||
MOUSE_MMB_DBLCLK,
|
MOUSE_MMB_DBLCLK,
|
||||||
MOUSE_OVER,
|
MOUSE_RMB_UP,
|
||||||
MOUSE_LEAVE,
|
MOUSE_RMB_DOWN,
|
||||||
MOUSE_MW_DOWN,
|
MOUSE_RMB_DBLCLK,
|
||||||
|
MOUSE_X1MB_UP,
|
||||||
|
MOUSE_X1MB_DOWN,
|
||||||
|
MOUSE_X1MB_DBLCLK,
|
||||||
|
MOUSE_X2MB_UP,
|
||||||
|
MOUSE_X2MB_DOWN,
|
||||||
|
MOUSE_X2MB_DBLCLK,
|
||||||
|
|
||||||
MOUSE_MW_UP,
|
MOUSE_MW_UP,
|
||||||
|
MOUSE_MW_DOWN,
|
||||||
MOUSE_MW_LEFT,
|
MOUSE_MW_LEFT,
|
||||||
MOUSE_MW_RIGHT,
|
MOUSE_MW_RIGHT,
|
||||||
MOUSE_X1MB_DOWN,
|
|
||||||
MOUSE_X1MB_UP,
|
MOUSE_OVER,
|
||||||
MOUSE_X1MB_DBLCLK,
|
MOUSE_LEAVE,
|
||||||
MOUSE_X2MB_DOWN,
|
|
||||||
MOUSE_X2MB_UP,
|
MOUSEACTION_COUNT
|
||||||
MOUSE_X2MB_DBLCLK
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MOUSECURSOR
|
enum MOUSECURSOR
|
||||||
@ -59,10 +63,10 @@ enum MOUSECURSOR
|
|||||||
class CMouse
|
class CMouse
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMouse();
|
CMouse(CMeterWindow* meterWindow, CMeter* meter = NULL);
|
||||||
~CMouse();
|
~CMouse();
|
||||||
|
|
||||||
void ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWindow* meterWindow);
|
void ReadOptions(CConfigParser& parser, const WCHAR* section);
|
||||||
|
|
||||||
MOUSECURSOR GetCursorType() const { return m_CursorType; }
|
MOUSECURSOR GetCursorType() const { return m_CursorType; }
|
||||||
HCURSOR GetCursor() const;
|
HCURSOR GetCursor() const;
|
||||||
@ -70,62 +74,76 @@ public:
|
|||||||
|
|
||||||
void DestroyCustomCursor();
|
void DestroyCustomCursor();
|
||||||
|
|
||||||
|
bool HasActionCommand(MOUSEACTION action) const { return !m_MouseActions[action].empty(); }
|
||||||
std::wstring GetActionCommand(MOUSEACTION action) const;
|
std::wstring GetActionCommand(MOUSEACTION action) const;
|
||||||
|
|
||||||
const std::wstring& GetRightDownAction() const { return m_RightDownAction; }
|
bool HasButtonAction() const
|
||||||
const std::wstring& GetRightUpAction() const { return m_RightUpAction; }
|
{
|
||||||
const std::wstring& GetRightDoubleClickAction() const { return m_RightDoubleClickAction; }
|
return !(
|
||||||
const std::wstring& GetLeftDownAction() const { return m_LeftDownAction; }
|
GetLeftUpAction().empty() &&
|
||||||
const std::wstring& GetLeftUpAction() const { return m_LeftUpAction; }
|
GetLeftDownAction().empty() &&
|
||||||
const std::wstring& GetLeftDoubleClickAction() const { return m_LeftDoubleClickAction; }
|
GetLeftDoubleClickAction().empty() &&
|
||||||
const std::wstring& GetMiddleDownAction() const { return m_MiddleDownAction; }
|
GetMiddleUpAction().empty() &&
|
||||||
const std::wstring& GetMiddleUpAction() const { return m_MiddleUpAction; }
|
GetMiddleDownAction().empty() &&
|
||||||
const std::wstring& GetMiddleDoubleClickAction() const { return m_MiddleDoubleClickAction; }
|
GetMiddleDoubleClickAction().empty() &&
|
||||||
const std::wstring& GetOverAction() const { return m_OverAction; }
|
GetRightUpAction().empty() &&
|
||||||
const std::wstring& GetLeaveAction() const { return m_LeaveAction; }
|
GetRightDownAction().empty() &&
|
||||||
const std::wstring& GetMouseScrollUpAction() const { return m_MouseScrollUpAction; }
|
GetRightDoubleClickAction().empty() &&
|
||||||
const std::wstring& GetMouseScrollDownAction() const { return m_MouseScrollDownAction; }
|
GetX1UpAction().empty() &&
|
||||||
const std::wstring& GetMouseScrollLeftAction() const { return m_MouseScrollLeftAction; }
|
GetX1DownAction().empty() &&
|
||||||
const std::wstring& GetMouseScrollRightAction() const { return m_MouseScrollRightAction; }
|
GetX1DoubleClickAction().empty() &&
|
||||||
const std::wstring& GetX1DownAction() const { return m_X1DownAction; }
|
GetX2UpAction().empty() &&
|
||||||
const std::wstring& GetX1UpAction() const { return m_X1UpAction; }
|
GetX2DownAction().empty() &&
|
||||||
const std::wstring& GetX1DoubleClickAction() const { return m_X1DoubleClickAction; }
|
GetX2DoubleClickAction().empty()
|
||||||
const std::wstring& GetX2DownAction() const { return m_X2DownAction; }
|
);
|
||||||
const std::wstring& GetX2UpAction() const { return m_X2UpAction; }
|
}
|
||||||
const std::wstring& GetX2DoubleClickAction() const { return m_X2DoubleClickAction; }
|
|
||||||
|
bool HasScrollAction() const
|
||||||
|
{
|
||||||
|
return !(
|
||||||
|
GetMouseScrollUpAction().empty() &&
|
||||||
|
GetMouseScrollDownAction().empty() &&
|
||||||
|
GetMouseScrollLeftAction().empty() &&
|
||||||
|
GetMouseScrollRightAction().empty()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring& GetLeftUpAction() const { return m_MouseActions[MOUSE_LMB_UP]; }
|
||||||
|
const std::wstring& GetLeftDownAction() const { return m_MouseActions[MOUSE_LMB_DOWN]; }
|
||||||
|
const std::wstring& GetLeftDoubleClickAction() const { return m_MouseActions[MOUSE_LMB_DBLCLK]; }
|
||||||
|
const std::wstring& GetMiddleUpAction() const { return m_MouseActions[MOUSE_MMB_UP]; }
|
||||||
|
const std::wstring& GetMiddleDownAction() const { return m_MouseActions[MOUSE_MMB_DOWN]; }
|
||||||
|
const std::wstring& GetMiddleDoubleClickAction() const { return m_MouseActions[MOUSE_MMB_DBLCLK]; }
|
||||||
|
const std::wstring& GetRightUpAction() const { return m_MouseActions[MOUSE_RMB_UP]; }
|
||||||
|
const std::wstring& GetRightDownAction() const { return m_MouseActions[MOUSE_RMB_DOWN]; }
|
||||||
|
const std::wstring& GetRightDoubleClickAction() const { return m_MouseActions[MOUSE_RMB_DBLCLK]; }
|
||||||
|
const std::wstring& GetX1UpAction() const { return m_MouseActions[MOUSE_X1MB_UP]; }
|
||||||
|
const std::wstring& GetX1DownAction() const { return m_MouseActions[MOUSE_X1MB_DOWN]; }
|
||||||
|
const std::wstring& GetX1DoubleClickAction() const { return m_MouseActions[MOUSE_X1MB_DBLCLK]; }
|
||||||
|
const std::wstring& GetX2UpAction() const { return m_MouseActions[MOUSE_X2MB_UP]; }
|
||||||
|
const std::wstring& GetX2DownAction() const { return m_MouseActions[MOUSE_X2MB_DOWN]; }
|
||||||
|
const std::wstring& GetX2DoubleClickAction() const { return m_MouseActions[MOUSE_X2MB_DBLCLK]; }
|
||||||
|
|
||||||
|
const std::wstring& GetMouseScrollUpAction() const { return m_MouseActions[MOUSE_MW_UP]; }
|
||||||
|
const std::wstring& GetMouseScrollDownAction() const { return m_MouseActions[MOUSE_MW_DOWN]; }
|
||||||
|
const std::wstring& GetMouseScrollLeftAction() const { return m_MouseActions[MOUSE_MW_LEFT]; }
|
||||||
|
const std::wstring& GetMouseScrollRightAction() const { return m_MouseActions[MOUSE_MW_RIGHT]; }
|
||||||
|
|
||||||
|
const std::wstring& GetOverAction() const { return m_MouseActions[MOUSE_OVER]; }
|
||||||
|
const std::wstring& GetLeaveAction() const { return m_MouseActions[MOUSE_LEAVE]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReplaceMouseVariables(std::wstring& result) const;
|
void ReplaceMouseVariables(std::wstring& result) const;
|
||||||
std::wstring GetMouseVariable(std::wstring variable) const;
|
std::wstring GetMouseVariable(const std::wstring& variable) const;
|
||||||
|
|
||||||
std::wstring m_LeftDownAction;
|
std::wstring m_MouseActions[MOUSEACTION_COUNT];
|
||||||
std::wstring m_RightDownAction;
|
|
||||||
std::wstring m_MiddleDownAction;
|
|
||||||
std::wstring m_LeftUpAction;
|
|
||||||
std::wstring m_RightUpAction;
|
|
||||||
std::wstring m_MiddleUpAction;
|
|
||||||
std::wstring m_LeftDoubleClickAction;
|
|
||||||
std::wstring m_RightDoubleClickAction;
|
|
||||||
std::wstring m_MiddleDoubleClickAction;
|
|
||||||
std::wstring m_OverAction;
|
|
||||||
std::wstring m_LeaveAction;
|
|
||||||
std::wstring m_MouseScrollDownAction;
|
|
||||||
std::wstring m_MouseScrollUpAction;
|
|
||||||
std::wstring m_MouseScrollLeftAction;
|
|
||||||
std::wstring m_MouseScrollRightAction;
|
|
||||||
std::wstring m_X1DownAction;
|
|
||||||
std::wstring m_X1UpAction;
|
|
||||||
std::wstring m_X1DoubleClickAction;
|
|
||||||
std::wstring m_X2DownAction;
|
|
||||||
std::wstring m_X2UpAction;
|
|
||||||
std::wstring m_X2DoubleClickAction;
|
|
||||||
|
|
||||||
MOUSECURSOR m_CursorType;
|
MOUSECURSOR m_CursorType;
|
||||||
HCURSOR m_CustomCursor;
|
HCURSOR m_CustomCursor;
|
||||||
bool m_CursorState;
|
bool m_CursorState;
|
||||||
|
|
||||||
CMeterWindow* m_MeterWindow;
|
CMeterWindow* m_MeterWindow;
|
||||||
std::wstring m_MeterName;
|
CMeter* m_Meter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user