Enlightenment CVS committal

Author  : moom
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        Etk.h Makefile.am etk_colorpicker.c etk_colorpicker.h 
        etk_combobox.h etk_types.h 
Removed Files:
        etk_colorpicker_square.c etk_colorpicker_square.h 
        etk_colorpicker_vertical.c etk_colorpicker_vertical.h 


Log Message:
* Start to rewrite the colorpicker


===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/Etk.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- Etk.h       12 May 2006 19:13:39 -0000      1.30
+++ Etk.h       16 May 2006 22:02:59 -0000      1.31
@@ -42,8 +42,6 @@
 #include "etk_text_view.h"
 #include "etk_canvas.h"
 #include "etk_colorpicker.h"
-#include "etk_colorpicker_vertical.h"
-#include "etk_colorpicker_square.h"
 #include "etk_tree.h"
 #include "etk_tree_model.h"
 #include "etk_range.h"
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/Makefile.am,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -3 -r1.35 -r1.36
--- Makefile.am 12 May 2006 19:13:39 -0000      1.35
+++ Makefile.am 16 May 2006 22:02:59 -0000      1.36
@@ -34,7 +34,7 @@
 etk_button.h etk_toggle_button.h etk_check_button.h etk_radio_button.h \
 etk_entry.h etk_text_view.h \
 etk_canvas.h \
-etk_colorpicker.h etk_colorpicker_vertical.h etk_colorpicker_square.h \
+etk_colorpicker.h \
 etk_tree.h etk_tree_model.h \
 etk_range.h etk_slider.h etk_scrollbar.h \
 etk_separator.h \
@@ -74,7 +74,7 @@
 etk_button.c etk_toggle_button.c etk_check_button.c etk_radio_button.c \
 etk_entry.c etk_text_view.c \
 etk_canvas.c \
-etk_colorpicker.c etk_colorpicker_vertical.c etk_colorpicker_square.c \
+etk_colorpicker.c \
 etk_tree.c etk_tree_model.c \
 etk_range.c etk_slider.c etk_scrollbar.c \
 etk_separator.c \
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_colorpicker.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- etk_colorpicker.c   12 May 2006 19:13:39 -0000      1.9
+++ etk_colorpicker.c   16 May 2006 22:02:59 -0000      1.10
@@ -1,42 +1,58 @@
 /** @file etk_colorpicker.c */
 #include "etk_colorpicker.h"
 #include <stdlib.h>
-#include <string.h>
-#include <math.h>
+#include <stdint.h>
 #include "etk_signal.h"
 #include "etk_signal_callback.h"
 #include "etk_utils.h"
-#include "etk_box.h"
 #include "etk_radio_button.h"
-#include "etk_colorpicker_vertical.h"
-#include "etk_colorpicker_square.h"
 
 /**
  * @addtogroup Etk_Colorpicker
  * @{
  */
 
-static int _etk_colorpicker_mode[6] = {
-  ETK_COLOR_MODE_H, 
-  ETK_COLOR_MODE_S,
-  ETK_COLOR_MODE_V,
-  ETK_COLOR_MODE_R,
-  ETK_COLOR_MODE_G,
-  ETK_COLOR_MODE_B
+enum Etk_Combobox_Signal_Id
+{
+   ETK_CP_COLOR_CHANGED_SIGNAL,
+   ETK_CP_NUM_SIGNALS
 };
 
-enum _Etk_Cp_Property_Id
+enum Etk_Colorpicker_Property_Id
 {
-   ETK_CP_COLOR_MODE_PROPERTY
+   ETK_CP_MODE_PROPERTY
 };
 
 static void _etk_colorpicker_constructor(Etk_Colorpicker *cp);
 static void _etk_colorpicker_property_set(Etk_Object *object, int property_id, 
Etk_Property_Value *value);
 static void _etk_colorpicker_property_get(Etk_Object *object, int property_id, 
Etk_Property_Value *value);
+static void _etk_colorpicker_size_request(Etk_Widget *widget, Etk_Size *size);
+static void _etk_colorpicker_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry);
+
+static void _etk_colorpicker_realize_cb(Etk_Object *object, void *data);
+static void _etk_colorpicker_unrealize_cb(Etk_Object *object, void *data);
+static void _etk_colorpicker_radio_toggled_cb(Etk_Object *object, void *data);
+
+static void _etk_colorpicker_sp_mouse_down_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+static void _etk_colorpicker_sp_mouse_up_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+static void _etk_colorpicker_sp_mouse_move_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+static void _etk_colorpicker_vp_mouse_down_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+static void _etk_colorpicker_vp_mouse_up_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+static void _etk_colorpicker_vp_mouse_move_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info);
+
+static void _etk_colorpicker_sp_move_resize(Etk_Colorpicker *cp, int x, int y, 
int w, int h);
+static void _etk_colorpicker_vp_move_resize(Etk_Colorpicker *cp, int x, int y, 
int w, int h);
+
+static void _etk_colorpicker_update(Etk_Colorpicker *cp, Etk_Bool sp_image, 
Etk_Bool sp_cursor, Etk_Bool vp_image, Etk_Bool vp_cursor);
+static void _etk_colorpicker_sp_image_update(Etk_Colorpicker *cp);
+static void _etk_colorpicker_sp_cursor_update(Etk_Colorpicker *cp);
+static void _etk_colorpicker_vp_image_update(Etk_Colorpicker *cp);
+static void _etk_colorpicker_vp_cursor_update(Etk_Colorpicker *cp);
+static void _etk_colorpicker_sp_color_get(Etk_Colorpicker *cp, int i, int j, 
int *r, int *g, int *b);
+static void _etk_colorpicker_vp_color_get(Etk_Colorpicker *cp, int i, int *r, 
int *g, int *b);
+static void _etk_colorpicker_color_calc(Etk_Colorpicker_Mode mode, float 
sp_xpos, float sp_ypos, float vp_pos, int *r, int *g, int *b);
+static Etk_Signal *_etk_colorpicker_signals[ETK_CP_NUM_SIGNALS];
 
-static void _etk_colorpicker_cps_cb(Etk_Object *object, void *data);
-static void _etk_colorpicker_cpv_cb(Etk_Object *object, void *data);
-static void _etk_colorpicker_radio_cb(Etk_Object *object, void *data);
 
 /**************************
  *
@@ -46,7 +62,7 @@
 
 /**
  * @brief Gets the type of an Etk_Colorpicker
- * @return Returns the type on an Etk_Colorpicker
+ * @return Returns the type of an Etk_Colorpicker
  */
 Etk_Type *etk_colorpicker_type_get()
 {
@@ -54,10 +70,15 @@
 
    if (!cp_type)
    {
-      cp_type = etk_type_new("Etk_Colorpicker", ETK_HBOX_TYPE, 
sizeof(Etk_Colorpicker), ETK_CONSTRUCTOR(_etk_colorpicker_constructor), NULL);
-
-      etk_type_property_add(cp_type, "color_mode", ETK_CP_COLOR_MODE_PROPERTY, 
ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, 
etk_property_value_int(ETK_COLOR_MODE_H));
-
+      cp_type = etk_type_new("Etk_Colorpicker", ETK_WIDGET_TYPE, 
sizeof(Etk_Colorpicker),
+         ETK_CONSTRUCTOR(_etk_colorpicker_constructor), NULL);
+   
+      _etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL] = 
etk_signal_new("color_changed",
+         cp_type, -1, etk_marshaller_VOID__VOID, NULL, NULL);
+      
+      etk_type_property_add(cp_type, "mode", ETK_CP_MODE_PROPERTY,
+         ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, 
etk_property_value_int(ETK_COLORPICKER_H));
+   
       cp_type->property_set = _etk_colorpicker_property_set;
       cp_type->property_get = _etk_colorpicker_property_get;
    }
