CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
PlatformWindow.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
12
14
17
20
21namespace CeresEngine {
22
26 Rect2 frame = {0, 0, 100, 100};
27
29 String title = "Ceres Engine";
30 };
31
35 Rect2 frame;
36
39
41 bool isVisible : 1 = false;
42 };
43
45 public:
48
49 public: // Events
51 Event<void(PlatformWindow&, Vector2)> didResize;
52
55
56 public: // Input events
59
61 Event<void(const KeyEvent&)> onKeyDown;
62
64 Event<void(const KeyEvent&)> onKeyUp;
65
68
70 Event<void(const MouseEvent&)> onMouseUp;
71
74
77
80
83
84 public:
85 explicit PlatformWindow(const PlatformWindowProperties& properties) : properties(properties) {}
86 virtual ~PlatformWindow() = default;
87
88 public:
89 Event<void(const Rect2& newRect, const Rect2& oldRect)> didChangeFrame;
91
92 public:
95 virtual void activate() = 0;
96
99 virtual void deactivate() = 0;
100
101 public:
104 [[nodiscard]] CE_SCRIPT_EXPORT()
105 virtual String getTitle() const = 0;
106
110 virtual void setTitle(const String& title) = 0;
111
114 [[nodiscard]] CE_SCRIPT_EXPORT(property = "getter", name = "size")
115 virtual Vector2 getSize() const = 0;
116
121 virtual void resize(double width, double height) = 0;
122
125 CE_SCRIPT_EXPORT(property = "setter", name = "size")
126 void resize(const Vector2 size) { resize(size.x, size.y); }
127
130 virtual void close() = 0;
131
134 [[nodiscard]] CE_SCRIPT_EXPORT(property = "getter", name = "fullScreen")
135 virtual bool isFullscreen() const = 0;
136
140 CE_SCRIPT_EXPORT(property = "setter", name = "fullScreen")
141 virtual void setFullscreen(bool fullscreen) = 0;
142
144 [[nodiscard]] virtual double getScalingFactor() const = 0;
145
146 public:
149 void sendEvent(const AnyInputEvent& event);
150 };
151
152} // namespace CeresEngine
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
A type that describes any possible event type.
Definition InputEvent.hpp:142
Definition PlatformWindow.hpp:44
Event< void(const MouseEvent &)> onMouseScroll
An event fired when a mouse scroll event is received.
Definition PlatformWindow.hpp:79
Event< void(const KeyEvent &)> onKeyUp
An event fired when a key up event is received.
Definition PlatformWindow.hpp:64
virtual ~PlatformWindow()=default
Event< void(const MouseEvent &)> onMouseMove
An event fired when a mouse move event is received.
Definition PlatformWindow.hpp:73
const PlatformWindowProperties & properties
Definition PlatformWindow.hpp:47
Event< bool()> windowShouldClose
Definition PlatformWindow.hpp:90
Event< void(const MouseEvent &)> onMouseDown
An event fired when a mouse down event is received.
Definition PlatformWindow.hpp:67
PlatformWindow(const PlatformWindowProperties &properties)
Definition PlatformWindow.hpp:85
Event< void(const TextEvent &)> onTextInput
An event fired when a text input event is received.
Definition PlatformWindow.hpp:82
Event< void(PlatformWindow &, Vector2)> didResize
A signal that gets dispatched whenever the window gets resized.
Definition PlatformWindow.hpp:51
Event< void(const AnyInputEvent &)> onEvent
An event fired when any input event is received on the window.
Definition PlatformWindow.hpp:58
Event< void(PlatformWindow &)> didClose
A signal that gets dispatched whenever the window gets closed.
Definition PlatformWindow.hpp:54
Event< void(const MouseEvent &)> onMouseDrag
An event fired when a mouse drag eent is received.
Definition PlatformWindow.hpp:76
Event< void(const KeyEvent &)> onKeyDown
An event fired when a key down event is received.
Definition PlatformWindow.hpp:61
void resize(const Vector2 size)
Resizes the window.
Definition PlatformWindow.hpp:126
Event< void(const MouseEvent &)> onMouseUp
An event fired when a mouse up event is received.
Definition PlatformWindow.hpp:70
Event< void(const Rect2 &newRect, const Rect2 &oldRect)> didChangeFrame
Definition PlatformWindow.hpp:89
Base template for the event class.
Definition Event.hpp:27
Definition Application.hpp:19
A structure that describes a key press event.
Definition InputEvent.hpp:55
A structure that describes a mouse event.
Definition InputEvent.hpp:98
A structure that describes how to create a new window.
Definition PlatformWindow.hpp:24
Rect2 frame
Describes the current window position and size.
Definition PlatformWindow.hpp:26
String title
Describes the current window title.
Definition PlatformWindow.hpp:29
A structure that contains the state and settings for the window.
Definition PlatformWindow.hpp:33
String title
Describes the current window title.
Definition PlatformWindow.hpp:38
Rect2 frame
Describes the current window position and size.
Definition PlatformWindow.hpp:35
bool isVisible
If true, the window is visible on the screen.
Definition PlatformWindow.hpp:41
A structure that describes a text input event.
Definition InputEvent.hpp:124