Committed, thanks. This seems to handle the edge cases a lot better then the previous code did.

I noticed one thing as I was playing with it. It seems like the initial click on the spectrum (the square one) before you move your mouse at all the cross hairs end up in the wrong spot. As soon as you move your mouse they correct to be under the mouse as expected.

dan



Peter Wehrfritz wrote:
Hi all,

here is a patch for ewl_spectrum to set the cross hair on the right position.

regards

peter


------------------------------------------------------------------------

Index: ewl_spectrum.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ewl/src/lib/ewl_spectrum.c,v
retrieving revision 1.20
diff -u -r1.20 ewl_spectrum.c
--- ewl_spectrum.c      22 Feb 2006 03:51:01 -0000      1.20
+++ ewl_spectrum.c      7 Apr 2006 20:10:55 -0000
@@ -318,7 +318,6 @@
 {
        Ewl_Spectrum *sp;
        Ewl_Event_Mouse_Down *e;
-       unsigned int x, y;
DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
@@ -330,15 +329,7 @@
ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, ewl_spectrum_cb_mouse_move, NULL); - x = e->x - CURRENT_X(w);
-       y = e->y - CURRENT_Y(w);
-
-       if (x > (unsigned int)(CURRENT_X(sp->canvas) + CURRENT_W(sp->canvas)))
-               x = (CURRENT_W(sp->canvas) - CURRENT_X(sp->canvas));
-       if (y > (unsigned int)(CURRENT_Y(sp->canvas) + CURRENT_H(sp->canvas)))
-               y = (CURRENT_H(sp->canvas) - CURRENT_Y(sp->canvas));
-
-       ewl_spectrum_mouse_process(sp, x, y);
+       ewl_spectrum_mouse_process(sp, e->x, e->y);
DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -348,7 +339,6 @@
 {
        Ewl_Spectrum *sp;
        Ewl_Event_Mouse_Move *e;
-       int x, y;
DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
@@ -357,15 +347,7 @@
        sp = EWL_SPECTRUM(w);
        e = ev;
- x = e->x - CURRENT_X(sp);
-       y = e->y - CURRENT_Y(sp);
-
-       if (x > (CURRENT_X(sp->canvas) + CURRENT_W(sp->canvas)))
-               x = (CURRENT_W(sp->canvas) - CURRENT_X(sp->canvas));
-       if (y > (CURRENT_Y(sp->canvas) + CURRENT_H(sp->canvas)))
-               y = (CURRENT_H(sp->canvas) - CURRENT_Y(sp->canvas));
-
-       ewl_spectrum_mouse_process(sp, x, y);
+       ewl_spectrum_mouse_process(sp, e->x, e->y);
DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -392,16 +374,25 @@
 {
        Evas_Coord img_w, img_h;
        unsigned int r, g, b;
+       unsigned int mx, my;
DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("sp", sp);
        DCHECK_TYPE("sp", sp, EWL_SPECTRUM_TYPE);
+ if (x > (CURRENT_X(sp->canvas) + CURRENT_W(sp->canvas)))
+               x = CURRENT_X(sp->canvas) + CURRENT_W(sp->canvas);
+       if (y > (CURRENT_Y(sp->canvas) + CURRENT_H(sp->canvas)))
+               y = CURRENT_Y(sp->canvas) + CURRENT_H(sp->canvas);
+
+       mx = x - CURRENT_X(sp->canvas);
+       my = y - CURRENT_Y(sp->canvas);
        evas_object_image_size_get(EWL_IMAGE(sp->canvas)->image, &img_w, 
&img_h);
-       ewl_spectrum_color_coord_map(sp, x, y, img_w, img_h, &r, &g, &b);
+       ewl_spectrum_color_coord_map(sp, mx, my, img_w, img_h, &r, &g, &b);
        ewl_spectrum_rgb_set(sp, r, g, b);
/* place the horizontal cross hair */
+       y -= CURRENT_H(sp->cross_hairs.horizontal) / 2;
ewl_object_position_request(EWL_OBJECT(sp->cross_hairs.horizontal), CURRENT_X(sp), y); ewl_object_w_request(EWL_OBJECT(sp->cross_hairs.horizontal), @@ -413,6 +404,7 @@
        /* place the vertical cross hair if needed */
        if (sp->type == EWL_SPECTRUM_TYPE_SQUARE)
        {
+               x -= CURRENT_W(sp->cross_hairs.vertical) / 2;
ewl_object_position_request(EWL_OBJECT(sp->cross_hairs.vertical), x, CURRENT_Y(sp)); ewl_object_h_request(EWL_OBJECT(sp->cross_hairs.vertical),



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to