HoverRace  2.0
Box.h
Go to the documentation of this file.
1 
2 // Box.h
3 //
4 // Copyright (c) 2016 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 "Color.h"
25 
26 #include "UiViewModel.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 Display;
41  }
42 }
43 
44 namespace HoverRace {
45 namespace Display {
46 
52 {
53  using SUPER = UiViewModel;
54 
55 public:
56  struct Props
57  {
58  enum
59  {
60  SIZE = SUPER::Props::NEXT_,
62  };
63  };
64 
65 public:
66  Box(const Vec2 &size, uiLayoutFlags_t layoutFlags = 0) :
67  SUPER(layoutFlags), size(size) { }
68  virtual ~Box() { }
69 
70 public:
75  const Vec2 &GetSize() const { return size; }
76  void SetSize(const Vec2 &size);
78  void SetSize(double w, double h) { SetSize(Vec2(w, h)); }
79 
80 public:
81  virtual void AdjustHeight(double h);
82  virtual void AdjustWidth(double w);
83 
84 public:
85  virtual Vec3 Measure() { return size.Promote(); }
86 
87 private:
89 };
90 
91 } // namespace Display
92 } // namespace HoverRace
93 
94 #undef MR_DllDeclare
constexpr Vec3 Promote(double z=0) const noexcept
Definition: Vec.h:206
std::enable_if< MPL::HasSetSize< T >::value, void >::type SetSize(T &widget, double w, double h)
Definition: MPL.h:60
Base class for UI (2D) components.
Definition: UiViewModel.h:56
Base class for low-level bounded widgets.
Definition: Box.h:51
Definition: Vec.h:38
First index for subclasses.
Definition: Box.h:61
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
virtual Vec3 Measure()
Calculate the size of the component.
Definition: Box.h:85
virtual ~Box()
Definition: Box.h:68
Vec2 size
Definition: Box.h:88
void SetSize(double w, double h)
Convenience function for SetSize(const Vec2&).
Definition: Box.h:78
Box(const Vec2 &size, uiLayoutFlags_t layoutFlags=0)
Definition: Box.h:66
#define MR_DllDeclare
Definition: Box.h:35
const Vec2 & GetSize() const
Retrieve the size of the box.
Definition: Box.h:75
Definition: Box.h:56
static const Vec2 SIZE
Definition: ProfileEditScene.cpp:90
Definition: Announcement.h:24
Definition: Vec.h:114