HoverRace  2.0
KeycapIcon.h
Go to the documentation of this file.
1 
2 // KeycapIcon.h
3 //
4 // Copyright (c) 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 "FillBox.h"
25 
26 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
27 # ifdef MR_ENGINE
28 # define MR_DllDeclare __declspec( dllexport )
29 # else
30 # define MR_DllDeclare __declspec( dllimport )
31 # endif
32 #else
33 # define MR_DllDeclare
34 #endif
35 
36 namespace HoverRace {
37 namespace Display {
38 
44 {
45  using SUPER = FillBox;
46 
47 public:
48  struct Props
49  {
50  enum
51  {
52  KEY_HASH = SUPER::Props::NEXT_,
54  };
55  };
56 
57 public:
58  KeycapIcon(double height, int keyHash,
59  const Color color = COLOR_WHITE, uiLayoutFlags_t layoutFlags = 0);
60  virtual ~KeycapIcon() { }
61 
62 public:
63  void AttachView(Display &disp) override { AttachViewDynamic(disp, this); }
64 
65 public:
66  int GetKeyHash() const { return keyHash; }
67  void SetKeyHash(int keyHash);
68 
69  void AdjustHeight(double h) override;
70  void AdjustWidth(double w) override;
71 
72 public:
73  Vec3 Measure() override
74  {
75  return GetView() ? GetView()->Measure() : Vec3(0, 0, 0);
76  }
77 
78 private:
79  int keyHash;
80 };
81 
82 } // namespace Display
83 } // namespace HoverRace
84 
85 #undef MR_DllDeclare
First index for subclasses.
Definition: KeycapIcon.h:53
Definition: Color.h:40
#define MR_DllDeclare
Definition: KeycapIcon.h:33
Base class for UI (2D) components.
Definition: UiViewModel.h:56
constexpr Color COLOR_WHITE
Definition: Color.h:64
Definition: KeycapIcon.h:48
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
Base class for display managers.
Definition: Display.h:73
Icon for a keycap (keyboard key or gamepad button(.
Definition: KeycapIcon.h:43
A colored rectangle, that's all.
Definition: FillBox.h:51
int keyHash
Definition: KeycapIcon.h:79
int GetKeyHash() const
Definition: KeycapIcon.h:66
void AttachView(Display &disp) override
Definition: KeycapIcon.h:63
Definition: Announcement.h:24
Definition: Vec.h:114
virtual ~KeycapIcon()
Definition: KeycapIcon.h:60
Vec3 Measure() override
Calculate the size of the component.
Definition: KeycapIcon.h:73