The base class for all dev widgets.
Dev widgets represent a developer utility. They can be as simple as a function call, or as complex as custom views and interactions. Each dev widget, when added to a dev panel, has a dev panel item. This item tells the user what the widget does, what state it is in, and may provide configuration options.
Dev widgets can be in one of four states:
The widget state has to be set by the widget itself, and must be updated as needed. The CYIDevWidget::State::On and CYIDevWidget::State::Off state imply that the widget makes use of an on/off indicator in the dev panel. This is handled automatically by the dev panel. Widgets that do not wish to make use of the on/off indicator should set their state to CYIDevWidget::StateLESS. When the widget state is set to CYIDevWidget::State::Disabled, it cannot be selected in the dev panel.
Hooks into the app are available through the OnDraw(), OnUpdate(), OnHandleKeyInputs() and OnHandleActionInputs() functions.
On touch devices, arrow and enter keys can be simulated by the dev widget. This can be enabled using the SetUseSimulatedKeys() function.
Configuration options can be provided for dev widgets. If the SetUsesConfigurationItems() function is called with true, the dev panel will automatically display and manage a list of configuraiton items for the widget. These configuration items are configured through the GetConfigurationButtonTitles() function, and the widgets are notified when these configuration items are activated through the OnConfigurationItemClicked() function. Dev widgets may also provide their own configuration views by overriding the OnConfigureButtonClicked() button.
debug-tools
optional module. #include <debug/YiDevWidget.h>
Public Types | |
enum | State { State::Off = 0, State::On, State::Stateless, State::Disabled } |
Public Member Functions | |
CYIDevWidget (const CYIString &title, const CYIString &subtitle="") | |
virtual | ~CYIDevWidget () |
bool | IsUsingIndicator () const |
bool | IsUsingSimulatedKeys () const |
bool | IsCapturingAllEvents () const |
bool | IsUsingConfigurationItems () const |
State | GetState () const |
virtual const CYIString & | GetTitle () const |
virtual const CYIString & | GetSubtitle () const |
void | SetParentPanel (CYIDevPanel *pPanel, size_t indexInPanel) |
size_t | GetIndexInPanel () const |
void | UpdateWidgetState () |
virtual void | OnPanelItemClicked ()=0 |
virtual void | RefreshState () |
virtual void | OnConfigureButtonClicked () |
virtual void | OnConfigurationItemClicked (size_t buttonID) |
virtual void | OnConfigurationSubpanelClosed () |
virtual void | OnDraw () |
virtual bool | OnUpdate (bool *pSkipUpdate=nullptr) |
virtual bool | OnHandleKeyInputs (const CYIKeyEvent &keyEvent) |
virtual bool | OnHandleActionInputs (const CYIActionEvent &actionEvent) |
virtual bool | OnPreFilterEvent (const std::shared_ptr< CYIEventDispatcher > &pDispatcher, CYIEvent *pEvent, CYIEventHandler *pDestination) |
void | SimulatePanelItemClicked () |
bool | SimulateKeyPress (const CYIKeyEvent &keyEvent) |
void | SimulatedKeyPressesEnded () |
![]() | |
CYISignalHandler () | |
CYISignalHandler (const CYISignalHandler &signalHandler) | |
virtual | ~CYISignalHandler () |
CYISignalHandler & | operator= (const CYISignalHandler &signalHandler) |
void | MoveToThread (CYIThread *pThread) |
This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More... | |
CYIThreadHandle | GetThreadAffinity () const |
void | SetThreadAffinity (const CYIThreadHandle &threadAffinity) |
virtual bool | IsConnected () const |
virtual bool | IsConnected (const CYISignalBase &signal) const |
void | Disconnect (CYISignalBase &signal) |
void | DisconnectFromAllSignals () |
![]() | |
Listener () | |
virtual | ~Listener () |
virtual void | OnThreadStarted (CYIThread *) |
virtual void | OnThreadTerminated (CYIThread *) |
virtual void | OnThreadFinished (CYIThread *) |
Protected Member Functions | |
void | SetUseSimulatedKeys (bool useSimulatedKeys) |
void | SetCaptureAllEvents (bool captureAllEvents) |
void | SetUsesConfigurationItems (bool usesConfigurationItems) |
virtual std::vector< std::pair< CYIString, CYIString > > | GetConfigurationButtonTitles () |
CYISceneNode * | GetLogicalRoot () const |
Protected Attributes | |
CYIDevPanel * | m_pParentPanel |
size_t | m_indexInPanel |
State | m_state |
CYIString | m_title |
CYIString | m_subtitle |
|
strong |
|
virtual |
|
protectedvirtual |
Returns a vector of configuration items. These items will be used to populate the configuration subpanel when that subpanel is open. The pairs in the vector must contain the title and subtitle of the configuration items respectively.
size_t CYIDevWidget::GetIndexInPanel | ( | ) | const |
Returns the index of the widget within the dev panel.
|
protected |
Finds and returns the logical root of the scene tree.
State CYIDevWidget::GetState | ( | ) | const |
Returns the current state of the widget.
|
virtual |
Returns the subtitle for this widget. The subtitle is displayed in the dev panel's entry for the widget. The subtitle is displayed under the title, but in a smaller font. By default this returns the value of the m_subtitle variable, but sub-classes can override this function to return something different.
|
virtual |
Returns the title for this widget. The title is displayed in the dev panel's entry for the widget. By default this returns the value of the m_title variable, but sub-classes can override this function to return something different.
bool CYIDevWidget::IsCapturingAllEvents | ( | ) | const |
Returns true if this widget is capturing all events when active.
bool CYIDevWidget::IsUsingConfigurationItems | ( | ) | const |
Returns true if this widget has configuration items.
bool CYIDevWidget::IsUsingIndicator | ( | ) | const |
Returns true if this widget uses an on/off indicator in the dev panel.
bool CYIDevWidget::IsUsingSimulatedKeys | ( | ) | const |
Returns true if this widget makes use of simulated keys (for touch devices).
|
virtual |
Called when the user selects a configuration item. The buttonID parameter denotes the index of the configuration item that was selected, starting at 0.
|
virtual |
Called when the configuration subpanel is closing.
|
virtual |
Called when the user clicks the 'configure' button for this widget. Normally this does not need to be overridden, and the GetConfigurationButtonTitles() function is overridden instead to provide configuration options. However, some widgets may want to override this function to display a custom configuration view.
|
inlinevirtual |
Called during the app's Draw cycle. This is called after the scene tree has been rendered (and after the dev panel itself has been rendered). Widgets that make use of CYIGeometryBatch will typically want to implement this function.
Reimplemented in CYIDevWidgetWithText.
|
virtual |
Called when an action input occurs. If true is returned, the input will not be propagated to the app.
Reimplemented in CYIDevWidgetWithText.
|
virtual |
Called when a key event occurs. If true is returned, the event will not be propagated to the app.
Reimplemented in CYIDevWidgetWithText.
|
pure virtual |
Called when the widget's item in the dev panel is clicked. This is where a widgets should implement its behaviour. Widgets often update their state when this function is called.
Implemented in CYIDevWidgetWithText, CYISignalWidget, and CYIDevWidgetWithView.
|
virtual |
Called before an event is processed by the default event dispatcher. If true is returned, the event is not propagated to the rest of the app.
|
virtual |
Called during the app's Update cycle. This is called prior to the scene tree's update. The pSkipUpdate boolean can be set to true to skip updating the scene tree. This function should return true if a draw is required.
Reimplemented in CYIDevWidgetWithText.
|
inlinevirtual |
Used to refresh the state of the widget. This is called when the dev panel is opened.
Reimplemented in CYISignalWidget, and CYIDevWidgetWithView.
|
protected |
Sets whether this widget should capture all events when active. If called with true, this widget will report all key and action events (including trackpad events) as having been 'handled', even if the widget did not report those events as handled. This is useful for full-screen widgets which should block all input to the rest of the app.
void CYIDevWidget::SetParentPanel | ( | CYIDevPanel * | pPanel, |
size_t | indexInPanel | ||
) |
Sets owner of this widget to pPanel, and the index in the owner's list to indexInPanel. This is called by the dev panel when a widget is added to said panel, and the set values are used by the widget to access panel functions.
|
protected |
Sets the 'uses configuration items' flag of this widget. If called with usesConfigurationItems set to true, the dev panel will display a configuration arrow for this widget's dev panel item.
The configuration arrow is a button displayed in the dev panel to indicate that a specific entry has configuration options, as well as to provide to the user a way to display the configuration items.
|
protected |
Sets the 'use simulated key' flag of this widget. When called with useSimulatedKeys set to true, the widget will be using 'simulated' arrow and 'enter' keys. This is useful on touch devices for simulating key presses.
void CYIDevWidget::SimulatedKeyPressesEnded | ( | ) |
Called by the dev panel when simulated key presses have ended. This is used to stop repeated key events.
bool CYIDevWidget::SimulateKeyPress | ( | const CYIKeyEvent & | keyEvent | ) |
Called by the dev panel to simulate a keypress.
void CYIDevWidget::SimulatePanelItemClicked | ( | ) |
Simulates clicking the widget's item in the dev panel. This is useful for enabling the widget when the user selects a configuration option.
void CYIDevWidget::UpdateWidgetState | ( | ) |
Update the title, the subtitle and the on/off indicator of widget on the dev panel.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |