Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk
Dir : e17/libs/etk/src/lib Modified Files: etk_cache.c etk_canvas.c etk_canvas.h etk_check_button.c etk_check_button.h etk_colorpicker.c etk_colorpicker.h etk_frame.c etk_shadow.c etk_signal_callback.h Log Message: * [Canvas] Don't resize the object when adding it. * [Colorpicker] Fix bug where "color_changed" signal where not emitted or emitted twice * [Colorpicker] Rename the swallow parts of the theme-groups * Doc++ and cleanup =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_cache.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- etk_cache.c 17 Jan 2007 21:46:56 -0000 1.14 +++ etk_cache.c 23 Feb 2007 20:44:41 -0000 1.15 @@ -300,5 +300,11 @@ * @addtogroup Etk_Cache * * You will almost never have to use Etk_Cache directly, except if you are implementing a new widget that needs to - * load a lot of images efficiently, or if you are creating a new tree-model that displays images. + * load a lot of images efficiently, or if you are creating a new tree-model that displays images. @n + * + * The cache system is a simple pool where you can store a limited number of Evas objects associated to a filename and + * to a key. If you try to add a new object with etk_cache_add() while the cache is already full, the oldest object + * of the cache will be destroyed. You can then retrieve a cached object from its filename/key with etk_cache_find(). @n + * You can also dynamically change the maximum size of the cache system with etk_cache_size_set() and know the current + * number of cached objects with etk_cache_num_objects_get(). */ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_canvas.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- etk_canvas.c 20 Oct 2006 17:51:44 -0000 1.17 +++ etk_canvas.c 23 Feb 2007 20:44:41 -0000 1.18 @@ -27,7 +27,7 @@ * @brief Gets the type of an Etk_Canvas * @return Returns the type of an Etk_Canvas */ -Etk_Type *etk_canvas_type_get() +Etk_Type *etk_canvas_type_get(void) { static Etk_Type *canvas_type = NULL; @@ -44,22 +44,21 @@ * @brief Creates a new canvas * @return Returns the new canvas widget */ -Etk_Widget *etk_canvas_new() +Etk_Widget *etk_canvas_new(void) { return etk_widget_new(ETK_CANVAS_TYPE, NULL); } /** - * @brief Adds an evas object to the canvas. The object will be moved to the top left corner of the canvas - * and will be resized to 32x32. The object will also be clipped against the canvas. @n - * You can then use any Evas function to control the object + * @brief Adds an Evas object to the canvas. The object will be moved to the top left corner of the canvas and + * will be clipped against the canvas. You can then use any Evas function to control the object * @param canvas a canvas * @param object the object to add - * @return Returns ETK_TRUE on success, or ETK_FALSE on failure - * (probably because the canvas and the object do not belong to the same evas) + * @return Returns ETK_TRUE on success, or ETK_FALSE on failure (probably because the canvas and + * the object do not belong to the same Evas) * @note The object will be automatically deleted when the canvas is destroyed * @warning The object position remains relative to the window, and not to the canvas itself - * (See the detailed description Etk_Canvas, at the top of this page, for more information) + * (See the detailed description of Etk_Canvas, at the top of this page, for more information) */ Etk_Bool etk_canvas_object_add(Etk_Canvas *canvas, Evas_Object *object) { @@ -78,7 +77,6 @@ if ((result = etk_widget_member_object_add(ETK_WIDGET(canvas), object))) { evas_object_move(object, cx, cy); - evas_object_resize(object, 32, 32); evas_object_clip_set(object, canvas->clip); evas_object_show(canvas->clip); @@ -90,7 +88,7 @@ } /** - * @brief Removes an evas object from the canvas. The evas object will also be automatically hidden + * @brief Removes an Evas object from the canvas. The removed object will be automatically hidden * @param canvas a canvas * @param object the evas object to remove */ @@ -115,13 +113,13 @@ } /** - * @brief Moves an Evas Object to position ( @a x, @a y ), relatively to the canvas top-left corner. + * @brief Moves an Evas object to position ( @a x, @a y ), relatively to the canvas' top-left corner. * @param canvas a canvas - * @param object the object to move. The object does not necessarily belong to the canvas - * @param x the x component of the position where to move the object, relative to the canvas top-left corner - * @param y the y component of the position where to move the object, relative to the canvas top-left corner - * @note You can still use evas_object_move(), but the position passed to evas_object_move() is relative to the evas, - * not to the canvas. + * @param object the object to move + * @param x the x component of the position where to move the object, relative to the canvas' top-left corner + * @param y the y component of the position where to move the object, relative to the canvas' top-left corner + * @note You can still use evas_object_move() to move an object of the canvas, but the position passed to + * evas_object_move() is relative to the Evas, not to the canvas. */ void etk_canvas_object_move(Etk_Canvas *canvas, Evas_Object *object, int x, int y) { @@ -135,17 +133,17 @@ } /** - * @brief Gets the geometry of an Evas Object. The returned position will be relative to the canvas top-left corner + * @brief Gets the geometry of an Evas Object. The returned position will be relative to the canvas' top-left corner * @param canvas a canvas - * @param object the object to get the position of. The object does not necessarily belong to the canvas + * @param object the object to get the geomtry of * @param x the location where to store the x component of the position of the object, - * relative to the canvas top-left corner + * relative to the canvas' top-left corner * @param y the location where to store the y component of the position of the object, - * relative to the canvas top-left corner + * relative to the canvas' top-left corner * @param w the location where to store the width of the object * @param h the location where to store the height of the object * @note You can still use evas_object_geometry_get(), but the position returned by evas_object_geometry_get() is - * relative to the evas, not to the canvas. + * relative to the Evas, not to the canvas. */ void etk_canvas_object_geometry_get(Etk_Canvas *canvas, Evas_Object *object, int *x, int *y, int *w, int *h) { @@ -229,6 +227,7 @@ return; canvas->clip = NULL; + evas_list_free(canvas->objects); canvas->objects = NULL; } @@ -257,9 +256,9 @@ * @addtogroup Etk_Canvas * * @image html widgets/canvas.png - * To add an object to a canvas, the object and the canvas should belong to the same evas. It means the canvas has to be - * realized when you create the objects. You can for example create the objects in a callback connected to the "realize" - * signal of the canvas widget. + * To add an object to a canvas, the object and the canvas should belong to the same evas. It means the canvas has + * to be realized when you create the objects. You can for example create the objects in a callback connected to the + * @b "realize" signal of the canvas widget. * @code * etk_signal_connect("realize", ETK_OBJECT(canvas), ETK_CALLBACK(canvas_realize_cb), NULL), * @@ -274,9 +273,9 @@ * } * @endcode @n * - * Once an object is added to the canvas, you can use any evas_object_* functions to control it. @n - * You just have to keep in mind that calling evas_object_move() on an object belonging to the canvas - * will move the object relatively to the top-left corner of the window, and not to the top corner of the canvas itself. @n + * Once an object is added to the canvas, you can use any @a evas_object_*() functions to control it. @n + * You just have to keep in mind that calling evas_object_move() on an object belonging to the canvas will move + * the object relatively to the top-left corner of the window, and not to the top corner of the canvas itself. @n * So if you want to move your object to the position (200, 300) inside the canvas, you first have to get the position * (cx, cy) of the canvas and then to move the object relatively to it: @n * @code @@ -286,7 +285,7 @@ * The function etk_canvas_object_move() does that for you. @n @n * * When the canvas is moved, the objects belonging to it are automatically moved with it, - * but you might want to add a notification callback to the @a "geometry" property of the canvas widget, which will be + * but you might want to add a notification callback to the @b "geometry" property of the canvas widget, which will be * called each time the geometry of the canvas is changed. That way, you can resize the objects when the size of the * canvas is modified: @n * @code =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_canvas.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- etk_canvas.h 6 Oct 2006 17:04:14 -0000 1.7 +++ etk_canvas.h 23 Feb 2007 20:44:41 -0000 1.8 @@ -19,6 +19,7 @@ /** Checks if the object is an Etk_Canvas */ #define ETK_IS_CANVAS(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_CANVAS_TYPE)) + /** * @brief @widget A widget that can contain any type of Evas_Object * @structinfo @@ -33,8 +34,9 @@ Evas_List *objects; }; -Etk_Type *etk_canvas_type_get(); -Etk_Widget *etk_canvas_new(); + +Etk_Type *etk_canvas_type_get(void); +Etk_Widget *etk_canvas_new(void); Etk_Bool etk_canvas_object_add(Etk_Canvas *canvas, Evas_Object *object); void etk_canvas_object_remove(Etk_Canvas *canvas, Evas_Object *object); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_check_button.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- etk_check_button.c 6 Oct 2006 17:04:14 -0000 1.8 +++ etk_check_button.c 23 Feb 2007 20:44:41 -0000 1.9 @@ -18,7 +18,7 @@ * @brief Gets the type of an Etk_Check_Button * @return Returns the type of an Etk_Check_Button */ -Etk_Type *etk_check_button_type_get() +Etk_Type *etk_check_button_type_get(void) { static Etk_Type *check_button_type = NULL; @@ -35,7 +35,7 @@ * @brief Creates a new check button * @return Returns the new check button widget */ -Etk_Widget *etk_check_button_new() +Etk_Widget *etk_check_button_new(void) { return etk_widget_new(ETK_CHECK_BUTTON_TYPE, "theme_group", "check_button", "focusable", ETK_TRUE, "xalign", 0.0, NULL); @@ -64,6 +64,13 @@ * @addtogroup Etk_Check_Button * * @image html widgets/check_button.png + * + * Since Etk_Check_Button inherits from Etk_Toggle_Button, you can use the @a etk_toggle_button_*() functions to + * change the state of the check-button. For example, to know if the button is checked, you should call + * etk_toggle_button_active_get(). @n + * You can also be notified when the state of the check button is changed with the @b "toggled" signal of + * Etk_Toggle_Button. + * * \par Object Hierarchy: * - Etk_Object * - Etk_Widget =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_check_button.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- etk_check_button.h 6 Oct 2006 17:04:14 -0000 1.4 +++ etk_check_button.h 23 Feb 2007 20:44:41 -0000 1.5 @@ -29,8 +29,9 @@ Etk_Toggle_Button toggle_button; }; -Etk_Type *etk_check_button_type_get(); -Etk_Widget *etk_check_button_new(); + +Etk_Type *etk_check_button_type_get(void); +Etk_Widget *etk_check_button_new(void); Etk_Widget *etk_check_button_new_with_label(const char *label); /** @} */ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- etk_colorpicker.c 21 Feb 2007 05:19:17 -0000 1.26 +++ etk_colorpicker.c 23 Feb 2007 20:44:41 -0000 1.27 @@ -2,12 +2,10 @@ #include "etk_colorpicker.h" #include <stdlib.h> #include <stdint.h> -#include <Edje.h> #include "etk_table.h" #include "etk_slider.h" #include "etk_label.h" #include "etk_radio_button.h" -#include "etk_theme.h" #include "etk_signal.h" #include "etk_signal_callback.h" #include "etk_utils.h" @@ -75,8 +73,9 @@ static void _etk_colorpicker_vp_move_resize(Etk_Colorpicker *cp, int x, int y, int w, int h); static void _etk_colorpicker_sp_cursor_replace(Etk_Colorpicker *cp); static void _etk_colorpicker_vp_cursor_replace(Etk_Colorpicker *cp); - static void _etk_colorpicker_sp_cursor_move(Etk_Colorpicker *cp, float xpercent, float ypercent); + +static void _etk_colorpicker_update_from_sliders(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode, Etk_Bool update_sp, Etk_Bool update_vp); 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); @@ -144,9 +143,6 @@ */ void etk_colorpicker_mode_set(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode) { - float value; - int i; - if (!cp || (cp->mode == mode)) return; @@ -180,20 +176,8 @@ break; } - /* Update the colorpicker */ - for (i = (mode / 3) * 3; i < ((mode / 3) + 1) * 3; i++) - { - value = etk_range_value_get(ETK_RANGE(cp->sliders[i])); - if (i == mode) - cp->vp_pos = value / _etk_colorpicker_max_values[i]; - else if (i == cp->sp_xcomponent) - cp->sp_xpos = value / _etk_colorpicker_max_values[i]; - else if (i == cp->sp_ycomponent) - cp->sp_ypos = value / _etk_colorpicker_max_values[i]; - } - _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE); - cp->mode = mode; + _etk_colorpicker_update_from_sliders(cp, mode, ETK_TRUE, ETK_TRUE); etk_object_notify(ETK_OBJECT(cp), "color_mode"); } @@ -222,14 +206,15 @@ return; } - /* TODO: this may bug if the B component is not changed... */ - /* TODO: this may emit the signal twice... */ cp->ignore_value_changed = ETK_TRUE; etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R]), color.r); etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G]), color.g); - cp->ignore_value_changed = ETK_FALSE; etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B]), color.b); etk_range_value_set(ETK_RANGE(cp->alpha_slider), color.a); + cp->ignore_value_changed = ETK_FALSE; + + _etk_colorpicker_update_from_sliders(cp, ETK_COLORPICKER_R, ETK_TRUE, ETK_TRUE); + etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); } /** @@ -263,13 +248,13 @@ if (cp->use_alpha) { etk_widget_show(cp->alpha_slider); - etk_widget_show(cp->alpha_name_label); + etk_widget_show(cp->alpha_label); etk_range_value_set(ETK_RANGE(cp->alpha_slider), cp->current_color.a); } else { etk_widget_hide(cp->alpha_slider); - etk_widget_hide(cp->alpha_name_label); + etk_widget_hide(cp->alpha_label); cp->current_color.a = 255; } etk_object_notify(ETK_OBJECT(cp), "use_alpha"); @@ -296,12 +281,11 @@ /* Initializes the colorpicker */ static void _etk_colorpicker_constructor(Etk_Colorpicker *cp) { - Etk_Widget *cp_widget; char *labels[6] = { _("H"), _("S"), _("V"), _("R"), _("G"), _("B") }; float steps[6] = { 1.0, 0.01, 0.01, 1.0, 1.0, 1.0 }; int i; - if (!(cp_widget = ETK_WIDGET(cp))) + if (!cp) return; cp->mode = ETK_COLORPICKER_H; @@ -339,13 +323,12 @@ cp->vp_cursor_needs_update = ETK_FALSE; cp->sliders_need_update = ETK_FALSE; cp->ignore_value_changed = ETK_FALSE; - cp->emit_signal = ETK_TRUE; /* We create the widgets */ cp->main_table = etk_table_new(2, 2, ETK_FALSE); etk_widget_internal_set(cp->main_table, ETK_TRUE); - etk_widget_parent_set(cp->main_table, cp_widget); + etk_widget_parent_set(cp->main_table, ETK_WIDGET(cp)); etk_widget_show(cp->main_table); cp->picker_widget = etk_widget_new(ETK_WIDGET_TYPE, "theme_group", "picker", "theme_parent", cp, NULL); @@ -365,9 +348,9 @@ cp->radios[i] = etk_radio_button_new_with_label(labels[i], NULL); else cp->radios[i] = etk_radio_button_new_with_label_from_widget(labels[i], ETK_RADIO_BUTTON(cp->radios[0])); + etk_widget_internal_set(cp->radios[i], ETK_TRUE); etk_table_attach(ETK_TABLE(cp->component_table), cp->radios[i], 0, 0, i, i, 0, 0, ETK_TABLE_HFILL | ETK_TABLE_VEXPAND); - etk_widget_internal_set(cp->radios[i], ETK_TRUE); etk_widget_show(cp->radios[i]); cp->sliders[i] = etk_hslider_new(0.0, _etk_colorpicker_max_values[i], 0.0, steps[i], steps[i] * 5); @@ -392,9 +375,9 @@ /* Alpha slider */ { - cp->alpha_name_label = etk_label_new(_("Alpha")); - etk_widget_internal_set(cp->alpha_name_label, ETK_TRUE); - etk_table_attach(ETK_TABLE(cp->component_table), cp->alpha_name_label, 0, 0, 6, 6, + cp->alpha_label = etk_label_new(_("Alpha")); + etk_widget_internal_set(cp->alpha_label, ETK_TRUE); + etk_table_attach(ETK_TABLE(cp->component_table), cp->alpha_label, 0, 0, 6, 6, 0, 0, ETK_TABLE_HFILL | ETK_TABLE_VEXPAND); cp->alpha_slider = etk_hslider_new(0.0, 255.0, 255.0, 10, 5.0); @@ -429,16 +412,16 @@ 0, 0, ETK_TABLE_HFILL | ETK_TABLE_HEXPAND); etk_widget_show(cp->current_color_widget); - - cp_widget->size_request = _etk_colorpicker_size_request; - cp_widget->size_allocate = _etk_colorpicker_size_allocate; - etk_signal_connect("realize", ETK_OBJECT(cp->picker_widget), ETK_CALLBACK(_etk_colorpicker_realize_cb), cp); etk_signal_connect("unrealize", ETK_OBJECT(cp->picker_widget), ETK_CALLBACK(_etk_colorpicker_unrealize_cb), cp); etk_signal_connect("realize", ETK_OBJECT(cp->current_color_widget), ETK_CALLBACK(_etk_colorpicker_current_color_realize_cb), cp); etk_signal_connect("unrealize", ETK_OBJECT(cp->current_color_widget), ETK_CALLBACK(_etk_colorpicker_current_color_unrealize_cb), cp); + + + ETK_WIDGET(cp)->size_request = _etk_colorpicker_size_request; + ETK_WIDGET(cp)->size_allocate = _etk_colorpicker_size_allocate; } /* Destroys the colorpicker */ @@ -466,6 +449,9 @@ case ETK_CP_MODE_PROPERTY: etk_colorpicker_mode_set(cp, etk_property_value_int_get(value)); break; + case ETK_CP_USE_ALPHA_PROPERTY: + etk_colorpicker_use_alpha_set(cp, etk_property_value_bool_get(value)); + break; default: break; } @@ -484,6 +470,9 @@ case ETK_CP_MODE_PROPERTY: etk_property_value_int_set(value, cp->mode); break; + case ETK_CP_USE_ALPHA_PROPERTY: + etk_property_value_bool_set(value, cp->use_alpha); + break; default: break; } @@ -549,7 +538,7 @@ /* Square picker objects */ cp->sp_object = _etk_colorpicker_picker_object_add(evas, cp, _etk_colorpicker_sp_move_resize); - etk_widget_swallow_object(cp->picker_widget, "square_picker", cp->sp_object); + etk_widget_swallow_object(cp->picker_widget, "etk.swallow.square_picker", cp->sp_object); picker_sd = evas_object_smart_data_get(cp->sp_object); cp->sp_image = evas_object_image_add(evas); @@ -576,7 +565,7 @@ /* Vertical picker objects */ cp->vp_object = _etk_colorpicker_picker_object_add(evas, cp, _etk_colorpicker_vp_move_resize); - etk_widget_swallow_object(cp->picker_widget, "vertical_picker", cp->vp_object); + etk_widget_swallow_object(cp->picker_widget, "etk.swallow.vertical_picker", cp->vp_object); picker_sd = evas_object_smart_data_get(cp->vp_object); cp->vp_image = evas_object_image_add(evas); @@ -645,7 +634,7 @@ evas_object_show(cp->sliders_image[i]); evas_object_event_callback_add(cp->sliders_image[i], EVAS_CALLBACK_RESIZE, _etk_colorpicker_slider_image_resize_cb, NULL); - etk_widget_swallow_object(slider, "slider_image", cp->sliders_image[i]); + etk_widget_swallow_object(slider, "etk.swallow.image", cp->sliders_image[i]); _etk_colorpicker_update(cp, ETK_FALSE, ETK_FALSE, ETK_FALSE, ETK_FALSE); return; @@ -684,7 +673,7 @@ return; cp->current_color_rect = evas_object_rectangle_add(evas); - etk_widget_swallow_object(cp->current_color_widget, "preview_rect", cp->current_color_rect); + etk_widget_swallow_object(cp->current_color_widget, "etk.swallow.preview", cp->current_color_rect); evas_object_show(cp->current_color_rect); color = cp->current_color; @@ -709,104 +698,23 @@ { Etk_Widget *slider; Etk_Colorpicker *cp; - Etk_Color color; - Etk_Bool update_sp_image; - Etk_Bool update_vp_image; - float h, s, v; + Etk_Bool update_sp; + Etk_Bool update_vp; int i; if (!(slider = ETK_WIDGET(object)) || !(cp = ETK_COLORPICKER(data))) return; + if (cp->ignore_value_changed) + return; for (i = 0; i < 6; i++) { if (cp->sliders[i] == slider) { - /* First, we update the position of the cursors */ - if (i == cp->mode) - cp->vp_pos = value / _etk_colorpicker_max_values[i]; - else if (i == cp->sp_xcomponent) - cp->sp_xpos = value / _etk_colorpicker_max_values[i]; - else if (i == cp->sp_ycomponent) - cp->sp_ypos = value / _etk_colorpicker_max_values[i]; - - if (cp->ignore_value_changed) - return; - - /* Then, we update the values of the other sliders */ - switch (i) - { - case ETK_COLORPICKER_H: - h = value; - s = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S])); - v = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_V])); - evas_color_hsv_to_rgb(h, s, v, &color.r, &color.g, &color.b); - break; - case ETK_COLORPICKER_S: - h = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_H])); - s = value; - v = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_V])); - evas_color_hsv_to_rgb(h, s, v, &color.r, &color.g, &color.b); - break; - case ETK_COLORPICKER_V: - h = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_H])); - s = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S])); - v = value; - evas_color_hsv_to_rgb(h, s, v, &color.r, &color.g, &color.b); - break; - case ETK_COLORPICKER_R: - color.r = (int)value; - color.g = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G])); - color.b = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B])); - break; - case ETK_COLORPICKER_G: - color.r = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R])); - color.g = (int)value; - color.b = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B])); - break; - case ETK_COLORPICKER_B: - color.r = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R])); - color.g = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G])); - color.b = (int)value; - break; - default: - break; - } - - if (i == ETK_COLORPICKER_H || i == ETK_COLORPICKER_S || i == ETK_COLORPICKER_V) - { - cp->ignore_value_changed = ETK_TRUE; - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R]), color.r); - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G]), color.g); - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B]), color.b); - cp->ignore_value_changed = ETK_FALSE; - } - else - { - cp->ignore_value_changed = ETK_TRUE; - evas_color_rgb_to_hsv(color.r, color.g, color.b, &h, &s, &v); - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_H]), h); - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S]), s); - etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_V]), v); - cp->ignore_value_changed = ETK_FALSE; - } - - /* And then, we update the current color and the colorpicker */ - if (color.r != cp->current_color.r || color.g != cp->current_color.g || color.b != cp->current_color.b) - { - cp->current_color.r = color.r; - cp->current_color.g = color.g; - cp->current_color.b = color.b; - evas_color_argb_premul(cp->current_color.a, &color.r, &color.g, &color.b); - evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, cp->current_color.a); - if (cp->emit_signal) - etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); - } - - update_sp_image = !((i != cp->mode) && ((i / 3) == (cp->mode / 3))); - update_vp_image = !((i / 3) == (cp->mode / 3)); - _etk_colorpicker_update(cp, update_sp_image, ETK_TRUE, update_vp_image, ETK_TRUE); - + update_sp = ((i != cp->sp_xcomponent) && (i != cp->sp_ycomponent)); + update_vp = ((i / 3) != (cp->mode / 3)); + _etk_colorpicker_update_from_sliders(cp, i, update_sp, update_vp); + etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); return; } } @@ -822,10 +730,6 @@ if (!(slider = ETK_WIDGET(object)) || !(cp = ETK_COLORPICKER(data))) return; - /* TODO: do we really need that?? */ - if (cp->ignore_value_changed) - return; - color.r = cp->current_color.r; color.g = cp->current_color.g; color.b = cp->current_color.b; @@ -834,7 +738,7 @@ evas_color_argb_premul(cp->current_color.a, &color.r, &color.g, &color.b); evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, cp->current_color.a); - if (cp->emit_signal) + if (!cp->ignore_value_changed) etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); } @@ -875,6 +779,7 @@ xpercent = ETK_CLAMP((float)(event->canvas.x - x) / w, 0.0, 1.0); ypercent = 1.0 - ETK_CLAMP((float)(event->canvas.y - y) / h, 0.0, 1.0); + printf("Mouse Down\n"); _etk_colorpicker_sp_cursor_move(cp, xpercent, ypercent); cp->sp_dragging = ETK_TRUE; } @@ -900,6 +805,7 @@ if (!(cp = ETK_COLORPICKER(data)) || !(event = event_info) || !cp->sp_dragging) return; + printf("Mouse Move\n"); evas_object_geometry_get(cp->sp_image, &x, &y, &w, &h); xpercent = ETK_CLAMP((float)(event->cur.canvas.x - x) / w, 0.0, 1.0); ypercent = 1.0 - ETK_CLAMP((float)(event->cur.canvas.y - y) / h, 0.0, 1.0); @@ -997,8 +903,8 @@ _etk_colorpicker_picker_smart_clip_set, _etk_colorpicker_picker_smart_clip_unset, NULL); + _etk_colorpicker_picker_smart_use = 0; } - /* TODO: _etk_colorpicker_picker_smart_use */ _etk_colorpicker_picker_smart_use++; obj = evas_object_smart_add(evas, _etk_colorpicker_picker_smart); @@ -1039,6 +945,13 @@ picker_sd->objects = evas_list_remove_list(picker_sd->objects, picker_sd->objects); } free(picker_sd); + + _etk_colorpicker_picker_smart_use--; + if (_etk_colorpicker_picker_smart_use <= 0 && _etk_colorpicker_picker_smart) + { + evas_smart_free(_etk_colorpicker_picker_smart); + _etk_colorpicker_picker_smart = NULL; + } } /* Moves the picker object */ @@ -1191,12 +1104,84 @@ if (!cp) return; - cp->emit_signal = ETK_FALSE; + cp->ignore_value_changed = ETK_TRUE; etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_xcomponent]), xpercent * _etk_colorpicker_max_values[cp->sp_xcomponent]); - cp->emit_signal = ETK_TRUE; etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_ycomponent]), ypercent * _etk_colorpicker_max_values[cp->sp_ycomponent]); + cp->ignore_value_changed = ETK_FALSE; + + _etk_colorpicker_update_from_sliders(cp, cp->mode, ETK_FALSE, ETK_FALSE); + etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); +} + +/* Updates the colorpicker from its sliders */ +static void _etk_colorpicker_update_from_sliders(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode, Etk_Bool update_sp, Etk_Bool update_vp) +{ + Etk_Color color; + float h, s, v; + double value; + int i; + + if (!cp) + return; + + /* First, we update the values of the other sliders */ + if (mode == ETK_COLORPICKER_H || mode == ETK_COLORPICKER_S || mode == ETK_COLORPICKER_V) + { + h = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S])); + s = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S])); + v = etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_V])); + evas_color_hsv_to_rgb(h, s, v, &color.r, &color.g, &color.b); + + cp->ignore_value_changed = ETK_TRUE; + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R]), color.r); + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G]), color.g); + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B]), color.b); + cp->ignore_value_changed = ETK_FALSE; + } + else + { + color.r = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R])); + color.g = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G])); + color.b = (int)etk_range_value_get(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B])); + + cp->ignore_value_changed = ETK_TRUE; + evas_color_rgb_to_hsv(color.r, color.g, color.b, &h, &s, &v); + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_H]), h); + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_S]), s); + etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_V]), v); + cp->ignore_value_changed = ETK_FALSE; + } + + /* Then, we update the position of the cursors */ + for (i = (cp->mode / 3) * 3; i < ((cp->mode / 3) + 1) * 3; i++) + { + value = etk_range_value_get(ETK_RANGE(cp->sliders[i])); + if (i == cp->mode) + cp->vp_pos = value / _etk_colorpicker_max_values[i]; + else if (i == cp->sp_xcomponent) + cp->sp_xpos = value / _etk_colorpicker_max_values[i]; + else if (i == cp->sp_ycomponent) + cp->sp_ypos = value / _etk_colorpicker_max_values[i]; + } + + /* And finally, we update the current color and the colorpicker */ + if (color.r != cp->current_color.r || color.g != cp->current_color.g || color.b != cp->current_color.b) + { + cp->current_color.r = color.r; + cp->current_color.g = color.g; + cp->current_color.b = color.b; + if (cp->current_color_rect) + { + evas_color_argb_premul(cp->current_color.a, &color.r, &color.g, &color.b); + evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, cp->current_color.a); + } + } + + _etk_colorpicker_update(cp, update_sp, ETK_TRUE, update_vp, ETK_TRUE); + + return; } /* Updates of the colorpicker */ @@ -1449,4 +1434,45 @@ /** @} */ -/* TODOC: write documentation... */ +/************************** + * + * Documentation + * + **************************/ + +/** + * @addtogroup Etk_Colorpicker + * + * @image html widgets/colorpicker.png + * A colorpicker can work in 6 different modes, H (Hue), S (saturation), V (value), R (red), G (green) and B (blue). + * The default mode is H, but you can change it with etk_colorpicker_mode_set(). For each of these modes, there is + * a slider that allows the user to change the corresponding value. @n + * Optionally, the colorpicker can also have a slider to control the alpha channel of the color, corresponding to how + * much the color is transparent. This slider is hidden by default, but can be shown with + * etk_colorpicker_use_alpha_set(). @n + * Most of the time, all you want to do is getting the selected color, and be notified when the selected color is + * changed. This can be done with etk_colorpicker_current_color_get() and by connecting a callback to the + * @b "color_changed" signal. + * + * \par Object Hierarchy: + * - Etk_Object + * - Etk_Widget + * - Etk_Colorpicker + * + * \par Signals: + * @signal_name "color_changed": Emitted when the selected color is changed + * @signal_cb void callback(Etk_Colorpicker *colorpicker, void *data) + * @signal_arg button: the colorpicker whose color has been changed + * @signal_data + * + * \par Properties: + * @prop_name "color_mode": The current color-mode of the colorpicker + * @prop_type Integer (Etk_Colorpicker_Mode) + * @prop_rw + * @prop_val ETK_COLORPICKER_H + * \par + * @prop_name "use_alpha": Whether or not the alpha slider is visible + * @prop_type Boolean + * @prop_rw + * @prop_val ETK_FALSE + */ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_colorpicker.h 21 Feb 2007 05:19:17 -0000 1.13 +++ etk_colorpicker.h 23 Feb 2007 20:44:41 -0000 1.14 @@ -20,7 +20,7 @@ #define ETK_IS_COLORPICKER(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_COLORPICKER_TYPE)) -/** @brief The color modes used by the colorpicker */ +/** @brief The different color modes that can be used by the colorpicker */ typedef enum Etk_Colorpicker_Mode { ETK_COLORPICKER_H, /**< The "Hue" mode */ @@ -31,6 +31,7 @@ ETK_COLORPICKER_B /**< The "Blue" mode */ } Etk_Colorpicker_Mode; + /** * @brief @widget A widget that allows the user to select a color * @structinfo @@ -66,19 +67,19 @@ Etk_Bool vp_image_needs_update; Etk_Bool vp_cursor_needs_update; + /* Component widgets */ + Etk_Widget *component_table; + Etk_Widget *radios[6]; + /* Sliders */ Etk_Widget *sliders[6]; Evas_Object *sliders_image[6]; int sliders_res; Etk_Bool sliders_need_update; - /* Component widgets */ - Etk_Widget *component_table; - Etk_Widget *radios[6]; - /* Alpha slider */ Etk_Widget *alpha_slider; - Etk_Widget *alpha_name_label; + Etk_Widget *alpha_label; /* Current color objects */ Etk_Widget *color_table; @@ -87,12 +88,11 @@ Evas_Object *current_color_rect; Etk_Bool ignore_value_changed; - Etk_Bool emit_signal; - Etk_Bool use_alpha; Etk_Colorpicker_Mode mode; Etk_Color current_color; }; + Etk_Type *etk_colorpicker_type_get(void); Etk_Widget *etk_colorpicker_new(void); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_frame.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_frame.c 29 Jan 2007 05:08:30 -0000 1.13 +++ etk_frame.c 23 Feb 2007 20:44:41 -0000 1.14 @@ -20,7 +20,7 @@ static void _etk_frame_destructor(Etk_Frame *frame); static void _etk_frame_property_set(Etk_Object *object, int property_id, Etk_Property_Value *value); static void _etk_frame_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value); -static void _etk_frame_realized_cb(Etk_Object *object, void *data); +static void _etk_frame_realize_cb(Etk_Object *object, void *data); /************************** * @@ -122,7 +122,7 @@ return; frame->label = NULL; - etk_signal_connect("realize", ETK_OBJECT(frame), ETK_CALLBACK(_etk_frame_realized_cb), NULL); + etk_signal_connect("realize", ETK_OBJECT(frame), ETK_CALLBACK(_etk_frame_realize_cb), NULL); } /* Destroys the frame */ @@ -176,7 +176,7 @@ **************************/ /* Called when the frame is realized */ -static void _etk_frame_realized_cb(Etk_Object *object, void *data) +static void _etk_frame_realize_cb(Etk_Object *object, void *data) { Etk_Frame *frame; =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_shadow.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- etk_shadow.c 3 Jan 2007 19:08:00 -0000 1.4 +++ etk_shadow.c 23 Feb 2007 20:44:41 -0000 1.5 @@ -50,8 +50,8 @@ static void _etk_shadow_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value); static void _etk_shadow_size_request(Etk_Widget *widget, Etk_Size *size); static void _etk_shadow_size_allocate(Etk_Widget *widget, Etk_Geometry geometry); -static void _etk_shadow_realized_cb(Etk_Object *object, void *data); -static void _etk_shadow_unrealized_cb(Etk_Object *object, void *data); +static void _etk_shadow_realize_cb(Etk_Object *object, void *data); +static void _etk_shadow_unrealize_cb(Etk_Object *object, void *data); static void _etk_shadow_shadow_recalc(Etk_Shadow *shadow); static void _etk_shadow_border_recalc(Etk_Shadow *shadow); static Etk_Bool _etk_shadow_edge_visible(Etk_Shadow *shadow, Etk_Shadow_Object_Id object_id); @@ -398,8 +398,8 @@ ETK_WIDGET(shadow)->size_request = _etk_shadow_size_request; ETK_WIDGET(shadow)->size_allocate = _etk_shadow_size_allocate; - etk_signal_connect("realize", ETK_OBJECT(shadow), ETK_CALLBACK(_etk_shadow_realized_cb), NULL); - etk_signal_connect("unrealize", ETK_OBJECT(shadow), ETK_CALLBACK(_etk_shadow_unrealized_cb), NULL); + etk_signal_connect("realize", ETK_OBJECT(shadow), ETK_CALLBACK(_etk_shadow_realize_cb), NULL); + etk_signal_connect("unrealize", ETK_OBJECT(shadow), ETK_CALLBACK(_etk_shadow_unrealize_cb), NULL); } /* Sets the property whose id is "property_id" to the value "value" */ @@ -685,7 +685,7 @@ **************************/ /* Called when the shadow container is realized */ -static void _etk_shadow_realized_cb(Etk_Object *object, void *data) +static void _etk_shadow_realize_cb(Etk_Object *object, void *data) { Etk_Shadow *shadow; Evas *evas; @@ -731,7 +731,7 @@ } /* Called when the shadow container is unrealized */ -static void _etk_shadow_unrealized_cb(Etk_Object *object, void *data) +static void _etk_shadow_unrealize_cb(Etk_Object *object, void *data) { Etk_Shadow *shadow; int i; =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_signal_callback.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- etk_signal_callback.h 13 Jan 2007 05:19:11 -0000 1.4 +++ etk_signal_callback.h 23 Feb 2007 20:44:41 -0000 1.5 @@ -7,7 +7,7 @@ /** * @defgroup Etk_Signal_Callback Etk_Signal_Callback - * @brief For more infos, see the page about Etk_Signal + * @brief For more info, see the page about Etk_Signal * @{ */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs