![]() |
KTech 1.1.0
C++ 2D terminal game engine library
|
World structure that comprises Textures, behaves as a user interface element, and exists within UI.
More...
#include <widget.hpp>
Classes | |
| struct | ChildWidget |
| This class is undocumented because it's planned to change (see GitHub issue #106). | |
Public Member Functions | |
| Widget (Engine &engine, Point position=Point(0, 0), std::string name="") | |
Construct a Widget. | |
| Widget (Engine &engine, const ID< UI > &parentUI, Point position=Point(0, 0), std::string name="") | |
Construct a Widget and immediately enter a UI. | |
| virtual | ~Widget () |
Leave parent UI (if in one) and remove itself from Memory. | |
| auto | AddWidget (const ID< Widget > &widget) -> bool |
| Undocumented due to planned changes (see GitHub issue #106). | |
| auto | RemoveWidget (const ID< Widget > &widget) -> bool |
| Undocumented due to planned changes (see GitHub issue #106). | |
| auto | RemoveAllWidgets () -> bool |
| Undocumented due to planned changes (see GitHub issue #106). | |
| auto | EnterWidget (const ID< Widget > &widget) -> bool |
| Undocumented due to planned changes (see GitHub issue #106). | |
| auto | EnterUI (const ID< UI > &ui) -> bool |
Enter a UI. | |
| auto | LeaveWidget () -> bool |
| Undocumented due to planned changes (see GitHub issue #106). | |
| auto | LeaveUI () -> bool |
Leave the parent UI. | |
| void | Select () |
Enable input callbacks, and call Widget::OnSelect(). | |
| void | Deselect () |
Disable input callbacks, and call Widget::OnDisable(). | |
| void | Show () |
Let UI render this Widget, and call Widget::OnShow(). | |
| void | Hide () |
Don't let UI render this Widget, and call Widget::OnHide(). | |
Public Attributes | |
| Engine & | engine |
Parent Engine. | |
| const ID< Widget > | m_id {ID<Widget>::Unique()} |
Personal ID. | |
| std::string | m_name |
| String name. | |
| ID< UI > | m_parentUI |
The UI containing this Widget. | |
| ID< Widget > | m_parentWidget = nullID<Widget> |
| Undocumented because it's planned to change (see GitHub issue #106). | |
| std::vector< ChildWidget > | m_childWidgets |
| Undocumented because it's planned to change (see GitHub issue #106). | |
| bool | m_selected = false |
true: player input reaches the Widget. false: player input doesn't. | |
| bool | m_shown = true |
true: will be rendered by UI. false: will be ignored by UI. | |
| Point | m_pos |
| World position. | |
| std::vector< Texture > | m_textures = {} |
Comprising Textures. | |
| Input::CallbackGroup | m_callbackGroup |
Group of all input callbacks, which are enabled and disabled in correspondence to Widget::m_selected. | |
Protected Member Functions | |
| virtual auto | OnTick () -> bool |
| Virtual function called once each tick. | |
| virtual void | OnSelect () |
Virtual function called by Widget::Select(). | |
| virtual void | OnDeselect () |
Virtual function called by Widget::Deselect(). | |
| virtual void | OnShow () |
Virtual function called by Widget::Show(). | |
| virtual void | OnHide () |
Virtual function called by Widget::Hide(). | |
Friends | |
| class | KTech::Memory |
World structure that comprises Textures, behaves as a user interface element, and exists within UI.
This and Object are the most commonly inherited-from world structures. Widget differs from Object because it can only contain Textures, while Object can also have Colliders (which are useless in user interfaces). Widget has functionality intended for user interfaces, which is utilized by the optional widgets in the ktech/widgets/ directory.
|
virtual |
| void KTech::Widget::Deselect | ( | ) |
Disable input callbacks, and call Widget::OnDisable().
Additional behavior is undocumented due to planned changes (see GitHub issue #106).
Widget::OnDisable(). | void KTech::Widget::Hide | ( | ) |
Don't let UI render this Widget, and call Widget::OnHide().
Additional behavior is undocumented due to planned changes (see GitHub issue #106).
Widget::OnHide(). | auto KTech::Widget::LeaveUI | ( | ) | -> bool |
|
protectedvirtual |
Virtual function called by Widget::Deselect().
Usually, you would override this function in your Widget-inherited class to make the Textures (Widget::m_textures) seem unselected in contrast to the one selected Widget in your user interface.
Widget::Deselect() Button::OnDeselect() for example.
|
protectedvirtual |
Virtual function called by Widget::Hide().
Widget::Show() sets Widget::m_shown to false (which tells UI to not render this Widget), so, you aren't supposed to override this function to set each Widget::m_textures->Texture::m_active to false. There's no actual reason to override this function to create a complete Widget. However, you may still want to do something when this Widget is hidden (for example, update a state machine).
Widget::Show()
|
protectedvirtual |
Virtual function called by Widget::Select().
Usually, you would override this function in your Widget-inherited class to make the Textures (Widget::m_textures) seem selected in contrast to the other, unselected, Widgets in your user interface.
Widget::Select() Button::OnSelect() for example.
|
protectedvirtual |
Virtual function called by Widget::Show().
Widget::Show() sets Widget::m_shown to true (which lets UI render this Widget), so, you aren't supposed to override this function to set each Widget::m_textures->Texture::m_active to true. There's no actual reason to override this function to create a complete Widget. However, you may still want to do something when this Widget is shown (for example, a visual effect).
Widget::Show()
|
protectedvirtual |
Virtual function called once each tick.
Called by Memory::CallOnTicks().
bool value, which is explained in Output::ShouldRenderThisTick().| void KTech::Widget::Select | ( | ) |
Enable input callbacks, and call Widget::OnSelect().
Additional behavior is undocumented due to planned changes (see GitHub issue #106).
Widget::OnSelect(). | void KTech::Widget::Show | ( | ) |
Let UI render this Widget, and call Widget::OnShow().
Additional behavior is undocumented due to planned changes (see GitHub issue #106).
Widget::OnShow().