| 1 | // LAF OS Library |
| 2 | // Copyright (C) 2019-2021 Igara Studio S.A. |
| 3 | // |
| 4 | // This file is released under the terms of the MIT license. |
| 5 | // Read LICENSE.txt for more information. |
| 6 | |
| 7 | #ifndef OS_WINDOW_SPEC_H_INCLUDED |
| 8 | #define OS_WINDOW_SPEC_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #include "gfx/rect.h" |
| 12 | #include "gfx/size.h" |
| 13 | #include "os/screen.h" |
| 14 | |
| 15 | namespace os { |
| 16 | |
| 17 | class Window; |
| 18 | |
| 19 | class WindowSpec { |
| 20 | public: |
| 21 | // Position of the window by default |
| 22 | enum class Position { |
| 23 | Default, // Default position selected by the OS (e.g. on Windows it is CW_USEDEFAULT) |
| 24 | Frame, // Position the window in the exact frame() coordinates |
| 25 | ContentRect, // Position the window leaving the client area origin in the exact contentRect() coordinates |
| 26 | Center, |
| 27 | }; |
| 28 | |
| 29 | WindowSpec() { |
| 30 | } |
| 31 | |
| 32 | WindowSpec(int width, int height, int scale = 1) |
| 33 | : m_contentRect(0, 0, width, height) |
| 34 | , m_scale(scale) { |
| 35 | } |
| 36 | |
| 37 | Position position() const { return m_position; } |
| 38 | bool titled() const { return m_titled; } |
| 39 | bool borderless() const { return m_borderless; } |
| 40 | bool closable() const { return m_closable; } |
| 41 | bool maximizable() const { return m_maximizable; } |
| 42 | bool minimizable() const { return m_minimizable; } |
| 43 | bool resizable() const { return m_resizable; } |
| 44 | bool floating() const { return m_floating; } |
| 45 | bool transparent() const { return m_transparent; } |
| 46 | |
| 47 | // Parent window used for floating windows |
| 48 | Window* parent() const { return m_parent; } |
| 49 | |
| 50 | void position(const Position p) { m_position = p; } |
| 51 | void titled(const bool s) { m_titled = s; } |
| 52 | void borderless(const bool s) { m_borderless = s; } |
| 53 | void closable(const bool s) { m_closable = s; } |
| 54 | void maximizable(const bool s) { m_maximizable = s; } |
| 55 | void minimizable(const bool s) { m_minimizable = s; } |
| 56 | void resizable(const bool s) { m_resizable = s; } |
| 57 | void floating(const bool s) { m_floating = s; } |
| 58 | void transparent(const bool s) { m_transparent = s; } |
| 59 | void parent(Window* p) { m_parent = p; } |
| 60 | |
| 61 | const gfx::Rect& frame() const { return m_frame; } |
| 62 | const gfx::Rect& contentRect() const { return m_contentRect; } |
| 63 | int scale() const { return m_scale; } |
| 64 | const ScreenRef& screen() const { return m_screen; } |
| 65 | |
| 66 | void frame(const gfx::Rect& frame) { m_frame = frame; } |
| 67 | void contentRect(const gfx::Rect& contentRect) { m_contentRect = contentRect; } |
| 68 | void scale(const int scale) { m_scale = scale; } |
| 69 | void screen(const ScreenRef& screen) { m_screen = screen; } |
| 70 | |
| 71 | private: |
| 72 | Position m_position = Position::Default; |
| 73 | bool m_titled = true; |
| 74 | bool m_borderless = false; |
| 75 | bool m_closable = true; |
| 76 | bool m_maximizable = true; |
| 77 | bool m_minimizable = true; |
| 78 | bool m_resizable = true; |
| 79 | bool m_floating = false; |
| 80 | bool m_transparent = false; |
| 81 | gfx::Rect m_frame; |
| 82 | gfx::Rect m_contentRect; |
| 83 | int m_scale = 1; |
| 84 | ScreenRef m_screen; |
| 85 | Window* m_parent = nullptr; |
| 86 | }; |
| 87 | |
| 88 | } // namespace os |
| 89 | |
| 90 | #endif |
| 91 | |