From 6683d42b636619e02e2bcf98923a2fdbf44bd95b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 May 2015 17:07:13 +0300 Subject: Move functions getColor, getIdByChar from palette to theme and userpalette. --- src/gui/palette.cpp | 13 ------------- src/gui/palette.h | 25 ------------------------- src/gui/theme.cpp | 13 +++++++++++++ src/gui/theme.h | 25 +++++++++++++++++++++++++ src/gui/userpalette.cpp | 13 +++++++++++++ src/gui/userpalette.h | 25 +++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index 88de9d5d0..757a61a23 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -72,19 +72,6 @@ const Color& Palette::getCharColor(const signed char c, bool &valid) const return BLACK; } -int Palette::getIdByChar(const signed char c, bool &valid) const -{ - const CharColors::const_iterator it = mCharColors.find(c); - if (it != mCharColors.end()) - { - valid = true; - return (*it).second; - } - - valid = false; - return 0; -} - void Palette::advanceGradients() { FOR_EACH (Palettes::const_iterator, it, mInstances) diff --git a/src/gui/palette.h b/src/gui/palette.h index b42ada438..fcfa40360 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -65,31 +65,6 @@ class Palette notfinal const Color &getCharColor(const signed char c, bool &valid) const A_WARN_UNUSED; - int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; - - /** - * Gets the color associated with the type. Sets the alpha channel - * before returning. - * - * @param type the color type requested - * @param alpha alpha channel to use - * - * @return the requested color - */ - inline const Color &getColor(int type, - const int alpha = 255) A_WARN_UNUSED - { - if (type >= static_cast(mColors.size()) || type < 0) - { - logger->log("incorrect color request type: %d from %u", - type, static_cast(mColors.size())); - type = 0; - } - Color* col = &mColors[type].color; - col->a = alpha; - return *col; - } - inline const Color &getColorWithAlpha(const int type) A_WARN_UNUSED { Color *const col = &mColors[type].color; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 7a6a49d45..c0a4e7bf7 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1215,3 +1215,16 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName) } return info; } + +int Theme::getIdByChar(const signed char c, bool &valid) const +{ + const CharColors::const_iterator it = mCharColors.find(c); + if (it != mCharColors.end()) + { + valid = true; + return (*it).second; + } + + valid = false; + return 0; +} diff --git a/src/gui/theme.h b/src/gui/theme.h index edbe31a08..5a9a75bb0 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -124,6 +124,31 @@ class Theme final : public Palette, float getMinimumOpacity() const A_WARN_UNUSED { return mMinimumOpacity; } + /** + * Gets the color associated with the type. Sets the alpha channel + * before returning. + * + * @param type the color type requested + * @param alpha alpha channel to use + * + * @return the requested color + */ + inline const Color &getColor(int type, + const int alpha = 255) A_WARN_UNUSED + { + if (type >= static_cast(mColors.size()) || type < 0) + { + logger->log("incorrect color request type: %d from %u", + type, static_cast(mColors.size())); + type = 0; + } + Color* col = &mColors[type].color; + col->a = alpha; + return *col; + } + + int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; + /** * Set the minimum opacity allowed to skins. * Set a negative value to free the minimum allowed. diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index d0e6c2c9a..629caca73 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -371,3 +371,16 @@ void UserPalette::addColor(const unsigned type, if (grad != GradientType::STATIC) mGradVector.push_back(&mColors[type]); } + +int UserPalette::getIdByChar(const signed char c, bool &valid) const +{ + const CharColors::const_iterator it = mCharColors.find(c); + if (it != mCharColors.end()) + { + valid = true; + return (*it).second; + } + + valid = false; + return 0; +} diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 3b3bd9d67..744c8441d 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -141,6 +141,31 @@ class UserPalette final : public Palette, public ListModel */ int getColorTypeAt(const int i) A_WARN_UNUSED; + /** + * Gets the color associated with the type. Sets the alpha channel + * before returning. + * + * @param type the color type requested + * @param alpha alpha channel to use + * + * @return the requested color + */ + inline const Color &getColor(int type, + const int alpha = 255) A_WARN_UNUSED + { + if (type >= static_cast(mColors.size()) || type < 0) + { + logger->log("incorrect color request type: %d from %u", + type, static_cast(mColors.size())); + type = 0; + } + Color* col = &mColors[type].color; + col->a = alpha; + return *col; + } + + int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; + private: /** * Define a color replacement. -- cgit v1.2.3-60-g2f50