HoverRace  2.0
Picture.h
Go to the documentation of this file.
1 
2 // Picture.h
3 //
4 // Copyright (c) 2014, 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 "Res.h"
25 
26 #include "Box.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  class Texture;
42  }
43 }
44 
45 namespace HoverRace {
46 namespace Display {
47 
52 class MR_DllDeclare Picture : public Box
53 {
54  using SUPER = Box;
55 
56 public:
57  struct Props
58  {
59  enum
60  {
61  TEXTURE = SUPER::Props::NEXT_,
64  };
65  };
66 
67 public:
68  Picture(std::shared_ptr<Res<Texture>> texture,
69  const Vec2 &size, const Color color = COLOR_WHITE,
70  uiLayoutFlags_t layoutFlags = 0);
71  Picture(std::shared_ptr<Res<Texture>> texture,
72  double w, double h, const Color color = COLOR_WHITE,
73  uiLayoutFlags_t layoutFlags = 0);
74  virtual ~Picture() { }
75 
76 public:
77  virtual void AttachView(Display &disp) { AttachViewDynamic(disp, this); }
78 
79 public:
80 
81  std::shared_ptr<Res<Texture>> ShareTexture() const { return texture; }
82  void SetTexture(std::shared_ptr<Res<Texture>> texture);
83 
84  const Color GetColor() const { return color; }
85  void SetColor(const Color color);
86 
87 private:
88  std::shared_ptr<Res<Texture>> texture;
90 };
91 
92 } // namespace Display
93 } // namespace HoverRace
94 
95 #undef MR_DllDeclare
Draws a single texture.
Definition: Picture.h:52
Definition: Color.h:40
std::shared_ptr< Res< Texture > > texture
Definition: Picture.h:88
Base class for UI (2D) components.
Definition: UiViewModel.h:56
Base class for loadable textures.
Definition: Res.h:94
constexpr Color COLOR_WHITE
Definition: Color.h:64
Base class for low-level bounded widgets.
Definition: Box.h:51
First index for subclasses.
Definition: Picture.h:63
Definition: Vec.h:38
MR_UInt32 uiLayoutFlags_t
Definition: UiLayoutFlags.h:53
Base class for display managers.
Definition: Display.h:73
Color color
Definition: Picture.h:89
const Color GetColor() const
Definition: Picture.h:84
std::shared_ptr< Res< Texture > > ShareTexture() const
Definition: Picture.h:81
Definition: Announcement.h:24
virtual ~Picture()
Definition: Picture.h:74
Definition: Picture.h:57
#define MR_DllDeclare
Definition: Picture.h:35
virtual void AttachView(Display &disp)
Definition: Picture.h:77