mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed incomplete fix in r420 and r422.
Fixed the issue that the result of some bangs is overwritten with the default value if DynamicVariables=1 is added to Measure/Meter. (Issue 125) Note that this fix is effective only when the setting is not defined in skin configuration file. The result of !RainmeterHideMeter(or Show/Toggle) is overwritten if Hidden=0/1 is added. Some minor changes.
This commit is contained in:
parent
669791c075
commit
b675265606
@ -657,7 +657,7 @@ int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Color CConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, Color defValue)
|
||||
Color CConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, const Color& defValue)
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
swprintf(buffer, L"%i, %i, %i, %i", defValue.GetR(), defValue.GetG(), defValue.GetB(), defValue.GetA());
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
double ReadFloat(LPCTSTR section, LPCTSTR key, double defValue);
|
||||
double ReadFormula(LPCTSTR section, LPCTSTR key, double defValue);
|
||||
int ReadInt(LPCTSTR section, LPCTSTR key, int defValue);
|
||||
Gdiplus::Color ReadColor(LPCTSTR section, LPCTSTR key, Gdiplus::Color defValue);
|
||||
Gdiplus::Color ReadColor(LPCTSTR section, LPCTSTR key, const Gdiplus::Color& defValue);
|
||||
std::vector<Gdiplus::REAL> ReadFloats(LPCTSTR section, LPCTSTR key);
|
||||
|
||||
std::wstring& GetFilename() { return m_Filename; }
|
||||
|
@ -67,8 +67,9 @@ CMeasure::CMeasure(CMeterWindow* meterWindow)
|
||||
m_MedianPos = 0;
|
||||
m_AveragePos = 0;
|
||||
m_AverageSize = 0;
|
||||
m_MeterWindow = meterWindow;
|
||||
m_DynamicVariables = false;
|
||||
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -97,7 +98,7 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0);
|
||||
m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0);
|
||||
m_Disabled = 0!=parser.ReadInt(section, L"Disabled", m_Disabled);
|
||||
|
||||
UINT updateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
|
||||
if (updateDivider != m_UpdateDivider)
|
||||
|
@ -33,9 +33,6 @@
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
int CMeter::c_OldX = 0;
|
||||
int CMeter::c_OldY = 0;
|
||||
|
||||
/*
|
||||
** CMeter
|
||||
**
|
||||
@ -45,6 +42,7 @@ int CMeter::c_OldY = 0;
|
||||
CMeter::CMeter(CMeterWindow* meterWindow)
|
||||
{
|
||||
m_Measure = NULL;
|
||||
|
||||
m_X = 0;
|
||||
m_Y = 0;
|
||||
m_W = 0;
|
||||
@ -57,14 +55,14 @@ CMeter::CMeter(CMeterWindow* meterWindow)
|
||||
m_UpdateCounter = 0;
|
||||
m_RelativeX = POSITION_ABSOLUTE;
|
||||
m_RelativeY = POSITION_ABSOLUTE;
|
||||
m_MeterWindow = NULL;
|
||||
m_SolidAngle = 0.0;
|
||||
m_MeterWindow = meterWindow;
|
||||
m_SolidAngle = 0.0f;
|
||||
m_AntiAlias = false;
|
||||
m_DynamicVariables = false;
|
||||
m_Initialized = false;
|
||||
m_HasMouseAction = false;
|
||||
m_MouseActionCursor = true;
|
||||
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -211,14 +209,19 @@ bool CMeter::HitTest(int x, int y)
|
||||
*/
|
||||
void CMeter::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
// The MeterStyle defines a template where the values are read if the meter doesn't have it itself
|
||||
const std::wstring& style = parser.ReadString(section, L"MeterStyle", L"");
|
||||
parser.SetStyleTemplate(style);
|
||||
if (!style.empty())
|
||||
{
|
||||
parser.SetStyleTemplate(style);
|
||||
}
|
||||
|
||||
std::wstring coord = parser.ReadString(section, L"X", L"0");
|
||||
if (coord.size() > 0)
|
||||
wsprintf(buffer, L"%i%c", m_X, (m_RelativeX == POSITION_RELATIVE_TL) ? L'r' : (m_RelativeX == POSITION_RELATIVE_BR) ? L'R' : L'');
|
||||
std::wstring coord = parser.ReadString(section, L"X", buffer);
|
||||
if (!coord.empty())
|
||||
{
|
||||
size_t len = coord.size();
|
||||
if (coord[len - 1] == L'r')
|
||||
@ -231,6 +234,10 @@ void CMeter::ReadConfig(const WCHAR* section)
|
||||
m_RelativeX = POSITION_RELATIVE_BR;
|
||||
coord.erase(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RelativeX = POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
double val;
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && -1 != parser.ReadFormula(coord, &val))
|
||||
@ -242,9 +249,15 @@ void CMeter::ReadConfig(const WCHAR* section)
|
||||
m_X = (int)parser.ParseDouble(coord, 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_X = 0;
|
||||
m_RelativeX = POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
coord = parser.ReadString(section, L"Y", L"0");
|
||||
if (coord.size() > 0)
|
||||
wsprintf(buffer, L"%i%c", m_Y, (m_RelativeY == POSITION_RELATIVE_TL) ? L'r' : (m_RelativeY == POSITION_RELATIVE_BR) ? L'R' : L'');
|
||||
coord = parser.ReadString(section, L"Y", buffer);
|
||||
if (!coord.empty())
|
||||
{
|
||||
size_t len = coord.size();
|
||||
if (coord[len - 1] == L'r')
|
||||
@ -257,6 +270,10 @@ void CMeter::ReadConfig(const WCHAR* section)
|
||||
m_RelativeY = POSITION_RELATIVE_BR;
|
||||
coord.erase(--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RelativeY = POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
double val;
|
||||
if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && -1 != parser.ReadFormula(coord, &val))
|
||||
@ -265,15 +282,20 @@ void CMeter::ReadConfig(const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Y = (int)parser.ParseDouble(coord, 0.0);;
|
||||
m_Y = (int)parser.ParseDouble(coord, 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Y = 0;
|
||||
m_RelativeY = POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
m_W = (int)parser.ReadFormula(section, L"W", 1.0);
|
||||
m_H = (int)parser.ReadFormula(section, L"H", 1.0);
|
||||
|
||||
m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0);
|
||||
m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", m_SolidBevel);
|
||||
m_Hidden = 0!=parser.ReadInt(section, L"Hidden", m_Hidden);
|
||||
m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE);
|
||||
|
||||
m_SolidColor = parser.ReadColor(section, L"SolidColor", Color(0, 0, 0, 0));
|
||||
m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor);
|
||||
@ -291,10 +313,7 @@ void CMeter::ReadConfig(const WCHAR* section)
|
||||
m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"", false);
|
||||
m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
||||
|
||||
if(m_MouseActionCursor == false)
|
||||
m_MouseActionCursor = 0!= parser.ReadInt(section, L"MouseActionCursor", 0);
|
||||
else
|
||||
m_MouseActionCursor = 0!= parser.ReadInt(section, L"MouseActionCursor", 1);
|
||||
m_MouseActionCursor = 0!=parser.ReadInt(section, L"MouseActionCursor", m_MouseActionCursor);
|
||||
|
||||
m_HasMouseAction =
|
||||
( !m_LeftMouseUpAction.empty() || !m_LeftMouseDownAction.empty() || !m_LeftMouseDoubleClickAction.empty()
|
||||
|
@ -112,9 +112,6 @@ protected:
|
||||
CMeter* m_RelativeMeter;
|
||||
bool m_DynamicVariables; // If true, the measure contains dynamic variables
|
||||
|
||||
static int c_OldX;
|
||||
static int c_OldY;
|
||||
|
||||
std::wstring m_RightMouseDownAction; // Actions for left and right and middle mouse buttons
|
||||
std::wstring m_RightMouseUpAction;
|
||||
std::wstring m_RightMouseDoubleClickAction;
|
||||
|
@ -1367,27 +1367,44 @@ void CMeterWindow::ReadConfig()
|
||||
std::wstring iniFile = m_Rainmeter->GetIniFile();
|
||||
const WCHAR* section = L"Rainmeter";
|
||||
|
||||
m_SavePosition = true; // Default value
|
||||
// Reset settings to the default value
|
||||
m_WindowX = L"0";
|
||||
m_WindowY = L"0";
|
||||
m_AnchorX = L"0";
|
||||
m_AnchorY = L"0";
|
||||
m_WindowZPosition = ZPOSITION_NORMAL;
|
||||
m_WindowDraggable = true;
|
||||
m_WindowHide = HIDEMODE_NONE;
|
||||
m_WindowStartHidden = false;
|
||||
m_SavePosition = true;
|
||||
m_SnapEdges = true;
|
||||
m_MeasuresToVariables = false;
|
||||
m_NativeTransparency = true;
|
||||
m_ClickThrough = false;
|
||||
m_KeepOnScreen = true;
|
||||
m_AutoSelectScreen = false;
|
||||
m_AlphaValue = 255;
|
||||
m_FadeDuration = 250;
|
||||
|
||||
CConfigParser parser;
|
||||
parser.Initialize(iniFile.c_str(), m_Rainmeter);
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
m_WindowX = parser.ReadString(section, L"WindowX", L"0");
|
||||
m_WindowY = parser.ReadString(section, L"WindowY", L"0");
|
||||
m_AnchorX = parser.ReadString(section, L"AnchorX", L"0");
|
||||
m_AnchorY = parser.ReadString(section, L"AnchorY", L"0");
|
||||
m_WindowX = parser.ReadString(section, L"WindowX", m_WindowX.c_str());
|
||||
m_WindowY = parser.ReadString(section, L"WindowY", m_WindowY.c_str());
|
||||
m_AnchorX = parser.ReadString(section, L"AnchorX", m_AnchorX.c_str());
|
||||
m_AnchorY = parser.ReadString(section, L"AnchorY", m_AnchorY.c_str());
|
||||
|
||||
if (!m_Rainmeter->GetDummyLitestep())
|
||||
{
|
||||
char tmpSz[MAX_LINE_LENGTH];
|
||||
// Check if step.rc has overrides these values
|
||||
if (GetRCString("RainmeterWindowX", tmpSz, "0", MAX_LINE_LENGTH - 1))
|
||||
if (GetRCString("RainmeterWindowX", tmpSz, ConvertToAscii(m_WindowX.c_str()).c_str(), MAX_LINE_LENGTH - 1))
|
||||
{
|
||||
m_WindowX = ConvertToWide(tmpSz);
|
||||
}
|
||||
if (GetRCString("RainmeterWindowY", tmpSz, "0", MAX_LINE_LENGTH - 1))
|
||||
if (GetRCString("RainmeterWindowY", tmpSz, ConvertToAscii(m_WindowY.c_str()).c_str(), MAX_LINE_LENGTH - 1))
|
||||
{
|
||||
m_WindowY = ConvertToWide(tmpSz);
|
||||
}
|
||||
@ -1409,7 +1426,7 @@ void CMeterWindow::ReadConfig()
|
||||
m_WindowY = buffer;
|
||||
}
|
||||
|
||||
int zPos = parser.ReadInt(section, L"AlwaysOnTop", ZPOSITION_NORMAL);
|
||||
int zPos = parser.ReadInt(section, L"AlwaysOnTop", m_WindowZPosition);
|
||||
if (zPos == -1)
|
||||
{
|
||||
m_WindowZPosition = ZPOSITION_ONBOTTOM;
|
||||
@ -1431,33 +1448,33 @@ void CMeterWindow::ReadConfig()
|
||||
m_WindowZPosition = ZPOSITION_NORMAL;
|
||||
}
|
||||
|
||||
m_WindowDraggable = 0!=parser.ReadInt(section, L"Draggable", 1);
|
||||
m_WindowHide = (HIDEMODE)parser.ReadInt(section, L"HideOnMouseOver", HIDEMODE_NONE);
|
||||
m_WindowStartHidden = 0!=parser.ReadInt(section, L"StartHidden", 0);
|
||||
m_SavePosition = 0!=parser.ReadInt(section, L"SavePosition", 1);
|
||||
m_SnapEdges = 0!=parser.ReadInt(section, L"SnapEdges", 1);
|
||||
m_MeasuresToVariables = 0!=parser.ReadInt(section, L"MeasuresToVariables", 0);
|
||||
m_NativeTransparency = 0!=parser.ReadInt(section, L"NativeTransparency", 1);
|
||||
m_ClickThrough = 0!=parser.ReadInt(section, L"ClickThrough", 0);
|
||||
m_KeepOnScreen = 0!=parser.ReadInt(section, L"KeepOnScreen", 1);
|
||||
m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", 0);
|
||||
m_WindowDraggable = 0!=parser.ReadInt(section, L"Draggable", m_WindowDraggable);
|
||||
m_WindowHide = (HIDEMODE)parser.ReadInt(section, L"HideOnMouseOver", m_WindowHide);
|
||||
m_WindowStartHidden = 0!=parser.ReadInt(section, L"StartHidden", m_WindowStartHidden);
|
||||
m_SavePosition = 0!=parser.ReadInt(section, L"SavePosition", m_SavePosition);
|
||||
m_SnapEdges = 0!=parser.ReadInt(section, L"SnapEdges", m_SnapEdges);
|
||||
m_MeasuresToVariables = 0!=parser.ReadInt(section, L"MeasuresToVariables", m_MeasuresToVariables);
|
||||
m_NativeTransparency = 0!=parser.ReadInt(section, L"NativeTransparency", m_NativeTransparency);
|
||||
m_ClickThrough = 0!=parser.ReadInt(section, L"ClickThrough", m_ClickThrough);
|
||||
m_KeepOnScreen = 0!=parser.ReadInt(section, L"KeepOnScreen", m_KeepOnScreen);
|
||||
m_AutoSelectScreen = 0!=parser.ReadInt(section, L"AutoSelectScreen", m_AutoSelectScreen);
|
||||
|
||||
m_AlphaValue = parser.ReadInt(section, L"AlphaValue", 255);
|
||||
m_AlphaValue = parser.ReadInt(section, L"AlphaValue", m_AlphaValue);
|
||||
m_AlphaValue = min(255, m_AlphaValue);
|
||||
m_AlphaValue = max(0, m_AlphaValue);
|
||||
|
||||
m_FadeDuration = parser.ReadInt(section, L"FadeDuration", 250);
|
||||
|
||||
// Disable native transparency if not 2K/XP
|
||||
if(CRainmeter::IsNT() == PLATFORM_9X || CRainmeter::IsNT() == PLATFORM_NT4)
|
||||
{
|
||||
m_NativeTransparency = 0;
|
||||
}
|
||||
m_FadeDuration = parser.ReadInt(section, L"FadeDuration", m_FadeDuration);
|
||||
|
||||
// On the second loop override settings from the skin's section
|
||||
section = m_SkinName.c_str();
|
||||
}
|
||||
|
||||
// Disable native transparency if not 2K/XP
|
||||
if(CRainmeter::IsNT() == PLATFORM_9X || CRainmeter::IsNT() == PLATFORM_NT4)
|
||||
{
|
||||
m_NativeTransparency = 0;
|
||||
}
|
||||
|
||||
// Set WindowXScreen/WindowYScreen temporarily
|
||||
WindowToScreen();
|
||||
}
|
||||
@ -1568,8 +1585,8 @@ void CMeterWindow::ReadSkin()
|
||||
m_DragMargins.Y = top;
|
||||
m_DragMargins.Height = bottom - top;
|
||||
|
||||
m_BackgroundMode = (BGMODE)m_Parser.ReadInt(L"Rainmeter", L"BackgroundMode", 0);
|
||||
m_SolidBevel = (BEVELTYPE)m_Parser.ReadInt(L"Rainmeter", L"BevelType", 0);
|
||||
m_BackgroundMode = (BGMODE)m_Parser.ReadInt(L"Rainmeter", L"BackgroundMode", BGMODE_IMAGE);
|
||||
m_SolidBevel = (BEVELTYPE)m_Parser.ReadInt(L"Rainmeter", L"BevelType", BEVELTYPE_NONE);
|
||||
|
||||
m_SolidColor = m_Parser.ReadColor(L"Rainmeter", L"SolidColor", Color::Gray);
|
||||
m_SolidColor2 = m_Parser.ReadColor(L"Rainmeter", L"SolidColor2", m_SolidColor);
|
||||
@ -2277,31 +2294,35 @@ void CMeterWindow::UpdateTransparency(int alpha, bool reset)
|
||||
typedef BOOL (WINAPI * FPUPDATELAYEREDWINDOW)(HWND hWnd, HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
|
||||
FPUPDATELAYEREDWINDOW UpdateLayeredWindow = (FPUPDATELAYEREDWINDOW)GetProcAddress(m_User32Library, "UpdateLayeredWindow");
|
||||
|
||||
BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
|
||||
POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY};
|
||||
POINT ptSrc = {0, 0};
|
||||
SIZE szWindow;
|
||||
|
||||
if (m_WindowW == 0 && m_WindowH == 0)
|
||||
{
|
||||
// Reset window to avoid invalid state
|
||||
UpdateLayeredWindow(m_Window, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0);
|
||||
// Set dummy size to avoid invalid state
|
||||
szWindow.cx = 1;
|
||||
szWindow.cy = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
BLENDFUNCTION blendPixelFunction= {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
|
||||
POINT ptWindowScreenPosition = {m_ScreenX, m_ScreenY};
|
||||
POINT ptSrc = {0, 0};
|
||||
SIZE szWindow = {m_WindowW, m_WindowH};
|
||||
|
||||
HDC dcScreen = GetDC(GetDesktopWindow());
|
||||
HDC dcMemory = CreateCompatibleDC(dcScreen);
|
||||
|
||||
HBITMAP dbBitmap;
|
||||
m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap);
|
||||
HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap);
|
||||
UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
|
||||
ReleaseDC(GetDesktopWindow(), dcScreen);
|
||||
SelectObject(dcMemory, oldBitmap);
|
||||
DeleteDC(dcMemory);
|
||||
DeleteObject(dbBitmap);
|
||||
szWindow.cx = m_WindowW;
|
||||
szWindow.cy = m_WindowH;
|
||||
}
|
||||
|
||||
HDC dcScreen = GetDC(GetDesktopWindow());
|
||||
HDC dcMemory = CreateCompatibleDC(dcScreen);
|
||||
|
||||
HBITMAP dbBitmap;
|
||||
m_DoubleBuffer->GetHBITMAP(Color(0, 0, 0, 0), &dbBitmap);
|
||||
HBITMAP oldBitmap = (HBITMAP)SelectObject(dcMemory, dbBitmap);
|
||||
UpdateLayeredWindow(m_Window, dcScreen, &ptWindowScreenPosition, &szWindow, dcMemory, &ptSrc, 0, &blendPixelFunction, ULW_ALPHA);
|
||||
ReleaseDC(GetDesktopWindow(), dcScreen);
|
||||
SelectObject(dcMemory, oldBitmap);
|
||||
DeleteDC(dcMemory);
|
||||
DeleteObject(dbBitmap);
|
||||
|
||||
m_TransparencyValue = alpha;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user