2.5
authorTon Roosendaal <ton@blender.org>
Tue, 16 Dec 2008 18:42:12 +0000 (18:42 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 16 Dec 2008 18:42:12 +0000 (18:42 +0000)
More notifier and redraw cleanup

- notifiers are not filtered anymore, apart from window/screen notifiers,
  they get to all regions.
- fixed drawing of 'action zones' in areas.
- added support for basic multilayer draw, like for action zones now,
  and future other area decorations (tabs, region handlers)
  check: ED_area_overdraw_flush()
         ED_area_overdraw()
- bugfix in UI redraw tags, it was calling region pointer in free'd
  data
- added notifier for marker-changed
- added keymap for markers to ipo window

source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_screen_types.h
source/blender/editors/interface/interface_handlers.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/space_ipo/space_ipo.c
source/blender/editors/space_time/ed_markers.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_time/time_ops.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c

index 3028a1f0ad6ab5f093fcdc1be0bd2903cab9d6b7..7b4dd41e4a8a9c774b6c5b4a1bf5c8e3e6375954 100644 (file)
@@ -54,11 +54,13 @@ void        ED_spacetypes_init(void);
 void   ED_spacetypes_keymap(struct wmWindowManager *wm);
 struct ARegionType *ED_regiontype_from_id(struct SpaceType *st, int regionid);
 int            ED_area_header_standardbuttons(const bContext *C, struct uiBlock *block, int yco);
+void   ED_area_overdraw(struct bContext *C);
+void   ED_area_overdraw_flush(struct bContext *C);
+
 
 /* areas */
 void   ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
 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);
 
index 29e62d51f7d86adeace108d8a7593db70fe07fad..7910351f318fe5384079344a04c9b0fed9455372 100644 (file)
@@ -32,7 +32,8 @@
 typedef struct AZone {
        struct AZone *next, *prev;
        int type;
-       int flag;
+       short flag;
+       short do_draw;
        int pos;
        short x1, y1, x2, y2;
 } AZone;
@@ -41,6 +42,8 @@ typedef struct AZone {
 #define        AZONE_TRI                       1
 #define AZONE_QUAD                     2
 
+/* actionzone flag */
+
 /* actionzone pos */
 #define AZONE_S                                1
 #define AZONE_SW                       2
index 6de197f5cac1c6b7b64539d318fdefbafbc9359b..761e0ff071264df64b4d1f27c320c3cb6a4a39b2 100644 (file)
@@ -2880,14 +2880,14 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
        if(data->origstr)
                MEM_freeN(data->origstr);
 
+       /* redraw (data is but->active!) */
+       ED_region_tag_redraw(data->region);
+       
        /* clean up button */
        MEM_freeN(but->active);
        but->active= NULL;
        but->flag &= ~(UI_ACTIVE|UI_SELECT);
 
-       /* redraw */
-       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
         * at this point the mouse may be over a button in another region */
index 3e44566e5932a4c9ca776400228ec2e1027ec0a8..5fe8d5e315cd5a7d68ad9bbfa8a1e65877ce73f0 100644 (file)
@@ -104,7 +104,6 @@ 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:
@@ -118,24 +117,54 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note)
        }
 }
 
