DISTRHO Plugin Framework
StandaloneWindow.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2021 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  */
35  : Window(app),
36  TopLevelWidget((Window&)*this) {}
37 
38  /**
39  Constructor with parent window, typically used to run as modal.
40  */
41  StandaloneWindow(Application& app, Window& parentWindow)
42  : Window(app, parentWindow),
43  TopLevelWidget((Window&)*this) {}
44 
45  /**
46  Overloaded functions to ensure they apply to the Window class.
47  */
48  bool isVisible() const noexcept { return Window::isVisible(); }
49  void setVisible(bool yesNo) { Window::setVisible(yesNo); }
50  void hide() { Window::hide(); }
51  void show() { Window::show(); }
52  uint getWidth() const noexcept { return Window::getWidth(); }
53  uint getHeight() const noexcept { return Window::getHeight(); }
54  const Size<uint> getSize() const noexcept { return Window::getSize(); }
55  void repaint() noexcept { Window::repaint(); }
56  void setWidth(uint width) { Window::setWidth(width); }
57  void setHeight(uint height) { Window::setHeight(height); }
58  void setSize(uint width, uint height) { Window::setSize(width, height); }
59  void setSize(const Size<uint>& size) { Window::setSize(size); }
60  bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0)
61  { return Window::addIdleCallback(callback, timerFrequencyInMs); }
62  bool removeIdleCallback(IdleCallback* callback) { return Window::removeIdleCallback(callback); }
63  const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); }
64  double getScaleFactor() const noexcept { return Window::getScaleFactor(); }
65  void setGeometryConstraints(uint minimumWidth, uint minimumHeight,
66  bool keepAspectRatio = false, bool automaticallyScale = false)
67  { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); }
68 
69  DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow)
70 };
71 
72 // -----------------------------------------------------------------------
73 
74 END_NAMESPACE_DGL
75 
76 #endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED
Window::setHeight
void setHeight(uint height)
GraphicsContext
Definition: Base.hpp:154
Window::show
void show()
Window::isVisible
bool isVisible() const noexcept
Window::setGeometryConstraints
void setGeometryConstraints(uint minimumWidth, uint minimumHeight, bool keepAspectRatio=false, bool automaticallyScale=false)
Window
Definition: Window.hpp:50
Window::getScaleFactor
double getScaleFactor() const noexcept
Size< uint >
Application
Definition: Application.hpp:34
StandaloneWindow::isVisible
bool isVisible() const noexcept
Definition: StandaloneWindow.hpp:48
Window::repaint
void repaint() noexcept
Window::getWidth
uint getWidth() const noexcept
Window::getGraphicsContext
const GraphicsContext & getGraphicsContext() const noexcept
Window::addIdleCallback
bool addIdleCallback(IdleCallback *callback, uint timerFrequencyInMs=0)
StandaloneWindow::StandaloneWindow
StandaloneWindow(Application &app)
Definition: StandaloneWindow.hpp:34
StandaloneWindow::repaint
void repaint() noexcept
Definition: StandaloneWindow.hpp:55
Window::setVisible
void setVisible(bool visible)
Window::setWidth
void setWidth(uint width)
Window::setSize
void setSize(uint width, uint height)
Window::removeIdleCallback
bool removeIdleCallback(IdleCallback *callback)
StandaloneWindow
Definition: StandaloneWindow.hpp:27
IdleCallback
Definition: Base.hpp:159
StandaloneWindow::StandaloneWindow
StandaloneWindow(Application &app, Window &parentWindow)
Definition: StandaloneWindow.hpp:41
Window::getSize
Size< uint > getSize() const noexcept
Window::getHeight
uint getHeight() const noexcept
TopLevelWidget
Definition: TopLevelWidget.hpp:46
Window::hide
void hide()