summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-14 01:24:44 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-14 01:24:44 +0300
commiteea8d5e39b746b240a4720c4f48de91ec81c8563 (patch)
treec3524bb67524431d3a710bd0aae2cf9fccf178dd /src/gui/theme.cpp
parent95445bb5a7fa0c61e489d2f518cd3ebfd35c4fba (diff)
downloadplus-eea8d5e39b746b240a4720c4f48de91ec81c8563.tar.gz
plus-eea8d5e39b746b240a4720c4f48de91ec81c8563.tar.bz2
plus-eea8d5e39b746b240a4720c4f48de91ec81c8563.tar.xz
plus-eea8d5e39b746b240a4720c4f48de91ec81c8563.zip
Move skin into separate file.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp115
1 files changed, 2 insertions, 113 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index b42f8c234..0b0744286 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -28,6 +28,8 @@
#include "configuration.h"
#include "graphicsmanager.h"
+#include "gui/skin.h"
+
#include "resources/dye.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
@@ -62,119 +64,6 @@ static void initDefaultThemePath()
defaultThemePath = "themes/";
}
-Skin::Skin(ImageRect *const restrict skin,
- const ImageRect *const restrict images,
- const std::string &filePath, const std::string &name,
- const int padding, const int titlePadding,
- std::map<std::string, int> *restrict const options):
- instances(1),
- mFilePath(filePath),
- mName(name),
- mBorder(skin),
- mCloseImage(images->grid[0]),
- mCloseImageHighlighted(images->grid[1]),
- mStickyImageUp(images->grid[2]),
- mStickyImageDown(images->grid[3]),
- mPadding(padding),
- mTitlePadding(titlePadding),
- mOptions(options)
-{
- if (!mCloseImageHighlighted)
- {
- mCloseImageHighlighted = mCloseImage;
- if (mCloseImageHighlighted)
- mCloseImageHighlighted->incRef();
- }
-}
-
-Skin::~Skin()
-{
- for (int i = 0; i < 9; i++)
- {
- if (mBorder && mBorder->grid[i])
- {
- mBorder->grid[i]->decRef();
- mBorder->grid[i] = nullptr;
- }
- }
-
- if (mCloseImage)
- {
- mCloseImage->decRef();
- mCloseImage = nullptr;
- }
-
- if (mCloseImageHighlighted)
- {
- mCloseImageHighlighted->decRef();
- mCloseImageHighlighted = nullptr;
- }
-
- if (mStickyImageUp)
- {
- mStickyImageUp->decRef();
- mStickyImageUp = nullptr;
- }
-
- if (mStickyImageDown)
- {
- mStickyImageDown->decRef();
- mStickyImageDown = nullptr;
- }
-
- delete2(mOptions);
- delete2(mBorder);
-}
-
-void Skin::updateAlpha(const float minimumOpacityAllowed)
-{
- const float alpha = static_cast<float>(
- std::max(static_cast<double>(minimumOpacityAllowed),
- static_cast<double>(client->getGuiAlpha())));
-
- if (mBorder)
- {
- for (int i = 0; i < 9; i++)
- {
- if (mBorder->grid[i])
- mBorder->grid[i]->setAlpha(alpha);
- }
- }
-
- if (mCloseImage)
- mCloseImage->setAlpha(alpha);
- if (mCloseImageHighlighted)
- mCloseImageHighlighted->setAlpha(alpha);
- if (mStickyImageUp)
- mStickyImageUp->setAlpha(alpha);
- if (mStickyImageDown)
- mStickyImageDown->setAlpha(alpha);
-}
-
-int Skin::getMinWidth() const
-{
- if (!mBorder || !mBorder->grid[ImageRect::UPPER_LEFT]
- || !mBorder->grid[ImageRect::UPPER_RIGHT])
- {
- return 1;
- }
-
- return mBorder->grid[ImageRect::UPPER_LEFT]->getWidth() +
- mBorder->grid[ImageRect::UPPER_RIGHT]->getWidth();
-}
-
-int Skin::getMinHeight() const
-{
- if (!mBorder || !mBorder->grid[ImageRect::UPPER_LEFT]
- || !mBorder->grid[ImageRect::LOWER_LEFT])
- {
- return 1;
- }
-
- return mBorder->grid[ImageRect::UPPER_LEFT]->getHeight() +
- mBorder->grid[ImageRect::LOWER_LEFT]->getHeight();
-}
-
Theme::Theme() :
Palette(THEME_COLORS_END * THEME_PALETTES),
mSkins(),