Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/dgl/StandaloneWindow.hpp @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 /* | |
2 * DISTRHO Plugin Framework (DPF) | |
3 * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |
4 * | |
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with | |
6 * or without fee is hereby granted, provided that the above copyright notice and this | |
7 * permission notice appear in all copies. | |
8 * | |
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 */ | |
16 | |
17 #ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED | |
18 #define DGL_STANDALONE_WINDOW_HPP_INCLUDED | |
19 | |
20 #include "TopLevelWidget.hpp" | |
21 #include "Window.hpp" | |
22 | |
23 START_NAMESPACE_DGL | |
24 | |
25 // ----------------------------------------------------------------------- | |
26 | |
27 class StandaloneWindow : public Window, | |
28 public TopLevelWidget | |
29 { | |
30 public: | |
31 /** | |
32 Constructor without parent. | |
33 */ | |
34 StandaloneWindow(Application& app) | |
35 : Window(app), | |
36 TopLevelWidget((Window&)*this), | |
37 sgc((Window&)*this) {} | |
38 | |
39 /** | |
40 Constructor with a transient parent window, typically used to run as modal. | |
41 */ | |
42 StandaloneWindow(Application& app, Window& transientParentWindow) | |
43 : Window(app, transientParentWindow), | |
44 TopLevelWidget((Window&)*this), | |
45 sgc((Window&)*this, transientParentWindow) {} | |
46 | |
47 /** | |
48 Clear current graphics context. | |
49 Must be called at the end of your StandaloneWindow constructor. | |
50 */ | |
51 void done() | |
52 { | |
53 sgc.done(); | |
54 } | |
55 | |
56 /** | |
57 Get a graphics context back again. | |
58 Called when a valid graphics context is needed outside the constructor. | |
59 */ | |
60 void reinit() | |
61 { | |
62 sgc.reinit(); | |
63 } | |
64 | |
65 /** | |
66 Overloaded functions to ensure they apply to the Window class. | |
67 */ | |
68 bool isVisible() const noexcept { return Window::isVisible(); } | |
69 void setVisible(bool yesNo) { Window::setVisible(yesNo); } | |
70 void hide() { Window::hide(); } | |
71 void show() { Window::show(); } | |
72 uint getWidth() const noexcept { return Window::getWidth(); } | |
73 uint getHeight() const noexcept { return Window::getHeight(); } | |
74 const Size<uint> getSize() const noexcept { return Window::getSize(); } | |
75 void repaint() noexcept { Window::repaint(); } | |
76 void setWidth(uint width) { Window::setWidth(width); } | |
77 void setHeight(uint height) { Window::setHeight(height); } | |
78 void setSize(uint width, uint height) { Window::setSize(width, height); } | |
79 void setSize(const Size<uint>& size) { Window::setSize(size); } | |
80 bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0) | |
81 { return Window::addIdleCallback(callback, timerFrequencyInMs); } | |
82 bool removeIdleCallback(IdleCallback* callback) { return Window::removeIdleCallback(callback); } | |
83 Application& getApp() const noexcept { return Window::getApp(); } | |
84 const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); } | |
85 double getScaleFactor() const noexcept { return Window::getScaleFactor(); } | |
86 void setGeometryConstraints(uint minimumWidth, uint minimumHeight, | |
87 bool keepAspectRatio = false, bool automaticallyScale = false) | |
88 { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); } | |
89 | |
90 private: | |
91 ScopedGraphicsContext sgc; | |
92 | |
93 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow) | |
94 }; | |
95 | |
96 // ----------------------------------------------------------------------- | |
97 | |
98 END_NAMESPACE_DGL | |
99 | |
100 #endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED |