HoverRace  2.0
ActionButton.h
Go to the documentation of this file.
1 
2 // ActionButton.h
3 //
4 // Copyright (c) 2013, 2014 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "../Control/Controller.h"
25 
26 #include "Button.h"
27 
28 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
29 # ifdef MR_ENGINE
30 # define MR_DllDeclare __declspec( dllexport )
31 # else
32 # define MR_DllDeclare __declspec( dllimport )
33 # endif
34 #else
35 # define MR_DllDeclare
36 #endif
37 
38 namespace HoverRace {
39  namespace Display {
40  class KeycapIcon;
41  }
42 }
43 
44 namespace HoverRace {
45 namespace Display {
46 
59 {
60  using SUPER = Button;
61 
62 public:
63  ActionButton(Display &display, uiLayoutFlags_t layoutFlags = 0);
64  ActionButton(Display &display, const std::string &text,
65  uiLayoutFlags_t layoutFlags = 0);
66  ActionButton(Display &display, const Vec2 &size,
67  uiLayoutFlags_t layoutFlags = 0);
68  ActionButton(Display &display, const Vec2 &size, const std::string &text,
69  uiLayoutFlags_t layoutFlags = 0);
70  virtual ~ActionButton();
71 
72 private:
73  void InitKeycap();
74 
75 public:
76  void AttachAction(Control::InputEventController &controller,
78  void DetachAction();
79 
80 protected:
81  virtual void FireClickedSignal();
82 
83 private:
84  std::string fixedText;
85  std::shared_ptr<KeycapIcon> keycap;
86  std::weak_ptr<Control::InputEventController::VoidActionPtr::element_type> action;
87  bool armed;
88 };
89 
90 } // namespace Display
91 } // namespace HoverRace
92 
93 #undef MR_DllDeclare
std::string fixedText
Definition: ActionButton.h:84
std::shared_ptr< Action< voidSignal_t >> VoidActionPtr
Definition: Controller.h:133
A button that&#39;s bound to a controller action.
Definition: ActionButton.h:58
Definition: Vec.h:38
std::shared_ptr< KeycapIcon > keycap
Definition: ActionButton.h:85
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
std::weak_ptr< Control::InputEventController::VoidActionPtr::element_type > action
Definition: ActionButton.h:86
Base class for display managers.
Definition: Display.h:73
A standard button, with a text label.
Definition: Button.h:56
#define MR_DllDeclare
Definition: ActionButton.h:35
bool armed
Definition: ActionButton.h:87
Definition: Announcement.h:24
Translates input events into actions.
Definition: Controller.h:106