Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-16 15:28:00 +0300
committerTon Roosendaal <ton@blender.org>2008-12-16 15:28:00 +0300
commit6fe19cfc85a75f0ec6bb46a70fc9c849108b41ca (patch)
tree58cb50e504afb8e2cdbe22491544079eeadf297e /source/blender/editors
parentf518fa8ea76a39078ca43eb06fbfaf5aa9ac31dc (diff)
2.5
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_screen.h2
-rw-r--r--source/blender/editors/include/UI_view2d.h4
-rw-r--r--source/blender/editors/interface/interface_handlers.c17
-rw-r--r--source/blender/editors/interface/interface_regions.c4
-rw-r--r--source/blender/editors/interface/view2d.c2
-rw-r--r--source/blender/editors/interface/view2d_ops.c10
-rw-r--r--source/blender/editors/screen/area.c34
-rw-r--r--source/blender/editors/screen/screen_edit.c7
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c7
-rw-r--r--source/blender/editors/space_time/ed_markers.c14
-rw-r--r--source/blender/editors/space_time/space_time.c2
-rw-r--r--source/blender/editors/space_time/time_header.c8
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c6
13 files changed, 77 insertions, 40 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 8be027d3400..3028a1f0ad6 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -47,6 +47,7 @@ void ED_region_do_draw(struct bContext *C, struct ARegion *ar);
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);
@@ -59,6 +60,7 @@ void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct
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);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 09d57901b0b..a60b827c44c 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -101,7 +101,9 @@ enum {
/* ------ 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
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 9c62939946e..2e44fedc66a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -47,6 +47,8 @@
#include "BKE_texture.h"
#include "BKE_utildefines.h"
+#include "ED_screen.h"
+
#include "UI_interface.h"
#include "UI_text.h"
#include "interface.h"
@@ -1272,7 +1274,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
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)
@@ -1298,7 +1300,7 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
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);
}
}
@@ -1354,7 +1356,7 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
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 **************** */
@@ -2808,7 +2810,6 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
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)
@@ -2880,7 +2881,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
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
@@ -2978,7 +2979,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
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 */
@@ -3014,14 +3015,14 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
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;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index bb1105c79af..b1f70ddebd2 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -355,7 +355,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
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;
}
@@ -671,7 +671,7 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *
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;
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index a5ec52b3d38..7798f3535ad 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1526,7 +1526,7 @@ 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 notifier WM_NOTE_TIMELINE_SYNC */
void UI_view2d_sync(View2D *v2d, View2D *v2dfrom, int flag)
{
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index b945e260fb9..da3a412c147 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -48,6 +48,8 @@
#include "BIF_gl.h"
+#include "ED_screen.h"
+
#include "UI_resources.h"
#include "UI_view2d.h"
@@ -164,7 +166,7 @@ static void view_pan_apply(bContext *C, wmOperator *op)
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);
}
@@ -493,7 +495,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
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);
}
@@ -646,7 +648,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
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);
}
@@ -1027,7 +1029,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
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);
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index dfa6e1095f5..3e44566e593 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -108,11 +108,9 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note)
/* 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)
@@ -175,6 +173,26 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
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! */
@@ -489,7 +507,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
/* *********** 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;
@@ -538,11 +556,11 @@ static void newspace(bContext *C, ScrArea *sa, int type)
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);
}
@@ -588,8 +606,8 @@ static char *windowtype_pup(void)
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 */
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index a05ee3d8450..a8cd6b7203c 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -924,7 +924,7 @@ void ED_screen_do_listen(wmWindow *win, wmNotifier *note)
}
}
-
+/* only for edge lines between areas, and the blended join arrows */
void ED_screen_draw(wmWindow *win)
{
ScrArea *sa;
@@ -1010,6 +1010,9 @@ void ED_screens_initialize(wmWindowManager *wm)
}
}
+
+/* *********** exit calls are for closing running stuff ******** */
+
void ED_region_exit(bContext *C, ARegion *ar)
{
ARegion *prevar= C->region;
@@ -1110,7 +1113,7 @@ void ED_screen_set_subwinactive(wmWindow *win, wmEvent *event)
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);
}
}
}
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 4c29d71f62a..a042e915f13 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -158,7 +158,7 @@ static void buttons_main_area_draw(const bContext *C, ARegion *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);
@@ -167,6 +167,11 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(C, v2d);
+ /* swapbuffers indicator */
+ fac= BLI_frand();
+ glColor3f(fac, fac, fac);
+ glRecti(20, 2, 30, 12);
+
/* data... */
diff --git a/source/blender/editors/space_time/ed_markers.c b/source/blender/editors/space_time/ed_markers.c
index deb56b286b4..43b2601d2fa 100644
--- a/source/blender/editors/space_time/ed_markers.c
+++ b/source/blender/editors/space_time/ed_markers.c
@@ -332,7 +332,7 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op)
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);
}
@@ -374,7 +374,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
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;
}
@@ -451,7 +451,7 @@ XXX else if (mm->slink->spacetype == SPACE_ACTION) {
}
}
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
// headerprint(str); XXX
}
}
@@ -619,7 +619,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend)
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;
}
@@ -713,7 +713,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
}
/* XXX notifier for markers... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return 1;
}
@@ -767,7 +767,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
}
/* XXX notifier for markers... */
- WM_event_add_notifier(C, WM_NOTE_AREA_REDRAW, 0, NULL);
+ ED_area_tag_redraw(C->area);
return OPERATOR_FINISHED;
}
@@ -815,7 +815,7 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op)
/* 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;
}
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 29426840653..417ddb09373 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -166,7 +166,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn)
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;
diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c
index 4f7d00005a4..65203cb7421 100644
--- a/source/blender/editors/space_time/time_header.c
+++ b/source/blender/editors/space_time/time_header.c
@@ -162,7 +162,7 @@ static void do_time_viewmenu(bContext *C, void *arg, int event)
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 */
@@ -170,7 +170,7 @@ static void do_time_viewmenu(bContext *C, void *arg, int event)
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);
@@ -191,12 +191,12 @@ static void do_time_viewmenu(bContext *C, void *arg, int event)
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;
}
}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 9ccc7afe363..d98b59ac2c6 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -188,13 +188,17 @@ void view3d_keymap(struct wmWindowManager *wm)
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);
}