-/* only internal decoration, AZone for now */
-void ED_area_do_draw(bContext *C, ScrArea *sa)
+/* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
+void ED_area_overdraw_flush(bContext *C)
 {
-       AZone *az;
+       ScrArea *sa;
+       
+       for(sa= C->screen->areabase.first; sa; sa= sa->next) {
+               ARegion *ar;
+               
+               for(ar= sa->regionbase.first; ar; ar= ar->next) {
+                       if(ar->do_draw) {
+                               AZone *az;
+                               
+                               for(az= sa->actionzones.first; az; az= az->next) {
+                                       int xs= (az->x1+az->x2)/2, ys= (az->y1+az->y2)/2;
+               
+                                       /* test if inside */
+                                       if(BLI_in_rcti(&ar->winrct, xs, ys)) {
+                                               az->do_draw= 1;
+                                       }
+                               }
+                       }
+               }
+       }       
+}
+
+void ED_area_overdraw(bContext *C)
+{
+       ScrArea *sa;
        
-       /* hrmf, screenspace for zones */
+       /* Draw AZones, in screenspace */
        wm_subwindow_set(C->window, C->window->screen->mainwin);
+
+       glEnable( GL_BLEND );
+       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        
-       /* temporary viz for 'action corner' */
-       for(az= sa->actionzones.first; az; az= az->next) {
-               
-               glEnable( GL_BLEND );
-               glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
-               glColor4ub(0, 0, 0, 80);
-               if(az->type==AZONE_TRI) sdrawtrifill(az->x1, az->y1, az->x2, az->y2);
-               //if(az->type==AZONE_TRI) sdrawtri(az->x1, az->y1, az->x2, az->y2);
-               glDisable( GL_BLEND );
-       }
+       for(sa= C->screen->areabase.first; sa; sa= sa->next) {
+               AZone *az;
+               for(az= sa->actionzones.first; az; az= az->next) {
+                       if(az->do_draw) {
+                               if(az->type==AZONE_TRI) {
+                                       glColor4ub(0, 0, 0, 70);
+                                       sdrawtrifill(az->x1, az->y1, az->x2, az->y2);
+                               }
+                               az->do_draw= 0;
+                       }
+               }
+       }       
+       glDisable( GL_BLEND );
        
 }
 
@@ -180,15 +209,17 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
 
 void ED_region_tag_redraw(ARegion *ar)
 {
-       ar->do_draw= 1;
+       if(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;
+       if(sa)
+               for(ar= sa->regionbase.first; ar; ar= ar->next)
+                       ar->do_draw= 1;
 }
 
 
@@ -328,6 +359,7 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
        sa->winy= sa->totrct.ymax-sa->totrct.ymin+1;
 }
 
+
 #define AZONESPOT              12
 void area_azone_initialize(ScrArea *sa) 
 {
index 0be29fc53c005103eb1454e016da4779cdbce23a..f4739a218d6c46f95c1581c75a5ee11c109ee9ac 100644 (file)
@@ -103,7 +103,8 @@ void sdrawline(short x1, short y1, short x2, short y2)
 
 */
 
-static void sdrawtripoints(short x1, short y1, short x2, short y2){
+static void sdrawtripoints(short x1, short y1, short x2, short y2)
+{
        short v[2];
        v[0]= x1; v[1]= y1;
        glVertex2sv(v);
index 0afe38ea4700f0c9a8846c851c8c08a00c91bbcf..3395af35cd2a409c9badb4840ca9ec48e6431e30 100644 (file)
@@ -293,6 +293,12 @@ static void ipo_header_area_draw(const bContext *C, ARegion *ar)
 static void ipo_main_area_listener(ARegion *ar, wmNotifier *wmn)
 {
        /* context changes */
+       switch(wmn->type) {
+               
+               case WM_NOTE_MARKERS_CHANGED:
+                       ED_region_tag_redraw(ar);
+                       break;
+       }
 }
 
 /* only called once, from space/spacetypes.c */
@@ -316,7 +322,7 @@ void ED_spacetype_ipo(void)
        art->init= ipo_main_area_init;
        art->draw= ipo_main_area_draw;
        art->listener= ipo_main_area_listener;
-       art->keymapflag= ED_KEYMAP_VIEW2D;
+       art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS;
 
        BLI_addhead(&st->regiontypes, art);
        
index 43b2601d2fa9a26ccfe64c029184c453a399171b..0dc68fb4b275960ee3ac170b2914d0cbb8a5ba50 100644 (file)
@@ -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);     
        
-       ED_area_tag_redraw(C->area);
+       WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
 }
 
 
@@ -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);
-                               ED_area_tag_redraw(C->area);
+                               WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
                                return OPERATOR_FINISHED;
                        }
                        
@@ -451,7 +451,7 @@ XXX                                 else if (mm->slink->spacetype == SPACE_ACTION) {
                                        }
                                }
                                
