Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-16 07:32:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-16 07:32:09 +0300
commit8bda35d2f49879ced26e9069bce14ebf368761b3 (patch)
treeec92e726a8581f02183865e4830e4acc6acc3a94 /source/blender/windowmanager/intern
parent137586a13c758d95472c3a3eabfc7dd4b22b7502 (diff)
WM: remove hard-coded circle radius memory
Replace with operator type 'last_properties'. Also use generic function for circle gesture properties.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c6
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c49
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c46
3 files changed, 65 insertions, 36 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index f66efa72908..11f39dc934c 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -84,11 +84,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
rect->xmin = event->x - sx;
rect->ymin = event->y - sy;
if (type == WM_GESTURE_CIRCLE) {
-#ifdef GESTURE_MEMORY
- rect->xmax = circle_select_size;
-#else
- rect->xmax = 25; // XXX temp
-#endif
+ /* caller is responsible for initializing 'xmax' to radius. */
}
else {
rect->xmax = event->x - sx;
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 18836f34c99..2a44b4997a2 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -224,6 +224,9 @@ void WM_operator_properties_border_to_rctf(struct wmOperator *op, rctf *rect)
BLI_rctf_rcti_copy(rect, &rect_i);
}
+/**
+ * Use with #WM_border_select_invoke
+ */
void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend)
{
RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
@@ -235,19 +238,9 @@ void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend)
}
}
-void WM_operator_properties_mouse_select(wmOperatorType *ot)
-{
- PropertyRNA *prop;
-
- prop = RNA_def_boolean(ot->srna, "extend", false, "Extend",
- "Extend selection instead of deselecting everything first");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-}
-
+/**
+ * Use with #WM_gesture_straightline_invoke
+ */
void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
{
PropertyRNA *prop;
@@ -269,6 +262,36 @@ void WM_operator_properties_gesture_straightline(wmOperatorType *ot, int cursor)
}
/**
+ * Use with #WM_gesture_circle_invoke
+ */
+void WM_operator_properties_gesture_circle(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+ const int radius_default = 25;
+
+ prop = RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ prop = RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ RNA_def_int(ot->srna, "radius", radius_default, 1, INT_MAX, "Radius", "", 1, INT_MAX);
+ prop = RNA_def_int(ot->srna, "gesture_mode", 0, INT_MIN, INT_MAX, "Gesture Mode", "", INT_MIN, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
+
+void WM_operator_properties_mouse_select(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend",
+ "Extend selection instead of deselecting everything first");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+/**
* \param nth_can_disable: Enable if we want to be able to select no interval at all.
*/
void WM_operator_properties_checker_interval(wmOperatorType *ot, bool nth_can_disable)
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6fdc0a0a8c0..e4776ea7b29 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2394,14 +2394,15 @@ void WM_border_select_cancel(bContext *C, wmOperator *op)
/* **************** circle gesture *************** */
/* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
-#ifdef GESTURE_MEMORY
-int circle_select_size = 25; /* XXX - need some operator memory thing! */
-#endif
-
int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE);
+ wmGesture *gesture = op->customdata;
+ rcti *rect = gesture->customdata;
+ /* Default or previously stored value. */
+ rect->xmax = RNA_int_get(op->ptr, "radius");
+
/* add modal handler */
WM_event_add_modal_handler(C, op);
@@ -2428,9 +2429,6 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
retval = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(retval);
}
-#ifdef GESTURE_MEMORY
- circle_select_size = rect->xmax;
-#endif
}
int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2452,6 +2450,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (event->type == EVT_MODAL_MAP) {
+ bool is_circle_size = false;
float fac;
switch (event->val) {
@@ -2462,22 +2461,25 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
else
rect->xmax += floor(fac);
if (rect->xmax < 1) rect->xmax = 1;
- wm_gesture_tag_redraw(C);
+ is_circle_size = true;
break;
case GESTURE_MODAL_CIRCLE_ADD:
rect->xmax += 2 + rect->xmax / 10;
- wm_gesture_tag_redraw(C);
+ is_circle_size = true;
break;
case GESTURE_MODAL_CIRCLE_SUB:
rect->xmax -= 2 + rect->xmax / 10;
if (rect->xmax < 1) rect->xmax = 1;
- wm_gesture_tag_redraw(C);
+ is_circle_size = true;
break;
case GESTURE_MODAL_SELECT:
case GESTURE_MODAL_DESELECT:
case GESTURE_MODAL_NOP:
- if (RNA_struct_find_property(op->ptr, "gesture_mode"))
- RNA_int_set(op->ptr, "gesture_mode", event->val);
+ {
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "gesture_mode");
+ if (prop != NULL) {
+ RNA_property_int_set(op->ptr, prop, event->val);
+ }
if (event->val != GESTURE_MODAL_NOP) {
/* apply first click */
@@ -2486,12 +2488,22 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
wm_gesture_tag_redraw(C);
}
break;
-
+ }
case GESTURE_MODAL_CANCEL:
case GESTURE_MODAL_CONFIRM:
+ /* Normally we wouldn't store last-properties on cancel,
+ * this is an exception since the circle tool is modal. */
+ WM_operator_last_properties_store(op);
wm_gesture_end(C, op);
return OPERATOR_FINISHED; /* use finish or we don't get an undo */
}
+
+ if (is_circle_size) {
+ wm_gesture_tag_redraw(C);
+
+ /* So next use remembers last seen size, even if we didn't apply it. */
+ RNA_int_set(op->ptr, "radius", rect->xmax);
+ }
}
#ifdef WITH_INPUT_NDOF
else if (event->type == NDOF_MOTION) {
@@ -2522,12 +2534,10 @@ void WM_OT_circle_gesture(wmOperatorType *ot)
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
-
ot->poll = WM_operator_winactive;
-
- RNA_def_property(ot->srna, "x", PROP_INT, PROP_NONE);
- RNA_def_property(ot->srna, "y", PROP_INT, PROP_NONE);
- RNA_def_property(ot->srna, "radius", PROP_INT, PROP_NONE);
+
+ /* properties */
+ WM_operator_properties_gesture_circle(ot);
}
#endif