GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/skin.h Lines: 11 11 100.0 %
Date: 2021-03-17 Branches: 7 14 50.0 %

Line Branch Exec Source
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
47
        A_DELETE_COPY(Skin)
48
49
        ~Skin();
50
51
        /**
52
         * Returns the skin's name. Useful for giving a human friendly skin
53
         * name if a dialog for skin selection for a specific window type is
54
         * done.
55
         */
56
        const std::string &getName() const noexcept2 A_WARN_UNUSED
57
        { return mName; }
58
59
        /**
60
         * Returns the skin's xml file path.
61
         */
62
        const std::string &getFilePath() const noexcept2 A_WARN_UNUSED
63
        { return mFilePath; }
64
65
        /**
66
         * Returns the background skin.
67
         */
68
        const ImageRect &getBorder() const noexcept2 A_WARN_UNUSED
69
553
        { return *mBorder; }
70
71
        /**
72
         * Returns the image used by a close button for this skin.
73
         */
74
        const Image *getCloseImage(const bool state) const
75
                                   noexcept2 A_WARN_UNUSED
76

157
        { return state ? mCloseImageHighlighted : mCloseImage; }
77
78
        /**
79
         * Returns the image used by a sticky button for this skin.
80
         */
81
        const Image *getStickyImage(const bool state) const
82
                                    noexcept2 A_WARN_UNUSED
83

63
        { return state ? mStickyImageDown : mStickyImageUp; }
84
85
        /**
86
         * Returns the minimum width which can be used with this skin.
87
         */
88
        int getMinWidth() const A_WARN_UNUSED;
89
90
        /**
91
         * Returns the minimum height which can be used with this skin.
92
         */
93
        int getMinHeight() const A_WARN_UNUSED;
94
95
        /**
96
         * Updates the alpha value of the skin
97
         */
98
        void updateAlpha(const float minimumOpacityAllowed);
99
100
        int getPadding() const noexcept2 A_WARN_UNUSED
101
2057
        { return mPadding; }
102
103
        int getTitlePadding() const noexcept2 A_WARN_UNUSED
104
63
        { return mTitlePadding; }
105
106
3706
        int getOption(const std::string &name) const A_WARN_UNUSED
107
        {
108
11118
            if (mOptions->find(name) != mOptions->end())
109
1875
                return (*mOptions)[name];
110
            return 0;
111
        }
112
113
757
        int getOption(const std::string &name,
114
                      const int def) const A_WARN_UNUSED
115
        {
116
2271
            if (mOptions->find(name) != mOptions->end())
117
670
                return (*mOptions)[name];
118
            return def;
119
        }
120
121
        int instances;
122
123
    private:
124
        std::string mFilePath;     /**< File name path for the skin */
125
        std::string mName;         /**< Name of the skin to use */
126
        ImageRect *mBorder;        /**< The window border and background */
127
        Image *mCloseImage;        /**< Close Button Image */
128
        Image *mCloseImageHighlighted; /**< Highlighted close Button Image */
129
        Image *mStickyImageUp;     /**< Sticky Button Image */
130
        Image *mStickyImageDown;   /**< Sticky Button Image */
131
        int mPadding;
132
        int mTitlePadding;
133
        StringIntMap *mOptions A_NONNULLPOINTER;
134
};
135
136
#endif  // GUI_SKIN_H