@@ -71,243 +92,105 @@
  */
 Etk_Widget *etk_colorpicker_new()
 {
-   return etk_widget_new(ETK_COLORPICKER_TYPE, NULL);
+   return etk_widget_new(ETK_COLORPICKER_TYPE, "theme_group", "colorpicker", 
NULL);
 }
 
 /**
- * @brief Sets the color mode used by the colorpicker
+ * @brief Sets the current color mode of the colorpicker
  * @param cp a colorpicker
- * @param color_mode the color mode to use
+ * @param mode the color mode to use
  */
-void etk_colorpicker_color_mode_set(Etk_Colorpicker *cp, Etk_Color_Mode 
color_mode)
+void etk_colorpicker_mode_set(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode)
 {
-   if (!cp)
+   if (!cp || (cp->mode == mode))
       return;
-
-   if (cp->color_mode != color_mode)
-   {
-      Etk_Colorpicker_Square *cps;
-      Etk_Colorpicker_Vertical *cpv;
-      
-      cps = ETK_COLORPICKER_SQUARE(cp->cps);
-      cpv = ETK_COLORPICKER_VERTICAL(cp->cpv);
-      
-      cp->color_mode = color_mode;
-      cps->current_color = cp->color;
-        
-      switch (cp->color_mode)
-      {
-         case ETK_COLOR_MODE_H:
-         {
-            double h, s, v;
-           
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-            cpv->cursor_pos = 255 - h * 2.55;
-            cps->cursor_y = 255 - s * 2.55;
-            cps->cursor_x = v * 2.55;
-            break;
-         }
-         case ETK_COLOR_MODE_S:
-         {
-            double h, s, v;
-
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-            cpv->cursor_pos = 255 - s * 2.55;
-            cps->cursor_y = 255 - h * 2.55;
-            cps->cursor_x = v * 2.55;
-            break;
-         }
-         case ETK_COLOR_MODE_V:
-         {
-            double h, s, v;
-            
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-            cpv->cursor_pos = 255 - v * 2.55;
-            cps->cursor_y = 255 - h * 2.55;
-            cps->cursor_x = s * 2.55;
-            break;
-         }
-         case ETK_COLOR_MODE_R:
-         {
-            cpv->cursor_pos = 255 - cp->color.r;
-            cps->cursor_y = 255 - cp->color.g;
-            cps->cursor_x = cp->color.b;
-            break;
-         }
-         case ETK_COLOR_MODE_G:
-         {
-            cpv->cursor_pos = 255 - cp->color.g;
-            cps->cursor_y = 255 - cp->color.r;
-            cps->cursor_x = cp->color.b;
-            break;
-         }
-         case ETK_COLOR_MODE_B:
-         {
-            cpv->cursor_pos = 255 - cp->color.b;
-            cps->cursor_y = 255 - cp->color.r;
-            cps->cursor_x = cp->color.g;
-            break;
-         }
-      }
-      
etk_colorpicker_vertical_color_mode_set(ETK_COLORPICKER_VERTICAL(cp->cpv), 
cp->color_mode);
-      etk_colorpicker_square_color_mode_set(ETK_COLORPICKER_SQUARE(cp->cps), 
cp->color_mode);
-      etk_object_notify(ETK_OBJECT(cp), "color_mode");
-   }
+   
+   cp->mode = mode;
+   etk_colorpicker_current_color_set(cp, cp->current_color);
+   
+   etk_object_notify(ETK_OBJECT(cp), "mode");
 }
 
 /**
- * @brief Gets the color mode used by the colorpicker
+ * @brief Gets the current color mode of colorpicker
  * @param cp a colorpicker
- * @return Returns the color mode used by the colorpicker
+ * @return Returns the current color mode of colorpicker
  */
-Etk_Color_Mode etk_colorpicker_color_mode_get(Etk_Colorpicker *cp)
+Etk_Colorpicker_Mode etk_colorpicker_mode_get(Etk_Colorpicker *cp)
 {
    if (!cp)
-      return ETK_COLOR_MODE_H;
-   return cp->color_mode;
+      return ETK_COLORPICKER_H;
+   return cp->mode;
 }
 
 /**
- * @brief Gets the color selected by the colorpicker
+ * @brief Gets the color currently selected by the colorpicker
  * @param cp a colorpicker
  * @return Returns the color selected by the colorpicker
  */
-Etk_Color etk_colorpicker_color_get(Etk_Colorpicker *cp)
+Etk_Color etk_colorpicker_current_color_get(Etk_Colorpicker *cp)
 {
    if (!cp)
    {
       Etk_Color black;
-      black.a = 0;
       black.r = 0;
       black.g = 0;
       black.b = 0;
+      black.a = 255;
       return black;
    }
-   return cp->color;
-}
-
-/**
- * @brief Converts from rgb to hsv
- * @param color the rgb color
- * @param h the location to store the h component of the result
- * @param s the location to store the s component of the result
- * @param v the location to store the v component of the result
- */
-void etk_colorpicker_rgb_to_hsv(Etk_Color color, double *h, double *s, double 
*v)
-{
-   int min, max;
-   int delta;
    
-   max = (color.r + color.g + abs(color.r - color.g)) / 2;
-   max = (max + color.b + abs(max - color.b)) / 2;
-   min = (color.r + color.g - abs(color.r - color.g)) / 2;
-   min = (min + color.b - abs(min - color.b)) / 2;
-   
-   delta = max - min;
-   *v = (double)(100 * max) / 255.0;
-   
-   if (max != 0)
-      *s = (double)(100 * delta) / (double)max;
-   else
-   {
-      *s = 0.0;
-      *h = 0.0;
-      *v = 0.0;
-   }  
-   if (color.r == max)
-   {
-      *h = (double)(100 * (color.g - color.b)) / (double)(6.0 * delta);
-   }
-   else
-   {
-      if (color.g == max)
-         *h = (double)(100 * (2 * delta + color.b - color.r)) / (double)(6.0 * 
delta);
-      else
-         *h = (double)(100 * (4 * delta + color.r - color.g)) / (double)(6.0 * 
delta);
-   }
-   if (*h < 0.0)
-      *h += 100.0;
-   if (*h > 100.0)
-      *h -= 100.0;
+   return cp->current_color;
 }
 