-                               ED_area_tag_redraw(C->area);
+                               WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
                                // headerprint(str); XXX
                        }
        }
@@ -618,8 +618,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend)
        else
                select_timeline_marker_frame(cfra, 0);
        
-       /* XXX notifier for markers... */
-       ED_area_tag_redraw(C->area);
+       WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
 
        return OPERATOR_PASS_THROUGH;
 }
@@ -712,8 +711,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
                }
        }
        
-       /* XXX notifier for markers... */
-       ED_area_tag_redraw(C->area);
+       WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
 
        return 1;
 }
@@ -766,8 +764,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
                        marker->flag &= ~SELECT;
        }
        
-       /* XXX notifier for markers... */
-       ED_area_tag_redraw(C->area);
+       WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
 
        return OPERATOR_FINISHED;
 }
@@ -813,10 +810,9 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op)
                }
        }
        
-       /* XXX notifier for markers... */
-       if(changed)
-               ED_area_tag_redraw(C->area);
-
+       if(changed) {
+               WM_event_add_notifier(C, WM_NOTE_MARKERS_CHANGED, 0, NULL);
+       }
        return OPERATOR_FINISHED;
 }
 
index c5d5c088d7e3fcbd4cf85e4d8f5e4e955202db5a..a472c2d2717fd6305fcb850fe2d38aaf4c2602ad 100644 (file)
@@ -162,8 +162,11 @@ 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_MARKERS_CHANGED:
+                       ED_region_tag_redraw(ar);
+                       break;
        }
 }
 
index bc0ed1634dae6417ebdcce196a6f78ba68246d0f..c95e7fd7e9db6c8a366407eb699c4f74c9c29cb0 100644 (file)
@@ -218,8 +218,8 @@ void time_keymap(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "ED_TIME_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "ED_TIME_OT_toggle_time", TKEY, KM_PRESS, 0, 0);
        
-
        /* markers (XXX move to function?) */
+       keymap= WM_keymap_listbase(wm, "Markers", 0, 0);
        WM_keymap_verify_item(keymap, "ED_MARKER_OT_add", MKEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "ED_MARKER_OT_move", EVT_TWEAK_R, KM_ANY, 0, 0);
        WM_keymap_verify_item(keymap, "ED_MARKER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
index 5a148ef9a4fea2a2822d638d610e96d9ca6849f9..b85a83931bf38f6b34c98c4f185cf383c1dba189 100644 (file)
@@ -121,9 +121,8 @@ enum {
        WM_NOTE_WINDOW_REDRAW,
        WM_NOTE_SCREEN_CHANGED,
        WM_NOTE_GESTURE_REDRAW,
-       
+       WM_NOTE_MARKERS_CHANGED,
        WM_NOTE_OBJECT_CHANGED,
-       
        WM_NOTE_LAST
 };
 
index 710e7a5a4cc797d031c1b80499b293cd967558e0..7bfda3437a9a3ba7cfe9424e5c577d878ec2c41f 100644 (file)
@@ -101,15 +101,8 @@ void WM_event_add_notifier(bContext *C, int type, int value, void *data)
        BLI_addtail(&C->wm->queue, note);
        
        note->window= C->window;
-
-       /* catch local notifications here */
-       switch (type) {
-               case WM_NOTE_GESTURE_REDRAW:
-                       if(C->region) 
-                               note->swinid= C->region->swinid;
-               break;
-       }
-       
+       if(C->region)
+               note->swinid= C->region->swinid;
        note->type= type;
        note->value= value;
        note->data= data;
@@ -136,7 +129,7 @@ void wm_event_do_notifiers(bContext *C)
                        ARegion *ar;
 
                        C->window= win;
-                       C->screen= win->screen;
+                       C->screen= win->screen; /* XXX context in notifiers? */
                        
                        if(note->window && note->window!=win)
                                continue;
@@ -147,27 +140,13 @@ void wm_event_do_notifiers(bContext *C)
                        ED_screen_do_listen(win, note);
 
                        for(ar=win->screen->regionbase.first; ar; ar= ar->next) {
-                               if(note->swinid && note->swinid!=ar->swinid)
-                                       continue;
-
-                               C->region= ar;
                                ED_region_do_listen(ar, note);
-                               C->region= NULL;
                        }
                        
                        for(sa= win->screen->areabase.first; sa; sa= sa->next) {
-                               C->area= sa;
-
                                for(ar=sa->regionbase.first; ar; ar= ar->next) {
-                                       if(note->swinid && note->swinid!=ar->swinid)
-                                               continue;
-
-                                       C->region= ar;
                                        ED_region_do_listen(ar, note);
-                                       C->region= NULL;
                                }
-
-                               C->area= NULL;
                        }
 
                        C->window= NULL;
@@ -178,7 +157,8 @@ void wm_event_do_notifiers(bContext *C)
        }       
 }
 
