Dusk Audio Framework
Loading...
Searching...
No Matches
StandaloneWindow.hpp
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
23START_NAMESPACE_DGL
24
25// -----------------------------------------------------------------------
26
27class StandaloneWindow : public Window,
28 public TopLevelWidget
29{
30public:
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 repaint(const Rectangle<uint>& rect) noexcept { Window::repaint(rect); }
77 void setWidth(uint width) { Window::setWidth(width); }
78 void setHeight(uint height) { Window::setHeight(height); }
79 void setSize(uint width, uint height) { Window::setSize(width, height); }
80 void setSize(const Size<uint>& size) { Window::setSize(size); }
81 bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0)
82 { return Window::addIdleCallback(callback, timerFrequencyInMs); }
83 bool removeIdleCallback(IdleCallback* callback) { return Window::removeIdleCallback(callback); }
84 Application& getApp() const noexcept { return Window::getApp(); }
85 const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); }
86 double getScaleFactor() const noexcept { return Window::getScaleFactor(); }
87 void setGeometryConstraints(uint minimumWidth, uint minimumHeight,
88 bool keepAspectRatio = false, bool automaticallyScale = false)
89 { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); }
90
91private:
93
94 DAF_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow)
95};
96
97// -----------------------------------------------------------------------
98
99END_NAMESPACE_DGL
100
101#endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED
Definition Geometry.hpp:612
StandaloneWindow(Application &app)
Definition StandaloneWindow.hpp:34
void done()
Definition StandaloneWindow.hpp:51
bool isVisible() const noexcept
Definition StandaloneWindow.hpp:68
StandaloneWindow(Application &app, Window &transientParentWindow)
Definition StandaloneWindow.hpp:42
void repaint() noexcept
Definition StandaloneWindow.hpp:75
void reinit()
Definition StandaloneWindow.hpp:60
void setVisible(bool visible)
void setHeight(uint height)
void hide()
bool removeIdleCallback(IdleCallback *callback)
uint getHeight() const noexcept
bool isVisible() const noexcept
Application & getApp() const noexcept
void repaint() noexcept
double getScaleFactor() const noexcept
void setSize(uint width, uint height)
void show()
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio=false, bool automaticallyScale=false, bool resizeNowIfAutoScaling=true)
uint getWidth() const noexcept
const GraphicsContext & getGraphicsContext() const noexcept
void setWidth(uint width)
bool addIdleCallback(IdleCallback *callback, uint timerFrequencyInMs=0)
Size< uint > getSize() const noexcept
Definition Window.hpp:99