-/**
- * @brief Converts from hsv to rgb
- * @param h the h component of the color to convert
- * @param s the s component of the color to convert
- * @param v the v component of the color to convert
- * @param color the location to store the resulting rgb color
- */
-void etk_colorpicker_hsv_to_rgb(double h, double s, double v, Etk_Color *color)
+/* TODO: doc, signal */
+void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color)
 {
-   double hh, f;
-   double p, q, t;
-   int i;
-   
-   h = fabs(h);
-   s = fabs(s);
-   v = fabs(v);
-
-   if (s == 0.0)
-   {
-      color->r = ETK_ROUND((v * 255.0) / 100.0);
-      color->g = ETK_ROUND((v * 255.0) / 100.0);
-      color->b = ETK_ROUND((v * 255.0) / 100.0);
-      return;
-   }
+   int r, g, b;
+   float h, s, v;
    
-   hh = (h * 6.0) / 100.0;
-   i = floor(hh);
-   f = hh - (double)i;
+   r = color.r;
+   g = color.g;
+   b = color.b;
+   evas_color_rgb_to_hsv(r, g, b, &h, &s, &v);
    
-   p = fabs(v * (1.0 - s / 100.0) / 100.0);
-   q = fabs(v * (1.0 - (s * f) / 100.0) / 100.0);
-   t = fabs(v * (1.0 - s * (1.0 - f) / 100.0) / 100.0);
-   switch (i)
+   switch (cp->mode)
    {
-      case 0:
-      {
-         color->r = ETK_ROUND(v * 255.0 / 100.0);
-         color->g = ETK_ROUND(t * 255.0);
-         color->b = ETK_ROUND(p * 255.0);
+      case ETK_COLORPICKER_H:
+         cp->sp_xpos = v;
+         cp->sp_ypos = s;
+         cp->vp_pos = h / 360.0;
+         break;
+      case ETK_COLORPICKER_S:
+         cp->sp_xpos = v;
+         cp->sp_ypos = h / 360.0;
+         cp->vp_pos = s;
+         break;
+      case ETK_COLORPICKER_V:
+         cp->sp_xpos = s;
+         cp->sp_ypos = h / 360.0;
+         cp->vp_pos = v;
+         break;
+      case ETK_COLORPICKER_R:
+         cp->sp_xpos = b / 255.0;
+         cp->sp_ypos = g / 255.0;
+         cp->vp_pos = r / 255.0;
+         break;
+      case ETK_COLORPICKER_G:
+         cp->sp_xpos = b / 255.0;
+         cp->sp_ypos = r / 255.0;
+         cp->vp_pos = g / 255.0;
+         break;
+      case ETK_COLORPICKER_B:
+         cp->sp_xpos = g / 255.0;
+         cp->sp_ypos = r / 255.0;
+         cp->vp_pos = b / 255.0;
          break;
-      }
-      case 1:
-      {
-         color->r = ETK_ROUND(q * 255.0);
-         color->g = ETK_ROUND(v * 255.0 / 100.0);
-         color->b = ETK_ROUND(p * 255.0);
-         break;
-      }
-      case 2:
-      {
-         color->r = ETK_ROUND(p * 255.0);
-         color->g = ETK_ROUND(v * 255.0 / 100.0);
-         color->b = ETK_ROUND(t * 255.0);
-         break;
-      }
-      case 3:
-      {
-         color->r = ETK_ROUND(p * 255.0);
-         color->g = ETK_ROUND(q * 255.0);
-         color->b = ETK_ROUND(v * 255.0 / 100.0);
-         break;
-      }
-      case 4:
-      {
-         color->r = ETK_ROUND(t * 255.0);
-         color->g = ETK_ROUND(p * 255.0);
-         color->b = ETK_ROUND(v * 255.0 / 100.0);
-         break;
-      }
-      case 5:
-      {
-         color->r = ETK_ROUND(v * 255.0 / 100.0);
-         color->g = ETK_ROUND(p * 255.0);
-         color->b = ETK_ROUND(q * 255.0);
+      default:
          break;
-      }
    }
+   
+   _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE);
 }
 
 /**************************
@@ -316,61 +199,69 @@
  *
  **************************/
 
