Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_buttons.c132
-rw-r--r--source/blender/editors/space_image/image_draw.c64
-rw-r--r--source/blender/editors/space_image/image_header.c2
-rw-r--r--source/blender/editors/space_image/image_intern.h6
-rw-r--r--source/blender/editors/space_image/image_ops.c93
-rw-r--r--source/blender/editors/space_image/image_render.c2
-rw-r--r--source/blender/editors/space_image/space_image.c601
7 files changed, 563 insertions, 337 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index e5184ec98b0..047fc3493cf 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -518,6 +518,22 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI
/* ********************* callbacks for standard image buttons *************** */
+static char *slot_menu()
+{
+ char *str;
+ int a, slot;
+
+ str= MEM_callocN(RE_SLOT_MAX*32, "menu slots");
+
+ strcpy(str, "Slot %t");
+ a= strlen(str);
+
+ for(slot=0; slot<RE_SLOT_MAX; slot++)
+ a += sprintf(str+a, "|Slot %d %%x%d", slot+1, slot);
+
+ return str;
+}
+
static char *layer_menu(RenderResult *rr, short *curlay)
{
RenderLayer *rl;
@@ -577,14 +593,17 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v)
if(ima->anim) {
iuser->frames = IMB_anim_get_duration(ima->anim);
- BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0);
+ BKE_image_user_calc_frame(iuser, scene->r.cfra, 0);
}
}
/* 5 layer button callbacks... */
static void image_multi_cb(bContext *C, void *rr_v, void *iuser_v)
{
- BKE_image_multilayer_index(rr_v, iuser_v);
+ ImageUser *iuser= iuser_v;
+
+ RE_SetViewSlot(iuser->menunr);
+ BKE_image_multilayer_index(rr_v, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
}
static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v)
@@ -684,34 +703,45 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused)
}
#endif
-static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w)
+static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, int render)
{
uiBlock *block= uiLayoutGetBlock(layout);
uiBut *but;
RenderLayer *rl= NULL;
- int wmenu1, wmenu2;
+ int wmenu1, wmenu2, wmenu3;
char *strp;
uiLayoutRow(layout, 1);
/* layer menu is 1/3 larger than pass */
- wmenu1= (3*w)/5;
- wmenu2= (2*w)/5;
+ wmenu1= (2*w)/5;
+ wmenu2= (3*w)/5;
+ wmenu3= (3*w)/6;
/* menu buts */
- strp= layer_menu(rr, &iuser->layer);
- but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->layer, 0,0,0,0, "Select Layer");
- uiButSetFunc(but, image_multi_cb, rr, iuser);
- MEM_freeN(strp);
-
- rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */
- strp= pass_menu(rl, &iuser->pass);
- but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, 20, &iuser->pass, 0,0,0,0, "Select Pass");
- uiButSetFunc(but, image_multi_cb, rr, iuser);
- MEM_freeN(strp);
+ if(render) {
+ strp= slot_menu();
+ iuser->menunr= RE_GetViewSlot();
+ but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, 20, &iuser->menunr, 0,0,0,0, "Select Slot");
+ uiButSetFunc(but, image_multi_cb, rr, iuser);
+ MEM_freeN(strp);
+ }
+
+ if(rr) {
+ strp= layer_menu(rr, &iuser->layer);
+ but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, 20, &iuser->layer, 0,0,0,0, "Select Layer");
+ uiButSetFunc(but, image_multi_cb, rr, iuser);
+ MEM_freeN(strp);
+
+ rl= BLI_findlink(&rr->layers, iuser->layer - (rr->rectf?1:0)); /* fake compo layer, return NULL is meant to be */
+ strp= pass_menu(rl, &iuser->pass);
+ but= uiDefButS(block, MENU, 0, strp, 0, 0, wmenu3, 20, &iuser->pass, 0,0,0,0, "Select Pass");
+ uiButSetFunc(but, image_multi_cb, rr, iuser);
+ MEM_freeN(strp);
+ }
}
-static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser)
+static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int render)
{
uiBlock *block= uiLayoutGetBlock(layout);
uiLayout *row;
@@ -732,7 +762,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr,
but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer");
uiButSetFunc(but, image_multi_inclay_cb, rr, iuser);
- uiblock_layer_pass_buttons(row, rr, iuser, 230);
+ uiblock_layer_pass_buttons(row, rr, iuser, 230, render);
/* decrease, increase arrows */
but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass");
@@ -841,9 +871,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn
}
else if(ima->type==IMA_TYPE_R_RESULT) {
/* browse layer/passes */
- Render *re= RE_GetRender(scene->id.name);
+ Render *re= RE_GetRender(scene->id.name, RE_SLOT_VIEW);
RenderResult *rr= RE_AcquireResultRead(re);
- uiblock_layer_pass_arrow_buttons(layout, rr, iuser);
+ uiblock_layer_pass_arrow_buttons(layout, rr, iuser, 1);
RE_ReleaseResult(re);
}
}
@@ -870,29 +900,33 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propn
/* multilayer? */
if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) {
- uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser);
+ uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, 0);
}
else if(ima->source != IMA_SRC_GENERATED) {
- ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock);
- image_info(ima, ibuf, str);
- BKE_image_release_ibuf(ima, lock);
- uiItemL(layout, str, 0);
+ if(compact == 0) {
+ ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock);
+ image_info(ima, ibuf, str);
+ BKE_image_release_ibuf(ima, lock);
+ uiItemL(layout, str, 0);
+ }
}
if(ima->source != IMA_SRC_GENERATED) {
- uiItemS(layout);
+ if(compact == 0) { /* background image view doesnt need these */
+ uiItemS(layout);
- split= uiLayoutSplit(layout, 0, 0);
+ split= uiLayoutSplit(layout, 0, 0);
- col= uiLayoutColumn(split, 0);
- uiItemR(col, NULL, 0, &imaptr, "fields", 0);
- row= uiLayoutRow(col, 0);
- uiItemR(row, NULL, 0, &imaptr, "field_order", UI_ITEM_R_EXPAND);
- uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "fields"));
+ col= uiLayoutColumn(split, 0);
+ uiItemR(col, NULL, 0, &imaptr, "fields", 0);
+ row= uiLayoutRow(col, 0);
+ uiItemR(row, NULL, 0, &imaptr, "field_order", UI_ITEM_R_EXPAND);
+ uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "fields"));
- col= uiLayoutColumn(split, 0);
- uiItemR(col, NULL, 0, &imaptr, "antialias", 0);
- uiItemR(col, NULL, 0, &imaptr, "premultiply", 0);
+ col= uiLayoutColumn(split, 0);
+ uiItemR(col, NULL, 0, &imaptr, "antialias", 0);
+ uiItemR(col, NULL, 0, &imaptr, "premultiply", 0);
+ }
}
if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
@@ -946,10 +980,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser
/* render layers and passes */
if(ima && iuser) {
rr= BKE_image_acquire_renderresult(scene, ima);
-
- if(rr)
- uiblock_layer_pass_buttons(layout, rr, iuser, 160);
-
+ uiblock_layer_pass_buttons(layout, rr, iuser, 160, ima->type==IMA_TYPE_R_RESULT);
BKE_image_release_renderresult(scene, ima);
}
}
@@ -1021,5 +1052,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..cb942472b9e 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -68,47 +68,6 @@
#define HEADER_HEIGHT 18
-#if 0
-static int image_preview_active(SpaceImage *sima, Scene *scene, float *xim, float *yim)
-{
- /* only when compositor shows, and image handler set */
- if(sima->image && sima->image->type==IMA_TYPE_COMPOSITE) {
- /* XXX panels .. */
-#if 0
- short a;
-
- for(a=0; a<SPACE_MAXHANDLER; a+=2) {
- if(sima->blockhandler[a] == IMAGE_HANDLER_PREVIEW) {
- if(xim) *xim= (scene->r.size*scene->r.xsch)/100;
- if(yim) *yim= (scene->r.size*scene->r.ysch)/100;
- return 1;
- }
- }
-#endif
- }
- return 0;
-}
-#endif
-
-/* are there curves? curves visible? and curves do something? */
-static int image_curves_active(SpaceImage *sima)
-{
- if(sima->cumap) {
- if(curvemapping_RGBA_does_something(sima->cumap)) {
- /* XXX panels .. */
-#if 0
- short a;
- for(a=0; a<SPACE_MAXHANDLER; a+=2) {
- if(sima->blockhandler[a] == IMAGE_HANDLER_CURVES)
- return 1;
- }
-#endif
- }
- }
-
- return 0;
-}
-
static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf, int color_manage)
{
/* detect if we need to redo the curve map.
@@ -120,18 +79,13 @@ static void image_verify_buffer_float(SpaceImage *sima, Image *ima, ImBuf *ibuf,
if(ibuf->rect_float) {
if(ibuf->rect==NULL) {
- if(image_curves_active(sima)) {
- curvemapping_do_ibuf(sima->cumap, ibuf);
- }
- else {
- if (color_manage) {
- if (ima && ima->source == IMA_SRC_VIEWER)
- ibuf->profile = IB_PROFILE_LINEAR_RGB;
- } else {
- ibuf->profile = IB_PROFILE_NONE;
- }
- IMB_rect_from_float(ibuf);
+ if (color_manage) {
+ if (ima && ima->source == IMA_SRC_VIEWER)
+ ibuf->profile = IB_PROFILE_LINEAR_RGB;
+ } else {
+ ibuf->profile = IB_PROFILE_NONE;
}
+ IMB_rect_from_float(ibuf);
}
}
}
@@ -625,7 +579,7 @@ static void draw_image_paint_helpers(SpaceImage *sima, ARegion *ar, Scene *scene
brush= paint_brush(&scene->toolsettings->imapaint.paint);
- if(brush && (scene->toolsettings->imapaint.tool == PAINT_TOOL_CLONE)) {
+ if(brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
drawing with alpha */
clonerect= get_alpha_clone_image(scene, &w, &h);
@@ -701,7 +655,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
/* render info */
if(ibuf && ima && show_render)
draw_render_info(ima, ar);
-
+
/* XXX integrate this code */
#if 0
if(ibuf) {
diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c
index b0ec840bb4c..4e38d4ec082 100644
--- a/source/blender/editors/space_image/image_header.c
+++ b/source/blender/editors/space_image/image_header.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index a33475c1213..f5d84d7487f 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
@@ -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);
@@ -76,6 +77,8 @@ void IMAGE_OT_save_sequence(struct wmOperatorType *ot);
void IMAGE_OT_pack(struct wmOperatorType *ot);
void IMAGE_OT_unpack(struct wmOperatorType *ot);
+void IMAGE_OT_cycle_render_slot(struct wmOperatorType *ot);
+
void IMAGE_OT_sample(struct wmOperatorType *ot);
void IMAGE_OT_curves_point_set(struct wmOperatorType *ot);
@@ -88,6 +91,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..b69b6a552a6 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -37,6 +37,7 @@
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
@@ -44,7 +45,9 @@
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
@@ -704,7 +707,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;
@@ -740,7 +744,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE);
}
/******************** replace image operator ********************/
@@ -793,7 +797,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE);
}
/******************** save image as operator ********************/
@@ -809,7 +813,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera
if (ibuf) {
BLI_convertstringcode(name, G.sce);
- BLI_convertstringframe(name, scene->r.cfra);
+ BLI_convertstringframe(name, scene->r.cfra, 0);
if(scene->r.scemode & R_EXTENSION) {
BKE_add_image_extension(name, sima->imtypenr);
@@ -961,7 +965,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
/* properties */
RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE);
}
/******************** save image operator ********************/
@@ -1078,7 +1082,7 @@ static int save_sequence_exec(bContext *C, wmOperator *op)
break;
}
- printf("Saved: %s\n", ibuf->name);
+ BKE_reportf(op->reports, RPT_INFO, "Saved: %s\n", ibuf->name);
ibuf->userflags &= ~IB_BITMAPDIRTY;
}
}
@@ -1790,23 +1794,74 @@ void IMAGE_OT_record_composite(wmOperatorType *ot)
ot->poll= space_image_poll;
}
+/********************* cycle render slot operator *********************/
+
+static int cycle_render_slot_poll(bContext *C)
+{
+ Image *ima= CTX_data_edit_image(C);
+
+ return (ima && ima->type == IMA_TYPE_R_RESULT);
+}
+
+static int cycle_render_slot_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ int a, slot, cur= RE_GetViewSlot();
+
+ for(a=1; a<RE_SLOT_MAX; a++) {
+ slot= (cur+a)%RE_SLOT_MAX;
+
+ if(RE_GetRender(scene->id.name, slot)) {
+ RE_SetViewSlot(slot);
+ break;
+ }
+ }
+
+ if(a == RE_SLOT_MAX)
+ RE_SetViewSlot((cur == 1)? 0: 1);
+
+ WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Cycle Render Slot";
+ ot->idname= "IMAGE_OT_cycle_render_slot";
+
+ /* api callbacks */
+ ot->exec= cycle_render_slot_exec;
+ ot->poll= cycle_render_slot_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/******************** TODO ********************/
/* XXX notifier? */
-#if 0
+
/* goes over all ImageUsers, and sets frame numbers if auto-refresh is set */
-void BIF_image_update_frame(void)
+
+void ED_image_update_frame(const bContext *C)
{
+ Main *mainp = CTX_data_main(C);
+ Scene *scene= CTX_data_scene(C);
Tex *tex;
/* texture users */
- for(tex= G.main->tex.first; tex; tex= tex->id.next) {
- if(tex->type==TEX_IMAGE && tex->ima)
- if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
+ for(tex= mainp->tex.first; tex; tex= tex->id.next) {
+ if(tex->type==TEX_IMAGE && tex->ima) {
+ if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
if(tex->iuser.flag & IMA_ANIM_ALWAYS)
- BKE_image_user_calc_imanr(&tex->iuser, scene->r.cfra, 0);
-
+ BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0);
+ }
+ }
}
+
+#if 0
/* image window, compo node users */
if(G.curscreen) {
ScrArea *sa;
@@ -1815,12 +1870,12 @@ void BIF_image_update_frame(void)
View3D *v3d= sa->spacedata.first;
if(v3d->bgpic)
if(v3d->bgpic->iuser.flag & IMA_ANIM_ALWAYS)
- BKE_image_user_calc_imanr(&v3d->bgpic->iuser, scene->r.cfra, 0);
+ BKE_image_user_calc_frame(&v3d->bgpic->iuser, scene->r.cfra, 0);
}
else if(sa->spacetype==SPACE_IMAGE) {
SpaceImage *sima= sa->spacedata.first;
if(sima->iuser.flag & IMA_ANIM_ALWAYS)
- BKE_image_user_calc_imanr(&sima->iuser, scene->r.cfra, 0);
+ BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0);
}
else if(sa->spacetype==SPACE_NODE) {
SpaceNode *snode= sa->spacedata.first;
@@ -1832,13 +1887,15 @@ void BIF_image_update_frame(void)
ImageUser *iuser= node->storage;
if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
if(iuser->flag & IMA_ANIM_ALWAYS)
- BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0);
+ BKE_image_user_calc_frame(iuser, scene->r.cfra, 0);
}
}
}
}
}
}
-}
#endif
+}
+
+
diff --git a/source/blender/editors/space_image/image_render.c b/source/blender/editors/space_image/image_render.c
index 617749937cb..97b5f9847ff 100644
--- a/source/blender/editors/space_image/image_render.c
+++ b/source/blender/editors/space_image/image_render.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6479eb3b5b8..29041899fa3 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
@@ -76,6 +76,241 @@
#include "image_intern.h"
+/**************************** common state *****************************/
+
+/* note; image_panel_properties() uses pointer to sima->image directly */
+Image *ED_space_image(SpaceImage *sima)
+{
+ return sima->image;
+}
+
+/* called to assign images to UV faces */
+void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
+{
+ ED_uvedit_assign_image(scene, obedit, ima, sima->image);
+
+ /* change the space ima after because uvedit_face_visible uses the space ima
+ * to check if the face is displayed in UV-localview */
+ sima->image= ima;
+
+ if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
+ sima->flag &= ~SI_DRAWTOOL;
+
+ if(sima->image)
+ BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
+
+ if(sima->image && sima->image->id.us==0)
+ sima->image->id.us= 1;
+
+ if(C) {
+ if(obedit)
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+}
+
+ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
+{
+ ImBuf *ibuf;
+
+ if(sima && sima->image) {
+#if 0
+ if(sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare())
+ return BIF_render_spare_imbuf();
+ else
+#endif
+ ibuf= BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
+
+ if(ibuf && (ibuf->rect || ibuf->rect_float))
+ return ibuf;
+ }
+
+ return NULL;
+}
+
+void ED_space_image_release_buffer(SpaceImage *sima, void *lock)
+{
+ if(sima && sima->image)
+ BKE_image_release_ibuf(sima->image, lock);
+}
+
+int ED_space_image_has_buffer(SpaceImage *sima)
+{
+ ImBuf *ibuf;
+ void *lock;
+ int has_buffer;
+
+ ibuf= ED_space_image_acquire_buffer(sima, &lock);
+ has_buffer= (ibuf != NULL);
+ ED_space_image_release_buffer(sima, lock);
+
+ return has_buffer;
+}
+
+void ED_image_size(Image *ima, int *width, int *height)
+{
+ ImBuf *ibuf= NULL;
+ void *lock;
+
+ if(ima)
+ ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
+
+ if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
+ *width= ibuf->x;
+ *height= ibuf->y;
+ }
+ else {
+ *width= 256;
+ *height= 256;
+ }
+
+ if(ima)
+ BKE_image_release_ibuf(ima, lock);
+}
+
+void ED_space_image_size(SpaceImage *sima, int *width, int *height)
+{
+ Scene *scene= sima->iuser.scene;
+ ImBuf *ibuf;
+ void *lock;
+
+ ibuf= ED_space_image_acquire_buffer(sima, &lock);
+
+ if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
+ *width= ibuf->x;
+ *height= ibuf->y;
+ }
+ else if(sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) {
+ /* not very important, just nice */
+ *width= (scene->r.xsch*scene->r.size)/100;
+ *height= (scene->r.ysch*scene->r.size)/100;
+ }
+ /* I know a bit weak... but preview uses not actual image size */
+ // XXX else if(image_preview_active(sima, width, height));
+ else {
+ *width= 256;
+ *height= 256;
+ }
+
+ ED_space_image_release_buffer(sima, lock);
+}
+
+void ED_image_aspect(Image *ima, float *aspx, float *aspy)
+{
+ *aspx= *aspy= 1.0;
+
+ if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
+ (ima->aspx==0.0 || ima->aspy==0.0))
+ return;
+
+ /* x is always 1 */
+ *aspy = ima->aspy/ima->aspx;
+}
+
+void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
+{
+ ED_image_aspect(ED_space_image(sima), aspx, aspy);
+}
+
+void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
+{
+ int width, height;
+
+ ED_space_image_size(sima, &width, &height);
+
+ *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
+ *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
+}
+
+void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
+{
+ int w, h;
+
+ ED_space_image_aspect(sima, aspx, aspy);
+ ED_space_image_size(sima, &w, &h);
+
+ *aspx *= (float)w/256.0f;
+ *aspy *= (float)h/256.0f;
+}
+
+void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
+{
+ int w, h;
+
+ ED_image_aspect(ima, aspx, aspy);
+ ED_image_size(ima, &w, &h);
+
+ *aspx *= (float)w;
+ *aspy *= (float)h;
+}
+
+int ED_space_image_show_render(SpaceImage *sima)
+{
+ return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
+}
+
+int ED_space_image_show_paint(SpaceImage *sima)
+{
+ if(ED_space_image_show_render(sima))
+ return 0;
+
+ return (sima->flag & SI_DRAWTOOL);
+}
+
+int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
+{
+ if(ED_space_image_show_render(sima))
+ return 0;
+ if(ED_space_image_show_paint(sima))
+ return 0;
+
+ if(obedit && obedit->type == OB_MESH) {
+ BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
+ int ret;
+
+ ret = EDBM_texFaceCheck(em);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
+{
+ if(ED_space_image_show_render(sima))
+ return 0;
+
+ if(ED_space_image_show_paint(sima))
+ if(obedit && obedit->type == OB_MESH) {
+ BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
+ int ret;
+
+ ret = EDBM_texFaceCheck(em);
+
+ return ret;
+ }
+
+ return 0;
+}
+
+
+
+static void image_histogram_tag_refresh(ScrArea *sa)
+{
+ SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
+ ARegion *ar;
+
+ /* 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)
+ return;
+ }
+
+ sima->hist.ok=0;
+}
+
/* ******************** manage regions ********************* */
ARegion *image_has_buttons_region(ScrArea *sa)
@@ -105,6 +340,35 @@ 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;
+
+ image_histogram_tag_refresh(sa);
+
+ return arnew;
+}
+
/* ******************** default callbacks for image space ***************** */
static SpaceLink *image_new(const bContext *C)
@@ -136,6 +400,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");
@@ -158,10 +430,14 @@ static void image_free(SpaceLink *sl)
}
-/* spacetype; init callback */
+/* spacetype; init callback, add handlers */
static void image_init(struct wmWindowManager *wm, ScrArea *sa)
{
+ ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
+ /* add drop boxes */
+ WM_event_add_dropbox_handler(&sa->handlers, lb);
+
}
static SpaceLink *image_duplicate(SpaceLink *sl)
@@ -195,6 +471,8 @@ void image_operatortypes(void)
WM_operatortype_append(IMAGE_OT_pack);
WM_operatortype_append(IMAGE_OT_unpack);
+ WM_operatortype_append(IMAGE_OT_cycle_render_slot);
+
WM_operatortype_append(IMAGE_OT_sample);
WM_operatortype_append(IMAGE_OT_curves_point_set);
@@ -202,6 +480,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)
@@ -214,6 +493,9 @@ 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);
+
+ WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0);
keymap= WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0);
@@ -237,8 +519,6 @@ void image_keymap(struct wmKeyConfig *keyconf)
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
- WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
-
WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0);
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "point", 1);
@@ -246,6 +526,31 @@ void image_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "IMAGE_OT_toolbox", SPACEKEY, KM_PRESS, 0, 0);
}
+/* dropboxes */
+static int image_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+ if(drag->type==WM_DRAG_PATH)
+ if(ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
+ return 1;
+ return 0;
+}
+
+static void image_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ /* copy drag path to properties */
+ RNA_string_set(drop->ptr, "path", drag->path);
+}
+
+/* area+region dropbox definition */
+static void image_dropboxes(void)
+{
+ ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
+
+ WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy);
+}
+
+
+
static void image_refresh(const bContext *C, ScrArea *sa)
{
SpaceImage *sima= CTX_wm_space_image(C);
@@ -279,6 +584,8 @@ static void image_refresh(const bContext *C, ScrArea *sa)
static void image_listener(ScrArea *sa, wmNotifier *wmn)
{
+ SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
+
/* context changes */
switch(wmn->category) {
case NC_SCENE:
@@ -286,13 +593,19 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
case ND_MODE:
case ND_RENDER_RESULT:
case ND_COMPO_RESULT:
+ if (ED_space_image_show_render(sima))
+ image_histogram_tag_refresh(sa);
ED_area_tag_refresh(sa);
ED_area_tag_redraw(sa);
break;
}
break;
case NC_IMAGE:
- ED_area_tag_redraw(sa);
+ if (wmn->reference == sima->image || !wmn->reference) {
+ 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)
@@ -400,6 +713,7 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
keymap= WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+
}
static void image_main_area_draw(const bContext *C, ARegion *ar)
@@ -485,6 +799,54 @@ 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)
+{
+ SpaceImage *sima= CTX_wm_space_image(C);
+ void *lock;
+ ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
+ if(ibuf)
+ histogram_update(&sima->hist, ibuf);
+ ED_space_image_release_buffer(sima, lock);
+
+ ED_region_panels(C, ar, 1, NULL, -1);
+}
+
+static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+ /* context changes */
+ switch(wmn->category) {
+ case NC_SCENE:
+ switch(wmn->data) {
+ case ND_MODE:
+ case ND_RENDER_RESULT:
+ case ND_COMPO_RESULT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_IMAGE:
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_NODE:
+ ED_region_tag_redraw(ar);
+ break;
+
+ }
+}
+
/************************* header region **************************/
/* add handlers, stuff you only do once or on area/region changes */
@@ -515,6 +877,7 @@ void ED_spacetype_image(void)
st->duplicate= image_duplicate;
st->operatortypes= image_operatortypes;
st->keymap= image_keymap;
+ st->dropboxes= image_dropboxes;
st->refresh= image_refresh;
st->listener= image_listener;
st->context= image_context;
@@ -532,7 +895,7 @@ void ED_spacetype_image(void)
/* regions: listview/buttons */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_UI;
- art->minsizex= 220; // XXX
+ art->prefsizex= 220; // XXX
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
art->listener= image_buttons_area_listener;
art->init= image_buttons_area_init;
@@ -540,11 +903,21 @@ 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");
art->regionid = RGN_TYPE_HEADER;
- art->minsizey= HEADERY;
+ art->prefsizey= HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
art->init= image_header_area_init;
art->draw= image_header_area_draw;
@@ -553,217 +926,3 @@ void ED_spacetype_image(void)
BKE_spacetype_register(st);
}
-
-/**************************** common state *****************************/
-
-/* note; image_panel_properties() uses pointer to sima->image directly */
-Image *ED_space_image(SpaceImage *sima)
-{
- return sima->image;
-}
-
-/* called to assign images to UV faces */
-void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
-{
- ED_uvedit_assign_image(scene, obedit, ima, sima->image);
-
- /* change the space ima after because uvedit_face_visible uses the space ima
- * to check if the face is displayed in UV-localview */
- sima->image= ima;
-
- if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
- sima->flag &= ~SI_DRAWTOOL;
-
- if(sima->image)
- BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
-
- if(sima->image && sima->image->id.us==0)
- sima->image->id.us= 1;
-
- if(C) {
- if(obedit)
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
-
- ED_area_tag_redraw(CTX_wm_area(C));
- }
-}
-
-ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
-{
- ImBuf *ibuf;
-
- if(sima && sima->image) {
-#if 0
- if(sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare())
- return BIF_render_spare_imbuf();
- else
-#endif
- ibuf= BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
-
- if(ibuf && (ibuf->rect || ibuf->rect_float))
- return ibuf;
- }
-
- return NULL;
-}
-
-void ED_space_image_release_buffer(SpaceImage *sima, void *lock)
-{
- if(sima && sima->image)
- BKE_image_release_ibuf(sima->image, lock);
-}
-
-int ED_space_image_has_buffer(SpaceImage *sima)
-{
- ImBuf *ibuf;
- void *lock;
- int has_buffer;
-
- ibuf= ED_space_image_acquire_buffer(sima, &lock);
- has_buffer= (ibuf != NULL);
- ED_space_image_release_buffer(sima, lock);
-
- return has_buffer;
-}
-
-void ED_image_size(Image *ima, int *width, int *height)
-{
- ImBuf *ibuf= NULL;
- void *lock;
-
- if(ima)
- ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
-
- if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
- *width= ibuf->x;
- *height= ibuf->y;
- }
- else {
- *width= 256;
- *height= 256;
- }
-
- if(ima)
- BKE_image_release_ibuf(ima, lock);
-}
-
-void ED_space_image_size(SpaceImage *sima, int *width, int *height)
-{
- Scene *scene= sima->iuser.scene;
- ImBuf *ibuf;
- void *lock;
-
- ibuf= ED_space_image_acquire_buffer(sima, &lock);
-
- if(ibuf && ibuf->x > 0 && ibuf->y > 0) {
- *width= ibuf->x;
- *height= ibuf->y;
- }
- else if(sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) {
- /* not very important, just nice */
- *width= (scene->r.xsch*scene->r.size)/100;
- *height= (scene->r.ysch*scene->r.size)/100;
- }
- /* I know a bit weak... but preview uses not actual image size */
- // XXX else if(image_preview_active(sima, width, height));
- else {
- *width= 256;
- *height= 256;
- }
-
- ED_space_image_release_buffer(sima, lock);
-}
-
-void ED_image_aspect(Image *ima, float *aspx, float *aspy)
-{
- *aspx= *aspy= 1.0;
-
- if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
- (ima->aspx==0.0 || ima->aspy==0.0))
- return;
-
- /* x is always 1 */
- *aspy = ima->aspy/ima->aspx;
-}
-
-void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
-{
- ED_image_aspect(ED_space_image(sima), aspx, aspy);
-}
-
-void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
-{
- int width, height;
-
- ED_space_image_size(sima, &width, &height);
-
- *zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
- *zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
-}
-
-void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
-{
- int w, h;
-
- ED_space_image_aspect(sima, aspx, aspy);
- ED_space_image_size(sima, &w, &h);
-
- *aspx *= (float)w/256.0f;
- *aspy *= (float)h/256.0f;
-}
-
-void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
-{
- int w, h;
-
- ED_image_aspect(ima, aspx, aspy);
- ED_image_size(ima, &w, &h);
-
- *aspx *= (float)w;
- *aspy *= (float)h;
-}
-
-int ED_space_image_show_render(SpaceImage *sima)
-{
- return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
-}
-
-int ED_space_image_show_paint(SpaceImage *sima)
-{
- if(ED_space_image_show_render(sima))
- return 0;
-
- return (sima->flag & SI_DRAWTOOL);
-}
-
-int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
-{
- if(ED_space_image_show_render(sima))
- return 0;
- if(ED_space_image_show_paint(sima))
- return 0;
-
- if(obedit && obedit->type == OB_MESH) {
- BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
-
- return EDBM_texFaceCheck(em);
- }
-
- return 0;
-}
-
-int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
-{
- if(ED_space_image_show_render(sima))
- return 0;
-
- if(ED_space_image_show_paint(sima))
- if(obedit && obedit->type == OB_MESH) {
- BMEditMesh *em = ((Mesh*)obedit->data)->edit_btmesh;
-
- return EDBM_texFaceCheck(em);
- }
-
- return 0;
-}
-