Skip to content

Commit

Permalink
Bitmap Meter
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAzack9 committed Feb 2, 2018
1 parent 019cebf commit 47ff4ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
25 changes: 3 additions & 22 deletions Library/MeterBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ using namespace Gdiplus;

MeterBitmap::MeterBitmap(Skin* skin, const WCHAR* name) : Meter(skin, name),
m_Image(L"BitmapImage", nullptr, true, skin),
m_NeedsReload(false),
m_ZeroFrame(false),
m_FrameCount(1),
m_TransitionFrameCount(0),
Expand Down Expand Up @@ -45,11 +44,11 @@ void MeterBitmap::Initialize()
// Load the bitmaps if defined
if (!m_ImageName.empty())
{
m_Image.LoadImage(m_ImageName, m_NeedsReload);
m_Image.LoadImage(m_ImageName);

if (m_Image.IsLoaded())
{
Bitmap* bitmap = m_Image.GetImage();
Gfx::D2DBitmap* bitmap = m_Image.GetImage();

m_W = bitmap->GetWidth();
m_H = bitmap->GetHeight();
Expand Down Expand Up @@ -157,8 +156,6 @@ void MeterBitmap::ReadOptions(ConfigParser& parser, const WCHAR* section)
{
// Store the current values so we know if the image needs to be updated
std::wstring oldImageName = m_ImageName;
int oldW = m_W;
int oldH = m_H;

Meter::ReadOptions(parser, section);

Expand All @@ -168,10 +165,6 @@ void MeterBitmap::ReadOptions(ConfigParser& parser, const WCHAR* section)
// Read tinting options
m_Image.ReadOptions(parser, section);
}
else
{
m_Image.ClearOptionFlags();
}

m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1);
m_ZeroFrame = parser.ReadBool(section, L"BitmapZeroFrame", false);
Expand Down Expand Up @@ -202,19 +195,7 @@ void MeterBitmap::ReadOptions(ConfigParser& parser, const WCHAR* section)

if (m_Initialized)
{
m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0);

if (m_NeedsReload ||
m_Image.IsOptionsChanged())
{
Initialize(); // Reload the image
}
else
{
// Reset to old dimensions
m_W = oldW;
m_H = oldH;
}
}
}

Expand Down Expand Up @@ -275,7 +256,7 @@ bool MeterBitmap::Draw(Gfx::Canvas& canvas)

if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue

Bitmap* bitmap = m_Image.GetImage();
Gfx::D2DBitmap* bitmap = m_Image.GetImage();

Gdiplus::Rect meterRect = GetMeterRectPadding();

Expand Down
5 changes: 2 additions & 3 deletions Library/MeterBitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define __METERBITMAP_H__

#include "Meter.h"
#include "TintedImage.h"
#include "GeneralImage.h"

class MeterBitmap : public Meter
{
Expand All @@ -33,9 +33,8 @@ class MeterBitmap : public Meter
virtual void ReadOptions(ConfigParser& parser, const WCHAR* section);

private:
TintedImage m_Image;
GeneralImage m_Image;
std::wstring m_ImageName;
bool m_NeedsReload;

bool m_ZeroFrame; // If true, the first frame is only shown when the measured value is zero
int m_FrameCount;
Expand Down

0 comments on commit 47ff4ea

Please sign in to comment.