Display.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef DC_DISPLAY_H_INCLUDED
34 #define DC_DISPLAY_H_INCLUDED
35 
36 /* Display
37 
38  An interface for displaying rendered data
39 
40 */
41 #include <string>
42 #include <Dynacoe/Backends/Backend.h>
43 #include <Dynacoe/Backends/Framebuffer/Framebuffer.h>
44 
45 namespace Dynacoe {
46 
47 
48 
53 class Display : public Backend {
54  public:
55 
59  public:
64  virtual void operator()(int newWidth, int newHeight) = 0;
65  };
66 
71  class CloseCallback {
72  public:
73 
76  virtual void operator()(void) = 0;
77  };
78 
79  virtual ~Display(){}
80 
81 
82 
83 
86  enum class Capability {
87  CanResize,
88  CanMove,
90  CanHide,
92  };
93 
96  enum class ViewPolicy {
97  NoPolicy,
98  MatchSize,
99  };
100 
101 
102 
103 
106  enum class DisplayHandleType {
107  X11Display,
108  WINAPIHandle,
109  Unknown
110  };
111 
113  enum class DisplayEventType {
114  X11Event,
115  WINAPIMsg,
116  Unknown
117 
118  };
119 
122  virtual void Resize(int w, int h) = 0;
123 
130  virtual void SetPosition(int x, int y) = 0;
131 
135  virtual void Fullscreen(bool) = 0;
136 
139  virtual void Hide(bool) = 0;
140 
144  virtual bool HasInputFocus() = 0;
145 
151  virtual void LockClientResize(bool) = 0;
152 
155  virtual void LockClientPosition(bool) = 0;
156 
160  virtual void SetViewPolicy(ViewPolicy) = 0;
161 
164  virtual int Width() = 0;
165 
168  virtual int Height() = 0;
169 
172  virtual int X() = 0;
173 
176  virtual int Y() = 0;
177 
178 
179 
182  virtual void SetName(const std::string &) = 0;
183 
187  virtual void AddResizeCallback(ResizeCallback *) = 0;
188 
191  virtual void RemoveResizeCallback(ResizeCallback *) = 0;
192 
200  virtual void AddCloseCallback(CloseCallback *) = 0;
203  virtual void RemoveCloseCallback(CloseCallback *) = 0;
204 
205 
206 
209  virtual bool IsCapable(Capability) = 0;
210 
211 
212 
213  // Interfacing with others
214 
215 
220  virtual void AttachSource(Framebuffer *) = 0;
221 
223  virtual Framebuffer * GetSource() = 0;
224 
228  virtual void Update() = 0;
229 
230  // Returns the framebuffer types that this renderer supports.
231  // Should the framebuffer not match one of the given types, the framebuffer
232  // attachment will fail
233  virtual std::vector<Dynacoe::Framebuffer::Type> SupportedFramebuffers() = 0;
234 
239 
243  virtual void * GetSystemHandle() = 0;
244 
248  virtual DisplayEventType GetSystemEventType() = 0;
249 
253  virtual void * GetLastSystemEvent() = 0;
254 
255 
256 
257 };
258 
259 
260 
261 
262 
263 
264 }
265 
266 #endif
virtual void LockClientPosition(bool)=0
Attempts to prevent moving on the user's side.
Base class for the trigger of a close signal from the user.
Definition: Display.h:71
DisplayEventType
The varienty of system event types that Display can give.
Definition: Display.h:113
virtual bool IsCapable(Capability)=0
Returns whether or not the Display is able to perform the requested capability.
virtual void * GetLastSystemEvent()=0
Returns an implementation-specific value that represents the last processed event generated form the ...
virtual void operator()(int newWidth, int newHeight)=0
Called upon resizing.
Backend.
Definition: Backend.h:56
Contains a visual state.
Definition: Framebuffer.h:49
virtual void Resize(int w, int h)=0
Resizes the display. If the display does not support resizing, no action is taken.
The display handle is an X11Display instance. In this case, the display is a window in an X11 environ...
Capability
The standard functional capabilities of a Display.
Definition: Display.h:86
virtual void RemoveCloseCallback(CloseCallback *)=0
Removes the callback of the same instance as one given via AddCloseCallback.
ViewPolicy
Controls how the Display displays Rendered data.
Definition: Display.h:96
virtual void operator()(void)=0
The actual callback.
The handle's type is not known and should not be relied on.
Base class for resize callbacks.
Definition: Display.h:58
The Display will show the attached Framebuffer's contents with no transformation. ...
The event is a pointer to a std::vector.
virtual DisplayEventType GetSystemEventType()=0
Returns the type of the system events returned by GetLastSystemEvent(). Like getting the system handl...
Definition: AssetID.h:37
The Display can be resized.
The event's type is not known and should not be relied on.
virtual void LockClientResize(bool)=0
Attempts to prevent resizing on the user's side.
virtual void SetName(const std::string &)=0
Sets the name of the display. On some systems, this can, for example, set the title bar of the applic...
virtual int X()=0
Returns the X position of the display.
virtual int Width()=0
Returns the width of the display.
The Display will stretch the attached Framebuffer's contents to match the windows dimensions...
The display handle is a MS Windows HWND instance.
virtual void RemoveResizeCallback(ResizeCallback *)=0
Removes the callback of the same instance as one given via AddResizeCallback.
virtual void AddCloseCallback(CloseCallback *)=0
Adds an additional callback function to be be called after the occurance of a closing event...
virtual Framebuffer * GetSource()=0
Returns the frame data to read from.
virtual DisplayHandleType GetSystemHandleType()=0
Returns the type associated with data returned by GetSystemHandle. Meant for internal use...
virtual void AttachSource(Framebuffer *)=0
Attaches the given framebuffer as the source of the display. Any updates to the display reflect the c...
The Display can be hidden.
virtual bool HasInputFocus()=0
Returns whether the display has user input focus. On display implementations where this doesnt apply...
The Display's size can consume the entire physical device, often in a special state.
virtual void Fullscreen(bool)=0
Set the display into a fullscreen context. If fullscreen is not supported, no action is taken...
virtual void Update()=0
Updates display with input visual data that is populated in the internal framebuffer. THe framebuffer's data canbe populated by modifying the framebuffer in GetSource()
Backend that controls how data is displayed to the user.
Definition: Display.h:53
DisplayHandleType
The variety of system handle types that Display can represent.
Definition: Display.h:106
The Display can prevent the user from changing the dimensions of the Display.
The Display's position can be moved.
virtual void * GetSystemHandle()=0
Returns an implementation-specific handle that represents this Display or this Display's properties...
virtual void AddResizeCallback(ResizeCallback *)=0
Adds an additional callback function to be be called after the occurance of a resize event...
The event is a pointer to a std::vector.
virtual void Hide(bool)=0
Attempts to hide the display. If hiding is not supported, no action is taken.
virtual int Y()=0
Returns the Y position of the display.
virtual void SetPosition(int x, int y)=0
Sets the position of the display.
virtual void SetViewPolicy(ViewPolicy)=0
Controls how the Renderer's information is displayed. The default policy is "MatchSize" See ViewPolic...
virtual int Height()=0
Returns the height of the display.