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.
This commit is contained in:
parent
c27123632b
commit
0df28e8c20
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------ */
|
||||
|
|
Loading…
Reference in New Issue