Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/space_image.c
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_interface.h" | |||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "image_intern.h" | #include "image_intern.h" | ||||
| /**************************** common state *****************************/ | /**************************** common state *****************************/ | ||||
| static void image_scopes_tag_refresh(ScrArea *sa) | static void image_scopes_tag_refresh(ScrArea *sa) | ||||
| { | { | ||||
| SpaceImage *sima = (SpaceImage *)sa->spacedata.first; | SpaceImage *sima = (SpaceImage *)sa->spacedata.first; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| /* only while histogram is visible */ | /* only while histogram is visible */ | ||||
| for (ar = sa->regionbase.first; ar; ar = ar->next) { | 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; | return; | ||||
| } | } | ||||
| sima->scopes.ok = 0; | sima->scopes.ok = 0; | ||||
| } | } | ||||
| /* ******************** manage regions ********************* */ | /* ******************** manage regions ********************* */ | ||||
| Show All 21 Lines | ARegion *image_has_buttons_region(ScrArea *sa) | ||||
| return arnew; | return arnew; | ||||
| } | } | ||||
| ARegion *image_has_scope_region(ScrArea *sa) | ARegion *image_has_scope_region(ScrArea *sa) | ||||
| { | { | ||||
| ARegion *ar, *arnew; | 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; | if (ar) return ar; | ||||
| /* add subdiv level; after buttons */ | /* add subdiv level; after buttons */ | ||||
| ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); | ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); | ||||
| /* is error! */ | /* is error! */ | ||||
| if (ar == NULL) return NULL; | if (ar == NULL) return NULL; | ||||
| arnew = MEM_callocN(sizeof(ARegion), "scopes for image"); | arnew = MEM_callocN(sizeof(ARegion), "scopes for image"); | ||||
| BLI_insertlinkafter(&sa->regionbase, ar, arnew); | BLI_insertlinkafter(&sa->regionbase, ar, arnew); | ||||
| arnew->regiontype = RGN_TYPE_PREVIEW; | arnew->regiontype = RGN_TYPE_TOOLS; | ||||
| arnew->alignment = RGN_ALIGN_LEFT; | arnew->alignment = RGN_ALIGN_LEFT; | ||||
| arnew->flag = RGN_FLAG_HIDDEN; | arnew->flag = RGN_FLAG_HIDDEN; | ||||
| image_scopes_tag_refresh(sa); | image_scopes_tag_refresh(sa); | ||||
| return arnew; | return arnew; | ||||
| } | } | ||||
| Show All 28 Lines | static SpaceLink *image_new(const bContext *UNUSED(C)) | ||||
| /* buttons/list view */ | /* buttons/list view */ | ||||
| ar = MEM_callocN(sizeof(ARegion), "buttons for image"); | ar = MEM_callocN(sizeof(ARegion), "buttons for image"); | ||||
| BLI_addtail(&simage->regionbase, ar); | BLI_addtail(&simage->regionbase, ar); | ||||
| ar->regiontype = RGN_TYPE_UI; | ar->regiontype = RGN_TYPE_UI; | ||||
| ar->alignment = RGN_ALIGN_RIGHT; | ar->alignment = RGN_ALIGN_RIGHT; | ||||
| ar->flag = RGN_FLAG_HIDDEN; | ar->flag = RGN_FLAG_HIDDEN; | ||||
| /* scopes */ | /* scopes/grease pencil/uv sculpt/paint */ | ||||
| ar = MEM_callocN(sizeof(ARegion), "buttons for image"); | ar = MEM_callocN(sizeof(ARegion), "buttons for image"); | ||||
| BLI_addtail(&simage->regionbase, ar); | BLI_addtail(&simage->regionbase, ar); | ||||
| ar->regiontype = RGN_TYPE_PREVIEW; | ar->regiontype = RGN_TYPE_TOOLS; | ||||
| ar->alignment = RGN_ALIGN_LEFT; | ar->alignment = RGN_ALIGN_LEFT; | ||||
| ar->flag = RGN_FLAG_HIDDEN; | ar->flag = RGN_FLAG_HIDDEN; | ||||
| /* main area */ | /* main area */ | ||||
| ar = MEM_callocN(sizeof(ARegion), "main area for image"); | ar = MEM_callocN(sizeof(ARegion), "main area for image"); | ||||
| BLI_addtail(&simage->regionbase, ar); | BLI_addtail(&simage->regionbase, ar); | ||||
| ar->regiontype = RGN_TYPE_WINDOW; | ar->regiontype = RGN_TYPE_WINDOW; | ||||
| ▲ Show 20 Lines • Show All 627 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void image_scope_area_draw(const bContext *C, ARegion *ar) | static void image_scope_area_draw(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| void *lock; | void *lock; | ||||
| ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); | ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); | ||||
| /* 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 (ibuf) { | ||||
| if (!sima->scopes.ok) { | if (!sima->scopes.ok) { | ||||
| BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); | BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); | ||||
| } | } | ||||
| if (sima->image->flag & IMA_VIEW_AS_RENDER) | if (sima->image->flag & IMA_VIEW_AS_RENDER) | ||||
| scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); | scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); | ||||
| else | else | ||||
| scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); | scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); | ||||
| } | } | ||||
brecht: I guess we'll have to live with that loose coupling, I don't think it's so bad.
The other… | |||||
| } | |||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| ED_region_panels(C, ar, 1, NULL, -1); | 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_scope_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) | ||||
| { | { | ||||
| /* context changes */ | /* context changes */ | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | void ED_spacetype_image(void) | ||||
| art->regionid = RGN_TYPE_UI; | art->regionid = RGN_TYPE_UI; | ||||
| art->prefsizex = 220; // XXX | art->prefsizex = 220; // XXX | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | ||||
| art->listener = image_buttons_area_listener; | art->listener = image_buttons_area_listener; | ||||
| art->init = image_buttons_area_init; | art->init = image_buttons_area_init; | ||||
| art->draw = image_buttons_area_draw; | art->draw = image_buttons_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| image_buttons_register(art); | |||||
| ED_uvedit_buttons_register(art); | ED_uvedit_buttons_register(art); | ||||
| /* regions: statistics/scope buttons */ | /* regions: statistics/scope buttons */ | ||||
| art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | ||||
| art->regionid = RGN_TYPE_PREVIEW; | art->regionid = RGN_TYPE_TOOLS; | ||||
| art->prefsizex = 220; // XXX | art->prefsizex = 220; // XXX | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | ||||
| art->listener = image_scope_area_listener; | art->listener = image_scope_area_listener; | ||||
| art->init = image_scope_area_init; | art->init = image_scope_area_init; | ||||
| art->draw = image_scope_area_draw; | art->draw = image_scope_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| image_buttons_register(art); | |||||
| /* regions: header */ | /* regions: header */ | ||||
| art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | ||||
| art->regionid = RGN_TYPE_HEADER; | art->regionid = RGN_TYPE_HEADER; | ||||
| art->prefsizey = HEADERY; | art->prefsizey = HEADERY; | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; | ||||
| art->listener = image_header_area_listener; | art->listener = image_header_area_listener; | ||||
| art->init = image_header_area_init; | art->init = image_header_area_init; | ||||
| art->draw = image_header_area_draw; | art->draw = image_header_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| BKE_spacetype_register(st); | BKE_spacetype_register(st); | ||||
| } | } | ||||
I guess we'll have to live with that loose coupling, I don't think it's so bad.
The other solution would be to compute the scopes just in time before drawing, but I don't like that much either, since ideally the scopes should be computed as part of the dependency graph somehow for better threading.