From 6efb485e6970d2d23e917aaa4af20133e3dc5dea Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 30 May 2012 21:51:06 +0300 Subject: [PATCH] Cosmetics --- Library/MeterBar.cpp | 4 ++-- Library/MeterBitmap.cpp | 4 ++-- Library/MeterButton.cpp | 4 ++-- Library/MeterHistogram.cpp | 24 ++++++++++++------------ Library/MeterHistogram.h | 6 +++--- Library/MeterRotator.cpp | 4 ++-- Library/TintedImage.cpp | 36 ++++++++++++++++++------------------ Library/TintedImage.h | 38 +++++++++++++++++++------------------- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index 7085c1e6..503578ac 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -104,7 +104,7 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_Image.ClearConfigFlags(); + m_Image.ClearOptionFlags(); } m_Border = parser.ReadInt(section, L"BarBorder", 0); @@ -130,7 +130,7 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || - m_Image.IsConfigsChanged()) + m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 01c616e1..027a9dec 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -174,7 +174,7 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_Image.ClearConfigFlags(); + m_Image.ClearOptionFlags(); } m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1); @@ -209,7 +209,7 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || - m_Image.IsConfigsChanged()) + m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } diff --git a/Library/MeterButton.cpp b/Library/MeterButton.cpp index c1a8b2d7..c5aabc57 100644 --- a/Library/MeterButton.cpp +++ b/Library/MeterButton.cpp @@ -146,7 +146,7 @@ void CMeterButton::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_Image.ClearConfigFlags(); + m_Image.ClearOptionFlags(); } m_Command = parser.ReadString(section, L"ButtonCommand", L"", false); @@ -156,7 +156,7 @@ void CMeterButton::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || - m_Image.IsConfigsChanged()) + m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 6a18ea47..a9334574 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -26,9 +26,9 @@ using namespace Gdiplus; extern CRainmeter* Rainmeter; -CTintedImageHelper_DefineConfigArray(CMeterHistogram::c_PrimaryConfigArray, L"Primary"); -CTintedImageHelper_DefineConfigArray(CMeterHistogram::c_SecondaryConfigArray, L"Secondary"); -CTintedImageHelper_DefineConfigArray(CMeterHistogram::c_BothConfigArray, L"Both"); +CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_PrimaryOptionArray, L"Primary"); +CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_SecondaryOptionArray, L"Secondary"); +CTintedImageHelper_DefineOptionArray(CMeterHistogram::c_BothOptionArray, L"Both"); /* ** The constructor @@ -42,9 +42,9 @@ CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterPos(), m_Autoscale(false), m_Flip(false), - m_PrimaryImage(L"PrimaryImage", c_PrimaryConfigArray), - m_SecondaryImage(L"SecondaryImage", c_SecondaryConfigArray), - m_OverlapImage(L"BothImage", c_BothConfigArray), + m_PrimaryImage(L"PrimaryImage", c_PrimaryOptionArray), + m_SecondaryImage(L"SecondaryImage", c_SecondaryOptionArray), + m_OverlapImage(L"BothImage", c_BothOptionArray), m_PrimaryNeedsReload(false), m_SecondaryNeedsReload(false), m_OverlapNeedsReload(false), @@ -217,7 +217,7 @@ void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_PrimaryImage.ClearConfigFlags(); + m_PrimaryImage.ClearOptionFlags(); } m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L""); @@ -230,7 +230,7 @@ void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_SecondaryImage.ClearConfigFlags(); + m_SecondaryImage.ClearOptionFlags(); } m_OverlapImageName = parser.ReadString(section, L"BothImage", L""); @@ -243,7 +243,7 @@ void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_OverlapImage.ClearConfigFlags(); + m_OverlapImage.ClearOptionFlags(); } m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); @@ -272,9 +272,9 @@ void CMeterHistogram::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_PrimaryNeedsReload || m_SecondaryNeedsReload || m_OverlapNeedsReload || - m_PrimaryImage.IsConfigsChanged() || - m_SecondaryImage.IsConfigsChanged() || - m_OverlapImage.IsConfigsChanged()) + m_PrimaryImage.IsOptionsChanged() || + m_SecondaryImage.IsOptionsChanged() || + m_OverlapImage.IsOptionsChanged()) { Initialize(); // Reload the image } diff --git a/Library/MeterHistogram.h b/Library/MeterHistogram.h index b09c20ba..6620d7d6 100644 --- a/Library/MeterHistogram.h +++ b/Library/MeterHistogram.h @@ -76,9 +76,9 @@ private: bool m_GraphStartLeft; bool m_GraphHorizontalOrientation; - static const WCHAR* c_PrimaryConfigArray[CTintedImage::ConfigCount]; - static const WCHAR* c_SecondaryConfigArray[CTintedImage::ConfigCount]; - static const WCHAR* c_BothConfigArray[CTintedImage::ConfigCount]; + static const WCHAR* c_PrimaryOptionArray[CTintedImage::ConfigCount]; + static const WCHAR* c_SecondaryOptionArray[CTintedImage::ConfigCount]; + static const WCHAR* c_BothOptionArray[CTintedImage::ConfigCount]; }; #endif diff --git a/Library/MeterRotator.cpp b/Library/MeterRotator.cpp index 8c38429e..064ff1be 100644 --- a/Library/MeterRotator.cpp +++ b/Library/MeterRotator.cpp @@ -94,7 +94,7 @@ void CMeterRotator::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - m_Image.ClearConfigFlags(); + m_Image.ClearOptionFlags(); } m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0); @@ -110,7 +110,7 @@ void CMeterRotator::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || - m_Image.IsConfigsChanged()) + m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } diff --git a/Library/TintedImage.cpp b/Library/TintedImage.cpp index 62e4ad0b..4361a0dd 100644 --- a/Library/TintedImage.cpp +++ b/Library/TintedImage.cpp @@ -143,7 +143,7 @@ const Gdiplus::ColorMatrix CTintedImage::c_IdentityMatrix = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; -CTintedImageHelper_DefineConfigArray(CTintedImage::c_DefaultConfigArray, L""); +CTintedImageHelper_DefineOptionArray(CTintedImage::c_DefaultOptionArray, L""); /* ** The constructor. @@ -154,8 +154,8 @@ CTintedImageHelper_DefineConfigArray(CTintedImage::c_DefaultConfigArray, L""); ** */ CTintedImage::CTintedImage(const WCHAR* name, const WCHAR** configArray, bool disableTransform) : m_DisableTransform(disableTransform), - m_ConfigName(name ? name : L"Image"), - m_ConfigArray(configArray ? configArray : c_DefaultConfigArray), + m_Name(name ? name : L"Image"), + m_OptionArray(configArray ? configArray : c_DefaultOptionArray), m_Bitmap(), m_BitmapTint(), @@ -326,7 +326,7 @@ void CTintedImage::LoadImage(const std::wstring& imageName, bool bLoadAlways) } else { - LogWithArgs(LOG_ERROR, L"%s: Unable to load: %s", m_ConfigName.c_str(), filename.c_str()); + LogWithArgs(LOG_ERROR, L"%s: Unable to load: %s", m_Name, filename.c_str()); } } CloseHandle(fileHandle); @@ -358,7 +358,7 @@ void CTintedImage::LoadImage(const std::wstring& imageName, bool bLoadAlways) } else { - LogWithArgs(LOG_ERROR, L"%s: Unable to open: %s", m_ConfigName.c_str(), filename.c_str()); + LogWithArgs(LOG_ERROR, L"%s: Unable to open: %s", m_Name, filename.c_str()); if (fileHandle != INVALID_HANDLE_VALUE) { @@ -581,7 +581,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Crop.X = m_Crop.Y = m_Crop.Width = m_Crop.Height = -1; m_CropMode = CROPMODE_TL; - const std::wstring& crop = parser.ReadString(section, m_ConfigArray[ConfigIndexImageCrop], L""); + const std::wstring& crop = parser.ReadString(section, m_OptionArray[OptionIndexImageCrop], L""); if (!crop.empty()) { if (wcschr(crop.c_str(), L',')) @@ -624,17 +624,17 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) if (m_CropMode < CROPMODE_TL || m_CropMode > CROPMODE_C) { m_CropMode = CROPMODE_TL; - LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_ConfigArray[ConfigIndexImageCrop], crop, section); + LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_OptionArray[OptionIndexImageCrop], crop, section); } } } m_NeedsCrop = (oldCrop.X != m_Crop.X || oldCrop.Y != m_Crop.Y || oldCrop.Width != m_Crop.Width || oldCrop.Height != m_Crop.Height || oldCropMode != m_CropMode); - m_GreyScale = 0!=parser.ReadInt(section, m_ConfigArray[ConfigIndexGreyscale], 0); + m_GreyScale = 0!=parser.ReadInt(section, m_OptionArray[OptionIndexGreyscale], 0); - Color tint = parser.ReadColor(section, m_ConfigArray[ConfigIndexImageTint], Color::White); - int alpha = parser.ReadInt(section, m_ConfigArray[ConfigIndexImageAlpha], tint.GetAlpha()); // for backwards compatibility + Color tint = parser.ReadColor(section, m_OptionArray[OptionIndexImageTint], Color::White); + int alpha = parser.ReadInt(section, m_OptionArray[OptionIndexImageAlpha], tint.GetAlpha()); // for backwards compatibility alpha = min(255, alpha); alpha = max(0, alpha); @@ -644,7 +644,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) // It has to be read in like this because it crashes when reading over 17 floats // at one time. The parser does it fine, but after putting the returned values // into the Color Matrix the next time the parser is used it crashes. - std::vector matrix1 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix1]); + std::vector matrix1 = parser.ReadFloats(section, m_OptionArray[OptionIndexColorMatrix1]); if (matrix1.size() == 5) { for (int i = 0; i < 4; ++i) // The fifth column must be 0. @@ -657,7 +657,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_ColorMatrix->m[0][0] = (REAL)tint.GetRed() / 255.0f; } - std::vector matrix2 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix2]); + std::vector matrix2 = parser.ReadFloats(section, m_OptionArray[OptionIndexColorMatrix2]); if (matrix2.size() == 5) { for (int i = 0; i < 4; ++i) // The fifth column must be 0. @@ -670,7 +670,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_ColorMatrix->m[1][1] = (REAL)tint.GetGreen() / 255.0f; } - std::vector matrix3 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix3]); + std::vector matrix3 = parser.ReadFloats(section, m_OptionArray[OptionIndexColorMatrix3]); if (matrix3.size() == 5) { for (int i = 0; i < 4; ++i) // The fifth column must be 0. @@ -683,7 +683,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_ColorMatrix->m[2][2] = (REAL)tint.GetBlue() / 255.0f; } - std::vector matrix4 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix4]); + std::vector matrix4 = parser.ReadFloats(section, m_OptionArray[OptionIndexColorMatrix4]); if (matrix4.size() == 5) { for (int i = 0; i < 4; ++i) // The fifth column must be 0. @@ -696,7 +696,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_ColorMatrix->m[3][3] = (REAL)alpha / 255.0f; } - std::vector matrix5 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix5]); + std::vector matrix5 = parser.ReadFloats(section, m_OptionArray[OptionIndexColorMatrix5]); if (matrix5.size() == 5) { for (int i = 0; i < 4; ++i) // The fifth column must be 1. @@ -707,7 +707,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix)); - const WCHAR* flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE").c_str(); + const WCHAR* flip = parser.ReadString(section, m_OptionArray[OptionIndexImageFlip], L"NONE").c_str(); if (_wcsicmp(flip, L"NONE") == 0) { m_Flip = RotateNoneFlipNone; @@ -726,12 +726,12 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_ConfigArray[ConfigIndexImageFlip], flip, section); + LogWithArgs(LOG_ERROR, L"%s=%s (origin) is not valid in [%s]", m_OptionArray[OptionIndexImageFlip], flip, section); } if (!m_DisableTransform) { - m_Rotate = (REAL)parser.ReadFloat(section, m_ConfigArray[ConfigIndexImageRotate], 0.0); + m_Rotate = (REAL)parser.ReadFloat(section, m_OptionArray[OptionIndexImageRotate], 0.0); } m_NeedsTransform = (oldFlip != m_Flip || oldRotate != m_Rotate); diff --git a/Library/TintedImage.h b/Library/TintedImage.h index 6df1fbb7..41ac8774 100644 --- a/Library/TintedImage.h +++ b/Library/TintedImage.h @@ -28,7 +28,7 @@ ** It's necessary to give a string literal to the prefix parameter. ** */ -#define CTintedImageHelper_DefineConfigArray(name, prefix) \ +#define CTintedImageHelper_DefineOptionArray(name, prefix) \ const WCHAR* (name)[CTintedImage::ConfigCount] = { \ prefix L"ImageCrop", \ prefix L"Greyscale", \ @@ -48,32 +48,32 @@ class CConfigParser; class CTintedImage { public: - enum ConfigIndex + enum OptionIndex { - ConfigIndexImageCrop = 0, - ConfigIndexGreyscale, - ConfigIndexImageTint, - ConfigIndexImageAlpha, - ConfigIndexColorMatrix1, - ConfigIndexColorMatrix2, - ConfigIndexColorMatrix3, - ConfigIndexColorMatrix4, - ConfigIndexColorMatrix5, - ConfigIndexImageFlip, - ConfigIndexImageRotate, + OptionIndexImageCrop = 0, + OptionIndexGreyscale, + OptionIndexImageTint, + OptionIndexImageAlpha, + OptionIndexColorMatrix1, + OptionIndexColorMatrix2, + OptionIndexColorMatrix3, + OptionIndexColorMatrix4, + OptionIndexColorMatrix5, + OptionIndexImageFlip, + OptionIndexImageRotate, ConfigCount }; - CTintedImage(const WCHAR* name = L"Image", const WCHAR** configArray = c_DefaultConfigArray, bool disableTransform = false); + CTintedImage(const WCHAR* name = L"Image", const WCHAR** configArray = c_DefaultOptionArray, bool disableTransform = false); ~CTintedImage(); void ReadConfig(CConfigParser& parser, const WCHAR* section); bool IsLoaded() { return (m_Bitmap != NULL); } bool IsTinted() { return (m_BitmapTint != NULL); } - bool IsConfigsChanged() { return m_NeedsCrop || m_NeedsTinting || m_NeedsTransform; } - void ClearConfigFlags() { m_NeedsCrop = m_NeedsTinting = m_NeedsTransform = false; } + bool IsOptionsChanged() { return m_NeedsCrop || m_NeedsTinting || m_NeedsTransform; } + void ClearOptionFlags() { m_NeedsCrop = m_NeedsTinting = m_NeedsTransform = false; } Gdiplus::Bitmap* GetOriginalImage() { return m_Bitmap; } Gdiplus::Bitmap* GetTintedImage() { return m_BitmapTint; } @@ -104,8 +104,8 @@ protected: Gdiplus::Bitmap* m_Bitmap; Gdiplus::Bitmap* m_BitmapTint; // Tinted bitmap - const std::wstring m_ConfigName; - const WCHAR** m_ConfigArray; + const WCHAR* m_Name; + const WCHAR** m_OptionArray; const bool m_DisableTransform; bool m_NeedsCrop; @@ -124,7 +124,7 @@ protected: static const Gdiplus::ColorMatrix c_GreyScaleMatrix; static const Gdiplus::ColorMatrix c_IdentityMatrix; - static const WCHAR* c_DefaultConfigArray[ConfigCount]; + static const WCHAR* c_DefaultOptionArray[ConfigCount]; }; #endif