|
FifeGUI 0.3.0
A C++ GUI library designed for games.
|
#include <focushandler.hpp>
Classes | |
| class | ModalScope |
| struct | ModalState |
Public Types | |
| using | InputModalScope = ModalScope |
Public Member Functions | |
| virtual void | add (Widget *widget) |
| virtual void | clearModal () |
| FocusHandler (FocusHandler &&)=delete | |
| FocusHandler (FocusHandler const &)=delete | |
| virtual void | focusNext () |
| virtual void | focusNone () |
| virtual void | focusPrevious () |
| virtual Widget * | getDraggedWidget () |
| virtual Widget * | getFocused () const |
| virtual Widget * | getFocusOwner () const |
| virtual Widget * | getLastWidgetPressed () |
| virtual Widget * | getLastWidgetWithModalFocus () |
| virtual Widget * | getLastWidgetWithModalMouseInputFocus () |
| virtual Widget * | getLastWidgetWithMouse () |
| virtual Widget * | getMouseCaptureOwner () const |
| virtual bool | hasModalFocus () const |
| virtual bool | isFocused (Widget const *widget) const |
| FocusHandler & | operator= (FocusHandler &&)=delete |
| FocusHandler & | operator= (FocusHandler const &)=delete |
| virtual void | popModal () noexcept |
| virtual void | pushModal (Widget *focusOwner, Widget *mouseOwner=nullptr) |
| virtual void | releaseFocus (Widget *widget) |
| virtual void | remove (Widget *widget) |
| virtual void | requestFocus (Widget *widget) |
| virtual void | setDraggedWidget (Widget *draggedWidget) |
| virtual void | setFocusedWidget (Widget *widget) |
| virtual void | setLastWidgetPressed (Widget *lastWidgetPressed) |
| virtual void | setLastWidgetWithModalFocus (Widget *lastWidgetWithModalFocus) |
| virtual void | setLastWidgetWithModalMouseInputFocus (Widget *lastWidgetWithModalMouseInputFocus) |
| virtual void | setLastWidgetWithMouse (Widget *lastWidgetWithMouse) |
| virtual void | tabNext () |
| virtual void | tabPrevious () |
| virtual void | widgetHidden (Widget *widget) |
Protected Types | |
| using | WidgetIterator = WidgetVector::iterator |
| using | WidgetVector = std::vector<Widget*> |
Protected Member Functions | |
| virtual void | distributeFocusGainedEvent (Event const &focusEvent) |
| virtual void | distributeFocusLostEvent (Event const &focusEvent) |
Protected Attributes | |
| Widget * | mDraggedWidget |
| Widget * | mFocusedWidget |
| Widget * | mLastWidgetPressed |
| Widget * | mLastWidgetWithModalFocus |
| Widget * | mLastWidgetWithModalMouseInputFocus |
| Widget * | mLastWidgetWithMouse |
| std::vector< ModalState > | mModalStack |
| WidgetVector | mWidgets |
Manages focus navigation and assignment among widgets within a Gui instance.
Each Gui has at least one focus handler. You will probably not use the focus handler directly as Widget has functions that automatically uses the active focus handler.
Definition at line 33 of file focushandler.hpp.
Alias for ModalScope to clarify its purpose for input handling.
|
protected |
Iterator for WidgetVector.
Definition at line 392 of file focushandler.hpp.
|
protected |
Vector of Widget pointers.
Definition at line 389 of file focushandler.hpp.
| fcn::FocusHandler::FocusHandler | ( | ) |
Definition at line 26 of file focushandler.cpp.
|
virtual |
Adds a widget to by handles by the focus handler.
| widget | The widget to add. |
Definition at line 283 of file focushandler.cpp.
References add(), and mWidgets.
Referenced by fcn::Widget::_setFocusHandler(), and add().
|
virtual |
Clears all modal states from the stack.
Resets all modal focus and mouse input.
Definition at line 114 of file focushandler.cpp.
References clearModal(), and mModalStack.
Referenced by clearModal().
|
protectedvirtual |
Distributes a focus gained event.
| focusEvent | the event to distribute. |
Definition at line 469 of file focushandler.cpp.
References fcn::Widget::_getFocusListeners(), distributeFocusGainedEvent(), and fcn::Event::getSource().
Referenced by distributeFocusGainedEvent(), focusNext(), focusPrevious(), requestFocus(), tabNext(), and tabPrevious().
|
protectedvirtual |
Distributes a focus lost event.
| focusEvent | the event to distribute. |
Definition at line 457 of file focushandler.cpp.
References fcn::Widget::_getFocusListeners(), distributeFocusLostEvent(), and fcn::Event::getSource().
Referenced by distributeFocusLostEvent(), focusNext(), focusNone(), focusPrevious(), releaseFocus(), requestFocus(), tabNext(), and tabPrevious().
|
virtual |
Focuses the next widget added to a container.
If no widget has focus the first widget gets focus. The order in which the widgets are focused is determined by the order they were added to a container.
Definition at line 174 of file focushandler.cpp.
References distributeFocusGainedEvent(), distributeFocusLostEvent(), focusNext(), mFocusedWidget, and mWidgets.
Referenced by focusNext().
|
virtual |
Focuses nothing.
A focus event will also be sent to the focused widget's focus listeners if a widget has focus.
Definition at line 325 of file focushandler.cpp.
References distributeFocusLostEvent(), focusNone(), and mFocusedWidget.
Referenced by focusNone(), and pushModal().
|
virtual |
Focuses the previous widget added to a container.
If no widget has focus the first widget gets focus. The order in which the widgets are focused is determined by the order they were added to a container.
Definition at line 224 of file focushandler.cpp.
References distributeFocusGainedEvent(), distributeFocusLostEvent(), focusPrevious(), mFocusedWidget, and mWidgets.
Referenced by focusPrevious().
|
virtual |
Gets the widget being dragged.
Used by the GUI class to keep track of the dragged widget.
Definition at line 481 of file focushandler.cpp.
References getDraggedWidget(), and mDraggedWidget.
Referenced by getDraggedWidget().
|
virtual |
Gets the widget with focus.
Definition at line 151 of file focushandler.cpp.
References getFocused(), and mFocusedWidget.
Referenced by getFocused(), and fcn::Gui::getKeyEventSource().
|
virtual |
Gets the active input root widget for focus routing.
Returns the top of the modal stack for focus, or nullptr if no modal.
Definition at line 156 of file focushandler.cpp.
References getFocusOwner(), and mModalStack.
Referenced by getFocusOwner(), tabNext(), and tabPrevious().
|
virtual |
Gets the last widget pressed.
Used by the GUI class to keep track of pressed widgets.
Definition at line 521 of file focushandler.cpp.
References getLastWidgetPressed(), and mLastWidgetPressed.
Referenced by getLastWidgetPressed().
|
virtual |
Gets the last widget with modal focus.
Definition at line 501 of file focushandler.cpp.
References getLastWidgetWithModalFocus(), and mLastWidgetWithModalFocus.
Referenced by getLastWidgetWithModalFocus().
|
virtual |
Gets the last widget with modal mouse input focus.
Definition at line 511 of file focushandler.cpp.
References getLastWidgetWithModalMouseInputFocus(), and mLastWidgetWithModalMouseInputFocus.
Referenced by getLastWidgetWithModalMouseInputFocus().
|
virtual |
Gets the last widget with the mouse.
Used by the GUI class to keep track the last widget with the mouse.
Definition at line 491 of file focushandler.cpp.
References getLastWidgetWithMouse(), and mLastWidgetWithMouse.
Referenced by getLastWidgetWithMouse().
|
virtual |
Gets the widget with modal mouse input focus.
Definition at line 165 of file focushandler.cpp.
References getMouseCaptureOwner(), and mModalStack.
Referenced by getMouseCaptureOwner().
|
virtual |
Checks if any modal state is active.
Definition at line 63 of file focushandler.cpp.
References hasModalFocus(), and mModalStack.
Referenced by hasModalFocus().
|
virtual |
Checks if a widget is focused.
| widget | The widget to check. |
Definition at line 278 of file focushandler.cpp.
References isFocused(), and mFocusedWidget.
Referenced by isFocused(), and remove().
|
virtualnoexcept |
Pops the current modal state from the stack.
Restores focus to the previous modal level if any.
Definition at line 92 of file focushandler.cpp.
References mModalStack, popModal(), and requestFocus().
Referenced by popModal().
Pushes a new modal state onto the stack.
| focusOwner | The widget that will have modal focus. |
| mouseOwner | Optional widget for modal mouse input focus. |
Definition at line 68 of file focushandler.cpp.
References focusNone(), fcn::FocusHandler::ModalState::focusOwner, fcn::Widget::getMouseCapture(), fcn::Widget::isDescendantOf(), mFocusedWidget, mModalStack, fcn::FocusHandler::ModalState::mouseOwner, and pushModal().
Referenced by pushModal().
|
virtual |
Releases focus for the specified widget if it is currently focused.
| widget | The widget to release focus for. |
Definition at line 119 of file focushandler.cpp.
References distributeFocusLostEvent(), mFocusedWidget, and releaseFocus().
Referenced by releaseFocus().
|
virtual |
Removes a widget from the focus handler.
| widget | The widget to remove. |
Definition at line 288 of file focushandler.cpp.
References isFocused(), mDraggedWidget, mFocusedWidget, mLastWidgetPressed, mLastWidgetWithModalFocus, mLastWidgetWithModalMouseInputFocus, mLastWidgetWithMouse, mWidgets, and remove().
Referenced by remove().
|
virtual |
Requests focus for a widget.
Focus will only be granted to a widget if it's focusable and if no other widget has modal focus. If a widget receives focus, a focus event will be sent to the focus listeners of the widget.
| widget | The widget to request focus for. |
Definition at line 36 of file focushandler.cpp.
References distributeFocusGainedEvent(), distributeFocusLostEvent(), mFocusedWidget, mWidgets, requestFocus(), setFocusedWidget(), and fcn::throwException().
Referenced by popModal(), and requestFocus().
|
virtual |
Sets the widget being dragged.
Used by the GUI class to keep track of the dragged widget.
| draggedWidget | The widget being dragged. |
Definition at line 486 of file focushandler.cpp.
References mDraggedWidget, and setDraggedWidget().
Referenced by setDraggedWidget().
|
virtual |
Sets the focused widget directly.
| widget | The widget to focus, or nullptr to clear focus. |
Definition at line 132 of file focushandler.cpp.
References mFocusedWidget, fcn::Widget::setFocused(), and setFocusedWidget().
Referenced by requestFocus(), and setFocusedWidget().
|
virtual |
Sets the last widget pressed.
Used by the GUI class to keep track of pressed widgets.
| lastWidgetPressed | The last widget pressed. |
Definition at line 526 of file focushandler.cpp.
References mLastWidgetPressed, and setLastWidgetPressed().
Referenced by setLastWidgetPressed().
|
virtual |
Sets the last widget with modal focus.
| lastWidgetWithModalFocus | The last widget with modal focus. |
Definition at line 506 of file focushandler.cpp.
References mLastWidgetWithModalFocus, and setLastWidgetWithModalFocus().
Referenced by setLastWidgetWithModalFocus().
|
virtual |
Sets the last widget with modal mouse input focus.
| lastWidgetWithModalMouseInputFocus | The last widget with modal mouse input focus. |
Definition at line 516 of file focushandler.cpp.
References mLastWidgetWithModalMouseInputFocus, and setLastWidgetWithModalMouseInputFocus().
Referenced by setLastWidgetWithModalMouseInputFocus().
|
virtual |
Sets the last widget with the mouse.
Used by the GUI class to keep track the last widget with the mouse.
| lastWidgetWithMouse | The last widget with the mouse. |
Definition at line 496 of file focushandler.cpp.
References mLastWidgetWithMouse, and setLastWidgetWithMouse().
Referenced by setLastWidgetWithMouse().
|
virtual |
Focuses the next widget which allows tabbing in unless the current focused Widget disallows tabbing out.
Definition at line 336 of file focushandler.cpp.
References distributeFocusGainedEvent(), distributeFocusLostEvent(), getFocusOwner(), mFocusedWidget, mWidgets, and tabNext().
Referenced by tabNext().
|
virtual |
Focuses the previous widget which allows tabbing in unless current focused Widget disallows tabbing out.
Definition at line 397 of file focushandler.cpp.
References distributeFocusGainedEvent(), distributeFocusLostEvent(), getFocusOwner(), mFocusedWidget, mWidgets, and tabPrevious().
Referenced by tabPrevious().
|
virtual |
Informs the focus handler that a widget was hidden.
This is needed because the focus handler must determine which widget has the mouse now.
| widget | Widget that was hidden |
Definition at line 531 of file focushandler.cpp.
References widgetHidden().
Referenced by widgetHidden().
|
protected |
Holds the dragged widget.
Nullptr if no widget is being dragged.
Definition at line 430 of file focushandler.hpp.
Referenced by getDraggedWidget(), remove(), and setDraggedWidget().
|
protected |
Holds the focused widget.
Nullptr if no widget has focus.
Definition at line 423 of file focushandler.hpp.
Referenced by focusNext(), focusNone(), focusPrevious(), getFocused(), isFocused(), pushModal(), releaseFocus(), remove(), requestFocus(), setFocusedWidget(), tabNext(), and tabPrevious().
|
protected |
Holds the last widget pressed.
Definition at line 450 of file focushandler.hpp.
Referenced by getLastWidgetPressed(), remove(), and setLastWidgetPressed().
|
protected |
Holds the last widget with modal focus.
Definition at line 440 of file focushandler.hpp.
Referenced by getLastWidgetWithModalFocus(), remove(), and setLastWidgetWithModalFocus().
|
protected |
Holds the last widget with modal mouse input focus.
Definition at line 445 of file focushandler.hpp.
Referenced by getLastWidgetWithModalMouseInputFocus(), remove(), and setLastWidgetWithModalMouseInputFocus().
|
protected |
Holds the last widget with the mouse.
Definition at line 435 of file focushandler.hpp.
Referenced by getLastWidgetWithMouse(), remove(), and setLastWidgetWithMouse().
|
protected |
Holds the modal stack for nested modal dialogs.
Definition at line 413 of file focushandler.hpp.
Referenced by clearModal(), getFocusOwner(), getMouseCaptureOwner(), hasModalFocus(), popModal(), and pushModal().
|
protected |
Holds the widgets currently being handled by the focus handler.
Definition at line 418 of file focushandler.hpp.
Referenced by add(), focusNext(), focusPrevious(), remove(), requestFocus(), tabNext(), and tabPrevious().