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>2018-07-02 13:41:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-02 13:43:36 +0300
commitec22327a5f9af5d23a7b6adaa745828c9a7ddb78 (patch)
treef85873c09ad03b6017e4683a86f6b6bdea224764
parentb076b3853c99d947806e05fe2dec29ca5fa944fa (diff)
parentc6416ae65316c1ff89f9b65d2a87ad4ea6cdd1d6 (diff)
Merge branch 'master' into blender2.8
-rw-r--r--source/blender/editors/screen/screen_ops.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index c6041d830b1..7c36ced212b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1835,8 +1835,11 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
int dir;
/* no full window splitting allowed */
- if (sc->state != SCREENNORMAL)
- return OPERATOR_CANCELLED;
+ BLI_assert(sc->state == SCREENNORMAL);
+
+ PropertyRNA *prop_dir = RNA_struct_find_property(op->ptr, "direction");
+ PropertyRNA *prop_factor = RNA_struct_find_property(op->ptr, "factor");
+ PropertyRNA *prop_cursor = RNA_struct_find_property(op->ptr, "cursor");
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
@@ -1856,49 +1859,73 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* prepare operator state vars */
if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') {
dir = 'h';
- RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
+ RNA_property_float_set(
+ op->ptr, prop_factor,
+ ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
}
else {
dir = 'v';
- RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
+ RNA_property_float_set(
+ op->ptr, prop_factor,
+ ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
}
- RNA_enum_set(op->ptr, "direction", dir);
+ RNA_property_enum_set(op->ptr, prop_dir, dir);
/* general init, also non-UI case, adds customdata, sets area and defaults */
- if (!area_split_init(C, op))
+ if (!area_split_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
+ }
+ else if (RNA_property_is_set(op->ptr, prop_dir)) {
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa == NULL) {
+ return OPERATOR_CANCELLED;
+ }
+ dir = RNA_property_enum_get(op->ptr, prop_dir);
+ if (dir == 'h') {
+ RNA_property_float_set(
+ op->ptr, prop_factor,
+ ((float)(event->x - sa->v1->vec.x)) / (float)sa->winx);
+ }
+ else {
+ RNA_property_float_set(
+ op->ptr, prop_factor,
+ ((float)(event->y - sa->v1->vec.y)) / (float)sa->winy);
+ }
+ if (!area_split_init(C, op)) {
+ return OPERATOR_CANCELLED;
+ }
}
else {
ScrEdge *actedge;
rcti screen_rect;
- int x, y;
+ int event_co[2];
/* retrieve initial mouse coord, so we can find the active edge */
- if (RNA_struct_property_is_set(op->ptr, "mouse_x"))
- x = RNA_int_get(op->ptr, "mouse_x");
- else
- x = event->x;
-
- if (RNA_struct_property_is_set(op->ptr, "mouse_y"))
- y = RNA_int_get(op->ptr, "mouse_y");
- else
- y = event->x;
+ if (RNA_property_is_set(op->ptr, prop_cursor)) {
+ RNA_property_int_get_array(op->ptr, prop_cursor, event_co);
+ }
+ else {
+ copy_v2_v2_int(event_co, &event->x);
+ }
WM_window_screen_rect_calc(win, &screen_rect);
- actedge = screen_geom_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), &screen_rect, x, y);
- if (actedge == NULL)
+ actedge = screen_geom_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), &screen_rect, event_co[0], event_co[1]);
+ if (actedge == NULL) {
return OPERATOR_CANCELLED;
+ }
dir = screen_geom_edge_is_horizontal(actedge) ? 'v' : 'h';
- RNA_enum_set(op->ptr, "direction", dir);
+ RNA_property_enum_set(op->ptr, prop_dir, dir);
/* special case, adds customdata, sets defaults */
- if (!area_split_menu_init(C, op))
+ if (!area_split_menu_init(C, op)) {
return OPERATOR_CANCELLED;
-
+ }
}
sd = (sAreaSplitData *)op->customdata;
@@ -2098,8 +2125,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
/* rna */
RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", "");
RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
- RNA_def_int(ot->srna, "mouse_x", -100, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX);
- RNA_def_int(ot->srna, "mouse_y", -100, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
+ RNA_def_int_vector(ot->srna, "cursor", 2, NULL, INT_MIN, INT_MAX, "Cursor", "", INT_MIN, INT_MAX);
}
/** \} */
@@ -3127,8 +3153,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
/* store initial mouse cursor position */
- RNA_int_set(&ptr, "mouse_x", event->x);
- RNA_int_set(&ptr, "mouse_y", event->y);
+ RNA_int_set_array(&ptr, "cursor", &event->x);
uiItemFullO(layout, "SCREEN_OT_area_join", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
/* mouse cursor on edge, '4' can fail on wide edges... */