some minor tweaks & cleanups

This commit is contained in:
spx 2010-08-17 07:19:48 +00:00
parent b3e93c0765
commit bf026cc248
3 changed files with 71 additions and 55 deletions

View File

@ -101,6 +101,10 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
CMeasure::ReadConfig(parser, section);
// DynamicVariables is now disabled in MeasurePlugin due to a limitation of the re-initialization.
// Do not set m_DynamicVariables to "true".
m_DynamicVariables = false;
m_PluginName = parser.ReadString(section, L"Plugin", L"");
size_t pos = m_PluginName.rfind(L".");

View File

@ -93,6 +93,7 @@ CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstrin
m_TransitionUpdate = 100;
m_ActiveTransition = false;
m_HasNetMeasures = false;
m_HasButtons = false;
m_WindowHide = HIDEMODE_NONE;
m_WindowStartHidden = false;
m_SnapEdges = true;
@ -1863,6 +1864,7 @@ bool CMeterWindow::ReadSkin()
// Create the meters and measures
m_HasNetMeasures = false;
m_HasButtons = false;
// Get all the sections (i.e. different meters, measures and the other stuff)
std::vector<std::wstring> arraySections = m_Parser.GetSections();
@ -1907,7 +1909,7 @@ bool CMeterWindow::ReadSkin()
m_Parser.AddMeasure(measure);
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>((measure)))
if (!m_HasNetMeasures && dynamic_cast<CMeasureNet*>(measure))
{
m_HasNetMeasures = true;
}
@ -1950,6 +1952,11 @@ bool CMeterWindow::ReadSkin()
m_Meters.push_back(meter);
m_Parser.ResetStyleTemplate();
if (!m_HasButtons && dynamic_cast<CMeterButton*>(meter))
{
m_HasButtons = true;
}
}
}
// If it's not a meter or measure it will be ignored
@ -2376,7 +2383,7 @@ void CMeterWindow::Update(bool nodraw)
{
try
{
if ((*i)->HasDynamicVariables() && dynamic_cast<CMeasurePlugin*>((*i)) == NULL) // Plugins are not meant to be reinitialized
if ((*i)->HasDynamicVariables())
{
(*i)->ReadConfig(m_Parser, (*i)->GetName());
}
@ -2389,6 +2396,7 @@ void CMeterWindow::Update(bool nodraw)
}
// Update the meters
bool bActiveTransition = false;
std::list<CMeter*>::const_iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j)
{
@ -2405,6 +2413,22 @@ void CMeterWindow::Update(bool nodraw)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
// Update tooltips
if (!((*j)->GetToolTipHandle() != NULL) && (!(*j)->GetToolTipText().empty()))
{
(*j)->CreateToolTip(this);
}
if ((*j)->GetToolTipHandle() != NULL)
{
(*j)->UpdateToolTip();
}
// Check for transitions and start the timer if necessary
if (!bActiveTransition && (*j)->HasActiveTransition())
{
bActiveTransition = true;
}
}
if (!nodraw)
@ -2418,35 +2442,11 @@ void CMeterWindow::Update(bool nodraw)
Redraw();
}
j = m_Meters.begin();
for ( ; j != m_Meters.end(); ++j)
{
if (!((*j)->GetToolTipHandle() != NULL) && (!(*j)->GetToolTipText().empty()))
{
(*j)->CreateToolTip(this);
}
if ((*j)->GetToolTipHandle() != NULL)
{
(*j)->UpdateToolTip();
}
}
// Check for transitions and start the timer if necessary
bool bActiveTransition = false;
j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j)
{
if ((*j)->HasActiveTransition())
{
bActiveTransition = true;
break;
}
}
// Start/stop the transition timer if necessary
if (!m_ActiveTransition && bActiveTransition)
{
SetTimer(m_Window, TRANSITIONTIMER, m_TransitionUpdate, NULL);
m_ActiveTransition = true;
}
else if (m_ActiveTransition && !bActiveTransition)
{
@ -2841,7 +2841,10 @@ void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meter
// Hidden meters are ignored
if ((*j)->IsHidden()) continue;
CMeterButton* button = dynamic_cast<CMeterButton*>(*j);
CMeterButton* button = NULL;
if (m_HasButtons)
{
button = dynamic_cast<CMeterButton*>(*j);
if (button)
{
switch (proc)
@ -2860,6 +2863,7 @@ void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meter
break;
}
}
}
if (changeCursor && !drawCursor)
{
@ -4024,7 +4028,10 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
}
// Handle button
CMeterButton* button = dynamic_cast<CMeterButton*>(*j);
CMeterButton* button = NULL;
if (m_HasButtons)
{
button = dynamic_cast<CMeterButton*>(*j);
if (button)
{
if (!buttonFound)
@ -4043,6 +4050,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
}
}
}
}
if (!(*j)->IsMouseOver())
{
@ -4066,6 +4074,8 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
if ((*j)->IsMouseOver())
{
// Handle button
if (m_HasButtons)
{
CMeterButton* button = dynamic_cast<CMeterButton*>(*j);
if (button)
{
@ -4074,6 +4084,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
button->SetExecutable(false);
}
}
}
//DebugLog(L"MeterLeave: %s - [%s]", m_SkinName.c_str(), (*j)->GetName());
(*j)->SetMouseOver(false);

View File

@ -314,6 +314,7 @@ private:
int m_TransitionUpdate; // Transition redraw frequency
bool m_ActiveTransition;
bool m_HasNetMeasures;
bool m_HasButtons;
HIDEMODE m_WindowHide; // If true, the window is hidden when mouse is over it
bool m_WindowStartHidden; // If true, the window is hidden at startup
bool m_SavePosition; // If true, the window's position is saved