DISTRHO Plugin Framework
|
#include <Window.hpp>
Classes | |
struct | ScopedGraphicsContext |
Public Member Functions | |
Window (Application &app) | |
Window (Application &app, Window &transientParentWindow) | |
Window (Application &app, uintptr_t parentWindowHandle, double scaleFactor, bool resizable) | |
Window (Application &app, uintptr_t parentWindowHandle, uint width, uint height, double scaleFactor, bool resizable) | |
virtual | ~Window () |
bool | isEmbed () const noexcept |
bool | isVisible () const noexcept |
void | setVisible (bool visible) |
void | show () |
void | hide () |
void | close () |
bool | isResizable () const noexcept |
void | setResizable (bool resizable) |
int | getOffsetX () const noexcept |
int | getOffsetY () const noexcept |
Point< int > | getOffset () const noexcept |
void | setOffsetX (int x) |
void | setOffsetY (int y) |
void | setOffset (int x, int y) |
void | setOffset (const Point< int > &offset) |
uint | getWidth () const noexcept |
uint | getHeight () const noexcept |
Size< uint > | getSize () const noexcept |
void | setWidth (uint width) |
void | setHeight (uint height) |
void | setSize (uint width, uint height) |
void | setSize (const Size< uint > &size) |
const char * | getTitle () const noexcept |
void | setTitle (const char *title) |
bool | isIgnoringKeyRepeat () const noexcept |
void | setIgnoringKeyRepeat (bool ignore) noexcept |
const void * | getClipboard (size_t &dataSize) |
bool | setClipboard (const char *mimeType, const void *data, size_t dataSize) |
bool | setCursor (MouseCursor cursor) |
bool | addIdleCallback (IdleCallback *callback, uint timerFrequencyInMs=0) |
bool | removeIdleCallback (IdleCallback *callback) |
Application & | getApp () const noexcept |
const GraphicsContext & | getGraphicsContext () const noexcept |
uintptr_t | getNativeWindowHandle () const noexcept |
double | getScaleFactor () const noexcept |
void | focus () |
bool | openFileBrowser (const DGL_NAMESPACE::FileBrowserOptions &options=FileBrowserOptions()) |
void | repaint () noexcept |
void | repaint (const Rectangle< uint > &rect) noexcept |
void | renderToPicture (const char *filename) |
void | runAsModal (bool blockWait=false) |
Size< uint > | getGeometryConstraints (bool &keepAspectRatio) |
void | setGeometryConstraints (uint minimumWidth, uint minimumHeight, bool keepAspectRatio=false, bool automaticallyScale=false, bool resizeNowIfAutoScaling=true) |
void | setTransientParent (uintptr_t transientParentWindowHandle) |
bool | getIgnoringKeyRepeat () const noexcept |
double | getScaling () const noexcept |
void | exec (bool blockWait=false) |
Protected Member Functions | |
std::vector< ClipboardDataOffer > | getClipboardDataOfferTypes () |
virtual uint32_t | onClipboardDataOffer () |
virtual bool | onClose () |
virtual void | onFocus (bool focus, CrossingMode mode) |
virtual void | onReshape (uint width, uint height) |
virtual void | onScaleFactorChanged (double scaleFactor) |
virtual void | onFileSelected (const char *filename) |
virtual void | fileBrowserSelected (const char *filename) |
Friends | |
class | Application |
class | TopLevelWidget |
class | DISTRHO_NAMESPACE::PluginWindow |
DGL Window class.
This is the where all OS-related events initially happen, before being propagated to any widgets.
A Window MUST have an Application instance tied to it. It is not possible to swap Application instances from within the lifetime of a Window. But it is possible to completely change the Widgets that a Window contains during its lifetime.
Typically the event handling functions as following: Application -> Window -> Top-Level-Widget -> SubWidgets
Please note that, unlike many other graphical toolkits out there, DGL makes a clear distinction between a Window and a Widget. You cannot directly draw in a Window, you need to create a Widget for that.
Also, a Window MUST have a single top-level Widget. The Window will take care of global screen positioning and resizing, everything else is sent for widgets to handle.
...
|
explicit |
Constructor for a regular, standalone window.
|
explicit |
Constructor for a modal window, by having another window as its transient parent. The Application instance must be the same between the 2 windows.
|
explicit |
Constructor for an embed Window without known size, typically used in modules or plugins that run inside another host.
|
explicit |
Constructor for an embed Window with known size, typically used in modules or plugins that run inside another host.
|
virtual |
Destructor.
|
noexcept |
|
noexcept |
Check if this window is visible / mapped. Invisible windows do not receive events except resize.
void Window::setVisible | ( | bool | visible | ) |
Set window visible (or not) according to visible. Only valid for standalones, embed windows are always visible.
void Window::show | ( | ) |
Show window. This is the same as calling setVisible(true).
void Window::hide | ( | ) |
Hide window. This is the same as calling setVisible(false).
void Window::close | ( | ) |
Hide window and notify application of a window close event. The application event-loop will stop when all windows have been closed. For standalone windows only, has no effect if window is embed.
|
noexcept |
Check if this window is resizable (by the user or window manager).
void Window::setResizable | ( | bool | resizable | ) |
Set window as resizable (by the user or window manager). It is always possible to resize a window programmatically, which is not the same as the user being allowed to it.
|
noexcept |
Get X offset, typically 0.
|
noexcept |
Get Y offset, typically 0.
|
noexcept |
Get offset.
void Window::setOffsetX | ( | int | x | ) |
Set X offset.
void Window::setOffsetY | ( | int | y | ) |
Set Y offset.
void Window::setOffset | ( | int | x, |
int | y | ||
) |
Set offset using x and y values.
void Window::setOffset | ( | const Point< int > & | offset | ) |
Set offset.
|
noexcept |
Get width.
|
noexcept |
Get height.
|
noexcept |
Get size.
void Window::setWidth | ( | uint | width | ) |
Set width.
void Window::setHeight | ( | uint | height | ) |
Set height.
void Window::setSize | ( | uint | width, |
uint | height | ||
) |
Set size using width and height values.
void Window::setSize | ( | const Size< uint > & | size | ) |
Set size.
|
noexcept |
Get the title of the window previously set with setTitle().
void Window::setTitle | ( | const char * | title | ) |
Set the title of the window, typically displayed in the title bar or in window switchers.
This only makes sense for non-embedded windows.
|
noexcept |
Check if key repeat events are ignored.
|
noexcept |
Set to ignore (or not) key repeat events according to ignore.
const void* Window::getClipboard | ( | size_t & | dataSize | ) |
Get the clipboard contents.
This gets the system clipboard contents, which may have been set with setClipboard() or copied from another application.
Returns the clipboard contents, or null.
bool Window::setClipboard | ( | const char * | mimeType, |
const void * | data, | ||
size_t | dataSize | ||
) |
Set the clipboard contents.
This sets the system clipboard contents, which can be retrieved with getClipboard() or pasted into other applications.
If using a string, the use of a null terminator is required (and must be part of dataSize).
The MIME type of the data "text/plain" is assumed if null is used.
bool Window::setCursor | ( | MouseCursor | cursor | ) |
Set the mouse cursor.
This changes the system cursor that is displayed when the pointer is inside the window. May fail if setting the cursor is not supported on this system, for example if compiled on X11 without Xcursor support.
bool Window::addIdleCallback | ( | IdleCallback * | callback, |
uint | timerFrequencyInMs = 0 |
||
) |
Add a callback function to be triggered on every idle cycle or on a specific timer frequency. You can add more than one, and remove them at anytime with removeIdleCallback(). This can be used to perform some action at a regular interval with relatively low frequency.
If providing a timer frequency, there are a few things to note:
bool Window::removeIdleCallback | ( | IdleCallback * | callback | ) |
Remove an idle callback previously added via addIdleCallback().
|
noexcept |
Get the application associated with this window.
|
noexcept |
Get the graphics context associated with this window. GraphicsContext is an empty struct and needs to be casted into a different type in order to be usable, for example GraphicsContext.
|
noexcept |
Get the "native" window handle. Returned value depends on the platform:
BView
.NSView*
.HWND
.Window
.
|
noexcept |
Get the scale factor requested for this window. This is purely informational, and up to developers to choose what to do with it.
If you do not want to deal with this yourself, consider using setGeometryConstraints() where you can specify to automatically scale the window contents.
void Window::focus | ( | ) |
Grab the keyboard input focus.
bool Window::openFileBrowser | ( | const DGL_NAMESPACE::FileBrowserOptions & | options = FileBrowserOptions() | ) |
Open a file browser dialog with this window as transient parent. A few options can be specified to setup the dialog.
If a path is selected, onFileSelected() will be called with the user chosen path. If the user cancels or does not pick a file, onFileSelected() will be called with nullptr as filename.
This function does not block the event loop.
|
noexcept |
Request repaint of this window, for the entire area.
|
noexcept |
Request partial repaint of this window, with bounds according to rect.
void Window::renderToPicture | ( | const char * | filename | ) |
Render this window's content into a picture file, specified by filename. Window must be visible and on screen. Written picture format is PPM.
void Window::runAsModal | ( | bool | blockWait = false | ) |
Run this window as a modal, blocking input events from the parent. Only valid for windows that have been created with another window as parent (as passed in the constructor). Can optionally block-wait, but such option is only available if the application is running as standalone.
Size<uint> Window::getGeometryConstraints | ( | bool & | keepAspectRatio | ) |
Get the geometry constraints set for the Window.
void Window::setGeometryConstraints | ( | uint | minimumWidth, |
uint | minimumHeight, | ||
bool | keepAspectRatio = false , |
||
bool | automaticallyScale = false , |
||
bool | resizeNowIfAutoScaling = true |
||
) |
Set geometry constraints for the Window when resized by the user, and optionally scale contents automatically.
void Window::setTransientParent | ( | uintptr_t | transientParentWindowHandle | ) |
Set the transient parent of the window.
Set this for transient children like dialogs, to have them properly associated with their parent window. This should be not be called for embed windows, or after making the window visible.
|
inlinenoexcept |
DEPRECATED Use isIgnoringKeyRepeat().
|
inlinenoexcept |
DEPRECATED Use getScaleFactor().
|
inline |
DEPRECATED Use runAsModal(bool).
|
protected |
Get the types available for the data in a clipboard. Must only be called within the context of onClipboardDataOffer.
|
protectedvirtual |
A function called when clipboard has data present, possibly with several datatypes. While handling this event, the data types can be investigated with getClipboardDataOfferTypes() to decide whether to accept the offer.
Reimplement and return a non-zero id to accept the clipboard data offer for a particular type. Applications must ignore any type they do not recognize.
The default implementation accepts the "text/plain" mimetype.
|
protectedvirtual |
A function called when the window is attempted to be closed. Returning true closes the window, which is the default behaviour. Override this method and return false to prevent the window from being closed by the user.
This method is not used for embed windows, and not even made available in DISTRHO_NAMESPACE::UI. For embed windows, closing is handled by the host/parent process and we have no control over it. As such, a close action on embed windows will always succeed and cannot be cancelled.
NOTE: This currently does not work under macOS.
|
protectedvirtual |
A function called when the window gains or loses the keyboard focus. The default implementation does nothing.
|
protectedvirtual |
A function called when the window is resized. If there is a top-level widget associated with this window, its size will be set right after this function. The default implementation sets up drawing context where necessary.
|
protectedvirtual |
A function called when scale factor requested for this window changes. The default implementation does nothing. WARNING function needs a proper name
|
protectedvirtual |
A function called when a path is selected by the user, as triggered by openFileBrowser(). This action happens after the user confirms the action, so the file browser dialog will be closed at this point. The default implementation does nothing.
|
inlineprotectedvirtual |
DEPRECATED Use onFileSelected().