Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_colordialog.c ewl_colordialog.h ewl_colorpicker.c ewl_colorpicker.h Log Message: - API BREAK: ewl_color[picker|dialog]_previous_rbg_set -> ewl_color[picker|dialog]_previous_rbga_set - Add alpha channel support to the color picker - I'm not sure if I like the fact that the previous color set and the current colour set are different. (Current has separate _rgb_set and _alpha_set) Thoughts? =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colordialog.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 --- ewl_colordialog.c 12 Nov 2007 22:42:22 -0000 1.32 +++ ewl_colordialog.c 7 Dec 2007 05:59:15 -0000 1.33 @@ -88,6 +88,9 @@ ewl_colordialog_cb_button_click, cd); ewl_widget_show(o); + /* enable alpha channel by default */ + ewl_colordialog_has_alpha_set(cd, TRUE); + DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -213,19 +216,21 @@ * @param r: The red value to set * @param g: The green value to set * @param b: The blue value to set + * @param a: The alpha value to set * @return Returns no value. - * @brief This sets the given rgb values as the color to display in the + * @brief This sets the given rgba values as the color to display in the * previous color box of the color dialog. */ void -ewl_colordialog_previous_rgb_set(Ewl_Colordialog *cd, unsigned int r, - unsigned int g, unsigned int b) +ewl_colordialog_previous_rgba_set(Ewl_Colordialog *cd, unsigned int r, + unsigned int g, unsigned int b, + unsigned int a) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(cd); DCHECK_TYPE(cd, EWL_COLORDIALOG_TYPE); - ewl_colorpicker_previous_rgb_set(EWL_COLORPICKER(cd->picker), r, g, b); + ewl_colorpicker_previous_rgba_set(EWL_COLORPICKER(cd->picker), r, g, b, a); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -235,19 +240,21 @@ * @param r: Where to store the red value * @param g: Where to store the green value * @param b: Where to store the blue value + * @param a: Where to store the alpha value * @return Returns no value. * @brief This will retrieve the value current set into the previous color box of - * the color dialog rgb values from the color dialog + * the color dialog rgba values from the color dialog */ void -ewl_colordialog_previous_rgb_get(Ewl_Colordialog *cd, unsigned int *r, - unsigned int *g, unsigned int *b) +ewl_colordialog_previous_rgba_get(Ewl_Colordialog *cd, unsigned int *r, + unsigned int *g, unsigned int *b, + unsigned int *a) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(cd); DCHECK_TYPE(cd, EWL_COLORDIALOG_TYPE); - ewl_colorpicker_previous_rgb_get(EWL_COLORPICKER(cd->picker), r, g, b); + ewl_colorpicker_previous_rgba_get(EWL_COLORPICKER(cd->picker), r, g, b, a); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colordialog.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_colordialog.h 11 Nov 2007 06:07:46 -0000 1.21 +++ ewl_colordialog.h 7 Dec 2007 05:59:15 -0000 1.22 @@ -61,10 +61,12 @@ void ewl_colordialog_current_rgb_get(Ewl_Colordialog *cp, unsigned int *r, unsigned int *g, unsigned int *b); -void ewl_colordialog_previous_rgb_set(Ewl_Colordialog *cp, unsigned int r, - unsigned int g, unsigned int b); -void ewl_colordialog_previous_rgb_get(Ewl_Colordialog *cp, unsigned int *r, - unsigned int *g, unsigned int *b); +void ewl_colordialog_previous_rgba_set(Ewl_Colordialog *cp, unsigned int r, + unsigned int g, unsigned int b, + unsigned int a); +void ewl_colordialog_previous_rgba_get(Ewl_Colordialog *cp, unsigned int *r, + unsigned int *g, unsigned int *b, + unsigned int *a); void ewl_colordialog_color_mode_set(Ewl_Colordialog *cp, Ewl_Color_Mode type); Ewl_Color_Mode ewl_colordialog_color_mode_get(Ewl_Colordialog *cp); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colorpicker.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -3 -r1.44 -r1.45 --- ewl_colorpicker.c 29 Nov 2007 03:50:44 -0000 1.44 +++ ewl_colorpicker.c 7 Dec 2007 05:59:15 -0000 1.45 @@ -302,14 +302,27 @@ ewl_widget_show(o); } + o = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(vbox), o); + cp->alpha_box = o; + + o = ewl_label_new(); + ewl_label_text_set(EWL_LABEL(o), "A"); + ewl_container_child_append(EWL_CONTAINER(cp->alpha_box), o); + ewl_widget_show(o); + /* alpha spinner */ o = ewl_spinner_new(); ewl_widget_internal_set(o, TRUE); - ewl_container_child_append(EWL_CONTAINER(vbox), o); + ewl_container_child_append(EWL_CONTAINER(cp->alpha_box), o); ewl_range_minimum_value_set(EWL_RANGE(o), 0); ewl_range_maximum_value_set(EWL_RANGE(o), 255); - ewl_range_value_set(EWL_RANGE(o), 0); + ewl_range_value_set(EWL_RANGE(o), 255); + ewl_range_step_set(EWL_RANGE(o), 1); ewl_spinner_digits_set(EWL_SPINNER(o), 0); + ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, + ewl_colorpicker_cb_alpha_change, cp); + ewl_widget_show(o); cp->spinners.alpha = o; ewl_colorpicker_color_mode_set(cp, EWL_COLOR_MODE_HSV_HUE); @@ -330,7 +343,13 @@ DCHECK_PARAM_PTR(cp); DCHECK_TYPE(cp, EWL_COLORPICKER_TYPE); - cp->has_alpha = alpha; + if (cp->has_alpha == !!alpha) + DRETURN(DLEVEL_STABLE); + + cp->has_alpha = !!alpha; + + if (cp->has_alpha) ewl_widget_show(cp->alpha_box); + else ewl_widget_hide(cp->alpha_box); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -409,7 +428,8 @@ if (g > 255) g = 255; if (b > 255) b = 255; - ewl_widget_color_set(cp->preview.current, r, g, b, 255); + ewl_widget_color_set(cp->preview.current, r, g, b, + ewl_range_value_get(EWL_RANGE(cp->spinners.alpha))); ewl_spectrum_rgb_set(EWL_SPECTRUM(cp->picker.square), r, g, b); ewl_spectrum_rgb_set(EWL_SPECTRUM(cp->picker.vertical), r, g, b); @@ -445,12 +465,14 @@ * @param r: The red value to set * @param g: The green value to set * @param b: The blue value to set + * @param a: The alpha value to set * @return Returns no value. - * @brief Set the previous RBG values into the color picker + * @brief Set the previous RBGA values into the color picker */ void -ewl_colorpicker_previous_rgb_set(Ewl_Colorpicker *cp, unsigned int r, - unsigned int g, unsigned int b) +ewl_colorpicker_previous_rgba_set(Ewl_Colorpicker *cp, unsigned int r, + unsigned int g, unsigned int b, + unsigned int a) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(cp); @@ -459,8 +481,9 @@ cp->previous.r = r; cp->previous.g = g; cp->previous.b = b; + cp->previous.a = a; - ewl_widget_color_set(cp->preview.previous, r, g, b, 255); + ewl_widget_color_set(cp->preview.previous, r, g, b, a); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -470,12 +493,14 @@ * @param r: Where to store the red value * @param g: Where to store the green value * @param b: Where to store the blue value + * @param a: Where to store the alpha value * @return Returns no value. - * @brief Retrieve the previous RGB values from the color picker + * @brief Retrieve the previous RGBA values from the color picker */ void -ewl_colorpicker_previous_rgb_get(Ewl_Colorpicker *cp, unsigned int *r, - unsigned int *g, unsigned int *b) +ewl_colorpicker_previous_rgba_get(Ewl_Colorpicker *cp, unsigned int *r, + unsigned int *g, unsigned int *b, + unsigned int *a) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(cp); @@ -484,6 +509,7 @@ if (r) *r = cp->previous.r; if (g) *g = cp->previous.g; if (b) *b = cp->previous.b; + if (a) *a = cp->previous.a; DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -708,6 +734,37 @@ * @internal * @param w: The widget to work with * @param ev: UNUSED + * @param data: The colorpicker + * @return Returns no value + * @brief The callback for a spinner change + */ +void +ewl_colorpicker_cb_alpha_change(Ewl_Widget *w, void *ev __UNUSED__, void *data) +{ + Ewl_Colorpicker *cp; + unsigned int r, g, b, a; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(w); + DCHECK_PARAM_PTR(data); + DCHECK_TYPE(w, EWL_SPINNER_TYPE); + DCHECK_TYPE(data, EWL_COLORPICKER_TYPE); + + cp = data; + r = ewl_range_value_get(cp->spinners.rgb.r); + g = ewl_range_value_get(cp->spinners.rgb.g); + b = ewl_range_value_get(cp->spinners.rgb.b); + a = ewl_range_value_get(EWL_RANGE(w)); + + ewl_widget_color_set(cp->preview.current, r, g, b, a); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @param ev: UNUSED * @param data: The colorpicker widget * @return Returns no value * @brief Callback for a radio button change @@ -830,7 +887,8 @@ ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.s), s * 100); ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.v), v * 100); - ewl_widget_color_set(cp->preview.current, r, g, b, 255); + ewl_widget_color_set(cp->preview.current, r, g, b, + ewl_range_value_get((cp->spinners.alpha))); ewl_callback_call(EWL_WIDGET(cp), EWL_CALLBACK_VALUE_CHANGED); cp->updating = FALSE; =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colorpicker.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- ewl_colorpicker.h 11 Nov 2007 06:07:46 -0000 1.27 +++ ewl_colorpicker.h 7 Dec 2007 05:59:15 -0000 1.28 @@ -75,6 +75,8 @@ Ewl_Widget *alpha; /**< The alpha value */ } spinners; /**< The spinners to hold the different values */ + Ewl_Widget *alpha_box; /**< Box holding alpha information */ + Ewl_Color_Set previous; /**< The previous color */ Ewl_Color_Mode mode; /**< The current mode */ @@ -96,10 +98,12 @@ void ewl_colorpicker_current_rgb_get(Ewl_Colorpicker *cp, unsigned int *r, unsigned int *g, unsigned int *b); -void ewl_colorpicker_previous_rgb_set(Ewl_Colorpicker *cp, unsigned int r, - unsigned int g, unsigned int b); -void ewl_colorpicker_previous_rgb_get(Ewl_Colorpicker *cp, unsigned int *r, - unsigned int *g, unsigned int *b); +void ewl_colorpicker_previous_rgba_set(Ewl_Colorpicker *cp, unsigned int r, + unsigned int g, unsigned int b, + unsigned int a); +void ewl_colorpicker_previous_rgba_get(Ewl_Colorpicker *cp, unsigned int *r, + unsigned int *g, unsigned int *b, + unsigned int *a); void ewl_colorpicker_color_mode_set(Ewl_Colorpicker *cp, Ewl_Color_Mode type); Ewl_Color_Mode ewl_colorpicker_color_mode_get(Ewl_Colorpicker *cp); @@ -111,6 +115,7 @@ void ewl_colorpicker_cb_vertical_change(Ewl_Widget *w, void *ev, void *data); void ewl_colorpicker_cb_spinner_change(Ewl_Widget *w, void *ev, void *data); +void ewl_colorpicker_cb_alpha_change(Ewl_Widget *w, void *ev, void *data); void ewl_colorpicker_cb_radio_change(Ewl_Widget *w, void *ev, void *data); void ewl_colorpicker_cb_previous_clicked(Ewl_Widget *w, void *ev, void *data); ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs