Added OnChangeAction to measures

This commit is contained in:
Brian Ferguson 2013-01-10 23:03:07 -07:00
parent 9800692f19
commit 90b80a2ca9
3 changed files with 25 additions and 1 deletions

View File

@ -86,7 +86,9 @@ CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name
m_IfAboveCommitted(false),
m_IfBelowCommitted(false),
m_Disabled(false),
m_Initialized(false)
m_Initialized(false),
m_OldValue(0.0),
m_OldStringValue(L"")
{
}
@ -145,6 +147,7 @@ void CMeasure::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false);
m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false);
m_OnChangeAction = parser.ReadString(section, L"OnChangeAction", L"", false);
m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0);

View File

@ -69,6 +69,12 @@ public:
std::wstring GetOnUpdateAction() { return m_OnUpdateAction; }
std::wstring GetOnChangeAction() { return m_OnChangeAction; }
void SetOldValue(double value) { m_OldValue = value; }
double GetOldValue() { return m_OldValue; }
void SetOldStringValue(std::wstring value) { m_OldStringValue = value; }
std::wstring GetOldStringValue() { return m_OldStringValue; }
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name);
@ -114,6 +120,10 @@ protected:
std::wstring m_OnUpdateAction;
std::wstring m_OnChangeAction;
double m_OldValue;
std::wstring m_OldStringValue;
CMeterWindow* m_MeterWindow;
};

View File

@ -2689,6 +2689,17 @@ void CMeterWindow::Update(bool refresh)
{
Rainmeter->ExecuteCommand(updateAction.c_str(), this);
}
double newValue = (*i)->GetValue();
const WCHAR* newStringValue = (*i)->GetStringValue(AUTOSCALE_OFF, 1, -1, false);
std::wstring changeAction = (*i)->GetOnChangeAction();
if (((*i)->GetOldValue() != newValue || (*i)->GetOldStringValue() != newStringValue) && !changeAction.empty())
{
(*i)->SetOldValue(newValue);
(*i)->SetOldStringValue(newStringValue);
Rainmeter->ExecuteCommand(changeAction.c_str(), this);
}
}
}
}