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:
authorSergey Sharybin <sergey@blender.org>2020-08-12 13:36:19 +0300
committerSergey Sharybin <sergey@blender.org>2020-08-13 16:24:21 +0300
commitc27123632bb4e40a36785dea148dcf0a00dce019 (patch)
treecd0e747f8c999a74deafea8dfb3aec97c72181e3 /source/blender/editors
parentb89521de21be1a31c6dbfa186cf5512922a6ed36 (diff)
View2D: Centralize handling of changes to v2d->cur
Currently there are no functional changes, preparing code to add more functionality which is to be run from navigation/zoom operators.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_view2d.h6
-rw-r--r--source/blender/editors/interface/view2d.c5
-rw-r--r--source/blender/editors/interface/view2d_ops.c24
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c2
4 files changed, 24 insertions, 13 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 6e0f4434b7b..1bd9b3063bd 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -120,6 +120,12 @@ void UI_view2d_curRect_validate(struct View2D *v2d);
void UI_view2d_curRect_reset(struct View2D *v2d);
void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D *v2dcur, int flag);
+/* Perform all required updates after `v2d->cur` as been modified.
+ * This includes like validation view validation (UI_view2d_curRect_validate).
+ *
+ * Current lintent is to use it from user code, such as view navigation and zoom operations. */
+void UI_view2d_curRect_changed(const struct bContext *C, struct View2D *v2d);
+
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 3efed43e08c..9d029f3292f 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -853,6 +853,11 @@ void UI_view2d_curRect_validate(View2D *v2d)
ui_view2d_curRect_validate_resize(v2d, false);
}
+void UI_view2d_curRect_changed(const bContext *UNUSED(C), View2D *v2d)
+{
+ UI_view2d_curRect_validate(v2d);
+}
+
/* ------------------ */
/* Called by menus to activate it, or by view2d operators
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index d62058699d9..7caa61ec91d 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -185,8 +185,8 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
v2d->cur.ymax += dy;
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
+ /* Inform v2d about changes after this operation. */
+ UI_view2d_curRect_changed(C, v2d);
/* don't rebuild full tree in outliner, since we're just changing our view */
ED_region_tag_redraw_no_rebuild(vpd->region);
@@ -957,8 +957,8 @@ static void view_zoomstep_apply_ex(
}
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
+ /* Inform v2d about changes after this operation. */
+ UI_view2d_curRect_changed(C, v2d);
if (ED_region_snap_size_apply(region, snap_test)) {
ScrArea *area = CTX_wm_area(C);
@@ -1216,8 +1216,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
+ /* Inform v2d about changes after this operation. */
+ UI_view2d_curRect_changed(C, v2d);
if (ED_region_snap_size_apply(vzd->region, snap_test)) {
ScrArea *area = CTX_wm_area(C);
@@ -1806,7 +1806,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *region, const rctf *cur, const
if (ok == false) {
v2d->cur = sms.new_cur;
- UI_view2d_curRect_validate(v2d);
+ UI_view2d_curRect_changed(C, v2d);
ED_region_tag_redraw_no_rebuild(region);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
}
@@ -1853,7 +1853,7 @@ static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
BLI_rctf_interp(&v2d->cur, &sms->orig_cur, &sms->new_cur, step);
}
- UI_view2d_curRect_validate(v2d);
+ UI_view2d_curRect_changed(C, v2d);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
ED_region_tag_redraw_no_rebuild(region);
@@ -2176,8 +2176,8 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
break;
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
+ /* Inform v2d about changes after this operation. */
+ UI_view2d_curRect_changed(C, v2d);
/* request updates to be done... */
ED_region_tag_redraw_no_rebuild(vsm->region);
@@ -2410,8 +2410,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
}
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
+ /* Inform v2d about changes after this operation. */
+ UI_view2d_curRect_changed(C, v2d);
if (ED_region_snap_size_apply(region, snap_test)) {
ScrArea *area = CTX_wm_area(C);
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index c1dac30bcb6..2b9370970de 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -154,7 +154,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
View2D *v2d = UI_view2d_fromcontext(C);
v2d->cur = v2d->tot;
- UI_view2d_curRect_validate(v2d);
+ UI_view2d_curRect_changed(C, v2d);
UI_view2d_sync(screen, area, v2d, V2D_LOCK_COPY);
#if 0