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:
authorDalai Felinto <dfelinto@gmail.com>2018-12-04 22:30:23 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-12-04 22:42:31 +0300
commit7c56ac235562815231b195fd5a4dd4515353c0dd (patch)
tree269983942c82d8b815a48b25e39abab0b0ba8937 /source/blender/editors/screen
parentbaf89af0f5fedf0d693a9a74e690b3ca7d8ff292 (diff)
Fix area splitting from action zone flipping viewports
The top-left and bottom-right corners were creating the new area in the wrong place. Blender 2.7x only had action zone corners in the top-right, and bottom-left corners. So it had some hardcoded assumptions based on that. This commit feels a bit like a hack, but I think it may be fine. Bug reported via IRC, how to reproduce: * Change shading to Rendered. * Split viewport from the top-left corner.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/screen_ops.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 5df6b0c6f19..20d83b0a64b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1900,19 +1900,33 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2)
return OPERATOR_PASS_THROUGH;
- /* prepare operator state vars */
- if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') {
+ /* The factor will be close to 1.0f when near the top-left and the bottom-right corners. */
+ const float factor_v = ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy;
+ const float factor_h = ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx;
+ const bool is_left = factor_v < 0.5f;
+ const bool is_bottom = factor_h < 0.5f;
+ const bool is_right = !is_left;
+ const bool is_top = !is_bottom;
+ float factor;
+
+ /* Prepare operator state vars. */
+ if (ELEM(sad->gesture_dir, 'n', 's')) {
dir = 'h';
- RNA_property_float_set(
- op->ptr, prop_factor,
- ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
+ factor = factor_h;
}
else {
dir = 'v';
- RNA_property_float_set(
- op->ptr, prop_factor,
- ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
+ factor = factor_v;
}
+
+ if ((is_top && is_left) ||
+ (is_bottom && is_right))
+ {
+ factor = 1.0f - factor;
+ }
+
+ RNA_property_float_set(op->ptr, prop_factor, factor);
+
RNA_property_enum_set(op->ptr, prop_dir, dir);
/* general init, also non-UI case, adds customdata, sets area and defaults */