-/* Initializes the members */
+/* Initializes the colorpicker */
 static void _etk_colorpicker_constructor(Etk_Colorpicker *cp)
 {
-   Etk_Widget *widget;
-   Etk_Widget *vbox;
-   char *label[6] = {"H", "S", "V", "R", "G", "B"};
+   Etk_Widget *cp_widget;
+   char *labels[6] = {"H", "S", "V", "R", "G", "B"};
    int i;
 
-   if (!(widget = ETK_WIDGET(cp)))
+   if (!(cp_widget = ETK_WIDGET(cp)))
       return;
-
-   cp->cps = NULL;
-   cp->cpv = NULL;
-   cp->color_mode = ETK_COLOR_MODE_H;
-   cp->color.r = 0;
-   cp->color.g = 0;
-   cp->color.b = 0;
-   etk_box_spacing_set(ETK_BOX(cp), 6);
-
-   cp->cps = etk_colorpicker_square_new(64, 64);
-   if (cp->cps)
-   {
-      etk_widget_visibility_locked_set(cp->cps, ETK_TRUE);
-      etk_widget_size_request_set(cp->cps, 256, 256);
-      etk_box_pack_start(ETK_BOX(cp), cp->cps, ETK_FALSE, ETK_FALSE, 0);
-      etk_signal_connect("color_selected", ETK_OBJECT(cp->cps), 
ETK_CALLBACK(_etk_colorpicker_cps_cb), NULL);
-      etk_widget_show(cp->cps);
-   }
-
-   cp->cpv = etk_colorpicker_vertical_new(1, 256);
-   if (cp->cpv)
-   {
-      etk_widget_visibility_locked_set(cp->cpv, ETK_TRUE);
-      etk_widget_size_request_set(cp->cpv, 16, 256);
-      etk_box_pack_start(ETK_BOX(cp), cp->cpv, ETK_FALSE, ETK_FALSE, 0);
-      etk_signal_connect("color_selected", ETK_OBJECT(cp->cpv), 
ETK_CALLBACK(_etk_colorpicker_cpv_cb), NULL);
-      etk_widget_show(cp->cpv);
-   }
-
-   vbox = etk_vbox_new(0, ETK_TRUE);
-   etk_widget_visibility_locked_set(vbox, ETK_TRUE);
-   etk_box_pack_start(ETK_BOX(cp), vbox, ETK_FALSE, ETK_FALSE, 0);
-   etk_widget_show(vbox);
+   
+   cp->mode = ETK_COLORPICKER_H;
+   cp->current_color.r = 0;
+   cp->current_color.g = 0;
+   cp->current_color.b = 0;
+   cp->current_color.a = 255;
+   
+   cp->sp_image = NULL;
+   cp->sp_hcursor = NULL;
+   cp->sp_vcursor = NULL;
+   cp->sp_res = 64;
+   cp->sp_xpos = 0.0;
+   cp->sp_ypos = 0.0;
+   
+   cp->vp_image = NULL;
+   cp->vp_cursor = NULL;
+   cp->vp_res = 256;
+   cp->vp_pos = 0.0;
+   
+   cp->sp_dragging = ETK_FALSE;
+   cp->vp_dragging = ETK_FALSE;
+   cp->sp_image_needs_update = ETK_FALSE;
+   cp->sp_cursor_needs_update = ETK_FALSE;
+   cp->vp_image_needs_update = ETK_FALSE;
+   cp->vp_cursor_needs_update = ETK_FALSE;
+   
+   cp->radio_vbox = etk_vbox_new(0, ETK_TRUE);
+   etk_widget_parent_set(cp->radio_vbox, cp_widget);
+   etk_widget_visibility_locked_set(cp->radio_vbox, ETK_TRUE);
+   etk_widget_show(cp->radio_vbox);
+   
    for (i = 0; i < 6; i++)
    {
-      if (i == 0)
-         cp->radio[i] = etk_radio_button_new_with_label(label[i], NULL);
-      else
-         cp->radio[i] = etk_radio_button_new_with_label_from_widget(label[i], 
ETK_RADIO_BUTTON(cp->radio[0]));
-      etk_widget_visibility_locked_set(cp->radio[i], ETK_TRUE);
-      etk_box_pack_start(ETK_BOX(vbox), cp->radio[i], ETK_TRUE, ETK_TRUE, 0);
-      etk_widget_show(cp->radio[i]);
+      cp->radios[i] = etk_radio_button_new_with_label_from_widget(labels[i],
+         (i == 0) ? NULL : ETK_RADIO_BUTTON(cp->radios[0]));
+      etk_box_pack_start(ETK_BOX(cp->radio_vbox), cp->radios[i], ETK_TRUE, 
ETK_TRUE, 0);
+      etk_widget_visibility_locked_set(cp->radios[i], ETK_TRUE);
+      etk_widget_show(cp->radios[i]);
 
-      etk_signal_connect("pressed", ETK_OBJECT(cp->radio[i]), 
ETK_CALLBACK(_etk_colorpicker_radio_cb), &_etk_colorpicker_mode[i]);
+      etk_signal_connect("toggled", ETK_OBJECT(cp->radios[i]),
+         ETK_CALLBACK(_etk_colorpicker_radio_toggled_cb), cp);
    }
+   
+   cp_widget->size_request = _etk_colorpicker_size_request;
+   cp_widget->size_allocate = _etk_colorpicker_size_allocate;
+   
+   etk_signal_connect("realize", ETK_OBJECT(cp), 
ETK_CALLBACK(_etk_colorpicker_realize_cb), NULL);
+   etk_signal_connect("unrealize", ETK_OBJECT(cp), 
ETK_CALLBACK(_etk_colorpicker_unrealize_cb), NULL);
+   
+   Etk_Color test;
+   test.r = 161;
+   test.g = 177;
+   test.b = 0;
+   etk_colorpicker_current_color_set(cp, test);
 }
 
 /* Sets the property whose id is "property_id" to the value "value" */
@@ -383,8 +274,8 @@
 
    switch (property_id)
    {
-      case ETK_CP_COLOR_MODE_PROPERTY:
-         etk_colorpicker_color_mode_set(cp, etk_property_value_int_get(value));
+      case ETK_CP_MODE_PROPERTY:
+         etk_colorpicker_mode_set(cp, etk_property_value_int_get(value));
          break;
       default:
          break;
@@ -401,140 +292,490 @@
 
    switch (property_id)
    {
-      case ETK_CP_COLOR_MODE_PROPERTY:
-         etk_property_value_int_set(value, cp->color_mode);
+      case ETK_CP_MODE_PROPERTY:
+         etk_property_value_int_set(value, cp->mode);
          break;
       default:
          break;
    }
 }
 
-/* Called when a color is selected with the cps */
-static void _etk_colorpicker_cps_cb(Etk_Object *object, void *data)
+/* Calculates the ideal size of the colorpicker */
+/* TODO: size_request */
+static void _etk_colorpicker_size_request(Etk_Widget *widget, Etk_Size *size)
+{
+   if (!size)
+      return;
+   
+   size->w = 480;
+   size->h = 200;
+}
+
+/* Resizes the colorpicker to the allocated size */
+/* TODO: size_allocate */
+static void _etk_colorpicker_size_allocate(Etk_Widget *widget, Etk_Geometry 
geometry)
 {
    Etk_Colorpicker *cp;
+   Etk_Geometry child_geometry;
+   
+   if (!(cp = ETK_COLORPICKER(widget)))
+      return;
+   
+   /* First, updates the data of the images if needed */
+   if (cp->sp_image_needs_update)
+      _etk_colorpicker_sp_image_update(cp);
+   if (cp->sp_cursor_needs_update)
+      _etk_colorpicker_sp_cursor_update(cp);
+   if (cp->vp_image_needs_update)
+      _etk_colorpicker_vp_image_update(cp);
+   if (cp->vp_cursor_needs_update)
+      _etk_colorpicker_vp_cursor_update(cp);
+   
+   /* Then, moves and resizes the objects */
+   _etk_colorpicker_sp_move_resize(cp, geometry.x, geometry.y, (geometry.w / 
2) - 30, geometry.h);
+   _etk_colorpicker_vp_move_resize(cp, geometry.x + (geometry.w / 2) - 25, 
geometry.y, 20, geometry.h);
+   
+   child_geometry.x = geometry.x + (geometry.w / 2);
+   child_geometry.y = geometry.y;
+   child_geometry.w = geometry.w / 2;
+   child_geometry.h = geometry.h;
+   etk_widget_size_allocate(cp->radio_vbox, child_geometry);
    
-   cp = ETK_COLORPICKER(ETK_WIDGET(object)->parent);
-   cp->color = 
etk_colorpicker_square_color_get(ETK_COLORPICKER_SQUARE(object), 
ETK_COLORPICKER_SQUARE(object)->cursor_x, 
ETK_COLORPICKER_SQUARE(object)->cursor_y);
+   cp->sp_image_needs_update = ETK_FALSE;
+   cp->sp_cursor_needs_update = ETK_FALSE;
+   cp->vp_image_needs_update = ETK_FALSE;
+   cp->vp_cursor_needs_update = ETK_FALSE;
 }
 
