GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/skin.h Lines: 11 11 100.0 %
Date: 2017-11-29 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-2017  The ManaPlus Developers
8
 *
9
 *  This file is part of The ManaPlus Client.
10
 *
11
 *  This program is free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
#ifndef GUI_SKIN_H
26
#define GUI_SKIN_H
27
28
#include "utils/stringmap.h"
29
30
#include "localconsts.h"
31
32
class Image;
33
class ImageRect;
34
35
class Skin final
36
{
37
    public:
38
        Skin(ImageRect *const restrict skin,
39
             const ImageRect *const restrict images,
40
             const std::string &filePath,
41
             const std::string &name,
42
             const int padding,
43
             const int titlePadding,
44
             StringIntMap *restrict const options) A_NONNULL(8);
45
46
        A_DELETE_COPY(Skin)
47
48
        ~Skin();
49
50
        /**
51
         * Returns the skin's name. Useful for giving a human friendly skin
52
         * name if a dialog for skin selection for a specific window type is
53
         * done.
54
         */
55
        const std::string &getName() const noexcept2 A_WARN_UNUSED
56
        { return mName; }
57
58
        /**
59
         * Returns the skin's xml file path.
60
         */
61
        const std::string &getFilePath() const noexcept2 A_WARN_UNUSED
62
        { return mFilePath; }
63
64
        /**
65
         * Returns the background skin.
66
         */
67
        const ImageRect &getBorder() const noexcept2 A_WARN_UNUSED
68
1096
        { return *mBorder; }
69
70
        /**
71
         * Returns the image used by a close button for this skin.
72
         */
73
        const Image *getCloseImage(const bool state) const
74
                                   noexcept2 A_WARN_UNUSED
75

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

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