Code cleanup.

This commit is contained in:
spx 2011-08-31 16:04:29 +00:00
parent d51fc12841
commit 6366233d66

View File

@ -3736,8 +3736,8 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
else if (wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90) else if (wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90)
{ {
m_AlphaValue = (int)(255.0 - (wParam - ID_CONTEXT_SKINMENU_TRANSPARENCY_0) * (230.0 / (ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - ID_CONTEXT_SKINMENU_TRANSPARENCY_0))); m_AlphaValue = (int)(255.0 - (wParam - ID_CONTEXT_SKINMENU_TRANSPARENCY_0) * (230.0 / (ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - ID_CONTEXT_SKINMENU_TRANSPARENCY_0)));
WriteConfig(SETTING_ALPHAVALUE);
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
WriteConfig(SETTING_ALPHAVALUE);
} }
else if (wParam == ID_CONTEXT_CLOSESKIN) else if (wParam == ID_CONTEXT_CLOSESKIN)
{ {
@ -3748,51 +3748,34 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_WindowXFromRight = !m_WindowXFromRight; m_WindowXFromRight = !m_WindowXFromRight;
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION);
if (m_SavePosition)
{
WriteConfig(SETTING_WINDOWPOSITION);
}
} }
else if (wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM) else if (wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM)
{ {
m_WindowYFromBottom = !m_WindowYFromBottom; m_WindowYFromBottom = !m_WindowYFromBottom;
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION);
if (m_SavePosition)
{
WriteConfig(SETTING_WINDOWPOSITION);
}
} }
else if (wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE) else if (wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE)
{ {
m_WindowXPercentage = !m_WindowXPercentage; m_WindowXPercentage = !m_WindowXPercentage;
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION);
if (m_SavePosition)
{
WriteConfig(SETTING_WINDOWPOSITION);
}
} }
else if (wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE) else if (wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE)
{ {
m_WindowYPercentage = !m_WindowYPercentage; m_WindowYPercentage = !m_WindowYPercentage;
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION);
if (m_SavePosition)
{
WriteConfig(SETTING_WINDOWPOSITION);
}
} }
else if (wParam == ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT) else if (wParam == ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT)
{ {
m_AutoSelectScreen = !m_AutoSelectScreen; m_AutoSelectScreen = !m_AutoSelectScreen;
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION | SETTING_AUTOSELECTSCREEN); WriteConfig(SETTING_WINDOWPOSITION | SETTING_AUTOSELECTSCREEN);
} }
else if (wParam == ID_CONTEXT_SKINMENU_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST) else if (wParam == ID_CONTEXT_SKINMENU_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
@ -3825,7 +3808,6 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
m_Parser.ResetMonitorVariables(this); // Set present monitor variables m_Parser.ResetMonitorVariables(this); // Set present monitor variables
ScreenToWindow(); ScreenToWindow();
WriteConfig(SETTING_WINDOWPOSITION | SETTING_AUTOSELECTSCREEN); WriteConfig(SETTING_WINDOWPOSITION | SETTING_AUTOSELECTSCREEN);
} }
} }
@ -3947,8 +3929,8 @@ void CMeterWindow::SetSnapEdges(bool b)
void CMeterWindow::SetWindowHide(HIDEMODE hide) void CMeterWindow::SetWindowHide(HIDEMODE hide)
{ {
m_WindowHide = hide; m_WindowHide = hide;
WriteConfig(SETTING_HIDEONMOUSEOVER);
UpdateTransparency(m_AlphaValue, false); UpdateTransparency(m_AlphaValue, false);
WriteConfig(SETTING_HIDEONMOUSEOVER);
} }
/* /*
@ -4307,19 +4289,8 @@ LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
// Handle buttons // Handle buttons
HandleButtons(pos, BUTTONPROC_DOWN, NULL); HandleButtons(pos, BUTTONPROC_DOWN, NULL);
SHORT state = GetKeyState(VK_CONTROL); if ((GetKeyState(VK_CONTROL) & 0x80) || // Ctrl is pressed, so only run default action
bool down = ((unsigned short) state) >> 15; (!DoAction(pos.x, pos.y, MOUSE_LMB_DOWN, false) && m_WindowDraggable))
// Ctrl is pressed, so only run default action
if (down)
{
// Cancel the mouse event beforehand
SetMouseLeaveEvent(true);
// Run the DefWindowProc so the dragging works
return DefWindowProc(m_Window, uMsg, wParam, lParam);
}
if (!DoAction(pos.x, pos.y, MOUSE_LMB_DOWN, false) && m_WindowDraggable)
{ {
// Cancel the mouse event beforehand // Cancel the mouse event beforehand
SetMouseLeaveEvent(true); SetMouseLeaveEvent(true);
@ -4427,15 +4398,8 @@ LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
// Handle buttons // Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL); HandleButtons(pos, BUTTONPROC_MOVE, NULL);
SHORT state = GetKeyState(VK_CONTROL); if ((GetKeyState(VK_CONTROL) & 0x80) || // Ctrl is pressed, so only run default action
bool down = ((unsigned short) state) >> 15; !DoAction(pos.x, pos.y, MOUSE_RMB_UP, false))
// Ctrl is pressed, so only run default action
if (down)
{
return DefWindowProc(m_Window, WM_RBUTTONUP, wParam, lParam);
}
if (!DoAction(pos.x, pos.y, MOUSE_RMB_UP, false))
{ {
// Run the DefWindowProc so the context menu works // Run the DefWindowProc so the context menu works
return DefWindowProc(m_Window, WM_RBUTTONUP, wParam, lParam); return DefWindowProc(m_Window, WM_RBUTTONUP, wParam, lParam);
@ -4583,16 +4547,11 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
// Handle buttons // Handle buttons
HandleButtons(posc, BUTTONPROC_MOVE, NULL); HandleButtons(posc, BUTTONPROC_MOVE, NULL);
SHORT state = GetKeyState(VK_CONTROL); // If RMB up or RMB down or double-click cause actions, do not show the menu!
bool down = ((unsigned short) state) >> 15; if ((GetKeyState(VK_CONTROL) & 0x80) == 0 && // Ctrl is pressed, so ignore any actions
// Ctrl is pressed, so ignore any actions (DoAction(posc.x, posc.y, MOUSE_RMB_UP, false) || DoAction(posc.x, posc.y, MOUSE_RMB_DOWN, true) || DoAction(posc.x, posc.y, MOUSE_RMB_DBLCLK, true)))
if (!down)
{ {
// If RMB up or RMB down or double-click cause actions, do not show the menu! return 0;
if (DoAction(posc.x, posc.y, MOUSE_RMB_UP, false) || DoAction(posc.x, posc.y, MOUSE_RMB_DOWN, true) || DoAction(posc.x, posc.y, MOUSE_RMB_DBLCLK, true))
{
return 0;
}
} }
} }