-/* Called when a color is selected with the cpv */
-static void _etk_colorpicker_cpv_cb(Etk_Object *object, void *data)
+/**************************
+ *
+ * Callbacks and handlers
+ *
+ **************************/
+
+/* Called when the colorpicker is realized */
+/* TODO: use smart objects! */
+static void _etk_colorpicker_realize_cb(Etk_Object *object, void *data)
 {
    Etk_Colorpicker *cp;
-   Etk_Colorpicker_Square *cps;
-   Etk_Colorpicker_Vertical *cpv;
-   Etk_Color color;
+   Evas *evas;
+   
+   if (!(cp = ETK_COLORPICKER(object)) || !(evas = 
etk_widget_toplevel_evas_get(ETK_WIDGET(cp))))
+      return;
+   
+   /* Square picker */
+   cp->sp_image = evas_object_image_add(evas);
+   evas_object_image_alpha_set(cp->sp_image, 0);
+   evas_object_image_size_set(cp->sp_image, cp->sp_res, cp->sp_res);
+   evas_object_show(cp->sp_image);
+   etk_widget_member_object_add(ETK_WIDGET(cp), cp->sp_image);
+   
+   cp->sp_hcursor = evas_object_image_add(evas);
+   evas_object_image_alpha_set(cp->sp_hcursor, 0);
+   evas_object_image_size_set(cp->sp_hcursor, cp->sp_res, 1);
+   evas_object_pass_events_set(cp->sp_hcursor, 1);
+   evas_object_show(cp->sp_hcursor);
+   etk_widget_member_object_add(ETK_WIDGET(cp), cp->sp_hcursor);
+   
+   cp->sp_vcursor = evas_object_image_add(evas);
+   evas_object_image_alpha_set(cp->sp_vcursor, 0);
+   evas_object_image_size_set(cp->sp_vcursor, 1, cp->sp_res);
+   evas_object_pass_events_set(cp->sp_vcursor, 1);
+   evas_object_show(cp->sp_vcursor);
+   etk_widget_member_object_add(ETK_WIDGET(cp), cp->sp_vcursor);
+   
+   /* Vertical picker */
+   cp->vp_image = evas_object_image_add(evas);
+   evas_object_image_alpha_set(cp->vp_image, 0);
+   evas_object_image_size_set(cp->vp_image, 1, cp->vp_res);
+   evas_object_show(cp->vp_image);
+   etk_widget_member_object_add(ETK_WIDGET(cp), cp->vp_image);
+   
+   cp->vp_cursor = evas_object_image_add(evas);
+   evas_object_image_alpha_set(cp->vp_cursor, 0);
+   evas_object_image_size_set(cp->vp_cursor, 1, 1);
+   evas_object_pass_events_set(cp->vp_cursor, 1);
+   evas_object_show(cp->vp_cursor);
+   etk_widget_member_object_add(ETK_WIDGET(cp), cp->vp_cursor);
    
-   cp = ETK_COLORPICKER(ETK_WIDGET(object)->parent);
-   cps = ETK_COLORPICKER_SQUARE(cp->cps);
-   cpv = ETK_COLORPICKER_VERTICAL(cp->cpv);
+   /* Adds the mouse callbacks */
+   evas_object_event_callback_add(cp->sp_image, EVAS_CALLBACK_MOUSE_DOWN, 
_etk_colorpicker_sp_mouse_down_cb, cp);
+   evas_object_event_callback_add(cp->sp_image, EVAS_CALLBACK_MOUSE_UP, 
_etk_colorpicker_sp_mouse_up_cb, cp);
+   evas_object_event_callback_add(cp->sp_image, EVAS_CALLBACK_MOUSE_MOVE, 
_etk_colorpicker_sp_mouse_move_cb, cp);
+   evas_object_event_callback_add(cp->vp_image, EVAS_CALLBACK_MOUSE_DOWN, 
_etk_colorpicker_vp_mouse_down_cb, cp);
+   evas_object_event_callback_add(cp->vp_image, EVAS_CALLBACK_MOUSE_UP, 
_etk_colorpicker_vp_mouse_up_cb, cp);
+   evas_object_event_callback_add(cp->vp_image, EVAS_CALLBACK_MOUSE_MOVE, 
_etk_colorpicker_vp_mouse_move_cb, cp);
+   
+   /* Updates the colorpicker */
+   _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE);
+}
 
-   color = etk_colorpicker_vertical_color_get(cpv, cpv->cursor_pos);
+/* Called when the colorpicker is unrealized */
+static void _etk_colorpicker_unrealize_cb(Etk_Object *object, void *data)
+{
+   Etk_Colorpicker *cp;
+   
+   if (!(cp = ETK_COLORPICKER(object)))
+      return;
+   
+   cp->sp_image = NULL;
+   cp->sp_hcursor = NULL;
+   cp->sp_vcursor = NULL;
+   cp->vp_image = NULL;
+   cp->vp_cursor = NULL;
+}
 
