Work on getting notifiers in shape.
- Most important: local (to own region or area) redraw notifiers
have been depricated. This is not a good or correct notifier anyway.
Notifiers should be signals to other areas.
- Instead use these 2 functions:
ED_area_tag_redraw(area);
ED_region_tag_redraw(region);
It seems to me good convention to keep the area/region redraw tag
itself protected everywhere, for future improvements.
- Also added a basic WM function that checks overlapping regions,
and flushes redraws to underlying regions. This makes menus and
buttons allow to only send local region redraws.
(Brought back two "swapbuffer indicators" to test this.
- Todo: area 'action zone' redraws, and fixing other notifiers...
sending data pointers in a notifier seems to be bad idea.
void ED_region_exit(struct bContext *C, struct ARegion *ar);
void ED_region_pixelspace(const struct bContext *C, struct ARegion *ar);
void ED_region_init(struct bContext *C, struct ARegion *ar);
+void ED_region_tag_redraw(struct ARegion *ar);
/* spaces */
void ED_spacetypes_init(void);
void ED_area_exit(struct bContext *C, struct ScrArea *sa);
void ED_area_do_draw(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
+void ED_area_tag_redraw(ScrArea *sa);
/* screens */
void ED_screens_initialize(struct wmWindowManager *wm);
/* ------ Define for UI_view2d_sync ----- */
-/* means copy it from the other v2d */
+/* means copy it from another v2d */
+#define V2D_LOCK_SET 0
+/* means copy it to the other v2ds */
#define V2D_LOCK_COPY 1
#include "BKE_texture.h"
#include "BKE_utildefines.h"
+#include "ED_screen.h"
+
#include "UI_interface.h"
#include "UI_text.h"
#include "interface.h"
}
if(changed || (retval == WM_UI_HANDLER_BREAK))
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
if(retval == WM_UI_HANDLER_BREAK) {
ui_check_but(but);
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
}
if(data->interactive) ui_apply_button(C, block, but, data, 1);
else ui_check_but(but);
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
/* ****************** menu opening for various types **************** */
}
data->state= state;
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
}
static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type)
but->flag &= ~(UI_ACTIVE|UI_SELECT);
/* redraw */
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
/* adds empty mousemove in queue for re-init handler, in case mouse is
* still over a button. we cannot just check for this ourselfs because
if(!data->tooltip) {
data->tooltip= ui_tooltip_create(C, data->region, but);
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
}
/* handle menu auto open timer */
if(!(but->flag & UI_SELECT)) {
but->flag |= UI_SELECT;
data->cancel= 0;
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
}
else {
if(but->flag & UI_SELECT) {
but->flag &= ~UI_SELECT;
data->cancel= 1;
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(data->region);
}
}
break;
ED_region_init(C, ar);
/* notify change and redraw */
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(ar);
return ar;
}
wm_subwindow_getmatrix(C->window, ar->swinid, block->winmat);
/* notify change and redraw */
- WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+ ED_region_tag_redraw(ar);
return handle;
}
if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
}
-
+/* called by notifier WM_NOTE_TIMELINE_SYNC */
void UI_view2d_sync(View2D *v2d, View2D *v2dfrom, int flag)
{
#include "BIF_gl.h"
+#include "ED_screen.h"
+
#include "UI_resources.h"
#include "UI_view2d.h"
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
if(v2d->flag & V2D_VIEWSYNC_X)
WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_COPY, v2d);
}
/* generic notes first */
switch(note->type) {
case WM_NOTE_WINDOW_REDRAW:
- case WM_NOTE_AREA_REDRAW:
- case WM_NOTE_REGION_REDRAW:
case WM_NOTE_GESTURE_REDRAW:
case WM_NOTE_SCREEN_CHANGED:
- ar->do_draw= 1;
+ ED_region_tag_redraw(ar);
break;
default:
if(ar->type->listener)
ar->do_draw= 0;
}
+/* **********************************
+ maybe silly, but let's try for now
+ to keep do_draw tags protected
+ ********************************** */
+
+void ED_region_tag_redraw(ARegion *ar)
+{
+ ar->do_draw= 1;
+}
+
+void ED_area_tag_redraw(ScrArea *sa)
+{
+ ARegion *ar;
+
+ for(ar= sa->regionbase.first; ar; ar= ar->next)
+ ar->do_draw= 1;
+}
+
+
+
/* *************************************************************** */
/* dir is direction to check, not the splitting edge direction! */
/* *********** Space switching code, local now *********** */
/* XXX make operator for this */
-static void newspace(bContext *C, ScrArea *sa, int type)
+static void area_newspace(bContext *C, ScrArea *sa, int type)
{
if(sa->spacetype != type) {
SpaceType *st;
slold->regionbase= sa->regionbase;
sa->regionbase= sl->regionbase;
sl->regionbase.first= sl->regionbase.last= NULL;
-
- ED_area_initialize(C->wm, C->window, sa);
}
}
+ ED_area_initialize(C->wm, C->window, sa);
+
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
}
static void spacefunc(struct bContext *C, void *arg1, void *arg2)
{
- newspace(C, C->area, C->area->butspacetype);
- WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+ area_newspace(C, C->area, C->area->butspacetype);
+ ED_area_tag_redraw(C->area);
}
/* returns offset for next button in header */
}
}
-
+/* only for edge lines between areas, and the blended join arrows */
void ED_screen_draw(wmWindow *win)
{
ScrArea *sa;
}
}
+
+/* *********** exit calls are for closing running stuff ******** */
+
void ED_region_exit(bContext *C, ARegion *ar)
{
ARegion *prevar= C->region;
if(do_draw) {
for(ar= sa->regionbase.first; ar; ar= ar->next)
if(ar->regiontype==RGN_TYPE_HEADER)
- ar->do_draw= 1; /* XXX */
+ ED_region_tag_redraw(ar);
}
}
}
/* draw entirely, view changes should be handled here */
// SpaceButs *sbuts= C->area->spacedata.first;
View2D *v2d= &ar->v2d;
- float col[3];
+ float col[3], fac;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
UI_view2d_view_ortho(C, v2d);
+ /* swapbuffers indicator */
+ fac= BLI_frand();
+ glColor3f(fac, fac, fac);
+ glRecti(20, 2, 30, 12);
+
/* data... */
ed_marker_move_apply(C, op);
ed_marker_move_exit(C, op);
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
}
case RIGHTMOUSE:
if(WM_modal_tweak_check(evt, mm->event_type)) {
ed_marker_move_exit(C, op);
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return OPERATOR_FINISHED;
}
}
}
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
// headerprint(str); XXX
}
}
select_timeline_marker_frame(cfra, 0);
/* XXX notifier for markers... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return OPERATOR_PASS_THROUGH;
}
}
/* XXX notifier for markers... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return 1;
}
}
/* XXX notifier for markers... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return OPERATOR_FINISHED;
}
/* XXX notifier for markers... */
if(changed)
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return OPERATOR_FINISHED;
}
switch(wmn->type) {
case WM_NOTE_TIMELINE_SYNC:
if(ar->v2d.flag & V2D_VIEWSYNC_X) {
- ar->do_draw= 1; /* XXX GAH! */
+ ED_region_tag_redraw(ar);
UI_view2d_sync(&ar->v2d, wmn->data, wmn->value);
}
break;
v2d->cur.xmin=v2d->tot.xmin= (float)first-2;
v2d->cur.xmax=v2d->tot.xmax= (float)C->scene->r.efra+2;
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
}
break;
case 4: /* Maximize Window */
break;
case 5: /* show time or frames */
stime->flag ^= TIME_DRAWFRAMES;
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
break;
case 6:
//nextprev_marker(1);
if(v2d) {
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? */
+ WM_event_add_notifier(C, WM_NOTE_TIMELINE_SYNC, V2D_LOCK_SET, v2d);
}
break;
case 12: /* only show keyframes from selected data */
stime->flag ^= TIME_ONLYACTSEL;
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
break;
}
}
static void view3d_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
- float col[3];
+ float col[3], fac;
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
+ /* swapbuffers indicator */
+ fac= BLI_frand();
+ glColor3f(fac, fac, fac);
+ glRecti(20, 2, 30, 12);
}
enum {
WM_NOTE_WINDOW_REDRAW,
WM_NOTE_SCREEN_CHANGED,
- WM_NOTE_AREA_REDRAW,
- WM_NOTE_REGION_REDRAW,
WM_NOTE_GESTURE_REDRAW,
WM_NOTE_TIMELINE_SYNC,
/* catch local notifications here */
switch (type) {
- case WM_NOTE_AREA_REDRAW:
- case WM_NOTE_REGION_REDRAW:
case WM_NOTE_GESTURE_REDRAW:
if(C->region)
note->swinid= C->region->swinid;
}
}
+static void wm_flush_draw_updates(bScreen *screen, rcti *dirty)
+{
+ ScrArea *sa;
+ ARegion *ar;
+
+ for(sa= screen->areabase.first; sa; sa= sa->next) {
+ for(ar=sa->regionbase.first; ar; ar= ar->next) {
+ if( BLI_isect_rcti(dirty, &ar->winrct, NULL) )
+ ar->do_draw= 1;
+ }
+ }
+}
+
/* quick test to prevent changing window drawable */
static int wm_draw_update_test_window(wmWindow *win)
{
ScrArea *sa;
ARegion *ar;
+ /* flush */
+ for(ar=win->screen->regionbase.first; ar; ar= ar->next) {
+ if(ar->swinid && ar->do_draw) {
+ wm_flush_draw_updates(win->screen, &ar->winrct);
+ }
+ }
+
if(win->screen->do_refresh)
return 1;
if(win->screen->do_draw)
return 1;
if(win->screen->do_gesture)
return 1;
-
- for(ar=win->screen->regionbase.first; ar; ar= ar->next) {
- if(ar->swinid && ar->do_draw)
- return 1;
- }
-
+
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
for(ar=sa->regionbase.first; ar; ar= ar->next) {
if(ar->swinid && ar->do_draw)
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
}
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
op->customdata= NULL;
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
}