HoverRace  2.0
SdlBaseContainerView.h
Go to the documentation of this file.
1 
2 // SdlBaseContainerView.h
3 //
4 // Copyright (c) 2013-2015 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 "SdlDisplay.h"
25 #include "SdlView.h"
26 
27 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
28 # ifdef MR_ENGINE
29 # define MR_DllDeclare __declspec( dllexport )
30 # else
31 # define MR_DllDeclare __declspec( dllimport )
32 # endif
33 #else
34 # define MR_DllDeclare
35 #endif
36 
37 namespace HoverRace {
38  namespace Display {
39  class BaseContainer;
40  namespace SDL {
41  class SdlTexture;
42  }
43  }
44 }
45 
46 namespace HoverRace {
47 namespace Display {
48 namespace SDL {
49 
54 class MR_DllDeclare SdlBaseContainerView : public SdlView<BaseContainer>
55 {
57 public:
59  virtual ~SdlBaseContainerView();
60 
61 public:
62  void OnModelUpdate(int prop) override;
63 
64 public:
65  // Note: These are only calculated if the container is clipping so that
66  // we can check if coordinate are inside the bounds.
67  Vec2 GetScreenPos() const override { return screenPos; }
68  Vec2 GetScreenSize() const override { return screenSize; }
69 
70  Vec3 Measure() override;
71  void PrepareRender() override;
72  void Render() override;
73 
74 private:
77  bool rttChanged;
79  std::unique_ptr<SdlTexture> rttTarget;
80  boost::signals2::scoped_connection displayConfigChangedConn;
81 };
82 
83 } // namespace SDL
84 } // namespace Display
85 } // namespace HoverRace
86 
87 #undef MR_DllDeclare
Vec2 screenPos
Definition: SdlBaseContainerView.h:75
std::unique_ptr< SdlTexture > rttTarget
Definition: SdlBaseContainerView.h:79
boost::signals2::scoped_connection displayConfigChangedConn
Definition: SdlBaseContainerView.h:80
Base class for widgets that contain other widgets.
Definition: BaseContainer.h:63
bool rttChanged
Render-to-texture may need to be re-evaluated.
Definition: SdlBaseContainerView.h:77
Definition: Vec.h:38
SDL view for BaseContainer.
Definition: SdlBaseContainerView.h:54
Vec2 GetScreenPos() const override
Retrieve the screen-space position, if available.
Definition: SdlBaseContainerView.h:67
bool rttSizeChanged
Definition: SdlBaseContainerView.h:78
Definition: Announcement.h:24
Vec2 screenSize
Definition: SdlBaseContainerView.h:76
Vec2 GetScreenSize() const override
Retrieve the screen-space size, if available.
Definition: SdlBaseContainerView.h:68
Definition: Vec.h:114
#define MR_DllDeclare
Definition: SdlBaseContainerView.h:34
Base class for views that use SDL for rendering.
Definition: SdlView.h:54
SDL-based software rendering.
Definition: SdlDisplay.h:60