HoverRace  2.0
View.h
Go to the documentation of this file.
1 
2 // View.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 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
25 # ifdef MR_ENGINE
26 # define MR_DllDeclare __declspec( dllexport )
27 # else
28 # define MR_DllDeclare __declspec( dllimport )
29 # endif
30 #else
31 # define MR_DllDeclare
32 #endif
33 
34 namespace HoverRace {
35 namespace Display {
36 
43 {
44 public:
45  virtual ~View() { }
46 
47  // Disable assignment by default; a view should only be bound to the model
48  // once at construction time.
49  View &operator=(const View&) = delete;
50 
51 public:
58  virtual void OnModelUpdate(int prop) { HR_UNUSED(prop); }
59 
60 public:
66  virtual Vec2 GetScreenPos() const { return { 0, 0 }; }
67 
73  virtual Vec2 GetScreenSize() const { return { 0, 0 }; }
74 
75  virtual Vec3 Measure() = 0;
76  virtual void PrepareRender() = 0;
77  virtual void Render() = 0;
78 };
79 
80 } // namespace Display
81 } // namespace HoverRace
82 
83 #undef MR_DllDeclare
#define MR_DllDeclare
Definition: View.h:31
virtual ~View()
Definition: View.h:45
Definition: Vec.h:38
virtual Vec2 GetScreenSize() const
Retrieve the screen-space size, if available.
Definition: View.h:73
virtual void OnModelUpdate(int prop)
Called by the view model to indicate that a property has changed.
Definition: View.h:58
Base class for views.
Definition: View.h:42
virtual Vec2 GetScreenPos() const
Retrieve the screen-space position, if available.
Definition: View.h:66
Definition: Announcement.h:24
Definition: Vec.h:114