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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2020-08-12 13:12:29 +0300
committerSergey Sharybin <sergey@blender.org>2020-08-13 16:24:21 +0300
commit0df28e8c2044ece017c0a283625aba058c7ff5be (patch)
treedac1af8235161e8a10bbaabbec81d05f0ef8b4bb /source
parentc27123632bb4e40a36785dea148dcf0a00dce019 (diff)
View2D: Inform region type on current view changes
Allows to hook per-space code which is to be run on view navigation. This is required to have zoom-to-fit implemented in the sequencer. There might be more cases where the clalback is to be called from, but it could be easier to address those on the case-by-case basis when its needed.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_screen.h10
-rw-r--r--source/blender/editors/interface/view2d.c8
2 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index edab543fc37..1090deae93f 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -183,6 +183,16 @@ typedef struct ARegionType {
/* return context data */
int (*context)(const struct bContext *C, const char *member, struct bContextDataResult *result);
+ /* Is called whenever the current visible View2D's region changes.
+ *
+ * Used from user code such as view navigation/zoom operators to inform region about changes.
+ * The goal is to support zoom-to-fit features which gets disabled when manual navigation is
+ * performed.
+ *
+ * This callback is not called on indirect changes of the current viewport (which could happen
+ * when the `v2d->tot is changed and `cur` is adopted accordingly). */
+ void (*on_view2d_changed)(const struct bContext *C, struct ARegion *region);
+
/* custom drawing callbacks */
ListBase drawcalls;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 9d029f3292f..f15a95880f8 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -853,9 +853,15 @@ 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)
+void UI_view2d_curRect_changed(const bContext *C, View2D *v2d)
{
UI_view2d_curRect_validate(v2d);
+
+ ARegion *region = CTX_wm_region(C);
+
+ if (region->type->on_view2d_changed != NULL) {
+ region->type->on_view2d_changed(C, region);
+ }
}
/* ------------------ */