-   switch (cp->color_mode)
+/* Called when the color mode is changed with the radio buttons */
+static void _etk_colorpicker_radio_toggled_cb(Etk_Object *object, void *data)
+{
+   Etk_Colorpicker *cp;
+   Etk_Widget *radio;
+   int i;
+   
+   if (!(radio = ETK_WIDGET(object)) || !(cp = ETK_COLORPICKER(data)))
+      return;
+   if (!etk_toggle_button_active_get(ETK_TOGGLE_BUTTON(radio)))
+      return;
+   
+   for (i = 0; i < 6; i++)
    {
-      case ETK_COLOR_MODE_H:
+      if (cp->radios[i] == radio)
       {
-         double h, s, v;
-         double h1, s1, v1;
-
-         etk_colorpicker_rgb_to_hsv(cp->color, &h1, &s1, &v1);
-         etk_colorpicker_rgb_to_hsv(color, &h, &s, &v);
-         etk_colorpicker_hsv_to_rgb(h, s1, v1, &color);
-         if (cp->color.r != color.r ||
-            cp->color.g != color.g ||
-            cp->color.b != color.b)
-         {
-            cp->color = color;
-            cps->current_color = color;
-         }
-         break;
+         etk_colorpicker_mode_set(cp, i);
+         return;
       }
-      case ETK_COLOR_MODE_S:
+   }
+}
+
+/* Called when the square picker is pressed by the mouse */
+static void _etk_colorpicker_sp_mouse_down_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   Evas_Event_Mouse_Down *event;
+   int x, y, w, h;
+   
+   if (!(cp = ETK_COLORPICKER(data)) || !(event = event_info))
+      return;
+   
+   evas_object_geometry_get(cp->sp_image, &x, &y, &w, &h);
+   cp->sp_xpos = ETK_CLAMP((float)(event->canvas.x - x) / w, 0.0, 1.0);
+   cp->sp_ypos = 1.0 - ETK_CLAMP((float)(event->canvas.y - y) / h, 0.0, 1.0);
+   _etk_colorpicker_update(cp, ETK_FALSE, ETK_TRUE, ETK_FALSE, ETK_FALSE);
+   
+   cp->sp_dragging = ETK_TRUE;
+}
+
+/* Called when the square picker is released by the mouse */
+static void _etk_colorpicker_sp_mouse_up_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   
+   if (!(cp = ETK_COLORPICKER(data)))
+      return;
+   cp->sp_dragging = ETK_FALSE;
+}
+
+/* Called when the mouse is moved over the square picker */
+static void _etk_colorpicker_sp_mouse_move_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   Evas_Event_Mouse_Move *event;
+   int x, y, w, h;
+   
+   if (!(cp = ETK_COLORPICKER(data)) || !(event = event_info) || 
!cp->sp_dragging)
+      return;
+   
+   evas_object_geometry_get(cp->sp_image, &x, &y, &w, &h);
+   cp->sp_xpos = ETK_CLAMP((float)(event->cur.canvas.x - x) / w, 0.0, 1.0);
+   cp->sp_ypos = 1.0 - ETK_CLAMP((float)(event->cur.canvas.y - y) / h, 0.0, 
1.0);
+   _etk_colorpicker_update(cp, ETK_FALSE, ETK_TRUE, ETK_FALSE, ETK_FALSE);
+}
+
+/* Called when the vertical picker is pressed by the mouse */
+static void _etk_colorpicker_vp_mouse_down_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   Evas_Event_Mouse_Down *event;
+   int y, h;
+   
+   if (!(cp = ETK_COLORPICKER(data)) || !(event = event_info))
+      return;
+   
+   evas_object_geometry_get(cp->vp_image, NULL, &y, NULL, &h);
+   cp->vp_pos = 1.0 - ETK_CLAMP((float)(event->canvas.y - y) / h, 0.0, 1.0);
+   _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE);
+   
+   cp->vp_dragging = ETK_TRUE;
+}
+
+/* Called when the vertical picker is released by the mouse */
+static void _etk_colorpicker_vp_mouse_up_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   
+   if (!(cp = ETK_COLORPICKER(data)))
+      return;
+   cp->vp_dragging = ETK_FALSE;
+}
+
+/* Called when the mouse is moved over the vertical picker */
+static void _etk_colorpicker_vp_mouse_move_cb(void *data, Evas *e, Evas_Object 
*obj, void *event_info)
+{
+   Etk_Colorpicker *cp;
+   Evas_Event_Mouse_Move *event;
+   int y, h;
+   
+   if (!(cp = ETK_COLORPICKER(data)) || !(event = event_info) || 
!cp->vp_dragging)
+      return;
+   
+   evas_object_geometry_get(cp->vp_image, NULL, &y, NULL, &h);
+   cp->vp_pos = 1.0 - ETK_CLAMP((float)(event->cur.canvas.y - y) / h, 0.0, 
1.0);
+   _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE);
+}
+
+/**************************
+ *
+ * Private functions
+ *
+ **************************/
+
+/* Moves and resizes the square picker */
+static void _etk_colorpicker_sp_move_resize(Etk_Colorpicker *cp, int x, int y, 
int w, int h)
+{
+   if (!cp || !cp->sp_image || !cp->sp_hcursor || !cp->sp_vcursor)
+      return;
+   
+   evas_object_move(cp->sp_image, x, y);
+   evas_object_resize(cp->sp_image, w, h);
+   evas_object_image_fill_set(cp->sp_image, 0, 0, w, h);
+   
+   evas_object_move(cp->sp_hcursor, x, y + ((1.0 - cp->sp_ypos) * h));
+   evas_object_resize(cp->sp_hcursor, w, 1);
+   evas_object_image_fill_set(cp->sp_hcursor, 0, 0, w, 1);
+   
+   evas_object_move(cp->sp_vcursor, x + (cp->sp_xpos * w), y);
+   evas_object_resize(cp->sp_vcursor, 1, h);
+   evas_object_image_fill_set(cp->sp_vcursor, 0, 0, 1, h);
+}
+
+/* Moves and resizes the vertical picker */
+static void _etk_colorpicker_vp_move_resize(Etk_Colorpicker *cp, int x, int y, 
int w, int h)
+{
+   if (!cp || !cp->vp_image || !cp->vp_cursor)
+      return;
+   
+   evas_object_move(cp->vp_image, x, y);
+   evas_object_resize(cp->vp_image, w, h);
+   evas_object_image_fill_set(cp->vp_image, 0, 0, w, h);
+   
+   evas_object_move(cp->vp_cursor, x, y + ((1.0 - cp->vp_pos) * h));
+   evas_object_resize(cp->vp_cursor, w, 1);
+   evas_object_image_fill_set(cp->vp_cursor, 0, 0, w, 1);
+}
+
+/* Updates of the colorpicker */ 
+static void _etk_colorpicker_update(Etk_Colorpicker *cp, Etk_Bool sp_image, 
Etk_Bool sp_cursor, Etk_Bool vp_image, Etk_Bool vp_cursor)
+{
+   int r, g, b;
+   
+   if (!cp)
+      return;
+   
+   cp->sp_image_needs_update |= sp_image;
+   cp->sp_cursor_needs_update |= sp_cursor;
+   cp->vp_image_needs_update |= vp_image;
+   cp->vp_cursor_needs_update |= vp_cursor;
+   
+   /* Updates the color */
+   _etk_colorpicker_color_calc(cp->mode, cp->sp_xpos, cp->sp_ypos, cp->vp_pos, 
&r, &g, &b);
+   if (cp->current_color.r != r || cp->current_color.g != g || 
cp->current_color.b != b)
+   {
+      cp->current_color.r = r;
+      cp->current_color.g = g;
+      cp->current_color.b = b;
+      etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], 
ETK_OBJECT(cp), NULL);
+   }
+   
+   etk_widget_redraw_queue(ETK_WIDGET(cp));
+}
+
+/* Updates the square picker image */
+static void _etk_colorpicker_sp_image_update(Etk_Colorpicker *cp)
+{
+   uint32_t *data;
+   int i, j;
+   int r, g, b;
+   
+   if (!cp || !cp->sp_image)
+      return;
+   if (!(data = (uint32_t *)evas_object_image_data_get(cp->sp_image, 1)))
+      return;
+   
+   for (i = 0; i < cp->sp_res; i++)
+   {
+      for (j = 0; j < cp->sp_res; j++)
       {
-         double h, s, v;
-         double h1, s1, v1;
-      
-         etk_colorpicker_rgb_to_hsv(cp->color, &h1, &s1, &v1);
-         etk_colorpicker_rgb_to_hsv(color, &h, &s, &v);
-         etk_colorpicker_hsv_to_rgb(h1, s, v1, &color);
-         if (cp->color.r != color.r ||
-            cp->color.g != color.g ||
-            cp->color.b != color.b)
-         {
-            cp->color = color;
-            cps->current_color = color;
-         }
-         break;
+         _etk_colorpicker_sp_color_get(cp, i, j, &r, &g, &b);
+         *data = ((r << 16) | (g << 8) | b);
+         data++;
       }
-      case ETK_COLOR_MODE_V:
+   }
+   
+   evas_object_image_data_update_add(cp->sp_image, 0, 0, cp->sp_res, 
cp->sp_res);
+}
+
+/* Updates the cursor of the square picker */
+static void _etk_colorpicker_sp_cursor_update(Etk_Colorpicker *cp)
+{
+   uint32_t *data;
+   int i, j;
+   int r, g, b;
+   
+   if (!cp)
+      return;
+   
+   /* Updates the horizontal cursor */
+   if (cp->sp_hcursor && (data = (uint32_t 
*)evas_object_image_data_get(cp->sp_hcursor, 1)))
+   {
+      j = cp->sp_res * (1.0 - cp->sp_ypos);
+      for (i = 0; i < cp->sp_res; i++)
       {
-         double h, s, v;
-         double h1, s1, v1;
-      
-         etk_colorpicker_rgb_to_hsv(cp->color, &h1, &s1, &v1);
-         etk_colorpicker_rgb_to_hsv(color, &h, &s, &v);
-         etk_colorpicker_hsv_to_rgb(h1, s1, v, &color);
-         if (cp->color.r != color.r ||
-            cp->color.g != color.g ||
-            cp->color.b != color.b)
-         {
-            cp->color = color;
-            cps->current_color = color;
-         }
-         break;
+         _etk_colorpicker_sp_color_get(cp, i, j, &r, &g, &b);
+         *data = (((255 - r) << 16) | ((255 - g) << 8) | (255 - b));
+         data++;
       }
-      case ETK_COLOR_MODE_R:
+      evas_object_image_data_update_add(cp->sp_hcursor, 0, 0, cp->sp_res, 1);
+   }
+   
+   /* Updates the vertical cursor */
+   if (cp->sp_vcursor && (data = (uint32_t 
*)evas_object_image_data_get(cp->sp_vcursor, 1)))
+   {
+      i = cp->sp_res * cp->sp_xpos;
+      for (j = 0; j < cp->sp_res; j++)
       {
-         double h, s, v;
-      
-         if (cp->color.r != color.r)
-         {
-            cp->color.r = color.r;
-            cps->current_color.r = color.r;
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-         }
-         break;
+         _etk_colorpicker_sp_color_get(cp, i, j, &r, &g, &b);
+         *data = (((255 - r) << 16) | ((255 - g) << 8) | (255 - b));
+         data++;
       }
-      case ETK_COLOR_MODE_G:
-      {
-         double h, s, v;
-      
-         if (cp->color.g != color.g)
-         {
-            cp->color.g = color.g;
-            cps->current_color.g = color.g;
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-         }
+      evas_object_image_data_update_add(cp->sp_vcursor, 0, 0, 1, cp->sp_res);
+   }
+}
+
+/* Updates the vertical picker image */
+static void _etk_colorpicker_vp_image_update(Etk_Colorpicker *cp)
+{
+   uint32_t *data;
+   int i;
+   int r, g, b;
+   
+   if (!cp || !cp->vp_image)
+      return;
+   if (!(data = (uint32_t *)evas_object_image_data_get(cp->vp_image, 1)))
+      return;
+   
+   for (i = 0; i < cp->vp_res; i++)
+   {
+      _etk_colorpicker_vp_color_get(cp, i, &r, &g, &b);
+      *data = ((r << 16) | (g << 8) | b);
+      data++;
+   }
+   
+   evas_object_image_data_update_add(cp->vp_image, 0, 0, 1, cp->vp_res);
+}
+
+/* Updates the vertical picker cursor */
+static void _etk_colorpicker_vp_cursor_update(Etk_Colorpicker *cp)
+{
+   uint32_t *data;
+   int r, g, b;
+   
+   if (!cp || !cp->vp_cursor)
+      return;
+   if (!(data = (uint32_t *)evas_object_image_data_get(cp->vp_cursor, 1)))
+      return;
+   
+   _etk_colorpicker_vp_color_get(cp, cp->vp_res * (1.0 - cp->vp_pos), &r, &g, 
&b);
+   *data = (((255 - r) << 16) | ((255 - g) << 8) | (255 - b));
+   
+   evas_object_image_data_update_add(cp->vp_cursor, 0, 0, 1, 1);
+}
+
+/* Get the color of the square picker's image, at the point (i, j). (r, g, b) 
must not be NULL! */
+static void _etk_colorpicker_sp_color_get(Etk_Colorpicker *cp, int i, int j, 
int *r, int *g, int *b)
+{
+   _etk_colorpicker_color_calc(cp->mode, 1.0 - ((float)i / cp->sp_res), 
(float)j / cp->sp_res, cp->vp_pos, r, g, b);
+}
+
+/* Get the color of the vertical picker's image, at the point i. (r, g, b) 
must not be NULL!  */
+static void _etk_colorpicker_vp_color_get(Etk_Colorpicker *cp, int i, int *r, 
int *g, int *b)
+{
+   switch (cp->mode)
+   {
+      case ETK_COLORPICKER_H:
+         evas_color_hsv_to_rgb(360.0 * (1.0 - ((float)i / cp->vp_res)), 1.0, 
1.0, r, g, b);
          break;
-      }
-      case ETK_COLOR_MODE_B:
-      {
-         double h, s, v;
-      
-         if (cp->color.b != color.b)
-         {
-            cp->color.b = color.b;
-            cps->current_color.b = color.b;
-            etk_colorpicker_rgb_to_hsv(cp->color, &h, &s, &v);
-         }
+      case ETK_COLORPICKER_S:
+         *r = 255 - ((i * 255) / cp->vp_res);
+         *g = 255 - ((i * 255) / cp->vp_res);
+         *b = 255 - ((i * 255) / cp->vp_res);
+         break;
+      case ETK_COLORPICKER_V:
+         *r = 255 - ((i * 255) / cp->vp_res);
+         *g = 255 - ((i * 255) / cp->vp_res);
+         *b = 255 - ((i * 255) / cp->vp_res);
+         break;
+      case ETK_COLORPICKER_R:
+         *r = 255 - ((i * 255) / cp->vp_res);
+         *g = 0;
+         *b = 0;
+         break;
+      case ETK_COLORPICKER_G:
+         *r = 0;
+         *g = 255 - ((i * 255) / cp->vp_res);
+         *b = 0;
+         break;
+      case ETK_COLORPICKER_B:
+         *r = 0;
+         *g = 0;
+         *b = 255 - ((i * 255) / cp->vp_res);
+         break;
+      default:
          break;
-      }
    }
-   etk_colorpicker_square_update(cps);
 }
 
