ManaPlus
windowmenu.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef GUI_WINDOWMENU_H
25 #define GUI_WINDOWMENU_H
26 
28 
29 #include "gui/widgets/container.h"
30 
34 
35 #include "localconsts.h"
36 
37 class Button;
38 class ImageSet;
39 
40 struct ButtonInfo;
41 struct ButtonText;
42 
49 class WindowMenu final : public Container,
50  public ConfigListener,
51  public ActionListener,
52  public SelectionListener,
53  public MouseListener
54 {
55  public:
56  explicit WindowMenu(const Widget2 *const widget);
57 
59 
60  ~WindowMenu() override final;
61 
62  void action(const ActionEvent &event) override final;
63 
64  void mousePressed(MouseEvent &event) override final;
65 
66  void mouseMoved(MouseEvent &event) override final;
67 
68  void mouseExited(MouseEvent& event A_UNUSED) override final;
69 
70  std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
71  { return mButtonNames; }
72 
73  STD_VECTOR <Button*> &getButtons() A_WARN_UNUSED
74  { return mButtons; }
75 
76  STD_VECTOR <ButtonText*> &getButtonTexts() A_WARN_UNUSED
77  { return mButtonTexts; }
78 
79  void showButton(const std::string &name, const Visible visible);
80 
81  void loadButtons();
82 
83  void saveButtons() const;
84 
85  void optionChanged(const std::string &name) override final;
86 
87 #ifdef USE_PROFILER
88  void logicChildren();
89 #endif // USE_PROFILER
90 
91  protected:
92  void drawChildren(Graphics *const graphics) override final
93  A_NONNULL(2);
94 
95  void safeDrawChildren(Graphics *const graphics) override final
96  A_NONNULL(2);
97 
98  private:
99  inline void addButton(const char *const text,
100  const int iconNumber,
101  const std::string &description,
102  int &restrict x, int &restrict h,
103  const InputActionT key,
104  const Visible visible);
105 
106  void updateButtons();
107 
110  int mPadding;
111  int mSpacing;
112  STD_VECTOR <Button*> mButtons;
113  STD_VECTOR <ButtonText*> mButtonTexts;
114  std::map <std::string, ButtonInfo*> mButtonNames;
118 };
119 
120 extern WindowMenu *windowMenu;
121 
122 #endif // GUI_WINDOWMENU_H
virtual void logicChildren()
Definition: button.h:102
Definition: skin.h:37
void loadButtons()
Definition: windowmenu.cpp:484
void saveButtons() const
Definition: windowmenu.cpp:537
WindowMenu(const Widget2 *const widget)
Definition: windowmenu.cpp:53
void safeDrawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:566
void showButton(const std::string &name, const Visible visible)
Definition: windowmenu.cpp:447
std::map< std::string, ButtonInfo * > & getButtonNames()
Definition: windowmenu.h:70
void addButton(const char *const text, const int iconNumber, const std::string &description, int &x, int &h, const InputActionT key, const Visible visible)
Definition: windowmenu.cpp:323
void updateButtons()
Definition: windowmenu.cpp:459
ImageSet * mImageSet
Definition: windowmenu.h:109
std::vector< ButtonText * > mButtonTexts
Definition: windowmenu.h:113
std::vector< ButtonText * > & getButtonTexts()
Definition: windowmenu.h:76
void drawChildren(Graphics *const graphics)
Definition: windowmenu.cpp:554
void mousePressed(MouseEvent &event)
Definition: windowmenu.cpp:377
std::map< std::string, ButtonInfo * > mButtonNames
Definition: windowmenu.h:114
void mouseMoved(MouseEvent &event)
Definition: windowmenu.cpp:399
std::vector< Button * > & getButtons()
Definition: windowmenu.h:73
std::vector< Button * > mButtons
Definition: windowmenu.h:112
Skin * mSkin
Definition: windowmenu.h:108
int mAutoHide
Definition: windowmenu.h:116
void optionChanged(const std::string &name)
Definition: windowmenu.cpp:578
void action(const ActionEvent &event)
Definition: windowmenu.cpp:308
bool mHaveMouse
Definition: windowmenu.h:115
bool mSmallWindow
Definition: windowmenu.h:117
int mPadding
Definition: windowmenu.h:110
int mSpacing
Definition: windowmenu.h:111
void mouseExited(MouseEvent &event)
Definition: windowmenu.cpp:438
InputAction ::T InputActionT
Definition: inputaction.h:717
#define restrict
Definition: localconsts.h:165
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define A_UNUSED
Definition: localconsts.h:160
bool Visible
Definition: visible.h:30
WindowMenu * windowMenu
Definition: windowmenu.cpp:51