Added notifiers for timeline syncing. Works for Timeline window
only now.
Note that I've removed the malloc-free in a Notifier... notifier
system is still under probabtion :)
This commit is contained in:
Ton Roosendaal
2008-12-15 18:09:55 +00:00
parent a16df53619
commit 628f02d574
8 changed files with 56 additions and 17 deletions

View File

@@ -95,6 +95,12 @@ enum {
/* half the size (in pixels) of scroller 'handles' */
#define V2D_SCROLLER_HANDLE_SIZE 5
/* ------ Define for UI_view2d_sync ----- */
/* means copy it from the other v2d */
#define V2D_LOCK_COPY 1
/* ------------------------------------------ */
/* Macros: */
@@ -153,6 +159,7 @@ 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 View2D *v2d, struct View2D *v2dfrom, int flag);
/* operators */
void ui_view2d_operatortypes(void);

View File

@@ -1466,3 +1466,18 @@ void UI_view2d_getscale(View2D *v2d, float *x, float *y)
if (x) *x = (v2d->mask.xmax - v2d->mask.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
}
void UI_view2d_sync(View2D *v2d, View2D *v2dfrom, int flag)
{
if(flag == V2D_LOCK_COPY) {
v2d->cur.xmin= v2dfrom->cur.xmin;
v2d->cur.xmax= v2dfrom->cur.xmax;
}
else {
v2dfrom->cur.xmin= v2d->cur.xmin;
v2dfrom->cur.xmax= v2d->cur.xmax;
}
}

View File

@@ -165,7 +165,8 @@ static void view_pan_apply(bContext *C, wmOperator *op)
/* request updates to be done... */
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
/* cleanup temp customdata */
@@ -493,7 +494,8 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
/* request updates to be done... */
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
/* --------------- Individual Operators ------------------- */
@@ -645,7 +647,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
/* request updates to be done... */
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
/* cleanup temp customdata */
@@ -1025,7 +1028,8 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
/* request updates to be done... */
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
/* XXX: add WM_NOTE_TIME_CHANGED? */
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
/* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */

View File

@@ -104,7 +104,7 @@ void ED_region_pixelspace(const bContext *C, ARegion *ar)
void ED_region_do_listen(ARegion *ar, wmNotifier *note)
{
/* generic notes first */
switch(note->type) {
case WM_NOTE_WINDOW_REDRAW:

View File

@@ -162,6 +162,15 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
static void time_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->type) {
case WM_NOTE_TIMELINE_SYNC:
if(ar->v2d.flag & V2D_VIEWSYNC_X) {
ar->do_draw= 1; /* XXX GAH! */
UI_view2d_sync(&ar->v2d, wmn->data, wmn->value);
}
break;
}
}
/* ************************ header time area region *********************** */

View File

@@ -189,11 +189,11 @@ static void do_time_viewmenu(bContext *C, void *arg, int event)
break;
case 11:
if(v2d) {
//v2d->flag ^= V2D_VIEWSYNC_X;
//if(v2d->flag & V2D_VIEWSYNC_X)
// view2d_do_locks(curarea, 0);
v2d->flag ^= V2D_VIEWSYNC_X;
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, 0, v2d); /* XXX can notifier be called after data free? */
}
break;
break;
case 12: /* only show keyframes from selected data */
stime->flag ^= TIME_ONLYACTSEL;
WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);

View File

@@ -115,7 +115,11 @@ enum {
WM_NOTE_AREA_REDRAW,
WM_NOTE_REGION_REDRAW,
WM_NOTE_GESTURE_REDRAW,
WM_NOTE_TIMELINE_SYNC,
WM_NOTE_OBJECT_CHANGED,
WM_NOTE_LAST
};

View File

@@ -102,13 +102,14 @@ void WM_event_add_notifier(bContext *C, int type, int value, void *data)
note->window= C->window;
/* catch global notifications here */
/* catch local notifications here */
switch (type) {
case WM_NOTE_WINDOW_REDRAW:
case WM_NOTE_SCREEN_CHANGED:
break;
default:
if(C->region) note->swinid= C->region->swinid;
case WM_NOTE_AREA_REDRAW:
case WM_NOTE_REGION_REDRAW:
case WM_NOTE_GESTURE_REDRAW:
if(C->region)
note->swinid= C->region->swinid;
break;
}
note->type= type;
@@ -174,8 +175,7 @@ void wm_event_do_notifiers(bContext *C)
C->window= NULL;
C->screen= NULL;
}
if(note->data)
MEM_freeN(note->data);
MEM_freeN(note);
}
}