Ephoto: Better constraining via edje.

v-1.6.0
Stephen Houston 8 years ago
parent da9baaa313
commit 397f5005c7
  1. 44
      data/themes/crop.edc
  2. 40
      src/bin/ephoto_cropper.c

@ -3,19 +3,30 @@ collections {
script {
public message(Msg_Type:type, id, ...) {
if ((type == MSG_INT_SET) && (id == 1)) {
new movetype, cox, coy, pox, poy;
new movetype, cox, coy, pox, poy, ix, iy, iw, ih, cx, cy, cw, ch;
movetype = getarg(2);
cox = getarg(3);
coy = getarg(4);
get_geometry(PART:"ephoto.swallow.image", ix, iy, iw, ih);
get_geometry(PART:"ephoto.swallow.cropper", cx, cy, cw, ch);
custom_state(PART:"ephoto.swallow.cropper", "default", 0.0);
if (movetype == 0) {
new ppox, ppoy;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
if (cx+cox < ix)
cox = ix-cx;
if (cx+cw+cox > ix+iw)
cox = (ix+iw)-(cx+cw);
if (cy+coy < iy)
coy = iy-cy;
if (cy+ch+coy > iy+ih)
coy = (iy+ih)-(cy+ch);
pox += cox;
poy += coy;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
ppox += cox;
ppoy += coy;
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
@ -23,6 +34,10 @@ collections {
}
if (movetype == 1 || movetype == 2 || movetype == 8) {
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
if (cx+cox < ix)
cox = ix-cx;
if (cy+coy < iy)
coy = iy-cy;
cox += pox;
coy += poy;
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, cox, coy);
@ -30,14 +45,22 @@ collections {
if (movetype == 3) {
new ppox, ppoy;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
poy += coy;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
if (cy+coy < iy)
coy = iy-cy;
if (cx+cw+cox > ix+iw)
cox = (ix+iw)-(cx+cw);
poy += coy;
ppox += cox;
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
}
if (movetype == 4 || movetype == 5 || movetype == 6) {
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, pox, poy);
if (cx+cw+cox > ix+iw)
cox = (ix+iw)-(cx+cw);
if (cy+ch+coy > iy+ih)
coy = (iy+ih)-(cy+ch);
cox += pox;
coy += poy;
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, cox, coy);
@ -45,8 +68,12 @@ collections {
if (movetype == 7) {
new ppox, ppoy;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
pox += cox;
get_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
if (cx+cox < ix)
cox = ix-cx;
if (cy+ch+coy > iy+ih)
coy = (iy+ih)-(cy+ch);
pox += cox;
ppoy += coy;
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL1_OFFSET, pox, poy);
set_state_val(PART:"ephoto.swallow.cropper", STATE_REL2_OFFSET, ppox, ppoy);
@ -75,6 +102,7 @@ collections {
mouse_events: 1;
clip_to: "clipper";
description { state: "default" 0.0;
min: 20 20;
rel1.to: "ephoto.swallow.image";
rel1.relative: 0.2 0.2;
rel2.to: "ephoto.swallow.image";
@ -165,6 +193,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 0 0;
rel1.to: "cropper";
rel1.relative: 0.0 0.0;
rel2.to: "cropper";
@ -179,6 +208,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 10 99999;
align: 1 1;
rel1.to: "cropper";
rel1.relative: 1.0 0.0;
rel2.to: "cropper";
@ -193,6 +223,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 1 1;
rel1.to: "cropper";
rel1.relative: 0.0 1.0;
rel2.to: "cropper";
@ -207,6 +238,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 10 99999;
align: 0 0;
rel1.to: "cropper";
rel1.relative: 0.0 0.0;
rel2.to: "cropper";
@ -221,6 +253,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 0 0;
rel1.to: "cropper";
rel1.relative: 0.0 0.0;
rel2.to: "cropper";
@ -235,6 +268,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 1 0;
rel1.to: "cropper";
rel1.relative: 1.0 0.0;
rel2.to: "cropper";
@ -249,6 +283,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 1 1;
rel1.to: "cropper";
rel1.relative: 1.0 1.0;
rel2.to: "cropper";
@ -263,6 +298,7 @@ collections {
color: 0 0 0 255;
min: 10 10;
max: 99999 10;
align: 0 1;
rel1.to: "cropper";
rel1.relative: 0.0 1.0;
rel2.to: "cropper";

@ -19,26 +19,16 @@ _cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
int mx, my, cx, cy, cw, ch, nx, ny;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
nx = mx - ec->startx;
ny = my - ec->starty;
ec->startx = mx;
ec->starty = my;
if (cx+nx < lx)
nx = lx-cx;
else if (cx+cw+nx > lx+lw)
nx = (lx+lw)-(cx+cw);
else if (cy+ny < ly)
ny = ly-cy;
else if (cy+ch+ny > ly+lh)
ny = (ly+lh)-(cy+ch);
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
msg->count = 3;
if (!strcmp(source, "handle1"))
@ -88,20 +78,14 @@ _cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
int mx, cx, cy, cw, ch, nx, lx, ly, lw, lh;
int mx, cx, cy, cw, ch, nx;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, 0);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
nx = mx - ec->startx;
ec->startx = mx;
if (cx+nx < lx)
nx = lx-cx;
else if (cx+cw+nx > lx+lw)
nx = (lx+lw)-(cx+cw);
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
msg->count = 3;
if (!strcmp(source, "handle4"))
@ -148,20 +132,14 @@ _cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
{
Ephoto_Cropper *ec = data;
Edje_Message_Int_Set *msg;
int my, cx, cy, cw, ch, ny, lx, ly, lw, lh;
int my, cx, cy, cw, ch, ny;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), 0, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
ny = my - ec->starty;
ec->starty = my;
if (cy+ny < ly)
ny = ly-cy;
else if (cy+ch+ny > ly+lh)
ny = (ly+lh)-(cy+ch);
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
msg->count = 3;
if (!strcmp(source, "handle2"))
@ -209,26 +187,16 @@ _cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emissi
if (!ec->resizing)
{
Edje_Message_Int_Set *msg;
int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
int mx, my, cx, cy, cw, ch, nx, ny;
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
nx = mx - ec->startx;
ny = my - ec->starty;
ec->startx = mx;
ec->starty = my;
if (cx+nx < lx)
nx = lx-cx;
else if (cx+cw+nx > lx+lw)
nx = (lx+lw)-(cx+cw);
else if (cy+ny < ly)
ny = ly-cy;
else if (cy+ch+ny > ly+lh)
ny = (ly+lh)-(cy+ch);
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
msg->count = 3;
msg->val[0] = 0;

Loading…
Cancel
Save