-/* Called when the color mode is changed with the radio buttons */
-static void _etk_colorpicker_radio_cb(Etk_Object *object, void *data)
+/* Calculates a color according to the color mode and the positions of the 
cursors */
+static void _etk_colorpicker_color_calc(Etk_Colorpicker_Mode mode, float 
sp_xpos, float sp_ypos, float vp_pos, int *r, int *g, int *b)
 {
-   Etk_Colorpicker *cp;
-   Etk_Widget *w;
-   Etk_Color_Mode color_mode = *(Etk_Color_Mode *)data;
-   
-   w = ETK_WIDGET(ETK_WIDGET(object)->parent);
-   cp = ETK_COLORPICKER(w->parent);
-   etk_colorpicker_color_mode_set(cp, color_mode);
+   switch (mode)
+   {
+      case ETK_COLORPICKER_H:
+         evas_color_hsv_to_rgb(vp_pos * 360.0, sp_xpos, sp_ypos, r, g, b);
+         break;
+      case ETK_COLORPICKER_S:
+         evas_color_hsv_to_rgb(sp_xpos * 360.0, vp_pos, sp_ypos, r, g, b);
+         break;
+      case ETK_COLORPICKER_V:
+         evas_color_hsv_to_rgb(sp_xpos * 360.0, sp_ypos, vp_pos, r, g, b);
+         break;
+      case ETK_COLORPICKER_R:
+         *r = 255 * vp_pos;
+         *g = 255 * sp_xpos;
+         *b = 255 * sp_ypos;
+         break;
+      case ETK_COLORPICKER_G:
+         *r = 255 * sp_xpos;
+         *g = 255 * vp_pos;
+         *b = 255 * sp_ypos;
+         break;
+      case ETK_COLORPICKER_B:
+         *r = 255 * sp_xpos;
+         *g = 255 * sp_ypos;
+         *b = 255 * vp_pos;
+         break;
+      default:
+         break;
+   }
 }
 
 /** @} */
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_colorpicker.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_colorpicker.h   12 May 2006 19:13:39 -0000      1.3
+++ etk_colorpicker.h   16 May 2006 22:03:00 -0000      1.4
@@ -7,55 +7,73 @@
 
 /**
  * @defgroup Etk_Colorpicker Etk_Colorpicker
+ * @brief TODO: doc
  * @{
  */
 
