[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] ewl_spectrum



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),