Base class for any graphical component. More...
Public Member Functions | |
Component (System *system) noexcept | |
virtual | ~Component () |
Layout * | getLayout () const |
Theme * | getTheme () const |
Font * | getFont () const |
nkMaths::Point | getPositionInParent () const |
nkMaths::Point | getPositionInScreen () const |
float | getWidth () const |
float | getHeight () const |
nkMaths::Rectangle | getAreaInParent () const |
nkMaths::Rectangle | getAreaInScreen () const |
virtual nkMaths::Point | getBorderExtents () const |
virtual float | getBorderExtent (BORDER_KIND border) const |
virtual float | getLayoutAllowedWidth () const |
virtual float | getLayoutAllowedHeight () const |
virtual float | getLayoutAllowedOffsetX () const |
virtual float | getLayoutAllowedOffsetY () const |
bool | isInitialized () const |
System * | getSystem () const |
Component * | getParentComponent () const |
COMPONENT_TYPE | getComponentType () const |
nkMemory::StringView | getComponentName () const |
bool | getVisibility () const |
virtual nkMemory::StringView | getLabel () const |
void * | getData () const |
bool | isEnabled () const |
bool | isForegroundWindow () const |
virtual unsigned int | getZDepth () const |
bool | getVisibleOnLoad () const |
std::function< bool(Component *)> | getCloseCallback () const |
std::function< void(Component *, bool)> | getVisibilityCallback () const |
std::function< void(Component *, const ClickEventData &)> | getClickCallback () const |
std::function< void(Component *, const WheelEventData &)> | getWheelCallback () const |
std::function< void(Component *, const KeyEventData &)> | getKeyCallback () const |
virtual Layout * | setLayout (LAYOUT_TYPE layoutType) |
virtual void | setTheme (Theme *theme) |
virtual void | setFont (Font *font) |
virtual void | setPositionInParent (nkMaths::Point position) |
virtual void | setPositionInScreen (nkMaths::Point position) |
virtual void | setSize (float width, float height) |
virtual void | setWidth (float width) |
virtual void | setHeight (float height) |
void | setMinSize (float width, float height) |
void | setMaxSize (float width, float height) |
void | setRatio (float widthOverHeight) |
virtual void | setAreaInParent (const nkMaths::Rectangle &area) |
virtual void | setAreaInScreen (const nkMaths::Rectangle &area) |
virtual void | setParentComponent (Component *parent, bool makeItVisible=true) |
virtual void | setLabel (nkMemory::StringView label) |
void | setComponentName (nkMemory::StringView name) |
virtual void | setVisibility (bool value) |
void | setData (void *data) |
void | setEnabled (bool value) |
void | setVisibleOnLoad (bool value) |
void | setCloseCallback (std::function< bool(Component *caller)> callback) |
void | setVisibilityCallback (std::function< void(Component *caller, bool visibility)> callback) |
void | setClickCallback (std::function< void(Component *caller, const ClickEventData &eventData)> callback) |
void | setWheelCallback (std::function< void(Component *caller, const WheelEventData &eventData)> callback) |
void | setKeyCallback (std::function< void(Component *caller, const KeyEventData &eventData)> callback) |
void | addChild (Component *child, bool makeItVisible=true) |
void | removeChild (Component *child) |
void | removeChild (unsigned int index) |
Component * | getChild (unsigned int index) |
unsigned int | getChildIndex (Component *child) |
void | unloadWithChildren () |
void | loadWithChildren () |
void | updateZDepth () |
void | bringToForeground () |
void | focusWindow () |
nkMaths::Point | getCoordRelativeFromAbsolute (nkMaths::Point absCoords) |
nkMaths::Point | getCoordAbsoluteFromRelative (nkMaths::Point relCoords) |
virtual void | load ()=0 |
virtual void | unload ()=0 |
void | reload () |
virtual void | updateWindow () |
nkImages::Image | paintToImage (bool withFrame=false) |
void | simulateEvent (const InputDescriptor &inputDescription) |
virtual void | onSized () |
virtual void | exportClassToTree (nkExport::Node *rootNode) override |
virtual void | exportIntrospection (nkExport::Node *rootNode) |
virtual void | importClassFromTree (nkExport::Node *rootNode) override |
Public Member Functions inherited from nkExport::Exportable | |
Exportable () noexcept | |
virtual | ~Exportable () |
Base class for any graphical component.
|
noexcept |
Constructor.
system | The parent system in which the component will live. |
|
virtual |
Destructor.
Layout* nkWinUi::Component::getLayout | ( | ) | const |
Theme* nkWinUi::Component::getTheme | ( | ) | const |
Font* nkWinUi::Component::getFont | ( | ) | const |
nkMaths::Point nkWinUi::Component::getPositionInParent | ( | ) | const |
nkMaths::Point nkWinUi::Component::getPositionInScreen | ( | ) | const |
float nkWinUi::Component::getWidth | ( | ) | const |
float nkWinUi::Component::getHeight | ( | ) | const |
nkMaths::Rectangle nkWinUi::Component::getAreaInParent | ( | ) | const |
nkMaths::Rectangle nkWinUi::Component::getAreaInScreen | ( | ) | const |
|
virtual |
|
virtual |
Provides with a designated border's pixel size.
border | The border to retrieve the pixel size from. |
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
|
virtual |
Reimplemented in nkWinUi::GroupBox.
bool nkWinUi::Component::isInitialized | ( | ) | const |
System* nkWinUi::Component::getSystem | ( | ) | const |
Component* nkWinUi::Component::getParentComponent | ( | ) | const |
COMPONENT_TYPE nkWinUi::Component::getComponentType | ( | ) | const |
nkMemory::StringView nkWinUi::Component::getComponentName | ( | ) | const |
bool nkWinUi::Component::getVisibility | ( | ) | const |
|
virtual |
void* nkWinUi::Component::getData | ( | ) | const |
bool nkWinUi::Component::isEnabled | ( | ) | const |
bool nkWinUi::Component::isForegroundWindow | ( | ) | const |
|
virtual |
bool nkWinUi::Component::getVisibleOnLoad | ( | ) | const |
std::function<bool (Component*)> nkWinUi::Component::getCloseCallback | ( | ) | const |
std::function<void (Component*, bool)> nkWinUi::Component::getVisibilityCallback | ( | ) | const |
std::function<void (Component*, const ClickEventData&)> nkWinUi::Component::getClickCallback | ( | ) | const |
std::function<void (Component*, const WheelEventData&)> nkWinUi::Component::getWheelCallback | ( | ) | const |
std::function<void (Component*, const KeyEventData&)> nkWinUi::Component::getKeyCallback | ( | ) | const |
|
virtual |
Sets the component's layout type by instantiating a new layout, and returns it for populating.
layoutType | The type of layout the component should instantiate. |
Reimplemented in nkWinUi::TabWindow.
|
virtual |
Sets an overridden theme to use for the component. The global theme to use through the application can be set using ThemeManager::setActiveTheme. However, if a sub-set of components needs to use a specific theme, it can be overridden through this setter.
theme | The theme to use rather than the active one, or nullptr to revert back to the default one. |
|
virtual |
Sets and overridden font to use for text rendering.
font | The font to use, or nullptr to revert back to the default font. |
|
virtual |
Change the component's position, relative to the parent.
position | The position to assign, in pixels. |
|
virtual |
Change the component's position, relative to screen (absolute).
position | The position to assign, in pixels. |
|
virtual |
Change the component's size.
width | The width to assign, in pixels. |
height | The height to assign, in pixels. |
|
virtual |
Change the component's width.
width | The width to assign, in pixels. |
|
virtual |
Change the component's height.
height | The height to assign, in pixels. |
void nkWinUi::Component::setMinSize | ( | float | width, |
float | height | ||
) |
Assign a minimum size the component should have.
width | The minimum width possible, in pixels. -1 symbolizes "no limit". |
height | The minimum height possible, in pixels. -1 symbolizes "no limit". |
void nkWinUi::Component::setMaxSize | ( | float | width, |
float | height | ||
) |
Assign a maximum size the component should have.
width | The maximum width possible, in pixels. -1 symbolizes "no limit". |
height | The maximum height possible, in pixels. -1 symbolizes "no limit". |
void nkWinUi::Component::setRatio | ( | float | widthOverHeight | ) |
Assign a ratio the component has to respect.
widthOverHeight | The ratio, as width / height. |
|
virtual |
Assign an area the component should cover, relative to its parent.
area | The area, in pixels, to cover. |
|
virtual |
Assign an area the component should cover, relative to the screen.
area | The area, in pixels, to cover. |
|
virtual |
Changes the parent component.
parent | The parent component to assign. |
makeItVisible | If the component should be made visible within the parent, if the parent is visible. |
|
virtual |
Changes the label of the component. This can be the title of a nkWinUi::Window, the txt of a nkWinUi::EditBox...
label | The text to assign. |
void nkWinUi::Component::setComponentName | ( | nkMemory::StringView | name | ) |
Sets the component name.
name | The name to assign. |
|
virtual |
Sets whether this component should be visible.
value | If the component should be visible on screen (true) or not (false). |
void nkWinUi::Component::setData | ( | void * | data | ) |
Attach user data to the component.
data | The user data to attach to the component. |
void nkWinUi::Component::setEnabled | ( | bool | value | ) |
Sets whether the component is enabled or not.
value | If it is enabled (true) or not (false). |
void nkWinUi::Component::setVisibleOnLoad | ( | bool | value | ) |
Sets whether a component should be visible after its load operation, or not. This can be used to load components but keep them hidden until further notice.
value | If the component should be visible (true) or not (false). |
void nkWinUi::Component::setCloseCallback | ( | std::function< bool(Component *caller)> | callback | ) |
Sets the callback whenever a close request happens. Such a request can happen when unload is called, or using the component's UI itself if offered.
callback | The callback to use. The argument is the calling component. The return boolean should be true to allow unloading, or false to prevent it. |
void nkWinUi::Component::setVisibilityCallback | ( | std::function< void(Component *caller, bool visibility)> | callback | ) |
Sets the callback for a visibility change event.
callback | The callback to use. The first argument is the calling component, and the second the new visibility status. |
void nkWinUi::Component::setClickCallback | ( | std::function< void(Component *caller, const ClickEventData &eventData)> | callback | ) |
Sets the callback for a mouse click event.
callback | The callback to use. The first argument is the calling component, and the second the event information. |
void nkWinUi::Component::setWheelCallback | ( | std::function< void(Component *caller, const WheelEventData &eventData)> | callback | ) |
Sets the callback for a mouse wheel event while the component is focused.
callback | The callback to use. The first argument is the calling component, and the second the event information. |
void nkWinUi::Component::setKeyCallback | ( | std::function< void(Component *caller, const KeyEventData &eventData)> | callback | ) |
Sets the callback for a key event while the component is focused.
callback | The callback to use. The first argument is the calling component, and the second the event information. |
void nkWinUi::Component::addChild | ( | Component * | child, |
bool | makeItVisible = true |
||
) |
Add a child component.
child | The component that should become a child. |
makeItVisible | If the child component has to become visible if the parent is also visible. |
void nkWinUi::Component::removeChild | ( | Component * | child | ) |
Removes a child.
child | The child component that should not be a child anymore. |
void nkWinUi::Component::removeChild | ( | unsigned int | index | ) |
Removes a child.
index | The index of the child component, in the children list, that should be removed. |
Component* nkWinUi::Component::getChild | ( | unsigned int | index | ) |
Returns a child component.
index | The child component at given index, in the children list. |
unsigned int nkWinUi::Component::getChildIndex | ( | Component * | child | ) |
Returns the index in the list of one child component.
child | The child component chich index is needed. |
void nkWinUi::Component::unloadWithChildren | ( | ) |
Unloads the component along with its children.
void nkWinUi::Component::loadWithChildren | ( | ) |
Loads the component along with its children.
void nkWinUi::Component::updateZDepth | ( | ) |
Updates the depth of the component. Computed from the component's hierarchy.
void nkWinUi::Component::bringToForeground | ( | ) |
Brings the component to the foreground.
void nkWinUi::Component::focusWindow | ( | ) |
Puts the component into focus.
nkMaths::Point nkWinUi::Component::getCoordRelativeFromAbsolute | ( | nkMaths::Point | absCoords | ) |
Converts given coordinates from absolute in screen to relative to the component.
absCoords | The absolute coordinates to convert. |
nkMaths::Point nkWinUi::Component::getCoordAbsoluteFromRelative | ( | nkMaths::Point | relCoords | ) |
Converts given coordinates from relative to the component to absolute in screen.
relCoords | The relative coordinates to convert. |
|
pure virtual |
Loads the component. This will trigger the initialization of the component in the windowing system.
|
pure virtual |
Unloads the component. This will make the component release resources from the windowing system.
void nkWinUi::Component::reload | ( | ) |
|
virtual |
Update the window for changes that could have occurred.
nkImages::Image nkWinUi::Component::paintToImage | ( | bool | withFrame = false | ) |
withFrame | Whether the non-client area, aka frame, should also be included in the image. |
void nkWinUi::Component::simulateEvent | ( | const InputDescriptor & | inputDescription | ) |
Simulates an event within the component, fitting the description given. Using this, it is possible to automatically hover components, or automatically generate keyboard events. Note that simulating an event will not impact the system's input system (cursor or focus).
inputDescription | The description of the input to simulate. |
|
virtual |
Component's callback for resize events.
|
overridevirtual |
A basic exporting capability.
rootNode | The root of the tree to export into. |
Implements nkExport::Exportable.
Reimplemented in nkWinUi::ContextMenu.
|
virtual |
A basic exporting capability, for components inheriting. Components inheriting this class should rather reimplement this function to export their internal data.
rootNode | The root of the tree to export into. |
Reimplemented in nkWinUi::TreeView, nkWinUi::ListBox, nkWinUi::TabWindow, nkWinUi::ComboBox, nkWinUi::Slider, nkWinUi::FileExplorer, nkWinUi::Window, nkWinUi::Static, nkWinUi::ImageDisplay, nkWinUi::EditBox, and nkWinUi::LogWin.
|
overridevirtual |
A basic importing capability.
rootNode | The root of the tree to import from. |
Implements nkExport::Exportable.
Reimplemented in nkWinUi::TreeView, nkWinUi::ListBox, nkWinUi::TabWindow, nkWinUi::ComboBox, nkWinUi::ContextMenu, nkWinUi::Slider, nkWinUi::FileExplorer, nkWinUi::Window, nkWinUi::Static, nkWinUi::ImageDisplay, nkWinUi::EditBox, and nkWinUi::LogWin.