|
hydrogen 1.1.1
|
Selection management for editor widgets. More...
#include <Selection.h>
Data Structures | |
| struct | SelectionGroup |
| Group of SelectionWidget objects sharing the same selection set. More... | |
Public Member Functions | |
| Selection (SelectionWidget< Elem > *w) | |
| void | merge (Selection *pOther) |
| Merge the selection groups of two Selection widgets. More... | |
| void | dump () |
| bool | isMoving () const |
| Is there an ongoing (and incomplete) selection movement gesture? More... | |
| bool | isMouseGesture () const |
| Is there a mouse gesture in progress? More... | |
| QPoint | movingOffset () const |
| During a selection "move" gesture, return the current movement position relative to the start position, in screen coordinates. More... | |
| bool | isLasso () const |
| Is there an ongoing lasso gesture? More... | |
| bool | isSelected (Elem e) const |
| Is an element in the set of currently selected elements? More... | |
| void | removeFromSelection (Elem e, bool bCheck=true) |
| void | addToSelection (Elem e) |
| void | clearSelection (bool bCheck=true) |
| void | updateWidgetGroup () |
| Update any widgets in this selection group. More... | |
| void | cancelGesture () |
| Cancel any selection gesture (lasso, move, with keyboard or mouse) in progress. More... | |
| void | paintSelection (QPainter *painter) |
| Paint selection-related elements (ie lasso) More... | |
Raw mouse events | |
Raw mouse events from Qt. These are handled by a state machine that models the intended user interaction including clicks and drags, with single buttons held down, and translated to meaningful user-level interaction events. These are named identically for the corresponding QWidget event handlers and should be called from those handlers of the SelectionWidget. | |
| void | mousePressEvent (QMouseEvent *ev) |
| void | mouseMoveEvent (QMouseEvent *ev) |
| void | mouseReleaseEvent (QMouseEvent *ev) |
Higher-level mouse events | |
These events are synthesised by the MouseState state machine, and are either processed by the SelectionState state machine, or passed to the corresponding event handlers of the SelectionWidget. | |
| void | mouseClick (QMouseEvent *ev) |
| void | mouseDragStart (QMouseEvent *ev) |
| void | mouseDragUpdate (QMouseEvent *ev) |
| void | mouseDragEnd (QMouseEvent *ev=nullptr) |
Keyboard interactions | |
| bool | keyPressEvent (QKeyEvent *ev) |
| Key press event filter. More... | |
| void | updateKeyboardCursorPosition (QRect cursor) |
| Update the keyboard cursor. More... | |
Private Attributes | |
| SelectionWidget< Elem > * | m_pWidget |
| std::set< Elem > | m_checkpointSelectedElements |
| For gestures modifying a selection, store the initial selection set as a checkpoint to restore when rebuilding the selection with the current lasso area. More... | |
| DragScroller * | m_pDragScroller |
| Scroller to use while dragging selections. More... | |
| std::shared_ptr< SelectionGroup > | m_pSelectionGroup |
Mouse state model | |
The state of the mouse is modeled as a simple state machine to distinguish user-level mouse actions (click, drag) using the information available in the lower-level Qt events (mouse press, release and move). This also filters out the potential ordering effects of non-standard user behaviour, such as pressing multiple mouse buttons at once. The Qt standard drag distance and time are used to identify the transition from a click to a drag. | |
| enum | MouseState { Up , Down , Dragging } |
| enum Selection::MouseState | m_mouseState |
| Qt::MouseButton | m_mouseButton |
| Mouse button that began the gesture. More... | |
| QMouseEvent * | m_pClickEvent |
| Mouse event to deliver as 'click' or 'drag' events. More... | |
Selection gestures | |
The Selection class implements a few multi-step gestures:
| |
| enum | SelectionState { Idle , MouseLasso , MouseMoving , KeyboardLasso , KeyboardMoving } |
| enum Selection::SelectionState | m_selectionState |
| QRect | m_lasso |
| Dimensions of a current selection lasso. More... | |
| QPoint | m_movingOffset |
| Offset that a selection has been moved by. More... | |
| QRect | m_keyboardCursorStart |
| Keyboard cursor position at the start of a keyboard gesture. More... | |
Selection iteration | |
Shorthand iteration is provided so that ranged for loops can be used for convenience: | |
| typedef std::set< Elem >::iterator | iterator |
| iterator | begin () |
| iterator | end () |
Selection management for editor widgets.
This template class bundles up the functionality necessary for interactive selections using mouse and keyboard.
The Selection class:
The client widget must:
Selections can be shared between multiple widgets providing different views of the same underlying model, so long as they share the same element type.
| typedef std::set<Elem>::iterator iterator |
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
Cancel any selection gesture (lasso, move, with keyboard or mouse) in progress.
|
inline |
|
inline |
|
inline |
|
inline |
Is there an ongoing lasso gesture?
|
inline |
Is there a mouse gesture in progress?
|
inline |
Is there an ongoing (and incomplete) selection movement gesture?
|
inline |
Is an element in the set of currently selected elements?
|
inline |
|
inline |
Merge the selection groups of two Selection widgets.
After this is called, the set of selected items will be shared between them, and any changes made by one widget will cause the other to be notified and potentially refreshed.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
During a selection "move" gesture, return the current movement position relative to the start position, in screen coordinates.
|
inline |
Paint selection-related elements (ie lasso)
|
inline |
|
inline |
Update the keyboard cursor.
Called by the client widget to tell the Selection the current location of the keyboard input cursor.
|
inline |
Update any widgets in this selection group.
|
private |
For gestures modifying a selection, store the initial selection set as a checkpoint to restore when rebuilding the selection with the current lasso area.
|
private |
Keyboard cursor position at the start of a keyboard gesture.
|
private |
Dimensions of a current selection lasso.
|
private |
Mouse button that began the gesture.
|
private |
|
private |
Offset that a selection has been moved by.
|
private |
Mouse event to deliver as 'click' or 'drag' events.
|
private |
Scroller to use while dragging selections.
|
private |
|
private |
|
private |