ManaPlus
skin.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2008 The Legend of Mazzeroth Development Team
4  * Copyright (C) 2009 Aethyra Development Team
5  * Copyright (C) 2009 The Mana World Development Team
6  * Copyright (C) 2009-2010 The Mana Developers
7  * Copyright (C) 2011-2019 The ManaPlus Developers
8  * Copyright (C) 2019-2021 Andrei Karas
9  *
10  * This file is part of The ManaPlus Client.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef GUI_SKIN_H
27 #define GUI_SKIN_H
28 
29 #include "utils/stringmap.h"
30 
31 #include "localconsts.h"
32 
33 class Image;
34 class ImageRect;
35 
36 class Skin final
37 {
38  public:
39  Skin(ImageRect *const restrict skin,
40  const ImageRect *const restrict images,
41  const std::string &filePath,
42  const std::string &name,
43  const int padding,
44  const int titlePadding,
45  StringIntMap *restrict const options) A_NONNULL(8);
46 
48 
49  ~Skin();
50 
56  const std::string &getName() const noexcept2 A_WARN_UNUSED
57  { return mName; }
58 
62  const std::string &getFilePath() const noexcept2 A_WARN_UNUSED
63  { return mFilePath; }
64 
69  { return *mBorder; }
70 
74  const Image *getCloseImage(const bool state) const
76  { return state ? mCloseImageHighlighted : mCloseImage; }
77 
81  const Image *getStickyImage(const bool state) const
83  { return state ? mStickyImageDown : mStickyImageUp; }
84 
88  int getMinWidth() const A_WARN_UNUSED;
89 
93  int getMinHeight() const A_WARN_UNUSED;
94 
98  void updateAlpha(const float minimumOpacityAllowed);
99 
101  { return mPadding; }
102 
104  { return mTitlePadding; }
105 
106  int getOption(const std::string &name) const A_WARN_UNUSED
107  {
108  if (mOptions->find(name) != mOptions->end())
109  return (*mOptions)[name];
110  return 0;
111  }
112 
113  int getOption(const std::string &name,
114  const int def) const A_WARN_UNUSED
115  {
116  if (mOptions->find(name) != mOptions->end())
117  return (*mOptions)[name];
118  return def;
119  }
120 
122 
123  private:
124  std::string mFilePath;
125  std::string mName;
131  int mPadding;
134 };
135 
136 #endif // GUI_SKIN_H
Definition: skin.h:37
~Skin()
Definition: skin.cpp:65
int mTitlePadding
Definition: skin.h:132
int mPadding
Definition: skin.h:131
std::string mFilePath
Definition: skin.h:124
Image * mStickyImageUp
Definition: skin.h:129
int getOption(const std::string &name) const
Definition: skin.h:106
Skin(ImageRect *const skin, const ImageRect *const images, const std::string &filePath, const std::string &name, const int padding, const int titlePadding, StringIntMap *const options)
Definition: skin.cpp:40
int getMinWidth() const
Definition: skin.cpp:129
int instances
Definition: skin.h:121
Image * mStickyImageDown
Definition: skin.h:130
const std::string & getName() const
Definition: skin.h:56
int getOption(const std::string &name, const int def) const
Definition: skin.h:113
StringIntMap * mOptions
Definition: skin.h:133
const ImageRect & getBorder() const
Definition: skin.h:68
const std::string & getFilePath() const
Definition: skin.h:62
const Image * getCloseImage(const bool state) const
Definition: skin.h:74
int getTitlePadding() const
Definition: skin.h:103
void updateAlpha(const float minimumOpacityAllowed)
Definition: skin.cpp:104
int getPadding() const
Definition: skin.h:100
Image * mCloseImage
Definition: skin.h:127
const Image * getStickyImage(const bool state) const
Definition: skin.h:81
int getMinHeight() const
Definition: skin.cpp:142
Image * mCloseImageHighlighted
Definition: skin.h:128
std::string mName
Definition: skin.h:125
ImageRect * mBorder
Definition: skin.h:126
#define restrict
Definition: localconsts.h:165
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
std::map< std::string, int > StringIntMap
Definition: stringmap.h:28