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:
authorMatt Ebb <matt@mke3.net>2010-03-30 09:52:05 +0400
committerMatt Ebb <matt@mke3.net>2010-03-30 09:52:05 +0400
commitb09ee4923d4066ec032fb3105355c79618352b46 (patch)
tree1f54c5a497ef48e08790de6b2da394cb02f93e01 /source/blender/editors
parent5089663962a14a3cc21f342db66a0c157bfd7dfc (diff)
Fix [#21711] Position of 2d cursor is not displayed correctly and cannot be set
in uv/image editor properties panel Note: Moved UV editor 2d cursor to SpaceImage rather than View2d, so it's more accessible to RNA.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/mesh/meshtools.c5
-rw-r--r--source/blender/editors/space_image/image_buttons.c43
-rw-r--r--source/blender/editors/transform/transform_generics.c13
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c5
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c38
5 files changed, 31 insertions, 73 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 3d09880de8f..0d2d39f938f 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1286,11 +1286,6 @@ float *editmesh_get_mirror_uv(int axis, float *uv, float *mirrCent, float *face_
cent_vec[1] = face_cent[1];
}
- /*
- G.v2d->cursor[0] = mirrCent[0];
- G.v2d->cursor[1] = mirrCent[1];
- */
-
/* TODO - Optimize */
{
EditFace *efa;
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 9f897c4ff2c..8d10da4e8a1 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -81,7 +81,6 @@
#define B_REDR 1
#define B_IMAGECHANGED 2
#define B_TRANS_IMAGE 3
-#define B_CURSOR_IMAGE 4
#define B_NOP 0
#define B_TWINANIM 5
#define B_SIMAGETILE 6
@@ -109,7 +108,6 @@ static int simaUVSel_Check() {return 0;}
/* proto */
static void image_editvertex_buts(const bContext *C, uiBlock *block);
-static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block);
static void do_image_panel_events(bContext *C, void *arg, int event)
@@ -123,9 +121,6 @@ static void do_image_panel_events(bContext *C, void *arg, int event)
case B_TRANS_IMAGE:
image_editvertex_buts(C, NULL);
break;
- case B_CURSOR_IMAGE:
- image_editcursor_buts(C, &ar->v2d, NULL);
- break;
}
/* all events now */
@@ -316,41 +311,6 @@ static void image_editvertex_buts(const bContext *C, uiBlock *block)
/* is used for both read and write... */
-static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block)
-{
- SpaceImage *sima= CTX_wm_space_image(C);
- static float ocent[2];
- int imx= 256, imy= 256;
- int step, digits;
-
- image_transform_but_attr(sima, &imx, &imy, &step, &digits);
-
- if(block) { // do the buttons
- ocent[0]= v2d->cursor[0];
- ocent[1]= v2d->cursor[1];
- if (sima->flag & SI_COORDFLOATS) {
- } else {
- ocent[0] *= imx;
- ocent[1] *= imy;
- }
-
- uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor X:", 165, 120, 145, 19, &ocent[0], -10*imx, 10.0*imx, step, digits, "");
- uiDefButF(block, NUM, B_CURSOR_IMAGE, "Cursor Y:", 165, 100, 145, 19, &ocent[1], -10*imy, 10.0*imy, step, digits, "");
- uiBlockEndAlign(block);
- }
- else { // apply event
- if (sima->flag & SI_COORDFLOATS) {
- v2d->cursor[0]= ocent[0];
- v2d->cursor[1]= ocent[1];
- }
- else {
- v2d->cursor[0]= ocent[0]/imx;
- v2d->cursor[1]= ocent[1]/imy;
- }
- WM_event_add_notifier(C, NC_IMAGE, sima->image);
- }
-}
static int image_panel_poll(const bContext *C, PanelType *pt)
{
@@ -1002,19 +962,20 @@ static void image_panel_uv(const bContext *C, Panel *pa)
uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
image_editvertex_buts(C, block);
- image_editcursor_buts(C, &ar->v2d, block);
}
void image_buttons_register(ARegionType *art)
{
PanelType *pt;
+ /* editvertex_buts not working atm
pt= MEM_callocN(sizeof(PanelType), "spacetype image panel uv");
strcpy(pt->idname, "IMAGE_PT_uv");
strcpy(pt->label, "UV");
pt->draw= image_panel_uv;
pt->poll= image_panel_uv_poll;
BLI_addtail(&art->paneltypes, pt);
+ */
pt= MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
strcpy(pt->idname, "IMAGE_PT_curves");
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 326fcce3173..1fd189e8b52 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1223,13 +1223,18 @@ void calculateCenterCursor2D(TransInfo *t)
{
View2D *v2d= t->view;
float aspx=1.0, aspy=1.0;
+ float *cursor;
- if(t->spacetype==SPACE_IMAGE) /* only space supported right now but may change */
- ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &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);
+ cursor = sima->cursor;
+ }
if (v2d) {
- t->center[0] = v2d->cursor[0] * aspx;
- t->center[1] = v2d->cursor[1] * aspy;
+ t->center[0] = cursor[0] * aspx;
+ t->center[1] = cursor[1] * aspy;
}
calculateCenter2D(t);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index ce59c8e37b4..e3bf1e83247 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -56,7 +56,6 @@
static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
{
- View2D *v2d= &ar->v2d;
float zoomx, zoomy, w, h;
int width, height;
@@ -67,7 +66,7 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
h= zoomy*height/256.0f;
cpack(0xFFFFFF);
- glTranslatef(v2d->cursor[0], v2d->cursor[1], 0.0f);
+ glTranslatef(sima->cursor[0], sima->cursor[1], 0.0f);
fdrawline(-0.05/w, 0, 0, 0.05/h);
fdrawline(0, 0.05/h, 0.05/w, 0);
fdrawline(0.05/w, 0, 0, -0.05/h);
@@ -95,7 +94,7 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar)
fdrawline(0, -0.020/h, 0, -0.1/h);
fdrawline(0, 0.1/h, 0, 0.020/h);
- glTranslatef(-v2d->cursor[0], -v2d->cursor[1], 0.0f);
+ glTranslatef(-sima->cursor[0], -sima->cursor[1], 0.0f);
setlinestyle(0);
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 3cfbac07e49..bae8d4b7fcf 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2357,17 +2357,17 @@ static void snap_uv_to_pixel(float *uvco, float w, float h)
uvco[1] = ((float)((int)((uvco[1]*h) + 0.5f)))/h;
}
-static void snap_cursor_to_pixels(SpaceImage *sima, View2D *v2d)
+static void snap_cursor_to_pixels(SpaceImage *sima)
{
int width= 0, height= 0;
ED_space_image_size(sima, &width, &height);
- snap_uv_to_pixel(v2d->cursor, width, height);
+ snap_uv_to_pixel(sima->cursor, width, height);
}
-static int snap_cursor_to_selection(Scene *scene, Image *ima, Object *obedit, View2D *v2d)
+static int snap_cursor_to_selection(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
{
- return uvedit_center(scene, ima, obedit, v2d->cursor, 0);
+ return uvedit_center(scene, ima, obedit, sima->cursor, 0);
}
static int snap_cursor_exec(bContext *C, wmOperator *op)
@@ -2376,23 +2376,22 @@ static int snap_cursor_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
Image *ima= CTX_data_edit_image(C);
- ARegion *ar= CTX_wm_region(C);
int change= 0;
switch(RNA_boolean_get(op->ptr, "target")) {
case 0:
- snap_cursor_to_pixels(sima, &ar->v2d);
+ snap_cursor_to_pixels(sima);
change= 1;
break;
case 1:
- change= snap_cursor_to_selection(scene, ima, obedit, &ar->v2d);
+ change= snap_cursor_to_selection(scene, ima, obedit, sima);
break;
}
if(!change)
return OPERATOR_CANCELLED;
- ED_region_tag_redraw(ar);
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, sima);
return OPERATOR_FINISHED;
}
@@ -2420,7 +2419,7 @@ void UV_OT_snap_cursor(wmOperatorType *ot)
/* ******************** snap selection operator **************** */
-static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *v2d)
+static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceImage *sima)
{
EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data);
EditFace *efa;
@@ -2430,11 +2429,11 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, View2D *
for(efa= em->faces.first; efa; efa= efa->next) {
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if(uvedit_face_visible(scene, ima, efa, tface)) {
- if(uvedit_uv_selected(scene, efa, tface, 0)) VECCOPY2D(tface->uv[0], v2d->cursor);
- if(uvedit_uv_selected(scene, efa, tface, 1)) VECCOPY2D(tface->uv[1], v2d->cursor);
- if(uvedit_uv_selected(scene, efa, tface, 2)) VECCOPY2D(tface->uv[2], v2d->cursor);
+ if(uvedit_uv_selected(scene, efa, tface, 0)) VECCOPY2D(tface->uv[0], sima->cursor);
+ if(uvedit_uv_selected(scene, efa, tface, 1)) VECCOPY2D(tface->uv[1], sima->cursor);
+ if(uvedit_uv_selected(scene, efa, tface, 2)) VECCOPY2D(tface->uv[2], sima->cursor);
if(efa->v4)
- if(uvedit_uv_selected(scene, efa, tface, 3)) VECCOPY2D(tface->uv[3], v2d->cursor);
+ if(uvedit_uv_selected(scene, efa, tface, 3)) VECCOPY2D(tface->uv[3], sima->cursor);
change= 1;
}
@@ -2614,7 +2613,6 @@ static int snap_selection_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
Image *ima= CTX_data_edit_image(C);
- ARegion *ar= CTX_wm_region(C);
int change= 0;
switch(RNA_boolean_get(op->ptr, "target")) {
@@ -2622,7 +2620,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op)
change= snap_uvs_to_pixels(sima, scene, obedit);
break;
case 1:
- change= snap_uvs_to_cursor(scene, ima, obedit, &ar->v2d);
+ change= snap_uvs_to_cursor(scene, ima, obedit, sima);
break;
case 2:
change= snap_uvs_to_adjacent_unselected(scene, ima, obedit);
@@ -3038,14 +3036,14 @@ void UV_OT_reveal(wmOperatorType *ot)
static int set_2d_cursor_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
RNA_float_get_array(op->ptr, "location", location);
- ar->v2d.cursor[0]= location[0];
- ar->v2d.cursor[1]= location[1];
+ sima->cursor[0]= location[0];
+ sima->cursor[1]= location[1];
- ED_area_tag_redraw(CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL);
return OPERATOR_FINISHED;
}
@@ -3096,7 +3094,7 @@ static int set_tile_exec(bContext *C, wmOperator *op)
RNA_int_get_array(op->ptr, "tile", tile);
ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1]);
- ED_area_tag_redraw(CTX_wm_area(C));
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL);
return OPERATOR_FINISHED;
}