|
Dusk Audio Framework
|
#include <Widget.hpp>
Classes | |
| struct | BaseEvent |
| struct | KeyboardEvent |
| struct | CharacterInputEvent |
| struct | MouseEvent |
| struct | MotionEvent |
| struct | ScrollEvent |
| struct | ResizeEvent |
| struct | FocusEvent |
| struct | PositionChangedEvent |
Public Member Functions | |
| virtual | ~Widget () |
| bool | isVisible () const noexcept |
| void | setVisible (bool visible) |
| void | show () |
| void | hide () |
| uint | getWidth () const noexcept |
| uint | getHeight () const noexcept |
| const Size< uint > | getSize () const noexcept |
| void | setWidth (uint width) noexcept |
| void | setHeight (uint height) noexcept |
| void | setSize (uint width, uint height) noexcept |
| void | setSize (const Size< uint > &size) noexcept |
| uint | getId () const noexcept |
| const char * | getName () const noexcept |
| void | setId (uint id) noexcept |
| void | setName (const char *name) noexcept |
| Application & | getApp () const noexcept |
| Window & | getWindow () const noexcept |
| const GraphicsContext & | getGraphicsContext () const noexcept |
| TopLevelWidget * | getTopLevelWidget () const noexcept |
| std::list< SubWidget * > | getChildren () const noexcept |
| virtual void | repaint () noexcept |
| virtual bool | wantsKeyboardFocus () |
| Application & | getParentApp () const noexcept |
| Window & | getParentWindow () const noexcept |
Protected Member Functions | |
| virtual void | onDisplay () |
| virtual bool | onKeyboard (const KeyboardEvent &) |
| virtual bool | onCharacterInput (const CharacterInputEvent &) |
| virtual bool | onMouse (const MouseEvent &) |
| virtual bool | onMotion (const MotionEvent &) |
| virtual bool | onScroll (const ScrollEvent &) |
| virtual void | onResize (const ResizeEvent &) |
| virtual void | onFocusChanged (const FocusEvent &) |
| virtual bool | onSpecial (const SpecialEvent &) |
Friends | |
| class | SubWidget |
| class | TopLevelWidget |
Base DGL Widget class.
This is the base Widget class, from which all widgets are built.
All widgets have a parent widget where they'll be drawn, this can be the top-level widget or a group widget. This parent is never changed during a widget's lifetime.
Widgets receive events in relative coordinates. (0, 0) means its top-left position.
The top-level widget will draw subwidgets in the order they are constructed. Early subwidgets are drawn first, at the bottom, then newer ones on top. Events are sent in the inverse order so that the top-most widgets get a chance to catch the event and stop its propagation.
All widget event callbacks do nothing by default and onDisplay MUST be reimplemented by subclasses.
|
virtual |
Destructor.
|
noexcept |
Check if this widget is visible within its parent window. Invisible widgets do not receive events except resize.
| void Widget::setVisible | ( | bool | visible | ) |
Set widget visible (or not) according to visible.
| void Widget::show | ( | ) |
Show widget. This is the same as calling setVisible(true).
| void Widget::hide | ( | ) |
Hide widget. This is the same as calling setVisible(false).
|
noexcept |
Get width.
|
noexcept |
Get height.
|
noexcept |
Get size.
|
noexcept |
Set width.
|
noexcept |
Set height.
|
noexcept |
Set size using width and height values.
|
noexcept |
Set size.
|
noexcept |
Get the Id associated with this widget. Returns 0 by default.
|
noexcept |
Get the name associated with this widget. This is completely optional, mostly useful for debugging purposes. Returns an empty string by default.
|
noexcept |
Set an Id to be associated with this widget.
|
noexcept |
Set a name to be associated with this widget. This is completely optional, only useful for debugging purposes.
|
noexcept |
Get the application associated with this widget's window. This is the same as calling getTopLevelWidget()->getApp().
|
noexcept |
Get the window associated with this widget. This is the same as calling getTopLevelWidget()->getWindow().
|
noexcept |
Get the graphics context associated with this widget's 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 top-level widget, as passed directly in the constructor or going up the chain of group widgets until it finds the top-level one.
|
noexcept |
Get list of children (a subwidgets) that belong to this widget.
|
virtualnoexcept |
Request repaint of this widget's area to the window this widget belongs to. On the raw Widget class this function does nothing.
Reimplemented in StandaloneWindow, SubWidget, and TopLevelWidget.
|
virtual |
Whether this widget wants the keyboard focus right now, typically because a text field in it is being edited.
This reports the widget's own state only. Window::anyWidgetWantsKeyboardFocus() asks every visible widget of a window, subwidgets included, so an override does not need to ask its children.
An embedded plugin editor on Windows uses the answer in the formats whose hosts have no keyboard focus API (CLAP and VST2): the editor takes the focus when clicked, keeps it while some widget wants it and hands it back to the host window once none does, so host shortcuts keep working after a click on a knob. Elsewhere the answer is informational.
It is asked on every idle of such an editor, so it should be cheap. The default implementation returns false.
|
inlineprotectedvirtual |
A function called to draw the widget contents.
Reimplemented in ImageBaseAboutWindow< ImageType >, ImageBaseAboutWindow< CairoImage >, ImageBaseAboutWindow< OpenGLImage >, ImageBaseButton< ImageType >, ImageBaseButton< CairoImage >, ImageBaseButton< OpenGLImage >, ImageBaseKnob< ImageType >, ImageBaseKnob< CairoImage >, ImageBaseKnob< OpenGLImage >, ImageBaseSlider< ImageType >, ImageBaseSlider< CairoImage >, ImageBaseSlider< OpenGLImage >, ImageBaseSwitch< ImageType >, ImageBaseSwitch< CairoImage >, and ImageBaseSwitch< OpenGLImage >.
|
protectedvirtual |
A function called when a key is pressed or released.
Reimplemented in ImageBaseAboutWindow< ImageType >, ImageBaseAboutWindow< CairoImage >, ImageBaseAboutWindow< OpenGLImage >, and TopLevelWidget.
|
protectedvirtual |
A function called when an UTF-8 character is received.
Reimplemented in TopLevelWidget.
|
protectedvirtual |
A function called when a mouse button is pressed or released.
Reimplemented in ImageBaseAboutWindow< ImageType >, ImageBaseAboutWindow< CairoImage >, ImageBaseAboutWindow< OpenGLImage >, ImageBaseButton< ImageType >, ImageBaseButton< CairoImage >, ImageBaseButton< OpenGLImage >, ImageBaseKnob< ImageType >, ImageBaseKnob< CairoImage >, ImageBaseKnob< OpenGLImage >, ImageBaseSlider< ImageType >, ImageBaseSlider< CairoImage >, ImageBaseSlider< OpenGLImage >, ImageBaseSwitch< ImageType >, ImageBaseSwitch< CairoImage >, ImageBaseSwitch< OpenGLImage >, and TopLevelWidget.
|
protectedvirtual |
A function called when the pointer moves.
Reimplemented in ImageBaseButton< ImageType >, ImageBaseButton< CairoImage >, ImageBaseButton< OpenGLImage >, ImageBaseKnob< ImageType >, ImageBaseKnob< CairoImage >, ImageBaseKnob< OpenGLImage >, ImageBaseSlider< ImageType >, ImageBaseSlider< CairoImage >, ImageBaseSlider< OpenGLImage >, and TopLevelWidget.
|
protectedvirtual |
A function called on scrolling (e.g. mouse wheel or track pad).
Reimplemented in ImageBaseKnob< ImageType >, ImageBaseKnob< CairoImage >, ImageBaseKnob< OpenGLImage >, and TopLevelWidget.
|
protectedvirtual |
A function called when the widget is resized.
|
protectedvirtual |
A function called when the window this widget belongs to gains or loses the keyboard focus. Unlike the input events this is delivered to every widget, visible or not, so that a widget holding input state can clear it.
|
inlineprotectedvirtual |
A function called when a special key is pressed or released. DEPRECATED use onKeyboard or onCharacterInput