diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-02-13 21:49:26 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-02-19 19:22:01 +0400 |
commit | eb7485389b8ae29c0f56c942e800722fe25ebebe (patch) | |
tree | 0c4f71c85a75647f1a7d1ca084a1cd4295f88288 /source/blender/editors | |
parent | 6b1a4fc66ef4e3197601318ce4c36db2c8359b98 (diff) |
Use tabs for image editor.
For initial discussion see T38371
This commit organized panels for image editor to new tab categories dependent
on the image editor mode:
View Mode:
Tools - contains UV tools (currently only transform and UV Sculpting)
Scopes - contains scopes
Grease Pencil - contains Grease Pencil operators
Paint Mode:
Tools - contains brush options
Scopes - as above
Grease Pencil - as above
Mask Mode
Mask - contains mask tools
Scopes - as above
Grease Pencil - as above
Grease Pencil panel/tab now includes operators, not view options which have been
moved to the UI region on the right.
To make this work better, image editor toolbar now is of type TOOLS instead
of PREVIEW as was the case previously. A nice version patch makes sure all
works predictably, but opening newer files with older blender executables
could backfire.
This commit does not address which UV Tools will be included in the
Tools tab for the view mode, but does include some basic tools (transform)
and provides a class to inherit from to avoid conflicts with UV Sculpting.
Reviewers: brecht, dingto, sergey
Differential Revision: https://developer.blender.org/D315
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 56 |
3 files changed, 41 insertions, 33 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 6b0f4a0615c..21f54a86df4 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -948,6 +948,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser void image_buttons_register(ARegionType *art) { PanelType *pt; + const char *category = "Grease Pencil"; pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil"); strcpy(pt->idname, "IMAGE_PT_gpencil"); @@ -955,6 +956,7 @@ void image_buttons_register(ARegionType *art) strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw_header = gpencil_panel_standard_header; pt->draw = gpencil_panel_standard; + BLI_strncpy(pt->category, category, BLI_strlen_utf8(category)); BLI_addtail(&art->paneltypes, pt); } @@ -985,7 +987,7 @@ void IMAGE_OT_properties(wmOperatorType *ot) static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); - ARegion *ar = image_has_scope_region(sa); + ARegion *ar = image_has_tools_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -993,12 +995,12 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void IMAGE_OT_scopes(wmOperatorType *ot) +void IMAGE_OT_toolshelf(wmOperatorType *ot) { - ot->name = "Scopes"; - ot->idname = "IMAGE_OT_scopes"; - ot->description = "Toggle display scopes panel"; - + ot->name = "Tool Shelf"; + ot->idname = "IMAGE_OT_toolshelf"; + ot->description = "Toggles tool shelf display"; + ot->exec = image_scopes_toggle_exec; ot->poll = ED_operator_image_active; diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 5184b1e1a73..f1a20f39c7c 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -47,7 +47,7 @@ struct bNodeTree; /* space_image.c */ struct ARegion *image_has_buttons_region(struct ScrArea *sa); -struct ARegion *image_has_scope_region(struct ScrArea *sa); +struct ARegion *image_has_tools_region(struct ScrArea *sa); extern const char *image_context_dir[]; /* doc access */ @@ -91,7 +91,7 @@ void IMAGE_OT_curves_point_set(struct wmOperatorType *ot); struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree); void image_buttons_register(struct ARegionType *art); void IMAGE_OT_properties(struct wmOperatorType *ot); -void IMAGE_OT_scopes(struct wmOperatorType *ot); +void IMAGE_OT_toolshelf(struct wmOperatorType *ot); #endif /* __IMAGE_INTERN_H__ */ diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 2197226beb2..e857583924e 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -69,6 +69,7 @@ #include "WM_types.h" #include "UI_resources.h" +#include "UI_interface.h" #include "UI_view2d.h" #include "image_intern.h" @@ -82,7 +83,7 @@ static void image_scopes_tag_refresh(ScrArea *sa) /* only while histogram is visible */ for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN) + if (ar->regiontype == RGN_TYPE_TOOLS && ar->flag & RGN_FLAG_HIDDEN) return; } @@ -116,11 +117,11 @@ ARegion *image_has_buttons_region(ScrArea *sa) return arnew; } -ARegion *image_has_scope_region(ScrArea *sa) +ARegion *image_has_tools_region(ScrArea *sa) { ARegion *ar, *arnew; - ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); if (ar) return ar; /* add subdiv level; after buttons */ @@ -132,7 +133,7 @@ ARegion *image_has_scope_region(ScrArea *sa) arnew = MEM_callocN(sizeof(ARegion), "scopes for image"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype = RGN_TYPE_PREVIEW; + arnew->regiontype = RGN_TYPE_TOOLS; arnew->alignment = RGN_ALIGN_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -177,11 +178,11 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - /* scopes */ + /* scopes/uv sculpt/paint */ ar = MEM_callocN(sizeof(ARegion), "buttons for image"); BLI_addtail(&simage->regionbase, ar); - ar->regiontype = RGN_TYPE_PREVIEW; + ar->regiontype = RGN_TYPE_TOOLS; ar->alignment = RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; @@ -255,7 +256,7 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_curves_point_set); WM_operatortype_append(IMAGE_OT_properties); - WM_operatortype_append(IMAGE_OT_scopes); + WM_operatortype_append(IMAGE_OT_toolshelf); } static void image_keymap(struct wmKeyConfig *keyconf) @@ -270,7 +271,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_scopes", TKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", TRUE); @@ -808,7 +809,7 @@ static void image_buttons_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) /* *********************** scopes region ************************ */ /* add handlers, stuff you only do once or on area/region changes */ -static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) +static void image_tools_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; @@ -819,28 +820,33 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); } -static void image_scope_area_draw(const bContext *C, ARegion *ar) +static void image_tools_area_draw(const bContext *C, ARegion *ar) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); void *lock; ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); - - if (ibuf) { - if (!sima->scopes.ok) { - BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); + /* XXX performance regression if name of scopes category changes! */ + PanelCategoryStack *category = UI_panel_category_active_find(ar, "Scopes"); + + /* only update scopes if scope category is active */ + if (category) { + if (ibuf) { + if (!sima->scopes.ok) { + BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); + } + if (sima->image->flag & IMA_VIEW_AS_RENDER) + scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); + else + scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); } - if (sima->image->flag & IMA_VIEW_AS_RENDER) - scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); - else - scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); } ED_space_image_release_buffer(sima, ibuf, lock); ED_region_panels(C, ar, 1, NULL, -1); } -static void image_scope_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void image_tools_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { @@ -942,17 +948,17 @@ void ED_spacetype_image(void) art->draw = image_buttons_area_draw; BLI_addhead(&st->regiontypes, art); - image_buttons_register(art); ED_uvedit_buttons_register(art); - + image_buttons_register(art); + /* regions: statistics/scope buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); - art->regionid = RGN_TYPE_PREVIEW; + art->regionid = RGN_TYPE_TOOLS; art->prefsizex = 220; // XXX art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; - art->listener = image_scope_area_listener; - art->init = image_scope_area_init; - art->draw = image_scope_area_draw; + art->listener = image_tools_area_listener; + art->init = image_tools_area_init; + art->draw = image_tools_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: header */ |