Add initial bits for Qt6 support
[carla.git] / source / modules / dgl / StandaloneWindow.hpp
blob673a85e6657733971be696453094488e77a6d2dc
1 /*
2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
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.
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.
17 #ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED
18 #define DGL_STANDALONE_WINDOW_HPP_INCLUDED
20 #include "TopLevelWidget.hpp"
21 #include "Window.hpp"
23 START_NAMESPACE_DGL
25 // -----------------------------------------------------------------------
27 class StandaloneWindow : public Window,
28 public TopLevelWidget
30 public:
31 /**
32 Constructor without parent.
34 StandaloneWindow(Application& app)
35 : Window(app),
36 TopLevelWidget((Window&)*this),
37 sgc((Window&)*this) {}
39 /**
40 Constructor with a transient parent window, typically used to run as modal.
42 StandaloneWindow(Application& app, Window& transientParentWindow)
43 : Window(app, transientParentWindow),
44 TopLevelWidget((Window&)*this),
45 sgc((Window&)*this, transientParentWindow) {}
47 /**
48 Clear current graphics context.
49 Must be called at the end of your StandaloneWindow constructor.
51 void done()
53 sgc.done();
56 /**
57 Overloaded functions to ensure they apply to the Window class.
59 bool isVisible() const noexcept { return Window::isVisible(); }
60 void setVisible(bool yesNo) { Window::setVisible(yesNo); }
61 void hide() { Window::hide(); }
62 void show() { Window::show(); }
63 uint getWidth() const noexcept { return Window::getWidth(); }
64 uint getHeight() const noexcept { return Window::getHeight(); }
65 const Size<uint> getSize() const noexcept { return Window::getSize(); }
66 void repaint() noexcept { Window::repaint(); }
67 void setWidth(uint width) { Window::setWidth(width); }
68 void setHeight(uint height) { Window::setHeight(height); }
69 void setSize(uint width, uint height) { Window::setSize(width, height); }
70 void setSize(const Size<uint>& size) { Window::setSize(size); }
71 bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0)
72 { return Window::addIdleCallback(callback, timerFrequencyInMs); }
73 bool removeIdleCallback(IdleCallback* callback) { return Window::removeIdleCallback(callback); }
74 Application& getApp() const noexcept { return Window::getApp(); }
75 const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); }
76 double getScaleFactor() const noexcept { return Window::getScaleFactor(); }
77 void setGeometryConstraints(uint minimumWidth, uint minimumHeight,
78 bool keepAspectRatio = false, bool automaticallyScale = false)
79 { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); }
81 private:
82 ScopedGraphicsContext sgc;
84 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow)
87 // -----------------------------------------------------------------------
89 END_NAMESPACE_DGL
91 #endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED