discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=aeca417ebe0f2d88d9736222490303ec38e238a3

commit aeca417ebe0f2d88d9736222490303ec38e238a3
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Apr 9 16:34:00 2015 -0400

    redo color dialog to use elm colorselector
    
    this is waaaaaaay less functional and good-looking, but at least it doesn't
    crash
---
 src/bin/e_color_dialog.c | 56 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 13 deletions(-)

diff --git a/src/bin/e_color_dialog.c b/src/bin/e_color_dialog.c
index 0da0a06..25fe253 100644
--- a/src/bin/e_color_dialog.c
+++ b/src/bin/e_color_dialog.c
@@ -4,7 +4,7 @@ static void _e_color_dialog_button1_click(void *data, E_Dialog 
*edia);
 static void _e_color_dialog_button2_click(void *data, E_Dialog *edia);
 static void _e_color_dialog_free(E_Color_Dialog *dia);
 static void _e_color_dialog_dia_del(void *obj);
-static void _e_color_dialog_cb_csel_change(void *data, Evas_Object *obj);
+static void _e_color_dialog_cb_csel_change(void *data, Evas_Object *obj, void 
*ev);
 
 /**
  * Create a color selector dialog.
@@ -17,8 +17,7 @@ E_Color_Dialog *
 e_color_dialog_new(const E_Color *color, Eina_Bool alpha_enabled)
 {
    E_Color_Dialog *dia;
-   Evas_Object *o;
-   Evas_Coord mw, mh;
+   Evas_Object *o, *bx, *re, *fr;
 
    dia = E_OBJECT_ALLOC(E_Color_Dialog, E_COLOR_DIALOG_TYPE, 
_e_color_dialog_free);
    if (!dia) return NULL;
@@ -36,11 +35,33 @@ e_color_dialog_new(const E_Color *color, Eina_Bool 
alpha_enabled)
 
    e_color_copy(dia->color, dia->initial);
 
-   o = e_widget_csel_add(evas_object_evas_get(dia->dia->win), dia->color, 
alpha_enabled);
+   bx = elm_box_add(dia->dia->win);
+   E_EXPAND(bx);
+   E_FILL(bx);
+
+   o = elm_colorselector_add(bx);
+   elm_colorselector_mode_set(o, ELM_COLORSELECTOR_COMPONENTS);
+   elm_colorselector_color_set(o, dia->color->r, dia->color->g, dia->color->b, 
dia->color->a);
+   E_EXPAND(o);
+   E_FILL(o);
    evas_object_show(o);
-   e_widget_size_min_get(o, &mw, &mh);
-   e_dialog_content_set(dia->dia, o, mw, mh);
-   e_widget_on_change_hook_set(o, _e_color_dialog_cb_csel_change, dia);
+   elm_box_pack_end(bx, o);
+
+   fr = elm_frame_add(bx);
+   E_WEIGHT(fr, EVAS_HINT_EXPAND, 0);
+   E_FILL(fr);
+   elm_object_text_set(fr, _("Color Preview"));
+   evas_object_show(fr);
+   elm_box_pack_end(bx, fr);
+
+   re = evas_object_rectangle_add(evas_object_evas_get(dia->dia->win));
+   evas_object_data_set(o, "rect", re);
+   evas_object_size_hint_min_set(re, 1, ELM_SCALE_SIZE(100));
+   evas_object_show(re);
+   elm_object_content_set(fr, re);
+
+   evas_object_smart_callback_add(o, "changed", 
_e_color_dialog_cb_csel_change, dia);
+   e_dialog_content_set(dia->dia, bx, 250, -1);
 
    /* buttons at the bottom */
    e_dialog_button_add(dia->dia, _("Select"), NULL, 
_e_color_dialog_button1_click, dia);
@@ -58,6 +79,7 @@ e_color_dialog_show(E_Color_Dialog *dia)
 {
    e_dialog_show(dia->dia);
    e_dialog_border_icon_set(dia->dia, "enlightenment/colors");
+   evas_object_size_hint_min_set(dia->dia->win, 250, -1);
 }
 
 void
@@ -88,11 +110,19 @@ e_color_dialog_change_callback_set(E_Color_Dialog *dia, 
void (*func)(E_Color_Dia
 }
 
 static void
-_e_color_dialog_cb_csel_change(void *data, Evas_Object *obj EINA_UNUSED)
+_e_color_dialog_cb_csel_change(void *data, Evas_Object *obj, void *ev 
EINA_UNUSED)
 {
-   E_Color_Dialog *dia;
-
-   dia = data;
+   E_Color_Dialog *dia = data;
+   Evas_Object *re;
+   int r, g, b;
+
+   elm_colorselector_color_get(obj, &dia->color->r, &dia->color->g, 
&dia->color->b, &dia->color->a);
+   r = dia->color->r;
+   g = dia->color->g;
+   b = dia->color->b;
+   re = evas_object_data_get(obj, "rect");
+   evas_color_argb_premul(dia->color->a, &r, &g, &b);
+   evas_object_color_set(re, r, g, b, dia->color->a);
    if (dia->change_func && dia->color)
      dia->change_func(dia, dia->color, dia->change_data);
 }
@@ -103,7 +133,7 @@ _e_color_dialog_button1_click(void *data, E_Dialog *edia 
EINA_UNUSED)
    E_Color_Dialog *dia;
 
    dia = data;
-   if (dia->select_func && dia->color)
+   if (dia->select_func)
      dia->select_func(dia, dia->color, dia->select_data);
    _e_color_dialog_free(dia);
 }
@@ -114,7 +144,7 @@ _e_color_dialog_button2_click(void *data, E_Dialog *edia 
EINA_UNUSED)
    E_Color_Dialog *dia;
 
    dia = data;
-   if (dia->cancel_func && dia->initial)
+   if (dia->cancel_func)
      dia->cancel_func(dia, dia->initial, dia->cancel_data);
    _e_color_dialog_free(data);
 }

-- 


Reply via email to