 |
Gorgon Game Engine
|
Go to the documentation of this file.
7 #include "ConsumableEvent.h"
38 static const struct FullscreenTag {
54 Window(WindowManager::Monitor::Primary(), rect, name, name, allowresize, visible) {}
63 Window(WindowManager::Monitor::Primary(), rect, name, name, allowresize, visible) {}
71 Window(
const Geometry::Size &size,
const std::string &name,
const std::string &title,
bool allowresize=
false,
bool visible=
true) :
72 Window(WindowManager::Monitor::Primary(), {automaticplacement, size}, name, title, allowresize, visible) { }
80 Window(
const Geometry::Size &size,
const char *name,
const char *title,
bool allowresize=
false,
bool visible=
true) :
81 Window(WindowManager::Monitor::Primary(), {automaticplacement, size}, name, title, allowresize, visible) { }
89 Window(WindowManager::Monitor::Primary(), {automaticplacement, size}, name, name, allowresize, visible) { }
97 Window(WindowManager::Monitor::Primary(), {automaticplacement, size}, name, name, allowresize, visible) { }
106 Window(monitor, {automaticplacement, size}, name, name, allowresize, visible) { }
115 Window(monitor, {automaticplacement, size}, name, name, allowresize, visible) { }
119 Window(
const FullscreenTag &,
const WindowManager::Monitor &monitor,
const std::string &name,
const std::string &title=
"");
123 Window(
const FullscreenTag &tag,
const std::string &name,
const std::string &title=
"") :
124 Window(tag, WindowManager::Monitor::Primary(), name, title) { }
168 virtual void Move(
int x,
int y)
override {
186 virtual void Resize(
int width,
int height)
override {
223 virtual void Show()
override;
226 virtual void Hide()
override;
241 void SetTitle(
const std::string &title);
297 virtual void Render()
override;
303 return mouselocation;
392 ConsumableEvent<Window, Input::Key, float>
KeyEvent{*
this};
427 void createglcontext();
429 void updatedataowner();
444 bool allowresize =
false;
446 bool cursorover =
true;
452 Graphics::Layer *pointerlayer =
nullptr;
453 bool iswmpointer =
true;
455 bool switchbacktolocalptr =
false;
bool move
Definition: X11.h:38
void Swap(Window &other)
Used for move semantics.
Definition: Window.cpp:17
virtual void Resize(const Geometry::Size &size)
Resizes the layer to the given size.
Definition: Layer.h:337
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
void processmessages()
This method is automatically called by the system.Unless its necessary, do not use it.
Definition: Window.cpp:652
Atom XA_WM_NAME
Definition: X11.h:85
Atom XA_ATOM
Definition: X11.h:79
static Geometry::Size GetMinimumRequiredSize()
Returns the minimum size required to fit any window inside.
Definition: WindowManager.cpp:14
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Geometry::Point GetMousePosition(Gorgon::internal::windowdata *wind)
Definition: X11.cpp:223
This class represents a window.
Definition: Window.h:31
bool IsInside(const basic_Bounds< T_ > &b, const basic_Point< T_ > &p)
Checks whether the given point is inside this bounds.
Definition: Bounds.h:514
static void UpdateSizes()
Updates the size of all framebuffers.
Definition: FrameBuffer.cpp:34
Input::Mouse::Button PressedButtons() const
Returns currently pressed buttons.
Definition: Window.h:307
void handleinputevent(XEvent event, Window &wind)
Definition: Input.cpp:463
int ClickThreshold
The maximum distance allowed for mouse to move between the press of the button and the release for cl...
Definition: Config.cpp:13
virtual bool IsVisible() const override
Returns whether this layer is effectively visible.
Definition: Window.h:229
virtual void Clear() override
Clears drawing buffer, in layer architecture this request only affects the layer itself,...
Definition: Layer.h:269
const Pointer & Current() const
Returns the pointer on top of the stack, if no pointer is on the stack, first pointer in the order of...
Definition: Pointer.cpp:53
void SetIcon(const WindowManager::Icon &icon)
Changes the icon of the window.
Definition: Window.cpp:644
bool focused
Definition: X11.h:42
Atom XA_PROTOCOLS
Definition: X11.h:69
void Clear()
Clears the window pointed by the active context.
Definition: OpenGL.cpp:277
virtual void Resize(int width, int height) override
Resizes the window to the given size.
Definition: Window.h:186
contains the Rectangle class
This class provides event mechanism.
Definition: Event.h:134
Geometry::Bounds GetUsable() const
Returns the area usable rectangle of the monitor. This region excludes any panels on the screen.
Definition: WindowManager.h:105
void Add(Layer &layer)
Adds the given layer as a child.
Definition: Layer.cpp:23
Event< Window > RestoredEvent
Called after the window is restored from minimized state, either by the user or programmatically.
Definition: Window.h:377
Atom XA_NET_FRAME_EXTENTS
Definition: X11.h:82
contains collection, a vector of references.
bool IsClosed() const
Whether the window is currently closed and cannot be acted on.
Definition: Window.cpp:413
bool IsX1ButtonPressed() const
Query whether the X1 mouse button is pressed.
Definition: Window.h:327
contains operating system functionality.
Window()
Empty constructor creates a non-initialized window.
Definition: Window.h:45
std::string GetTitle() const
Returns the current title of the window.
Definition: Window.cpp:392
T_ X
X coordinate.
Definition: Point.h:368
virtual void Move(const Geometry::Point &position) override
Moves the window to the given position.
Definition: Window.cpp:309
ConsumableEvent< Window, Input::Keyboard::Char > CharacterEvent
Called when a character is received.
Definition: Window.h:397
~Window()
Destroys this window.
Definition: Window.h:135
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
Atom XA_CARDINAL
Definition: X11.h:80
bool IsLeftButtonPressed() const
Query whether the left mouse button is pressed.
Definition: Window.h:312
T_ Height
Height of this size object.
Definition: Size.h:261
static const struct Gorgon::Window::FullscreenTag Fullscreen
Definition: WindowManager.cpp:12
void SetTitle(const std::string &title)
Changes the title of the window to the specified string.
Definition: Window.cpp:387
Atom XdndLeave
Definition: X11.h:105
Gorgon::internal::windowdata * getdata(const Window &w)
Definition: Window.cpp:15
bool IsRightButtonPressed() const
Query whether the right mouse button is pressed.
Definition: Window.h:317
void DisplayMessage(const std::string &message)
This function shows a OS message box to display errors, for other messages its better to use in-game ...
Definition: Linux.cpp:104
Geometry::Bounds Clip
Current clipping size, for mouse and clipping events.
Definition: Layer.cpp:20
bool min
Definition: X11.h:36
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
Window & operator=(Window &&other)
Moves another window into this one.
Definition: Window.h:141
bool IsLocalPointer() const
Returns whether the current pointer is a local pointer.
Definition: Window.h:279
::Window getanywindow()
Definition: Window.cpp:21
void Minimize()
Minimizes the window.
Definition: Window.cpp:454
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
bool IsPointerVisible() const
Returns whether the pointer is visible.
Definition: Window.h:265
void Focus()
Focuses this window.
Definition: Window.cpp:432
basic_Size< int > Size
Definition: Size.h:385
bool IsMaximized() const
Returns if the window is maximized.
Definition: Window.cpp:599
void SetupContext(const Geometry::Size &size)
Performs first time initialization on GL context.
Definition: OpenGL.cpp:225
void Swap(MouseHandler &other)
Definition: Layer.h:57
void ResetTransform(const Geometry::Size &size)
This should be called by the windows to reset transformation stack.
Definition: Layer.h:65
virtual bool IsVisible() const
Returns whether this layer is effectively visible.
Definition: Layer.h:459
This layer allows drawing texture images on.
Definition: Layer.h:169
basic_Size< T_ > GetSize() const
Returns the size of the rectangle.
Definition: Rectangle.h:218
bool IsMinimized() const
Returns if the window is minimized.
Definition: Window.cpp:580
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
void mouse_location()
These functions are used internally.
Definition: Window.cpp:166
bool pointerdisplayed
Definition: X11.h:37
bool IsX2ButtonPressed() const
Query whether the X2 mouse button is pressed.
Definition: Window.h:332
bool IsValid() const
Returns if the stack is valid to be used.
Definition: Pointer.cpp:67
void mouse_up(Geometry::Point location, Input::Mouse::Button button)
These functions are used internally.
Definition: Window.cpp:120
void mouse_event(Input::Mouse::EventType event, Geometry::Point location, Input::Mouse::Button button, float amount)
These functions are used internally.
Definition: Window.cpp:158
Geometry::Point moveto
Definition: X11.h:39
virtual void Hide() override
Hides this window, may generate Deactivated event.
Definition: Window.cpp:273
Geometry::Size GetSize() const
Returns the size of this monitor in pixels.
Definition: WindowManager.h:89
Event< Window > MinimizedEvent
Called after the window is minimized, either by the user or programmatically.
Definition: Window.h:374
Event< Window, bool & > ClosingEvent
Called when user tries to close the window.
Definition: Window.h:365
GLXContext context
Definition: X11.h:41
Atom XA_UTF8_STRING
Definition: X11.h:73
void Restore()
Restores a minimized or maximized window.
Definition: Window.cpp:508
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
void Move(const basic_Point< T_ > &p)
Changes the position of the rectangle.
Definition: Rectangle.h:181
void AllowResize()
Allows window to be resized by the user.
Definition: Window.cpp:619
Geometry::Bounds bounds
Bounds of this layer.
Definition: Layer.h:507
void assertkeys(Window &wind, Gorgon::internal::windowdata *data)
Definition: Input.cpp:267
virtual void Show() override
Displays this window, may generate Activated event.
Definition: Window.cpp:257
void handledndevent(XEvent event, Window &wind)
Definition: DnD.cpp:312
contains window manager dependent functionality.
Atom XA_NET_WM_STATE_ADD
Definition: X11.h:88
Geometry::Point GetLocation() const
Returns the location of this monitor relative to the other monitors in pixels.
Definition: WindowManager.h:95
virtual bool propagate_mouseevent(Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers)
Propagates a mouse event.
Definition: Layer.cpp:63
static Monitor & Primary()
Returns the default monitor.
Definition: WindowManager.h:122
void HidePointer()
Hides the pointer.
Definition: Window.cpp:280
virtual void Resize(const Geometry::Size &size) override
Resizes the window to the given size.
Definition: Window.cpp:323
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
void Clear()
Definition: Layer.h:49
Collection is a container for reference typed objects.
Definition: Collection.h:21
basic_Point< int > Point
Definition: Point.h:598
Atom XA_NET_WM_ICON
Definition: X11.h:96
Geometry::Transform3D Transform
Current layer transformation, only for render and mouse.
Definition: Layer.cpp:18
Atom XdndPosition
Definition: X11.h:104
::Window handle
Definition: X11.h:35
virtual void Render()
Renders the current layer, default handling is to pass the request to the sub-layers....
Definition: Layer.cpp:51
bool IsMiddleButtonPressed() const
Query whether the middle mouse button is pressed.
Definition: Window.h:322
void Draw(TextureTarget &target, int x, int y, RGBAf color=RGBAf(1.f)) const
Draw to the given coordinates.
Definition: Drawables.h:22
Atom WM_DELETE_WINDOW
Definition: X11.h:70
Geometry::Point ppoint
Definition: X11.h:43
virtual void Render() override
Renders the contents of the window.
Definition: Window.cpp:81
Geometry::Bounds GetExteriorBounds() const
Returns the exterior bounding box of the window.
Definition: Window.cpp:417
basic_Bounds< int > Bounds
Definition: Bounds.h:722
Float Distance(const basic_Point &target) const
Calculates Euclidean distance from this point to the given target.
Definition: Point.h:276
Graphics::PointerStack Pointers
Pointer system to be used within the window.
Definition: Window.h:346
This class manages a pointer stack that allows multiple pointers to be registered and switched.
Definition: Pointer.h:309
This class is the base class for all layer types.
Definition: Layer.h:79
This class represents a 2D point.
Definition: Point.h:32
Atom XA_NET_WM_STATE_FULLSCREEN
Definition: X11.h:89
Atom XA_NET_WM_STATE_MAXIMIZED_HORZ
Definition: X11.h:90
Atom XA_NET_WM_STATE_MAXIMIZED_VERT
Definition: X11.h:91
bool IsFocused() const
Returns if this window has the focus.
Definition: Window.cpp:445
void SwitchToLocalPointers()
Removes the operating system pointer and starts using Locally defined pointers.
Definition: Window.cpp:222
Atom XA_NET_ACTIVE_WINDOW
Definition: X11.h:93
void mouse_down(Geometry::Point location, Input::Mouse::Button button)
These functions are used internally.
Definition: Window.cpp:99
Event< Window > FocusedEvent
Called when this window is focused.
Definition: Window.h:352
void Initialize()
Initializes Graphics module, should be performed after an OpenGL context is created.
Definition: Graphics.cpp:37
static const Containers::Collection< Monitor > & Monitors()
Returns all monitors connected to this device.
Definition: WindowManager.h:131
Atom XA_NET_WM_NAME
Definition: X11.h:86
Event< Window > DestroyedEvent
Called when this window is destroyed.
Definition: Window.h:359
void Swap(PointerStack &other)
Definition: Pointer.h:368
contains event distribution mechanism
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
static const Containers::Collection< Window > & Windows
List of currently created windows.
Definition: Window.h:401
void Destroy()
Destroys this window.
Definition: Window.cpp:243
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
Event< Window > ResizedEvent
Called after the window is resized, either by the user or programmatically.
Definition: Window.h:371
virtual void Move(int x, int y) override
Moves the window to the given position.
Definition: Window.h:168
const WindowManager::Monitor & GetMonitor() const
Returns the monitor that the window is currently on.
Definition: Window.cpp:205
@ Graphics
Definition: Template.h:164
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
Atom XA_NET_WM_STATE_HIDDEN
Definition: X11.h:92
void Center(const WindowManager::Monitor &monitor)
Centers the window to the given monitor.
Definition: Window.h:289
basic_Point< T_ > Center() const
Returns center of bounds.
Definition: Bounds.h:115
Event< Window > LostFocusEvent
Called when this window is deactivated.
Definition: Window.h:355
T_ Y
Y coordinate.
Definition: Point.h:371
basic_Point< T_ > TopLeft() const
Returns top left corner.
Definition: Bounds.h:105
virtual void Hide()
Hides this layer.
Definition: Layer.h:456
virtual void Show()
Displays this layer.
Definition: Layer.h:453
Represents an icon object that can be used as window icon.
Definition: WindowManager.h:43
T_ Width
Width of this size object.
Definition: Size.h:258
basic_Size< T_ > GetSize() const
Returns the size of the bounds object.
Definition: Bounds.h:141
std::string GetName() const
Returns the name of the window that is set at creation time.
Definition: Window.h:247
virtual void added(Layer &layer) override
Will be called when a layer is added.
Definition: Window.cpp:216
virtual void located(Layer *) override
A window cannot be placed in another layer. This function always fails.
Definition: Window.h:419
void ShowPointer()
Displays the pointer.
Definition: Window.cpp:295
bool ismapped
Definition: X11.h:40
void Maximize()
Maximizes the window to cover the usable area of the screen.
Definition: Window.cpp:459
void Swap(Layer &other)
Swaps two layers, mostly used for move semantics.
Definition: Layer.h:125
void Center()
Centers the window to the default monitor.
Definition: Window.h:284
Geometry::Point Offset
Current layer offset from the top left of the window.
Definition: Layer.cpp:21
void deleting(Layer *layer)
Definition: Window.h:424
void Resize(const Geometry::Size &size)
Resizes the active context.
Definition: OpenGL.cpp:273
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Containers::Collection< Layer > children
Child layers that this layer holds, all child layers are considered to be above current layer.
Definition: Layer.h:501
Atom XdndDrop
Definition: X11.h:106
Containers::Collection< Layer > layers
Definition: Layer.h:61
friend class windaccess
Definition: Window.h:35
void SwitchToWMPointers()
Stops showing local pointers and makes window manager pointer visible.
Definition: Window.cpp:228
void Close()
Closes the window. After this function, any use of this object might fail.
Definition: Window.cpp:340
Geometry::Point GetMouseLocation() const
Returns the mouse location on the window.
Definition: Window.h:302
Atom XA_NET_WM_STATE
Definition: X11.h:87
void activatecontext()
Activates the GL context of the window.
Definition: Window.cpp:77
bool isvisible
Whether this layer is visible, invisible layers will not be drawn or receive any events.
Definition: Layer.h:511
Geometry::Size ScreenSize
Definition: Window.cpp:15
Graphics::RGBAf LayerColor
Definition: Layer.cpp:172
Event< Window > MovedEvent
Called after the window is moved, either by the user or programmatically.
Definition: Window.h:368
Geometry::Point GetPosition() const
Returns the current position of the window.
Definition: Window.h:196
ConsumableEvent< Window, Input::Key, float > KeyEvent
Called when a key is pressed or released.
Definition: Window.h:392
Definition: WindowManager.h:84
Atom XdndEnter
Definition: X11.h:101
Geometry::Size GetSize() const
Returns the size of the layer.
Definition: Layer.h:362
void PreventResize()
Prevents window to be resized by the user.
Definition: Window.cpp:631