-/** @brief Gets the type of a colorpicker */
+/** Gets the type of a colorpicker */
 #define ETK_COLORPICKER_TYPE        (etk_colorpicker_type_get())
-/** @brief Casts the object to a colorpicker */
+/** Casts the object to a colorpicker */
 #define ETK_COLORPICKER(obj)        (ETK_OBJECT_CAST((obj), 
ETK_COLORPICKER_TYPE, Etk_Colorpicker))
-/** @brief Check if the object is an Etk_Colorpicker */
+/** Check if the object is an Etk_Colorpicker */
 #define ETK_IS_COLORPICKER(obj)     (ETK_OBJECT_CHECK_TYPE((obj), 
ETK_COLORPICKER_TYPE))
 
-/**
- * @enum Etk_Color_Mode
- * @brief The color modes used by the colorpicker
- */
-enum _Etk_Color_Mode
+/** @brief The color modes used by the colorpicker */
+typedef enum Etk_Colorpicker_Mode
 {
-   ETK_COLOR_MODE_H, 
-   ETK_COLOR_MODE_S,
-   ETK_COLOR_MODE_V,
-   ETK_COLOR_MODE_R,
-   ETK_COLOR_MODE_G,
-   ETK_COLOR_MODE_B
-};
+   ETK_COLORPICKER_H,     /**< The "Hue" mode */
+   ETK_COLORPICKER_S,     /**< The "Saturation" mode */
+   ETK_COLORPICKER_V,     /**< The "Value" mode */
+   ETK_COLORPICKER_R,     /**< The "Red" mode */
+   ETK_COLORPICKER_G,     /**< The "Green" mode */
+   ETK_COLORPICKER_B      /**< The "Blue" mode */
+} Etk_Colorpicker_Mode;
 
-struct _Etk_Colorpicker
+/**
+ * @brief @widget The structure of a colorpicker
+ * @structinfo
+ */
+struct Etk_Colorpicker
 {
-  Etk_HBox hbox;
-  
-  Etk_Widget *cps;
-  Etk_Widget *cpv;
-  Etk_Widget *radio[6];
-  
-  Etk_Color_Mode color_mode;
-  
-  Etk_Color color;
+   /* private: */
+   /* Inherit from Etk_Widget */
+   Etk_Widget widget;
+   
+   /* Square picker */
+   Evas_Object *sp_image;
+   Evas_Object *sp_hcursor;
+   Evas_Object *sp_vcursor;
+   int sp_res;
+   float sp_xpos, sp_ypos;
+   Etk_Bool sp_dragging;
+   Etk_Bool sp_image_needs_update;
+   Etk_Bool sp_cursor_needs_update;
+   
+   /* Vertical picker */
+   Evas_Object *vp_image;
+   Evas_Object *vp_cursor;
+   int vp_res;
+   float vp_pos;
+   Etk_Bool vp_dragging;
+   Etk_Bool vp_image_needs_update;
+   Etk_Bool vp_cursor_needs_update;
+   
+   Etk_Widget *radio_vbox;
+   Etk_Widget *radios[6];
+   
+   Etk_Colorpicker_Mode mode;
+   Etk_Color current_color;
 };
 
 Etk_Type *etk_colorpicker_type_get();
 Etk_Widget *etk_colorpicker_new();
 
-void etk_colorpicker_color_mode_set(Etk_Colorpicker *cp, Etk_Color_Mode 
color_mode);
-Etk_Color_Mode etk_colorpicker_color_mode_get(Etk_Colorpicker *cp);
-
-Etk_Color etk_colorpicker_color_get(Etk_Colorpicker *cp);
+void etk_colorpicker_mode_set(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode);
+Etk_Colorpicker_Mode etk_colorpicker_mode_get(Etk_Colorpicker *cp);
 
-void etk_colorpicker_rgb_to_hsv(Etk_Color color, double *h, double *s, double 
*v);
-void etk_colorpicker_hsv_to_rgb(double h, double s, double v, Etk_Color 
*color);
+void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color);
+Etk_Color etk_colorpicker_current_color_get(Etk_Colorpicker *cp);
 
 /** @} */
 
-
-#endif /*  __ETK_COLORPICKER_H__ */
+#endif
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_combobox.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- etk_combobox.h      14 May 2006 14:14:58 -0000      1.9
+++ etk_combobox.h      16 May 2006 22:03:00 -0000      1.10
@@ -58,7 +58,7 @@
 };
 
 /**
- * @brief An item of a combobox
+ * @brief @widget The structure of an item of a combobox
  * @structinfo
  */
 struct Etk_Combobox_Item
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_types.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- etk_types.h 14 May 2006 21:29:22 -0000      1.39
+++ etk_types.h 16 May 2006 22:03:00 -0000      1.40
@@ -65,10 +65,7 @@
 typedef struct _Etk_Entry Etk_Entry;
 typedef struct _Etk_Text_View Etk_Text_View;
 typedef struct Etk_Canvas Etk_Canvas;
-typedef struct _Etk_Colorpicker Etk_Colorpicker;
-typedef struct _Etk_Colorpicker_Vertical Etk_Colorpicker_Vertical;
-typedef struct _Etk_Colorpicker_Square Etk_Colorpicker_Square;
-typedef enum   _Etk_Color_Mode Etk_Color_Mode;
+typedef struct Etk_Colorpicker Etk_Colorpicker;
 typedef struct _Etk_Tree Etk_Tree;
 typedef enum   _Etk_Tree_Mode Etk_Tree_Mode;
 typedef struct _Etk_Tree_Col Etk_Tree_Col;
@@ -118,11 +115,14 @@
 
 /**
  * @struct Etk_Color
- * @brief A color
+ * @brief A RGBA color
  */
 typedef struct Etk_Color
 {
-   int r, g, b, a;
+   int r;       /**< The red component of the color */
+   int g;       /**< The green component of the color */
+   int b;       /**< The blue component of the color */
+   int a;       /**< The alpha component of the color */
 } Etk_Color;
 
 /** @} */




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to