Browse Source

Automatically set target for DragStart, Enter, Select, DragHover, etc.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
0292387e58
2 changed files with 10 additions and 14 deletions
  1. +6
    -14
      include/event.hpp
  2. +4
    -0
      src/event.cpp

+ 6
- 14
include/event.hpp View File

@@ -147,7 +147,6 @@ struct HoverScroll : Base, PositionBase {


/** Occurs when a Widget begins consuming the Hover event.
Must consume to set the widget as hovered.
Must set the Hover target to receive this event.
*/
struct Enter : Base {
@@ -155,7 +154,6 @@ struct Enter : Base {


/** Occurs when a different Widget is entered.
Must set the Enter target to receive this event.
*/
struct Leave : Base {
};
@@ -169,15 +167,13 @@ struct Select : Base {


/** Occurs when a different Widget is selected.
Must set the Select target to receive this event.
*/
struct Deselect : Base {
};


/** Occurs when a key is pressed, released, or repeated while a Widget is selected.
If consumed, a HoverKey event will not be triggered.
Must set the Select target to receive this event.
Must consume to prevent HoverKey from being triggered.
*/
struct SelectKey : Base, KeyBase {
};
@@ -185,7 +181,6 @@ struct SelectKey : Base, KeyBase {

/** Occurs when text is typed while a Widget is selected.
If consumed, a HoverText event will not be triggered.
Must set the Select target to receive this event.
*/
struct SelectText : Base, TextBase {
};
@@ -197,7 +192,6 @@ struct DragBase : Base {
};

/** Occurs when a Widget begins being dragged.
Must consume to set the widget as dragged.
Must set the Button target to receive this event.
*/
struct DragStart : DragBase {
@@ -205,14 +199,14 @@ struct DragStart : DragBase {


/** Occurs when a Widget stops being dragged by releasing the mouse button.
Must set the DragStart target to receive this event.
Must set the Button target to receive this event.
*/
struct DragEnd : DragBase {
};


/** Occurs every frame on the dragged Widget.
Must set the DragStart target to receive this event.
Must set the Button target to receive this event.
*/
struct DragMove : DragBase {
/** Change in mouse position since the last frame. Can be zero. */
@@ -222,7 +216,6 @@ struct DragMove : DragBase {

/** Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same one) is being dragged.
Recurses.
Must set the DragStart target to receive this event.
*/
struct DragHover : DragBase, PositionBase {
/** The dragged widget */
@@ -232,8 +225,7 @@ struct DragHover : DragBase, PositionBase {
};

/** Occurs when the mouse enters a Widget while dragging.
Must consume to set the widget as drag-hovered.
Must set the DragStart target to receive this event.
Must set the DragHover target to receive this event.
*/
struct DragEnter : DragBase {
/** The dragged widget */
@@ -242,7 +234,7 @@ struct DragEnter : DragBase {


/** Occurs when the mouse leaves a Widget while dragging.
Must set the DragStart target to receive this event.
Must set the DragHover target to receive this event.
*/
struct DragLeave : DragBase {
/** The dragged widget */
@@ -251,7 +243,7 @@ struct DragLeave : DragBase {


/** Occurs when the mouse button is released over a Widget while dragging.
Must set the DragStart target to receive this event.
Must set the DragHover target to receive this event.
*/
struct DragDrop : DragBase {
/** The dragged widget */


+ 4
- 0
src/event.cpp View File

@@ -20,6 +20,7 @@ void State::setHovered(widget::Widget *w) {
if (w) {
// Enter
Context cEnter;
cEnter.target = w;
Enter eEnter;
eEnter.context = &cEnter;
w->onEnter(eEnter);
@@ -44,6 +45,7 @@ void State::setDragged(widget::Widget *w, int button) {
if (w) {
// DragStart
Context cDragStart;
cDragStart.target = w;
DragStart eDragStart;
eDragStart.context = &cDragStart;
eDragStart.button = dragButton;
@@ -68,6 +70,7 @@ void State::setDragHovered(widget::Widget *w) {
if (w) {
// DragEnter
Context cDragEnter;
cDragEnter.target = w;
DragEnter eDragEnter;
eDragEnter.context = &cDragEnter;
eDragEnter.button = dragButton;
@@ -91,6 +94,7 @@ void State::setSelected(widget::Widget *w) {
if (w) {
// Select
Context cSelect;
cSelect.target = w;
Select eSelect;
eSelect.context = &cSelect;
w->onSelect(eSelect);


Loading…
Cancel
Save