Added OnUpdateAction to measures, meters and the [Rainmeter] section.

This commit is contained in:
Brian Ferguson 2013-01-10 15:50:38 -07:00
parent 24e080dfc0
commit 9800692f19
6 changed files with 33 additions and 1 deletions

View File

@ -144,6 +144,8 @@ void CMeasure::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_IfEqualValue = (int64_t)parser.ReadFloat(section, L"IfEqualValue", 0.0);
m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false);
m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false);
m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0);
m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0);

View File

@ -67,6 +67,8 @@ public:
static void GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue, WCHAR* buffer, size_t sizeInWords);
static void RemoveTrailingZero(WCHAR* str, int strLen);
std::wstring GetOnUpdateAction() { return m_OnUpdateAction; }
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
@ -110,6 +112,8 @@ protected:
bool m_Disabled; // Status of the measure
bool m_Initialized;
std::wstring m_OnUpdateAction;
CMeterWindow* m_MeterWindow;
};

View File

@ -320,6 +320,8 @@ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue());
m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0);
m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false);
m_Mouse.ReadOptions(parser, section, m_MeterWindow);
m_HasMouseAction =

View File

@ -76,6 +76,8 @@ public:
void SetMouseOver(bool over) { m_MouseOver = over; }
bool IsMouseOver() { return m_MouseOver; }
std::wstring GetOnUpdateAction() { return m_OnUpdateAction; }
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name);
@ -151,6 +153,8 @@ protected:
bool m_AntiAlias;
bool m_Initialized;
std::wstring m_OnUpdateAction;
CMeterWindow* m_MeterWindow;
};

View File

@ -2040,6 +2040,7 @@ bool CMeterWindow::ReadSkin()
m_OnCloseAction = m_Parser.ReadString(L"Rainmeter", L"OnCloseAction", L"", false);
m_OnFocusAction = m_Parser.ReadString(L"Rainmeter", L"OnFocusAction", L"", false);
m_OnUnfocusAction = m_Parser.ReadString(L"Rainmeter", L"OnUnfocusAction", L"", false);
m_OnUpdateAction = m_Parser.ReadString(L"Rainmeter", L"OnUpdateAction", L"", false);
m_WindowUpdate = m_Parser.ReadInt(L"Rainmeter", L"Update", INTERVAL_METER);
m_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", INTERVAL_TRANSITION);
@ -2681,7 +2682,14 @@ void CMeterWindow::Update(bool refresh)
std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
for ( ; i != m_Measures.end(); ++i)
{
UpdateMeasure((*i), refresh);
if (UpdateMeasure((*i), refresh))
{
std::wstring updateAction = (*i)->GetOnUpdateAction();
if (!updateAction.empty())
{
Rainmeter->ExecuteCommand(updateAction.c_str(), this);
}
}
}
}
@ -2696,6 +2704,12 @@ void CMeterWindow::Update(bool refresh)
if (UpdateMeter((*j), bActiveTransition, refresh))
{
bUpdate = true;
std::wstring updateAction = (*j)->GetOnUpdateAction();
if (!updateAction.empty())
{
Rainmeter->ExecuteCommand(updateAction.c_str(), this);
}
}
}
@ -2718,6 +2732,11 @@ void CMeterWindow::Update(bool refresh)
// Post-updates
PostUpdate(bActiveTransition);
if (!m_OnUpdateAction.empty())
{
Rainmeter->ExecuteCommand(m_OnUpdateAction.c_str(), this);
}
}
/*

View File

@ -371,6 +371,7 @@ private:
std::wstring m_OnCloseAction;
std::wstring m_OnFocusAction;
std::wstring m_OnUnfocusAction;
std::wstring m_OnUpdateAction;
std::wstring m_BackgroundName;
RECT m_BackgroundMargins;