mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Additional changes to c3982da
This commit is contained in:
parent
c3982da712
commit
4e27d71d97
@ -194,6 +194,9 @@
|
|||||||
<ClCompile Include="Export.cpp">
|
<ClCompile Include="Export.cpp">
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Section.cpp">
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="StdAfx.cpp">
|
<ClCompile Include="StdAfx.cpp">
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -321,6 +321,9 @@
|
|||||||
<ClCompile Include="Mouse.cpp">
|
<ClCompile Include="Mouse.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Section.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\Common\Dialog.cpp">
|
<ClCompile Include="..\Common\Dialog.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -69,7 +69,7 @@ extern CRainmeter* Rainmeter;
|
|||||||
** The constructor
|
** The constructor
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name), m_MeterWindow(meterWindow),
|
CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(meterWindow, name),
|
||||||
m_Invert(false),
|
m_Invert(false),
|
||||||
m_LogMaxValue(false),
|
m_LogMaxValue(false),
|
||||||
m_MinValue(),
|
m_MinValue(),
|
||||||
@ -87,8 +87,8 @@ CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name
|
|||||||
m_IfBelowCommitted(false),
|
m_IfBelowCommitted(false),
|
||||||
m_Disabled(false),
|
m_Disabled(false),
|
||||||
m_Initialized(false),
|
m_Initialized(false),
|
||||||
m_OldValue(0.0),
|
m_OldValue(),
|
||||||
m_OldStringValue(L"")
|
m_OldValueInitialized(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,6 +728,36 @@ void CMeasure::RemoveTrailingZero(WCHAR* str, int strLen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Execute OnChangeAction if action is set
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
void CMeasure::DoChangeAction()
|
||||||
|
{
|
||||||
|
if (!m_OldValueInitialized)
|
||||||
|
{
|
||||||
|
double newValue = GetValue();
|
||||||
|
const WCHAR* newStringValue = GetStringValue(AUTOSCALE_OFF, 1, -1, false);
|
||||||
|
|
||||||
|
m_OldValue = newValue;
|
||||||
|
m_OldStringValue = newStringValue;
|
||||||
|
m_OldValueInitialized = true;
|
||||||
|
}
|
||||||
|
else if (!m_OnChangeAction.empty())
|
||||||
|
{
|
||||||
|
double newValue = GetValue();
|
||||||
|
const WCHAR* newStringValue = GetStringValue(AUTOSCALE_OFF, 1, -1, false);
|
||||||
|
|
||||||
|
if (m_OldValue != newValue || wcscmp(m_OldStringValue.c_str(), newStringValue) != 0)
|
||||||
|
{
|
||||||
|
m_OldValue = newValue;
|
||||||
|
m_OldStringValue = newStringValue;
|
||||||
|
|
||||||
|
Rainmeter->ExecuteCommand(m_OnChangeAction.c_str(), m_MeterWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Creates the given measure. This is the factory method for the measures.
|
** Creates the given measure. This is the factory method for the measures.
|
||||||
** If new measures are implemented this method needs to be updated.
|
** If new measures are implemented this method needs to be updated.
|
||||||
|
@ -68,10 +68,7 @@ public:
|
|||||||
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
static void RemoveTrailingZero(WCHAR* str, int strLen);
|
||||||
|
|
||||||
const std::wstring& GetOnChangeAction() { return m_OnChangeAction; }
|
const std::wstring& GetOnChangeAction() { return m_OnChangeAction; }
|
||||||
void SetOldValue(double value) { m_OldValue = value; }
|
void DoChangeAction();
|
||||||
double GetOldValue() { return m_OldValue; }
|
|
||||||
void SetOldStringValue(std::wstring value) { m_OldStringValue = value; }
|
|
||||||
const std::wstring& GetOldStringValue() { return m_OldStringValue; }
|
|
||||||
|
|
||||||
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
|
CMeterWindow* GetMeterWindow() { return m_MeterWindow; }
|
||||||
|
|
||||||
@ -119,8 +116,7 @@ protected:
|
|||||||
std::wstring m_OnChangeAction;
|
std::wstring m_OnChangeAction;
|
||||||
double m_OldValue;
|
double m_OldValue;
|
||||||
std::wstring m_OldStringValue;
|
std::wstring m_OldStringValue;
|
||||||
|
bool m_OldValueInitialized;
|
||||||
CMeterWindow* m_MeterWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +39,7 @@ extern CRainmeter* Rainmeter;
|
|||||||
** The constructor
|
** The constructor
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name), m_MeterWindow(meterWindow),
|
CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : CSection(meterWindow, name),
|
||||||
m_X(),
|
m_X(),
|
||||||
m_Y(),
|
m_Y(),
|
||||||
m_W(0),
|
m_W(0),
|
||||||
|
@ -150,8 +150,6 @@ protected:
|
|||||||
Gdiplus::REAL m_SolidAngle;
|
Gdiplus::REAL m_SolidAngle;
|
||||||
bool m_AntiAlias;
|
bool m_AntiAlias;
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
|
|
||||||
CMeterWindow* m_MeterWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1228,7 +1228,7 @@ void CMeterWindow::UpdateMeter(const std::wstring& name, bool group)
|
|||||||
{
|
{
|
||||||
if (UpdateMeter((*j), bActiveTransition, true))
|
if (UpdateMeter((*j), bActiveTransition, true))
|
||||||
{
|
{
|
||||||
DoUpdateAction((*j));
|
(*j)->DoUpdateAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
|
SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size
|
||||||
@ -1354,8 +1354,8 @@ void CMeterWindow::UpdateMeasure(const std::wstring& name, bool group)
|
|||||||
|
|
||||||
if (UpdateMeasure((*i), true))
|
if (UpdateMeasure((*i), true))
|
||||||
{
|
{
|
||||||
DoUpdateAction((*i));
|
(*i)->DoUpdateAction();
|
||||||
//DoChangeAction((*i), false); // TODO: Check that this is the first update or not
|
(*i)->DoChangeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!group) return;
|
if (!group) return;
|
||||||
@ -2678,6 +2678,11 @@ void CMeterWindow::Update(bool refresh)
|
|||||||
{
|
{
|
||||||
++m_UpdateCounter;
|
++m_UpdateCounter;
|
||||||
|
|
||||||
|
#ifdef DEBUG_PERF_UPDATE
|
||||||
|
_QPC(s1);
|
||||||
|
__int64 e1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!m_Measures.empty())
|
if (!m_Measures.empty())
|
||||||
{
|
{
|
||||||
// Pre-updates
|
// Pre-updates
|
||||||
@ -2687,20 +2692,34 @@ void CMeterWindow::Update(bool refresh)
|
|||||||
CMeasureNet::UpdateStats();
|
CMeasureNet::UpdateStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_PERF_UPDATE
|
||||||
|
e1 = QPC();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Update all measures
|
// Update all measures
|
||||||
std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
|
std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||||
for ( ; i != m_Measures.end(); ++i)
|
for ( ; i != m_Measures.end(); ++i)
|
||||||
{
|
{
|
||||||
if (UpdateMeasure((*i), refresh))
|
if (UpdateMeasure((*i), refresh))
|
||||||
{
|
{
|
||||||
DoUpdateAction((*i));
|
(*i)->DoUpdateAction();
|
||||||
DoChangeAction((*i), refresh);
|
(*i)->DoChangeAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_PERF_UPDATE
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e1 = QPC();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CDialogAbout::UpdateMeasures(this);
|
CDialogAbout::UpdateMeasures(this);
|
||||||
|
|
||||||
|
#ifdef DEBUG_PERF_UPDATE
|
||||||
|
_QPC(e2);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Update all meters
|
// Update all meters
|
||||||
bool bActiveTransition = false;
|
bool bActiveTransition = false;
|
||||||
bool bUpdate = false;
|
bool bUpdate = false;
|
||||||
@ -2711,10 +2730,16 @@ void CMeterWindow::Update(bool refresh)
|
|||||||
{
|
{
|
||||||
bUpdate = true;
|
bUpdate = true;
|
||||||
|
|
||||||
DoUpdateAction((*j));
|
(*j)->DoUpdateAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_PERF_UPDATE
|
||||||
|
_QPC(e3);
|
||||||
|
double q1 = QPCms(s1,e1), q2 = QPCms(e1,e2), q3 = QPCms(e2,e3);
|
||||||
|
DebugString(L"Update: %.5f [ms] (PreUpdate: %.5f / Measure: %.5f / Meter: %.5f) :: %s", q1 + q2 + q3, q1, q2, q3, m_FolderPath.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
// Redraw all meters
|
// Redraw all meters
|
||||||
if (bUpdate || m_ResizeWindow || refresh)
|
if (bUpdate || m_ResizeWindow || refresh)
|
||||||
{
|
{
|
||||||
@ -2741,40 +2766,6 @@ void CMeterWindow::Update(bool refresh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMeterWindow::DoUpdateAction(CSection* section)
|
|
||||||
{
|
|
||||||
const std::wstring& updateAction = section->GetOnUpdateAction();
|
|
||||||
if (!updateAction.empty())
|
|
||||||
{
|
|
||||||
Rainmeter->ExecuteCommand(updateAction.c_str(), this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMeterWindow::DoChangeAction(CMeasure* measure, bool first)
|
|
||||||
{
|
|
||||||
const std::wstring& changeAction = measure->GetOnChangeAction();
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
double newValue = measure->GetValue();
|
|
||||||
const WCHAR* newStringValue = measure->GetStringValue(AUTOSCALE_OFF, 1, -1, false);
|
|
||||||
|
|
||||||
measure->SetOldValue(newValue);
|
|
||||||
measure->SetOldStringValue(newStringValue);
|
|
||||||
}
|
|
||||||
else if (!changeAction.empty())
|
|
||||||
{
|
|
||||||
double newValue = measure->GetValue();
|
|
||||||
const WCHAR* newStringValue = measure->GetStringValue(AUTOSCALE_OFF, 1, -1, false);
|
|
||||||
|
|
||||||
if (measure->GetOldValue() != newValue || wcscmp(measure->GetOldStringValue().c_str(), newStringValue) != 0)
|
|
||||||
{
|
|
||||||
measure->SetOldValue(newValue);
|
|
||||||
measure->SetOldStringValue(newStringValue);
|
|
||||||
Rainmeter->ExecuteCommand(changeAction.c_str(), this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Updates the window contents
|
** Updates the window contents
|
||||||
**
|
**
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "ConfigParser.h"
|
#include "ConfigParser.h"
|
||||||
#include "Section.h"
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "Mouse.h"
|
#include "Mouse.h"
|
||||||
|
|
||||||
@ -318,8 +317,6 @@ private:
|
|||||||
bool UpdateMeasure(CMeasure* measure, bool force);
|
bool UpdateMeasure(CMeasure* measure, bool force);
|
||||||
bool UpdateMeter(CMeter* meter, bool& bActiveTransition, bool force);
|
bool UpdateMeter(CMeter* meter, bool& bActiveTransition, bool force);
|
||||||
void Update(bool refresh);
|
void Update(bool refresh);
|
||||||
void DoUpdateAction(CSection* section);
|
|
||||||
void DoChangeAction(CMeasure* measure, bool first);
|
|
||||||
void UpdateWindow(int alpha, bool reset);
|
void UpdateWindow(int alpha, bool reset);
|
||||||
void ReadOptions();
|
void ReadOptions();
|
||||||
void WriteOptions(INT setting = OPTION_ALL);
|
void WriteOptions(INT setting = OPTION_ALL);
|
||||||
|
54
Library/Section.cpp
Normal file
54
Library/Section.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2013 spx
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "StdAfx.h"
|
||||||
|
#include "Section.h"
|
||||||
|
#include "Rainmeter.h"
|
||||||
|
|
||||||
|
extern CRainmeter* Rainmeter;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The constructor
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
CSection::CSection(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(meterWindow), m_Name(name),
|
||||||
|
m_DynamicVariables(false),
|
||||||
|
m_UpdateDivider(1),
|
||||||
|
m_UpdateCounter(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The destructor
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
CSection::~CSection()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Execute OnUpdateAction if action is set
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
void CSection::DoUpdateAction()
|
||||||
|
{
|
||||||
|
if (!m_OnUpdateAction.empty())
|
||||||
|
{
|
||||||
|
Rainmeter->ExecuteCommand(m_OnUpdateAction.c_str(), m_MeterWindow);
|
||||||
|
}
|
||||||
|
}
|
@ -23,10 +23,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
|
||||||
|
class CMeterWindow;
|
||||||
|
|
||||||
class CSection : public CGroup
|
class CSection : public CGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~CSection() {};
|
virtual ~CSection();
|
||||||
|
|
||||||
virtual UINT GetTypeID() = 0;
|
virtual UINT GetTypeID() = 0;
|
||||||
|
|
||||||
@ -41,9 +43,10 @@ public:
|
|||||||
int GetUpdateDivider() const { return m_UpdateDivider; }
|
int GetUpdateDivider() const { return m_UpdateDivider; }
|
||||||
|
|
||||||
const std::wstring& GetOnUpdateAction() { return m_OnUpdateAction; }
|
const std::wstring& GetOnUpdateAction() { return m_OnUpdateAction; }
|
||||||
|
void DoUpdateAction();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CSection(const WCHAR* name) : m_Name(name), m_DynamicVariables(false), m_UpdateDivider(1), m_UpdateCounter(1) {}
|
CSection(CMeterWindow* meterWindow, const WCHAR* name);
|
||||||
|
|
||||||
const std::wstring m_Name; // Name of this Section
|
const std::wstring m_Name; // Name of this Section
|
||||||
|
|
||||||
@ -52,6 +55,8 @@ protected:
|
|||||||
int m_UpdateCounter; // Current update counter
|
int m_UpdateCounter; // Current update counter
|
||||||
|
|
||||||
std::wstring m_OnUpdateAction;
|
std::wstring m_OnUpdateAction;
|
||||||
|
|
||||||
|
CMeterWindow* m_MeterWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user