2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001 Kimmo Pekkola
|
|
|
|
|
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "MeterBitmap.h"
|
|
|
|
#include "Measure.h"
|
|
|
|
#include "Error.h"
|
|
|
|
#include "Rainmeter.h"
|
2011-06-05 12:32:18 +00:00
|
|
|
#include "System.h"
|
2013-03-25 15:42:18 +00:00
|
|
|
#include "../Common/Gfx/Canvas.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
using namespace Gdiplus;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
extern Rainmeter* g_Rainmeter;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
** The constructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterBitmap::MeterBitmap(MeterWindow* meterWindow, const WCHAR* name) : Meter(meterWindow, name),
|
2013-06-07 19:35:36 +00:00
|
|
|
m_Image(L"BitmapImage", nullptr, true, meterWindow),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_NeedsReload(false),
|
|
|
|
m_ZeroFrame(false),
|
|
|
|
m_FrameCount(1),
|
|
|
|
m_TransitionFrameCount(),
|
|
|
|
m_Align(ALIGN_LEFT),
|
|
|
|
m_Extend(false),
|
|
|
|
m_Separation(),
|
|
|
|
m_Digits(),
|
|
|
|
m_Value(),
|
|
|
|
m_TransitionStartTicks(),
|
|
|
|
m_TransitionStartValue()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The destructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterBitmap::~MeterBitmap()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Load the image and get the dimensions of the meter from it.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void MeterBitmap::Initialize()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter::Initialize();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
// Load the bitmaps if defined
|
2011-03-29 19:21:57 +00:00
|
|
|
if (!m_ImageName.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-11-27 19:53:23 +00:00
|
|
|
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
2009-09-07 20:00:50 +00:00
|
|
|
|
2010-11-27 19:53:23 +00:00
|
|
|
if (m_Image.IsLoaded())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-11-27 19:53:23 +00:00
|
|
|
Bitmap* bitmap = m_Image.GetImage();
|
|
|
|
|
|
|
|
m_W = bitmap->GetWidth();
|
|
|
|
m_H = bitmap->GetHeight();
|
2010-06-03 14:14:53 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_H > m_W)
|
2010-06-03 14:14:53 +00:00
|
|
|
{
|
|
|
|
m_H = m_H / m_FrameCount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_W = m_W / m_FrameCount;
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-06-03 14:14:53 +00:00
|
|
|
}
|
2010-11-27 19:53:23 +00:00
|
|
|
else if (m_Image.IsLoaded())
|
2010-06-03 14:14:53 +00:00
|
|
|
{
|
2010-11-27 19:53:23 +00:00
|
|
|
m_Image.DisposeImage();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Checks if the given point is inside the meter.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool MeterBitmap::HitTest(int x, int y)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (m_Extend)
|
|
|
|
{
|
|
|
|
// Calc the number of numbers
|
|
|
|
int numOfNums = 0;
|
|
|
|
|
|
|
|
if (m_Digits > 0)
|
|
|
|
{
|
|
|
|
numOfNums = m_Digits;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-11 20:24:59 +00:00
|
|
|
int tmpValue = (int)m_Value;
|
|
|
|
tmpValue = max(0, tmpValue); // Only positive integers are supported
|
|
|
|
|
2009-07-21 12:26:50 +00:00
|
|
|
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
2009-02-10 18:37:48 +00:00
|
|
|
do
|
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
++numOfNums;
|
2009-07-21 12:26:50 +00:00
|
|
|
if (realFrames == 1)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
tmpValue /= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-21 12:26:50 +00:00
|
|
|
tmpValue /= realFrames;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while (tmpValue > 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rect rect(GetX(), GetY(), m_W * numOfNums + (numOfNums - 1) * m_Separation, m_H);
|
|
|
|
|
|
|
|
if (m_Align == ALIGN_CENTER)
|
|
|
|
{
|
|
|
|
rect.Offset(-rect.Width / 2, 0);
|
|
|
|
}
|
|
|
|
else if (m_Align == ALIGN_RIGHT)
|
|
|
|
{
|
|
|
|
rect.Offset(-rect.Width, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect.Contains(x, y))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
return Meter::HitTest(x, y);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-06-01 13:06:36 +00:00
|
|
|
** Read the options specified in the ini file.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void MeterBitmap::ReadOptions(ConfigParser& parser, const WCHAR* section)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2009-09-07 20:00:50 +00:00
|
|
|
// Store the current values so we know if the image needs to be updated
|
|
|
|
std::wstring oldImageName = m_ImageName;
|
2010-06-03 14:14:53 +00:00
|
|
|
int oldW = m_W;
|
|
|
|
int oldH = m_H;
|
2009-09-07 20:00:50 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter::ReadOptions(parser, section);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_ImageName = parser.ReadString(section, L"BitmapImage", L"");
|
2010-11-25 22:00:34 +00:00
|
|
|
if (!m_ImageName.empty())
|
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
// Read tinting options
|
2012-05-30 18:53:44 +00:00
|
|
|
m_Image.ReadOptions(parser, section);
|
2010-11-27 19:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-30 18:51:06 +00:00
|
|
|
m_Image.ClearOptionFlags();
|
2010-11-25 22:00:34 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1);
|
|
|
|
m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_Separation = parser.ReadInt(section, L"BitmapSeparation", 0);
|
|
|
|
m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0);
|
|
|
|
m_Digits = parser.ReadInt(section, L"BitmapDigits", 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-09-04 16:37:51 +00:00
|
|
|
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
|
2009-07-21 12:26:50 +00:00
|
|
|
|
2011-11-16 16:47:20 +00:00
|
|
|
const WCHAR* align = parser.ReadString(section, L"BitmapAlign", L"LEFT").c_str();
|
|
|
|
if (_wcsicmp(align, L"LEFT") == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
m_Align = ALIGN_LEFT;
|
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(align, L"RIGHT") == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
m_Align = ALIGN_RIGHT;
|
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(align, L"CENTER") == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
m_Align = ALIGN_CENTER;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"BitmapAlign=%s is not valid in [%s]", align, m_Name.c_str());
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2009-09-07 20:00:50 +00:00
|
|
|
|
2010-06-03 14:14:53 +00:00
|
|
|
if (m_Initialized)
|
2009-09-07 20:00:50 +00:00
|
|
|
{
|
2011-11-27 08:30:39 +00:00
|
|
|
m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0);
|
2010-11-27 19:53:23 +00:00
|
|
|
|
|
|
|
if (m_NeedsReload ||
|
2012-05-30 18:51:06 +00:00
|
|
|
m_Image.IsOptionsChanged())
|
2010-06-03 14:14:53 +00:00
|
|
|
{
|
|
|
|
Initialize(); // Reload the image
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reset to old dimensions
|
|
|
|
m_W = oldW;
|
|
|
|
m_H = oldH;
|
|
|
|
}
|
2009-09-07 20:00:50 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates the value(s) from the measures.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool MeterBitmap::Update()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
if (Meter::Update() && !m_Measures.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* measure = m_Measures[0];
|
2012-07-17 07:37:53 +00:00
|
|
|
double value = (m_Extend) ? measure->GetValue() : measure->GetRelativeValue();
|
2009-07-21 12:26:50 +00:00
|
|
|
|
|
|
|
if (m_TransitionFrameCount > 0)
|
|
|
|
{
|
|
|
|
int realFrames = m_FrameCount / (m_TransitionFrameCount + 1);
|
|
|
|
if ((int)(value * realFrames) != (int)(m_Value * realFrames))
|
|
|
|
{
|
|
|
|
m_TransitionStartValue = m_Value;
|
2013-05-31 14:18:52 +00:00
|
|
|
m_TransitionStartTicks = System::GetTickCount64();
|
2009-07-21 12:26:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_TransitionStartTicks = 0;
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2009-07-21 12:26:50 +00:00
|
|
|
|
|
|
|
m_Value = value;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Returns true if the meter has active transition animation.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool MeterBitmap::HasActiveTransition()
|
2009-07-21 12:26:50 +00:00
|
|
|
{
|
|
|
|
if (m_TransitionStartTicks > 0)
|
|
|
|
{
|
2009-02-10 18:37:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Draws the meter on the double buffer
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool MeterBitmap::Draw(Gfx::Canvas& canvas)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
if (!Meter::Draw(canvas)) return false;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
int newY, newX;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
|
2010-11-27 19:53:23 +00:00
|
|
|
|
|
|
|
Bitmap* bitmap = m_Image.GetImage();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
int x = GetX();
|
|
|
|
int y = GetY();
|
|
|
|
|
|
|
|
if (m_Extend)
|
|
|
|
{
|
|
|
|
int value = (int)m_Value;
|
|
|
|
value = max(0, value); // Only positive integers are supported
|
|
|
|
|
2009-07-21 12:26:50 +00:00
|
|
|
int transitionValue = (int)m_TransitionStartValue;
|
|
|
|
transitionValue = max(0, transitionValue); // Only positive integers are supported
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
// Calc the number of numbers
|
|
|
|
int numOfNums = 0;
|
|
|
|
|
|
|
|
if (m_Digits > 0)
|
|
|
|
{
|
|
|
|
numOfNums = m_Digits;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-11 20:24:59 +00:00
|
|
|
int tmpValue = value;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
do
|
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
++numOfNums;
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_FrameCount == 1)
|
|
|
|
{
|
|
|
|
tmpValue /= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpValue /= m_FrameCount;
|
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while (tmpValue > 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Blit the images
|
|
|
|
int offset;
|
|
|
|
if (m_Align == ALIGN_RIGHT)
|
|
|
|
{
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
else if (m_Align == ALIGN_CENTER)
|
|
|
|
{
|
|
|
|
offset = numOfNums * (m_W + m_Separation) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = numOfNums * (m_W + m_Separation);
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
offset = offset - (m_W + m_Separation);
|
|
|
|
|
2009-07-21 12:26:50 +00:00
|
|
|
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
|
|
|
int frame = (value % realFrames) * (m_TransitionFrameCount + 1);
|
|
|
|
|
|
|
|
// If transition is ongoing the pick the correct frame
|
|
|
|
if (m_TransitionStartTicks > 0)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
int diffTicks = (int)(System::GetTickCount64() - m_TransitionStartTicks);
|
2011-06-05 12:32:18 +00:00
|
|
|
|
|
|
|
int range = ((value % realFrames) - (transitionValue % realFrames)) * (m_TransitionFrameCount + 1);
|
2009-07-21 12:26:50 +00:00
|
|
|
if (range < 0)
|
|
|
|
{
|
|
|
|
range += m_FrameCount;
|
|
|
|
}
|
2011-06-05 12:32:18 +00:00
|
|
|
int frameAdjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
|
2009-07-21 12:26:50 +00:00
|
|
|
if (frameAdjustment > range)
|
|
|
|
{
|
|
|
|
m_TransitionStartTicks = 0; // The transition is over. Draw with the real value.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-05 12:32:18 +00:00
|
|
|
frame = (transitionValue % realFrames) * (m_TransitionFrameCount + 1);
|
2009-07-21 12:26:50 +00:00
|
|
|
frame += frameAdjustment;
|
|
|
|
frame %= m_FrameCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
// LogDebugF(L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
2009-07-21 12:26:50 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (bitmap->GetHeight() > bitmap->GetWidth())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
newX = 0;
|
2009-07-21 12:26:50 +00:00
|
|
|
newY = m_H * frame;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-21 12:26:50 +00:00
|
|
|
newX = m_W * frame;
|
2009-02-10 18:37:48 +00:00
|
|
|
newY = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-25 15:42:18 +00:00
|
|
|
canvas.DrawBitmap(bitmap, Rect(x + offset, y, m_W, m_H), Rect(newX, newY, m_W, m_H));
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_FrameCount == 1)
|
|
|
|
{
|
|
|
|
value /= 2;
|
2009-07-21 12:26:50 +00:00
|
|
|
transitionValue /= 2;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-21 12:26:50 +00:00
|
|
|
value /= realFrames;
|
|
|
|
transitionValue /= realFrames;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-03-30 22:37:05 +00:00
|
|
|
--numOfNums;
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while (numOfNums > 0);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int frame = 0;
|
2009-07-21 12:26:50 +00:00
|
|
|
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
if (m_ZeroFrame)
|
|
|
|
{
|
|
|
|
// Use the first frame only if the value is zero
|
|
|
|
if (m_Value > 0)
|
|
|
|
{
|
2009-07-21 12:26:50 +00:00
|
|
|
frame = (int)(m_Value * (realFrames - 1)) * (m_TransitionFrameCount + 1);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Select the correct frame linearly
|
2009-07-21 12:26:50 +00:00
|
|
|
frame = (int)(m_Value * realFrames) * (m_TransitionFrameCount + 1);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 12:26:50 +00:00
|
|
|
// If transition is ongoing the pick the correct frame
|
|
|
|
if (m_TransitionStartTicks > 0)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
int diffTicks = (int)(System::GetTickCount64() - m_TransitionStartTicks);
|
2011-06-05 12:32:18 +00:00
|
|
|
|
|
|
|
if (diffTicks > ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate()))
|
2009-07-21 12:26:50 +00:00
|
|
|
{
|
|
|
|
m_TransitionStartTicks = 0; // The transition is over. Draw with the real value.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double range = (m_Value - m_TransitionStartValue);
|
|
|
|
double adjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
|
|
|
|
double frameAdjustment = adjustment * m_FrameCount;
|
|
|
|
|
|
|
|
frame = (int)(m_TransitionStartValue * realFrames) * (m_TransitionFrameCount + 1);
|
|
|
|
frame += (int)frameAdjustment;
|
|
|
|
frame %= m_FrameCount;
|
|
|
|
frame = max(0, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
// LogDebugF(L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
2009-07-21 12:26:50 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (bitmap->GetHeight() > bitmap->GetWidth())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
newX = 0;
|
|
|
|
newY = frame * m_H;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newX = frame * m_W;
|
|
|
|
newY = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-25 15:42:18 +00:00
|
|
|
canvas.DrawBitmap(bitmap, Rect(x, y, m_W, m_H), Rect(newX, newY, m_W, m_H));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|