diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 09:27:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-20 09:27:31 +0400 |
commit | 170716ca533b250ffa9ae031096bbef9ad7c2976 (patch) | |
tree | 3c20404f22073aab79dc6ff5e9e08cd2f841d951 /source | |
parent | 984d2e42e4a81c1f92dc405ce1b265842bc94b9a (diff) |
use BKE_area_find_region_type in place of inline loops (no functional changes).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 12 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_logic/space_logic.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_nla/space_nla.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/space_sequencer.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_header.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_time/space_time.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 16 |
16 files changed, 84 insertions, 144 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 84cf5af5414..eb522a1d2b8 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -44,6 +44,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_screen.h" #include "BKE_global.h" @@ -1959,17 +1960,14 @@ View2D *UI_view2d_fromcontext(const bContext *C) /* same as above, but it returns regionwindow. Utility for pulldowns or buttons */ View2D *UI_view2d_fromcontext_rwin(const bContext *C) { - ScrArea *area= CTX_wm_area(C); + ScrArea *sa= CTX_wm_area(C); ARegion *region= CTX_wm_region(C); - if (area == NULL) return NULL; + if (sa == NULL) return NULL; if (region == NULL) return NULL; if (region->regiontype!=RGN_TYPE_WINDOW) { - ARegion *ar= area->regionbase.first; - for(; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) - return &(ar->v2d); - return NULL; + ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + return ar ? &(ar->v2d) : NULL; } return &(region->v2d); } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 1882d849116..a1a4f33d008 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -873,12 +873,10 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand if(sa->spacetype!=SPACE_TIME) { ARegion *ar; static rcti rect= {0, 10000, 0, 30}; /* same local check for all areas */ - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype == RGN_TYPE_WINDOW) - break; - if(ar) + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if(ar) { WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); + } } else WM_event_add_keymap_handler(handlers, keymap); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 02fae52219b..415aa05690a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2616,13 +2616,8 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) */ if((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) { ScrArea *sa= CTX_wm_area(C); - - /* loop over all regions until a matching one is found */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype == RGN_TYPE_HEADER) - break; - } - + ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* don't do anything if no region */ if(ar == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 554d2e36ccf..883b476f372 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -71,17 +71,12 @@ ARegion *graph_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_UI) - return ar; - } - + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; + /* add subdiv level; after main */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) - break; - } - + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + /* is error! */ if (ar==NULL) return NULL; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 409ab4b2fc6..2e9544f5d20 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -328,16 +328,13 @@ static void image_scopes_tag_refresh(ScrArea *sa) ARegion *image_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; @@ -355,16 +352,13 @@ ARegion *image_has_buttons_region(ScrArea *sa) ARegion *image_has_scope_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_PREVIEW) - return ar; - + + ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + if(ar) return ar; + /* add subdiv level; after buttons */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + /* is error! */ if(ar==NULL) return NULL; diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 7944f0737e1..f420d0ef690 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -63,16 +63,13 @@ ARegion *logic_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 90f9996e392..f2e0abe1e60 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -69,18 +69,13 @@ ARegion *nla_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_UI) - return ar; - } - + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; + /* add subdiv level; after main */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) - break; - } - + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + /* is error! */ if (ar==NULL) return NULL; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 1c2f604a650..96ce19b7601 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -70,16 +70,13 @@ ARegion *node_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 32bd9ce604c..d1df9699fa3 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -66,16 +66,13 @@ ARegion *sequencer_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index bfc600c774a..165cec238c0 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -55,6 +55,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_screen.h" #include "ED_screen.h" @@ -78,16 +79,13 @@ static ARegion *text_has_properties_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index ca9d786c4de..e55fbe11e52 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -367,15 +367,11 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) { - SpaceTime *stime = (SpaceTime *)sa->spacedata.first; - ARegion *ar; - /* find the main timeline region and refresh cache display*/ - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - time_cache_refresh(stime); - break; - } + ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if(ar) { + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; + time_cache_refresh(stime); } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b26883b8fd6..fb67e38cbf7 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -70,16 +70,13 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_UI) - return ar; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + if(ar) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) - break; - + ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + /* is error! */ if(ar==NULL) return NULL; @@ -147,10 +144,10 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) if(rv3d==NULL) { ScrArea *sa =CTX_wm_area(C); if(sa && sa->spacetype==SPACE_VIEW3D) { - ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) - return ar->regiondata; + ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if(ar) { + rv3d= ar->regiondata; + } } } return rv3d; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 804cea57195..1059ad2b19f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2561,16 +2561,10 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } if(v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */ - ARegion *ar_iter; - ScrArea *sa= CTX_wm_area(C); - /* find header and force tag redraw */ - for(ar_iter= sa->regionbase.first; ar_iter; ar_iter= ar_iter->next) - if(ar_iter->regiontype==RGN_TYPE_HEADER) { - ED_region_tag_redraw(ar_iter); - break; - } - + ScrArea *sa= CTX_wm_area(C); + ARegion *ar_header= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ED_region_tag_redraw(ar_header); /* can be NULL */ v3d->lay_used= lay_used; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6b6071c4912..5d45a63b05b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -110,6 +110,7 @@ EnumPropertyItem viewport_shade_items[] = { #include "BLI_math.h" +#include "BKE_screen.h" #include "BKE_animsys.h" #include "BKE_brush.h" #include "BKE_colortools.h" @@ -509,17 +510,12 @@ static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values) values[0] = values[1] = 1; - sa = rna_area_from_space(ptr); - if(!sa) return; - /* find aregion */ - for(ar=sa->regionbase.first; ar; ar=ar->next) { - if(ar->regiontype == RGN_TYPE_WINDOW) - break; + sa= rna_area_from_space(ptr); /* can be NULL */ + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if(ar) { + ED_space_image_zoom(sima, ar, &values[0], &values[1]); } - if(!ar) return; - - ED_space_image_zoom(sima, ar, &values[0], &values[1]); } static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index b09e264bd1d..2e4148ca51d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -48,6 +48,7 @@ #include "BKE_blender.h" #include "BKE_context.h" +#include "BKE_screen.h" #include "BKE_curve.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" @@ -247,15 +248,7 @@ int WM_init_game(bContext *C) CTX_wm_window_set(C, win); sa = biggest_view3d(C); - - if(sa) - { - for(ar=sa->regionbase.first; ar; ar=ar->next) { - if(ar->regiontype == RGN_TYPE_WINDOW) { - break; - } - } - } + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); // if we have a valid 3D view if (sa && ar) { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 336acd9f9bf..1720c738dd7 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -493,17 +493,17 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op } else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS)) - ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); - - if(ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + + if(ar) + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW)) - ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - - if(ar) - found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); + ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + + if(ar) + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r); } else { if(ar) |