-static void wm_flush_draw_updates(bScreen *screen, rcti *dirty)
+/* mark regions to redraw if overlapped with rect */
+static void wm_flush_regions(bScreen *screen, rcti *dirty)
 {
        ScrArea *sa;
        ARegion *ar;
@@ -191,19 +171,28 @@ static void wm_flush_draw_updates(bScreen *screen, rcti *dirty)
        }
 }
 
-/* quick test to prevent changing window drawable */
-static int wm_draw_update_test_window(wmWindow *win)
+/* all the overlay management, menus, actionzones, region tabs, etc */
+static void wm_flush_draw_update(bContext *C)
 {
-       ScrArea *sa;
        ARegion *ar;
        
-       /* flush */
-       for(ar=win->screen->regionbase.first; ar; ar= ar->next) {
+       /* flush redraws of screen regions (menus) down */
+       for(ar= C->screen->regionbase.first; ar; ar= ar->next) {
                if(ar->swinid && ar->do_draw) {
-                       wm_flush_draw_updates(win->screen, &ar->winrct);
+                       wm_flush_regions(C->screen, &ar->winrct);
                }
        }
+       
+       /* sets redraws for Azones, future region tabs, etc */
+       ED_area_overdraw_flush(C);
+}
 
+/* quick test to prevent changing window drawable */
+static int wm_draw_update_test_window(wmWindow *win)
+{
+       ScrArea *sa;
+       ARegion *ar;
+       
        if(win->screen->do_refresh)
                return 1;
        if(win->screen->do_draw)
@@ -211,12 +200,15 @@ static int wm_draw_update_test_window(wmWindow *win)
        if(win->screen->do_gesture)
                return 1;
        
-       for(sa= win->screen->areabase.first; sa; sa= sa->next) {
-               for(ar=sa->regionbase.first; ar; ar= ar->next) {
+       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)
                                return 1;
-               }
-       }
+
        return 0;
 }
 
@@ -238,25 +230,22 @@ void wm_draw_update(bContext *C)
                        /* notifiers for screen redraw */
                        if(win->screen->do_refresh)
                                ED_screen_refresh(C->wm, win);
+                       
+                       /* flush draw updates for multiple layers */
+                       wm_flush_draw_update(C);
 
                        for(sa= win->screen->areabase.first; sa; sa= sa->next) {
-                               int area_do_draw= 0;
                                
                                C->area= sa;
                                
                                for(ar=sa->regionbase.first; ar; ar= ar->next) {
                                        C->region= ar;
                                        
-                                       if(ar->swinid && ar->do_draw) {
+                                       if(ar->swinid && ar->do_draw)
                                                ED_region_do_draw(C, ar);
-                                               area_do_draw= 1;
-                                       }
                                        
                                        C->region= NULL;
                                }
-                               /* only internal decoration, like AZone */
-                               if(area_do_draw)
-                                       ED_area_do_draw(C, sa);
                                
                                C->area = NULL;
                        }
@@ -264,6 +253,8 @@ void wm_draw_update(bContext *C)
                        /* move this here so we can do area 'overlay' drawing */
                        if(win->screen->do_draw)
                                ED_screen_draw(win);
+                       
+                       ED_area_overdraw(C);
 
                        /* regions are menus here */
                        for(ar=win->screen->regionbase.first; ar; ar= ar->next) {