void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
int ED_space_image_has_buffer(struct SpaceImage *sima);
-void ED_space_image_size(struct SpaceImage *sima, int *width, int *height);
-void ED_space_image_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
-void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
-void ED_space_image_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
+void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height);
+void ED_space_image_get_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
+void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
+void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
void ED_space_image_paint_update(struct wmWindowManager *wm, struct ToolSettings *settings);
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings);
-void ED_image_size(struct Image *ima, int *width, int *height);
-void ED_image_aspect(struct Image *ima, float *aspx, float *aspy);
-void ED_image_uv_aspect(struct Image *ima, float *aspx, float *aspy);
+void ED_image_get_size(struct Image *ima, int *width, int *height);
+void ED_image_get_aspect(struct Image *ima, float *aspx, float *aspy);
+void ED_image_get_uv_aspect(struct Image *ima, float *aspx, float *aspy);
int ED_space_image_show_render(struct SpaceImage *sima);
int ED_space_image_show_paint(struct SpaceImage *sima);
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
- ED_space_image_size(sima, width, height);
+ ED_space_image_get_size(sima, width, height);
break;
}
default:
case SPACE_IMAGE:
{
SpaceImage *sima = sa->spacedata.first;
- ED_space_image_uv_aspect(sima, aspx, aspy);
+ ED_space_image_get_uv_aspect(sima, aspx, aspy);
break;
}
default:
void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa && sa->spacedata.first) {
+ switch (sa->spacetype) {
+ case SPACE_CLIP:
+ {
+ SpaceClip *sc = sa->spacedata.first;
+ int width, height;
+ float zoomx, zoomy, aspx, aspy;
- /* MASKTODO */
+ ED_space_clip_get_size(C, &width, &height);
+ ED_space_clip_get_zoom(C, &zoomx, &zoomy);
+ ED_space_clip_get_aspect(sc, &aspx, &aspy);
- if (sc) {
- int width, height;
- float zoomx, zoomy, aspx, aspy;
+ *scalex = ((float)width * aspx) * zoomx;
+ *scaley = ((float)height * aspy) * zoomy;
+ break;
+ }
+ case SPACE_SEQ:
+ {
+ *scalex = *scaley = 1.0f; /* MASKTODO? */
+ break;
+ }
+ case SPACE_IMAGE:
+ {
+ SpaceImage *sima = sa->spacedata.first;
+ ARegion *ar = CTX_wm_region(C);
+ int width, height;
+ float zoomx, zoomy, aspx, aspy;
- ED_space_clip_get_size(C, &width, &height);
- ED_space_clip_get_zoom(C, &zoomx, &zoomy);
- ED_space_clip_get_aspect(sc, &aspx, &aspy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
- *scalex = ((float)width * aspx) * zoomx;
- *scaley = ((float)height * aspy) * zoomy;
+ *scalex = ((float)width * aspx) * zoomx;
+ *scaley = ((float)height * aspy) * zoomy;
+ break;
+ }
+ default:
+ /* possible other spaces from which mask editing is available */
+ BLI_assert(0);
+ *scalex = *scaley = 1.0f;
+ break;
+ }
}
else {
- /* possible other spaces from which mask editing is available */
- *scalex = 1.0f;
- *scaley = 1.0f;
+ BLI_assert(0);
+ *scalex = *scaley = 1.0f;
}
}
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
- ED_space_image_zoom(sima, ar, zoomx, zoomy);
+ ED_space_image_get_zoom(sima, ar, zoomx, zoomy);
return 1;
}
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
sima = CTX_wm_space_image(C);
- ED_space_image_size(sima, &width, &height);
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
radius = BKE_brush_size_get(scene, brush) / (width * zoomx);
aspectRatio = width / (float)height;
radius = BKE_brush_size_get(scene, brush);
sima = CTX_wm_space_image(C);
- ED_space_image_size(sima, &width, &height);
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
aspectRatio = width / (float)height;
radius /= (width * zoomx);
what_image(sima);
if (sima->image) {
- ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
+ ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp);
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
if (sima->image->type == IMA_TYPE_COMPOSITE) {
/* retrieve the image and information about it */
ima = ED_space_image(sima);
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
show_viewer = (ima && ima->source == IMA_SRC_VIEWER);
show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT);
return has_buffer;
}
-void ED_image_size(Image *ima, int *width, int *height)
+void ED_image_get_size(Image *ima, int *width, int *height)
{
ImBuf *ibuf = NULL;
void *lock;
BKE_image_release_ibuf(ima, lock);
}
-void ED_space_image_size(SpaceImage *sima, int *width, int *height)
+void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
{
Scene *scene = sima->iuser.scene;
ImBuf *ibuf;
ED_space_image_release_buffer(sima, lock);
}
-void ED_image_aspect(Image *ima, float *aspx, float *aspy)
+void ED_image_get_aspect(Image *ima, float *aspx, float *aspy)
{
*aspx = *aspy = 1.0;
*aspy = ima->aspy / ima->aspx;
}
-void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
+void ED_space_image_get_aspect(SpaceImage *sima, float *aspx, float *aspy)
{
- ED_image_aspect(ED_space_image(sima), aspx, aspy);
+ ED_image_get_aspect(ED_space_image(sima), aspx, aspy);
}
-void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
+void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
{
int width, height;
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_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)
+void ED_space_image_get_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);
+ ED_space_image_get_aspect(sima, aspx, aspy);
+ ED_space_image_get_size(sima, &w, &h);
*aspx *= (float)w;
*aspy *= (float)h;
}
}
-void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
+void ED_image_get_uv_aspect(Image *ima, float *aspx, float *aspy)
{
int w, h;
- ED_image_aspect(ima, aspx, aspy);
- ED_image_size(ima, &w, &h);
+ ED_image_get_aspect(ima, aspx, aspy);
+ ED_image_get_size(ima, &w, &h);
*aspx *= (float)w;
*aspy *= (float)h;
if (sima->zoom < 0.1f || sima->zoom > 4.0f) {
/* check zoom limits */
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
width *= sima->zoom;
height *= sima->zoom;
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
float aspx, aspy, w, h;
- ED_space_image_size(sima, &width, &height);
- ED_space_image_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_aspect(sima, &aspx, &aspy);
w = width * aspx;
h = height * aspy;
sima = CTX_wm_space_image(C);
ar = CTX_wm_region(C);
- ED_space_image_size(sima, &width, &height);
- ED_space_image_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_aspect(sima, &aspx, &aspy);
w = width * aspx;
h = height * aspy;
obedit = CTX_data_edit_object(C);
ima = ED_space_image(sima);
- ED_space_image_size(sima, &width, &height);
- ED_image_aspect(ima, &aspx, &aspy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_image_get_aspect(ima, &aspx, &aspy);
width = width * aspx;
height = height * aspy;
if (image_preview_active(curarea, &width, &height)) ;
else
#endif
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
w = width;
h = height;
/* MASKTODO - see clip clamp w/h */
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
r_vec[0] *= aspx;
r_vec[1] *= aspy;
}
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy, v[2];
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0] = vec[0] / aspx;
v[1] = vec[1] / aspy;
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
vec[0] *= width;
vec[1] *= height;
}
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
vec[0] /= aspx;
vec[1] /= aspy;
}
if ((sima->flag & SI_COORDFLOATS) == 0) {
int width, height;
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
vec[0] /= width;
vec[1] /= height;
}
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
vec[0] *= aspx;
vec[1] *= aspy;
}
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy;
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
}
{
float aspx, aspy;
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
/* uv coords are scaled by aspects. this is needed for rotations and
* proportional editing to be consistent with the stretched uv coords
int a, width, height;
float aspx, aspy, invx, invy;
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_size(sima, &width, &height);
invx = 1.0f / aspx;
invy = 1.0f / aspy;
int a, clipx = 1, clipy = 1;
float aspx, aspy, min[2], max[2];
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
min[0] = min[1] = 0.0f;
max[0] = aspx; max[1] = aspy;
if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)t->sa->spacedata.first;
/* only space supported right now but may change */
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
cursor = sima->cursor;
}
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glLoadIdentity();
- ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
+ ED_space_image_get_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
w = (((float)wi) / 256.0f) * G.sima->zoom * xuser_asp;
h = (((float)hi) / 256.0f) * G.sima->zoom * yuser_asp;
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1);
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
t->tsnap.snapPoint[0] *= aspx;
t->tsnap.snapPoint[1] *= aspy;
/* evil hack - snapping needs to be adapted for image aspect ratio */
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
- ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
+ ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
}
for (i = 0; i <= max_index; i++) {
float center[2];
int imx, imy, step, digits;
- ED_space_image_size(sima, &imx, &imy);
+ ED_space_image_get_size(sima, &imx, &imy);
em = BMEdit_FromObject(obedit);
em = BMEdit_FromObject(obedit);
- ED_space_image_size(sima, &imx, &imy);
+ ED_space_image_get_size(sima, &imx, &imy);
uvedit_center(scene, em, ima, center);
if (sima->flag & SI_COORDFLOATS) {
float zoomx, zoomy, w, h;
int width, height;
- ED_space_image_size(sima, &width, &height);
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
w = zoomx * width / 256.0f;
h = zoomy * height / 256.0f;
float aspx, aspy, col[4], (*tf_uv)[2] = NULL, (*tf_uvorig)[2] = NULL;
int i, j, nverts;
- ED_space_image_uv_aspect(sima, &aspx, &aspy);
+ ED_space_image_get_uv_aspect(sima, &aspx, &aspy);
switch (sima->dt_uvstretch) {
case SI_UVDT_STRETCH_AREA:
float prev_aspect[2], fprev_aspect;
float aspect[2], faspect;
- ED_image_uv_aspect(previma, prev_aspect, prev_aspect + 1);
- ED_image_uv_aspect(ima, aspect, aspect + 1);
+ ED_image_get_uv_aspect(previma, prev_aspect, prev_aspect + 1);
+ ED_image_get_uv_aspect(ima, aspect, aspect + 1);
fprev_aspect = prev_aspect[0]/prev_aspect[1];
faspect = aspect[0]/aspect[1];
int width, height;
if (sima) {
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
}
else {
width = 256;
/* compute ellipse size and location, not a circle since we deal
* with non square image. ellipse is normalized, r = 1.0. */
- ED_space_image_size(sima, &width, &height);
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
+ ED_space_image_get_size(sima, &width, &height);
+ ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
{
int width = 0, height = 0;
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
snap_uv_to_pixel(sima->cursor, width, height);
}
float w, h;
short change = 0;
- ED_space_image_size(sima, &width, &height);
+ ED_space_image_get_size(sima, &width, &height);
w = (float)width;
h = (float)height;
float aspx, aspy;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
+ ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
if (aspx != aspy)
param_aspect_ratio(handle, aspx, aspy);
float aspx, aspy;
tf = CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY);
- ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
+ ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
if (aspx != aspy)
param_aspect_ratio(handle, aspx, aspy);
MTexPoly *tf;
tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
- ED_image_uv_aspect(tf->tpage, &aspx, &aspy);
+ ED_image_get_uv_aspect(tf->tpage, &aspx, &aspy);
}
if (aspx == aspy)
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]);
+ ED_space_image_get_zoom(sima, ar, &values[0], &values[1]);
}
}
}
else {
int w, h;
- ED_space_image_size(sima, &w, &h);
+ ED_space_image_get_size(sima, &w, &h);
values[0] = sima->cursor[0] * w;
values[1] = sima->cursor[1] * h;
}
else {
int w, h;
- ED_space_image_size(sima, &w, &h);
+ ED_space_image_get_size(sima, &w, &h);
sima->cursor[0] = values[0] / w;
sima->cursor[1] = values[1] / h;
short ANIM_remove_driver(struct ID *id, const char rna_path[], int array_index, short flag) {return 0;}
void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock) {}
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r) {return (struct ImBuf *) NULL;}
-void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {}
+void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {}
char *ED_info_stats_string(struct Scene *scene) {return (char *) NULL;}
void ED_area_tag_redraw(struct ScrArea *sa) {}
void ED_area_tag_refresh(struct ScrArea *sa) {}
void ED_sequencer_update_view(struct bContext *C, int view) {}
float ED_rollBoneToVector(struct EditBone *bone, float new_up_axis[3]) {return 0.0f;}
-void ED_space_image_size(struct SpaceImage *sima, int *width, int *height) {}
+void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) {}
void ED_nurb_set_spline_type(struct Nurb *nu, int type) {}