Animation: Vertically locking the NLA so it doesn't scroll to infinity #109473
|
@ -171,6 +171,12 @@ void UI_view2d_mask_from_win(const struct View2D *v2d, struct rcti *r_mask);
|
||||||
|
|
||||||
void UI_view2d_zoom_cache_reset(void);
|
void UI_view2d_zoom_cache_reset(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamp view2d area to what's visible, preventing
|
||||||
|
* scrolling vertically to infinity.
|
||||||
|
*/
|
||||||
|
|||||||
|
void UI_view2d_curRect_clamp_y(struct View2D *v2d);
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
|
@ -405,21 +405,6 @@ static void saction_channel_region_message_subscribe(const wmRegionMessageSubscr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_clamp_scroll(ARegion *region)
|
|
||||||
{
|
|
||||||
View2D *v2d = ®ion->v2d;
|
|
||||||
const float cur_height_y = BLI_rctf_size_y(&v2d->cur);
|
|
||||||
|
|
||||||
if (BLI_rctf_size_y(&v2d->cur) > BLI_rctf_size_y(&v2d->tot)) {
|
|
||||||
v2d->cur.ymin = -cur_height_y;
|
|
||||||
v2d->cur.ymax = 0;
|
|
||||||
}
|
|
||||||
else if (v2d->cur.ymin < v2d->tot.ymin) {
|
|
||||||
v2d->cur.ymin = v2d->tot.ymin;
|
|
||||||
v2d->cur.ymax = v2d->cur.ymin + cur_height_y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void action_main_region_listener(const wmRegionListenerParams *params)
|
static void action_main_region_listener(const wmRegionListenerParams *params)
|
||||||
{
|
{
|
||||||
ARegion *region = params->region;
|
ARegion *region = params->region;
|
||||||
|
@ -880,9 +865,8 @@ static void action_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||||
|
|
||||||
static void action_main_region_view2d_changed(const bContext * /*C*/, ARegion *region)
|
static void action_main_region_view2d_changed(const bContext * /*C*/, ARegion *region)
|
||||||
{
|
{
|
||||||
/* V2D_KEEPTOT_STRICT cannot be used to clamp scrolling
|
View2D *v2d = ®ion->v2d;
|
||||||
* because it also clamps the x-axis to 0. */
|
UI_view2d_curRect_clamp_y(v2d);
|
||||||
action_clamp_scroll(region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_spacetype_action()
|
void ED_spacetype_action()
|
||||||
|
|
|
@ -436,6 +436,12 @@ static void nla_main_region_message_subscribe(const wmRegionMessageSubscribePara
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nla_main_region_view2d_changed(const bContext * /*C*/, ARegion *region)
|
||||||
|
{
|
||||||
|
View2D *v2d = ®ion->v2d;
|
||||||
|
UI_view2d_curRect_clamp_y(v2d);
|
||||||
|
}
|
||||||
|
|
||||||
static void nla_channel_region_listener(const wmRegionListenerParams *params)
|
static void nla_channel_region_listener(const wmRegionListenerParams *params)
|
||||||
{
|
{
|
||||||
ARegion *region = params->region;
|
ARegion *region = params->region;
|
||||||
|
@ -619,6 +625,7 @@ void ED_spacetype_nla()
|
||||||
art->draw_overlay = nla_main_region_draw_overlay;
|
art->draw_overlay = nla_main_region_draw_overlay;
|
||||||
art->listener = nla_main_region_listener;
|
art->listener = nla_main_region_listener;
|
||||||
art->message_subscribe = nla_main_region_message_subscribe;
|
art->message_subscribe = nla_main_region_message_subscribe;
|
||||||
|
art->on_view2d_changed = nla_main_region_view2d_changed;
|
||||||
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
|
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
|
||||||
|
|
||||||
BLI_addhead(&st->regiontypes, art);
|
BLI_addhead(&st->regiontypes, art);
|
||||||
|
|
Loading…
Reference in New Issue
Both comment lines above end with extra trailing spaces.