diff options
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 86 |
5 files changed, 125 insertions, 2 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 6b92fc3fe4f..e740b355727 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -1036,5 +1036,26 @@ void IMAGE_OT_properties(wmOperatorType *ot) ot->flag= 0; } +static int image_scopes(bContext *C, wmOperator *op) +{ + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= image_has_scope_region(sa); + + if(ar) + ED_region_toggle_hidden(C, ar); + + return OPERATOR_FINISHED; +} +void IMAGE_OT_scopes(wmOperatorType *ot) +{ + ot->name= "Scopes"; + ot->idname= "IMAGE_OT_scopes"; + + ot->exec= image_scopes; + ot->poll= ED_operator_image_active; + + /* flags */ + ot->flag= 0; +} diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ea526b13219..2b2f1f0b3e4 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -204,6 +204,16 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f UI_DrawString(10, 10, str); } +static inline int get_bin_float(float f) +{ + CLAMP(f, 0.0, 1.0); + + //return (int) (((f + 0.25) / 1.5) * 512); + + return (int)(f * 511); +} + + /* image drawing */ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) @@ -702,6 +712,11 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) if(ibuf && ima && show_render) draw_render_info(ima, ar); + /* histogram */ + if (ibuf) { + histogram_update(&sima->hist, ibuf); + } + /* XXX integrate this code */ #if 0 if(ibuf) { diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index a33475c1213..b7f81245296 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -44,6 +44,7 @@ struct bNodeTree; /* space_image.c */ struct ARegion *image_has_buttons_region(struct ScrArea *sa); +struct ARegion *image_has_scope_region(struct ScrArea *sa); /* image_header.c */ void image_header_buttons(const struct bContext *C, struct ARegion *ar); @@ -88,6 +89,7 @@ void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene 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); #endif /* ED_IMAGE_INTERN_H */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index cef92153725..6b901814634 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -704,7 +704,8 @@ static int open_exec(bContext *C, wmOperator *op) // XXX other users? BKE_image_signal(ima, (sima)? &sima->iuser: NULL, IMA_SIGNAL_RELOAD); - + WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); + MEM_freeN(op->customdata); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 6c325d9722f..62021f824ae 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -104,6 +104,33 @@ ARegion *image_has_buttons_region(ScrArea *sa) return arnew; } +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; + + /* add subdiv level; after buttons */ + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_UI) + break; + + /* is error! */ + if(ar==NULL) return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "scopes for image"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype= RGN_TYPE_PREVIEW; + arnew->alignment= RGN_ALIGN_RIGHT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + /* ******************** default callbacks for image space ***************** */ static SpaceLink *image_new(const bContext *C) @@ -135,6 +162,14 @@ static SpaceLink *image_new(const bContext *C) ar->alignment= RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; + /* scopes */ + ar= MEM_callocN(sizeof(ARegion), "buttons for image"); + + BLI_addtail(&simage->regionbase, ar); + ar->regiontype= RGN_TYPE_PREVIEW; + ar->alignment= RGN_ALIGN_RIGHT; + ar->flag = RGN_FLAG_HIDDEN; + /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for image"); @@ -201,6 +236,7 @@ void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_toolbox); WM_operatortype_append(IMAGE_OT_properties); + WM_operatortype_append(IMAGE_OT_scopes); } void image_keymap(struct wmKeyConfig *keyconf) @@ -213,6 +249,7 @@ 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", PKEY, KM_PRESS, 0, 0); keymap= WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0); @@ -278,8 +315,16 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } +static void image_histogram_tag_refresh(ScrArea *sa) +{ + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + sima->hist.ok=0; +} + static void image_listener(ScrArea *sa, wmNotifier *wmn) { + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + /* context changes */ switch(wmn->category) { case NC_SCENE: @@ -293,7 +338,11 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_IMAGE: - ED_area_tag_redraw(sa); + if (wmn->reference == sima->image) { + image_histogram_tag_refresh(sa); + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + } break; case NC_SPACE: if(wmn->data == ND_SPACE_IMAGE) @@ -486,6 +535,31 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } } +/* *********************** scopes region ************************ */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void image_scope_area_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + ED_region_panels_init(wm, ar); + + keymap= WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void image_scope_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL, -1); +} + +static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + } +} + /************************* header region **************************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -541,6 +615,16 @@ void ED_spacetype_image(void) BLI_addhead(&st->regiontypes, art); image_buttons_register(art); + + /* regions: statistics/scope buttons */ + art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); + art->regionid = RGN_TYPE_PREVIEW; + art->minsizex= 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; + BLI_addhead(&st->regiontypes, art); /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype image region"); |