forked from bartvdbraak/blender
View2D - Vertical (within area) syncing for channel lists to stay in sync with the relevant keyframes...
I still need to work out how to get this to work correctly as soon as an Action Editor instance is created.
This commit is contained in:
parent
841f376a1c
commit
ad4d061091
@ -5102,6 +5102,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
ar->regiontype= RGN_TYPE_CHANNELS;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
ar->v2d.scroll= V2D_SCROLL_BOTTOM;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
break;
|
||||
case SPACE_NLA:
|
||||
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
|
||||
@ -5179,6 +5180,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
||||
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
|
||||
ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
//ar->v2d.flag |= V2D_IS_INITIALISED;
|
||||
break;
|
||||
}
|
||||
@ -5190,6 +5192,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
||||
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
|
||||
ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
//ar->v2d.flag |= V2D_IS_INITIALISED;
|
||||
break;
|
||||
}
|
||||
|
@ -228,11 +228,11 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
|
||||
float sfra, efra;
|
||||
int xmin, xmax;
|
||||
|
||||
/* convert min/max values from borderselect to region coordinates */
|
||||
xmin= RNA_int_get(op->ptr, "xmin")/* - ar->winrct.xmin*/;
|
||||
xmax= RNA_int_get(op->ptr, "xmax")/* - ar->winrct.xmin*/;
|
||||
/* get min/max values from border select rect (already in region coordinates, not screen) */
|
||||
xmin= RNA_int_get(op->ptr, "xmin");
|
||||
xmax= RNA_int_get(op->ptr, "xmax");
|
||||
|
||||
/* convert min/max values to frames */
|
||||
/* convert min/max values to frames (i.e. region to 'tot' rect) */
|
||||
UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL);
|
||||
UI_view2d_region_to_view(&ar->v2d, xmax, 0, &efra, NULL);
|
||||
|
||||
@ -244,10 +244,10 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
|
||||
if (efra < 1) efra = 1.0f;
|
||||
if (efra < sfra) efra= sfra;
|
||||
|
||||
scene->r.psfra= (int)sfra;
|
||||
scene->r.pefra= (int)efra;
|
||||
scene->r.psfra= (int)floor(sfra + 0.5f);
|
||||
scene->r.pefra= (int)floor(efra + 0.5f);
|
||||
|
||||
//BIF_undo_push("Clear Preview Range");
|
||||
//BIF_undo_push("Set Preview Range");
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ struct View2DScrollers;
|
||||
|
||||
struct wmWindowManager;
|
||||
struct bScreen;
|
||||
struct ScrArea;
|
||||
struct bContext;
|
||||
|
||||
typedef struct View2DGrid View2DGrid;
|
||||
@ -138,6 +139,7 @@ void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy)
|
||||
|
||||
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 *sa, struct View2D *v2dcur, int flag);
|
||||
|
||||
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
|
||||
|
||||
@ -165,7 +167,6 @@ void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *re
|
||||
struct View2D *UI_view2d_fromcontext(const struct bContext *C);
|
||||
struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
|
||||
void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_sync(struct bScreen *screen, struct View2D *v2dcur, int flag);
|
||||
|
||||
/* operators */
|
||||
void ui_view2d_operatortypes(void);
|
||||
|
@ -508,6 +508,70 @@ void UI_view2d_curRect_validate(View2D *v2d)
|
||||
|
||||
/* ------------------ */
|
||||
|
||||
/* Called by menus to activate it, or by view2d operators to make sure 'related' views stay in synchrony */
|
||||
void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
/* don't continue if no view syncing to be done */
|
||||
if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME|V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
|
||||
return;
|
||||
|
||||
/* check if doing within area syncing (i.e. channels/vertical) */
|
||||
if (v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) {
|
||||
for (ar= area->regionbase.first; ar; ar= ar->next) {
|
||||
/* don't operate on self */
|
||||
if (v2dcur != &ar->v2d) {
|
||||
/* only if view has vertical locks enabled */
|
||||
if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
|
||||
if (flag == V2D_LOCK_COPY) {
|
||||
/* other views with locks on must copy active */
|
||||
ar->v2d.cur.ymin= v2dcur->cur.ymin;
|
||||
ar->v2d.cur.ymax= v2dcur->cur.ymax;
|
||||
}
|
||||
else { /* V2D_LOCK_SET */
|
||||
/* active must copy others */
|
||||
v2dcur->cur.ymin= ar->v2d.cur.ymin;
|
||||
v2dcur->cur.ymax= ar->v2d.cur.ymax;
|
||||
}
|
||||
|
||||
/* region possibly changed, so refresh */
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if doing whole screen syncing (i.e. time/horizontal) */
|
||||
if (v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
/* don't operate on self */
|
||||
if (v2dcur != &ar->v2d) {
|
||||
/* only if view has horizontal locks enabled */
|
||||
if (ar->v2d.flag & V2D_VIEWSYNC_SCREEN_TIME) {
|
||||
if (flag == V2D_LOCK_COPY) {
|
||||
/* other views with locks on must copy active */
|
||||
ar->v2d.cur.xmin= v2dcur->cur.xmin;
|
||||
ar->v2d.cur.xmax= v2dcur->cur.xmax;
|
||||
}
|
||||
else { /* V2D_LOCK_SET */
|
||||
/* active must copy others */
|
||||
v2dcur->cur.xmin= ar->v2d.cur.xmin;
|
||||
v2dcur->cur.xmax= ar->v2d.cur.xmax;
|
||||
}
|
||||
|
||||
/* region possibly changed, so refresh */
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot)
|
||||
* This does not take into account if zooming the view on an axis will improve the view (if allowed)
|
||||
*/
|
||||
@ -1549,32 +1613,3 @@ void UI_view2d_getscale(View2D *v2d, float *x, float *y)
|
||||
if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
|
||||
}
|
||||
|
||||
/* called by menus to activate it, or by view2d operators */
|
||||
void UI_view2d_sync(bScreen *screen, View2D *v2dcur, int flag)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
if(!(v2dcur->flag & V2D_VIEWSYNC_X))
|
||||
return;
|
||||
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(v2dcur != &ar->v2d) {
|
||||
if(ar->v2d.flag & V2D_VIEWSYNC_X) {
|
||||
if(flag == V2D_LOCK_COPY) {
|
||||
|
||||
ar->v2d.cur.xmin= v2dcur->cur.xmin;
|
||||
ar->v2d.cur.xmax= v2dcur->cur.xmax;
|
||||
}
|
||||
else { /* V2D_LOCK_SET */
|
||||
v2dcur->cur.xmin= ar->v2d.cur.xmin;
|
||||
v2dcur->cur.xmax= ar->v2d.cur.xmax;
|
||||
}
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void view_pan_apply(bContext *C, wmOperator *op)
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
}
|
||||
|
||||
/* cleanup temp customdata */
|
||||
@ -497,7 +497,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
}
|
||||
|
||||
/* --------------- Individual Operators ------------------- */
|
||||
@ -650,7 +650,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
}
|
||||
|
||||
/* cleanup temp customdata */
|
||||
@ -1031,7 +1031,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
|
||||
|
||||
/* request updates to be done... */
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_COPY);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
}
|
||||
|
||||
/* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */
|
||||
|
@ -89,7 +89,7 @@ static SpaceLink *action_new(void)
|
||||
|
||||
/* only need to set scroll settings, as this will use 'listview' v2d configuration */
|
||||
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_Y;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for action");
|
||||
@ -119,6 +119,7 @@ static SpaceLink *action_new(void)
|
||||
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
||||
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
|
||||
ar->v2d.align= V2D_ALIGN_NO_POS_Y;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
|
||||
return (SpaceLink *)saction;
|
||||
}
|
||||
@ -245,7 +246,11 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
/* data... */
|
||||
|
||||
// temp... line for testing
|
||||
glColor3f(0, 0, 0);
|
||||
glLineWidth(2.0f);
|
||||
sdrawline(10, 0, 190, 0);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
/* reset view matrix */
|
||||
UI_view2d_view_restore(C);
|
||||
|
@ -194,8 +194,8 @@ static void do_time_viewmenu(bContext *C, void *arg, int event)
|
||||
break;
|
||||
case 11:
|
||||
if(v2d) {
|
||||
v2d->flag ^= V2D_VIEWSYNC_X;
|
||||
UI_view2d_sync(CTX_wm_screen(C), v2d, V2D_LOCK_SET);
|
||||
v2d->flag ^= V2D_VIEWSYNC_SCREEN_TIME;
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_SET);
|
||||
}
|
||||
break;
|
||||
case 12: /* only show keyframes from selected data */
|
||||
@ -240,7 +240,7 @@ static uiBlock *time_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center View|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_X)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT,
|
||||
uiDefIconTextBut(block, BUTM, 1, (v2d->flag & V2D_VIEWSYNC_SCREEN_TIME)?ICON_CHECKBOX_HLT:ICON_CHECKBOX_DEHLT,
|
||||
"Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
|
||||
|
||||
// if (!curarea->full)
|
||||
|
@ -89,15 +89,15 @@ typedef struct View2D {
|
||||
|
||||
/* general refresh settings (v2d->flag) */
|
||||
/* global view2d horizontal locking (for showing same time interval) */
|
||||
#define V2D_VIEWSYNC_X (1<<0)
|
||||
/* within region view2d vertical locking */
|
||||
#define V2D_VIEWSYNC_Y (1<<1)
|
||||
/* apply pixel offsets on x-axis */
|
||||
#define V2D_PIXELOFS_X (1<<2)
|
||||
/* apply pixel offsets on y-axis */
|
||||
#define V2D_PIXELOFS_Y (1<<3)
|
||||
#define V2D_VIEWSYNC_SCREEN_TIME (1<<0)
|
||||
/* within area (i.e. between regions) view2d vertical locking */
|
||||
#define V2D_VIEWSYNC_AREA_VERTICAL (1<<1)
|
||||
/* apply pixel offsets on x-axis when setting view matrices */
|
||||
#define V2D_PIXELOFS_X (1<<2)
|
||||
/* apply pixel offsets on y-axis when setting view matrices */
|
||||
#define V2D_PIXELOFS_Y (1<<3)
|
||||
/* view settings need to be set still... */
|
||||
#define V2D_IS_INITIALISED (1<<10)
|
||||
#define V2D_IS_INITIALISED (1<<10)
|
||||
|
||||
/* scroller flags for View2D (v2d->scroll) */
|
||||
/* left scrollbar */
|
||||
|
Loading…
Reference in New Issue
Block a user