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 06:31:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-16 06:31:19 +0300
commit14af3e485f1207e8f4ddb6991b22e1ba2f937c45 (patch)
tree157e34ab31912db5db2cd08f5c216b5971fb3d23 /source/blender
parenta1bb2ae0d7be4031c9dc1abb805b68d2338c96ea (diff)
parent137586a13c758d95472c3a3eabfc7dd4b22b7502 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c2
-rw-r--r--source/blender/python/intern/bpy_props.c9
-rw-r--r--source/blender/windowmanager/WM_types.h7
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c12
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c10
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c37
-rw-r--r--source/blender/windowmanager/wm.h1
7 files changed, 44 insertions, 34 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index ef86f3c773d..81b30f60cbf 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -827,7 +827,7 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, const wmEve
/* TODO, hardcoded, extend WM_gesture_straightline_ */
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
wmGesture *gesture = op->customdata;
- gesture->mode = 1;
+ gesture->is_active = true;
}
}
}
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index a46fda7ea63..b84fe84c2b6 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -73,9 +73,6 @@ static EnumPropertyItem property_flag_items[] = {
" :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE', 'LIBRARY_EDITABLE', 'PROPORTIONAL'," \
"'TEXTEDIT_UPDATE'].\n" \
" :type options: set\n" \
-" :arg poll: function to be called to determine whether an item is valid for this property.\n" \
-" The function must take 2 values (self,object) and return Bool.\n" \
-" :type poll: function\n" \
static EnumPropertyItem property_flag_enum_items[] = {
{PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
@@ -1941,6 +1938,11 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, PyObject *ge
" *Warning* there are no safety checks to avoid infinite recursion.\n" \
" :type update: function\n" \
+#define BPY_PROPDEF_POLL_DOC \
+" :arg poll: function to be called to determine whether an item is valid for this property.\n" \
+" The function must take 2 values (self, object) and return Bool.\n" \
+" :type poll: function\n" \
+
#define BPY_PROPDEF_GET_DOC \
" :arg get: Function to be called when this value is 'read',\n" \
" This function must take 1 value (self) and return the value of the property.\n" \
@@ -2884,6 +2886,7 @@ BPY_PROPDEF_TYPE_DOC
BPY_PROPDEF_NAME_DOC
BPY_PROPDEF_DESC_DOC
BPY_PROPDEF_OPTIONS_DOC
+BPY_PROPDEF_POLL_DOC
BPY_PROPDEF_UPDATE_DOC
);
PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 9df9afcb064..0e259c5fd8a 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -414,11 +414,14 @@ typedef struct wmNotifier {
typedef struct wmGesture {
struct wmGesture *next, *prev;
int event_type; /* event->type */
- int mode; /* for modal callback */
int type; /* gesture type define */
int swinid; /* initial subwindow id where it started */
int points; /* optional, amount of points stored */
- int size; /* optional, maximum amount of points stored */
+ int points_alloc; /* optional, maximum amount of points stored */
+
+ /* For modal operators which may be running idle, waiting for an event to activate the gesture.
+ * Typically this is set when the user is click-dragging the gesture (border and circle select for eg). */
+ uint is_active : 1;
void *customdata;
/* customdata for border is a recti */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f3864f7ed97..fe79798c3b7 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -84,6 +84,9 @@
#include "RNA_enum_types.h"
+/* Motion in pixels allowed before we don't consider single/double click. */
+#define WM_EVENT_CLICK_WIGGLE_ROOM 2
+
static void wm_notifier_clear(wmNotifier *note);
static void update_tablet_data(wmWindow *win, wmEvent *event);
@@ -2397,7 +2400,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
if ((event->val == KM_RELEASE) &&
(win->eventstate->prevval == KM_PRESS) &&
- (win->eventstate->check_click == true))
+ (win->eventstate->check_click == true) &&
+ ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
+ (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM))
{
event->val = KM_CLICK;
@@ -3394,8 +3399,9 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state)
(event_state->prevval == KM_RELEASE) &&
(event->val == KM_PRESS))
{
- if ((ISMOUSE(event->type) == false) || ((ABS(event->x - event_state->prevclickx)) <= 2 &&
- (ABS(event->y - event_state->prevclicky)) <= 2))
+ if ((ISMOUSE(event->type) == false) ||
+ ((abs(event->x - event_state->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
+ (abs(event->y - event_state->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM))
{
if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
return true;
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 77030fac5ea..7f1ca929fd6 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -97,11 +97,11 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
}
else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) {
short *lasso;
- gesture->customdata = lasso = MEM_callocN(2 * sizeof(short) * WM_LASSO_MIN_POINTS, "lasso points");
+ gesture->points_alloc = 1024;
+ gesture->customdata = lasso = MEM_mallocN(sizeof(short[2]) * gesture->points_alloc, "lasso points");
lasso[0] = event->x - sx;
lasso[1] = event->y - sy;
gesture->points = 1;
- gesture->size = WM_LASSO_MIN_POINTS;
}
return gesture;
@@ -437,10 +437,12 @@ void wm_gesture_draw(wmWindow *win)
else if (gt->type == WM_GESTURE_CIRCLE)
wm_gesture_draw_circle(gt);
else if (gt->type == WM_GESTURE_CROSS_RECT) {
- if (gt->mode == 1)
+ if (gt->is_active) {
wm_gesture_draw_rect(gt);
- else
+ }
+ else {
wm_gesture_draw_cross(win, gt);
+ }
}
else if (gt->type == WM_GESTURE_LINES)
wm_gesture_draw_lasso(win, gt, false);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index f34781650f1..2daac07b956 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2389,7 +2389,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type == MOUSEMOVE) {
wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
- if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) {
+ if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
rect->xmin = rect->xmax = event->x - sx;
rect->ymin = rect->ymax = event->y - sy;
}
@@ -2404,8 +2404,8 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
else if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
case GESTURE_MODAL_BEGIN:
- if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) {
- gesture->mode = 1;
+ if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->is_active == false) {
+ gesture->is_active = true;
wm_gesture_tag_redraw(C);
}
break;
@@ -2500,8 +2500,9 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
wm_gesture_tag_redraw(C);
- if (gesture->mode)
+ if (gesture->is_active) {
gesture_circle_apply(C, op);
+ }
}
else if (event->type == EVT_MODAL_MAP) {
float fac;
@@ -2534,7 +2535,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val != GESTURE_MODAL_NOP) {
/* apply first click */
gesture_circle_apply(C, op);
- gesture->mode = 1;
+ gesture->is_active = true;
wm_gesture_tag_redraw(C);
}
break;
@@ -2744,28 +2745,24 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE:
case INBETWEEN_MOUSEMOVE:
-
+
wm_gesture_tag_redraw(C);
-
+
wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
- if (gesture->points == gesture->size) {
- short *old_lasso = gesture->customdata;
- gesture->customdata = MEM_callocN(2 * sizeof(short) * (gesture->size + WM_LASSO_MIN_POINTS), "lasso points");
- memcpy(gesture->customdata, old_lasso, 2 * sizeof(short) * gesture->size);
- gesture->size = gesture->size + WM_LASSO_MIN_POINTS;
- MEM_freeN(old_lasso);
- // printf("realloc\n");
+ if (gesture->points == gesture->points_alloc) {
+ gesture->points_alloc *= 2;
+ gesture->customdata = MEM_reallocN(gesture->customdata, sizeof(short[2]) * gesture->points_alloc);
}
{
int x, y;
short *lasso = gesture->customdata;
-
+
lasso += (2 * gesture->points - 2);
x = (event->x - sx - lasso[0]);
y = (event->y - sy - lasso[1]);
-
+
/* make a simple distance check to get a smoother lasso
* add only when at least 2 pixels between this and previous location */
if ((x * x + y * y) > 4) {
@@ -2776,7 +2773,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
break;
-
+
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:
@@ -2934,7 +2931,7 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
if (event->type == MOUSEMOVE) {
wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
- if (gesture->mode == 0) {
+ if (gesture->is_active == false) {
rect->xmin = rect->xmax = event->x - sx;
rect->ymin = rect->ymax = event->y - sy;
}
@@ -2949,8 +2946,8 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
else if (event->type == EVT_MODAL_MAP) {
switch (event->val) {
case GESTURE_MODAL_BEGIN:
- if (gesture->mode == 0) {
- gesture->mode = 1;
+ if (gesture->is_active == false) {
+ gesture->is_active = true;
wm_gesture_tag_redraw(C);
}
break;
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index 915e190bb98..d81e301b579 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -62,7 +62,6 @@ void wm_window_keymap(wmKeyConfig *keyconf);
void wm_tweakevent_test(bContext *C, const wmEvent *event, int action);
/* wm_gesture.c */
-#define WM_LASSO_MIN_POINTS 1024
void wm_gesture_draw(struct wmWindow *win);
int wm_gesture_evaluate(wmGesture *gesture);
void wm_gesture_tag_redraw(bContext *C);