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.
This commit is contained in:
Sergey Sharybin 2020-08-12 12:36:19 +02:00
parent b89521de21
commit c27123632b
4 changed files with 24 additions and 13 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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