API Documentation
Loading...
Searching...
No Matches
WindowInstance.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: WindowInstance
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_VIEWPORT
35#include <NDEVR/KeyController.h>
36#include <NDEVR/Pointer.h>
37#include <functional>
38namespace NDEVR
39{
40 class GraphicsUpdateArguments;
41 class MouseEvent;
42 class KeyEvent;
43 class Camera;
44 class MouseController;
45 class DesignObjectLookup;
46
47 /**--------------------------------------------------------------------------------------------------
48 \brief Contains core information about a Viewport.
49 **/
50 class NDEVR_DESIGN_API WindowInstance
51 {
52 public:
53 WindowInstance();
54 WindowInstance(UUID camera, DesignObjectLookup* lookup);
55
56 MouseController& getMouseController();
57 KeyController& getKeyController();
58 void setLookup(DesignObjectLookup* lookup) { m_lookup = lookup; }
59 virtual Vector<2, uint04> pixelSize() const { return (m_device_pixel_ratio * m_size.as<2, fltp08>()).as<2, uint04>(); };
60 virtual Vector<2, uint04> logicalSize() const { return m_size; };
61 virtual fltp08 referenceSize() { return m_reference_size; }
62 virtual fltp08 referencePixelSize() { return m_device_pixel_ratio * m_reference_size;}
63 virtual void setSize(const Vector<2, uint04>& size);
64 virtual void setReferenceSize(fltp08 size);
65 void addResizeEvent(const std::function<void(Vector<2, uint04>)>& resize_event) { m_resize_events.add(resize_event); };
66 void addMouseEvent(const std::function<void(MouseEvent)>& mouse_event) { m_mouse_events.add(mouse_event); }
67 void addKeyboardEvent(const std::function<void(KeyEvent)>& key_event) { m_key_events.add(key_event); };
68 virtual bool visible() const { return true; }
69 virtual bool shouldExit() const { return false; }
70 virtual void* getSurface() = 0;
71 virtual void updateInstance() {};
72 Time getSurfaceUpdateTime() const { return m_surface_update_time; }
73 virtual uint04 getGrabImageSize() { return 0; }
74 virtual void finishFrame(GraphicsUpdateArguments&) {};
75 virtual void setCamera(const UUID& camera);
76 virtual ConstPointer<Camera> getCamera() const;
77 virtual DynamicPointer<Camera> getCamera();
78 const void* lockptr() const { return this; }
79 void createEvent(const MouseEvent& event);
80 void createEvent(const KeyEvent& event);
81 void createResizeEvent(const Vector<2, uint04>& event);
82 void setDevicePixelRatio(const fltp08 ratio) { m_device_pixel_ratio = ratio; };
83 fltp08 devicePixelRatio() const { return m_device_pixel_ratio; }
84 const UUID& cameraID() const { return m_camera; }
85 protected:
86 Buffer<std::function<void(Vector<2, uint04>)>> m_resize_events;
87 Buffer<std::function<void(MouseEvent)>> m_mouse_events;
88 Buffer<std::function<void(KeyEvent)>> m_key_events;
89 fltp08 m_device_pixel_ratio;
90
91 Vector<2, uint04> m_size;
92 fltp08 m_reference_size;
93 Time m_surface_update_time;
94 UUID m_camera;
95 DesignObjectLookup* m_lookup;
96 };
97}
98#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149