Nathan Ingersoll ha scritto:
On 1/17/07, DaveMDS <[EMAIL PROTECTED]> wrote:

evas_object_color_set() don't draw the alpha in the right way:
if the color is black the alpha are good,
if the color is white the alpha never change until 0 is reached(and then
disappear)

Seems that evas always make the transparency on a white background.

Sounds like you're not using pre-multiplied colors. Use
evas_color_argb_premul to convert your non-premul color to premul
before passing it to evas.


:) Yes thanks, that is !!

And here the adjusted patch...I love open source developing :)

Dave
Index: etk_colorpicker.c
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.c,v
retrieving revision 1.22
diff -u -r1.22 etk_colorpicker.c
--- etk_colorpicker.c	6 Oct 2006 17:04:14 -0000	1.22
+++ etk_colorpicker.c	18 Jan 2007 05:58:13 -0000
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include <Edje.h>
 #include "etk_table.h"
+#include "etk_box.h"
 #include "etk_slider.h"
 #include "etk_label.h"
 #include "etk_radio_button.h"
@@ -49,6 +50,7 @@
 static void _etk_colorpicker_current_color_realize_cb(Etk_Object *object, void *data);
 static void _etk_colorpicker_current_color_unrealize_cb(Etk_Object *object, void *data);
 static void _etk_colorpicker_slider_value_changed_cb(Etk_Object *object, double value, void *data);
+static void _etk_colorpicker_aslider_value_changed_cb(Etk_Object *object, double value, 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);
@@ -211,14 +213,15 @@
  */
 void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color)
 {
-   if (cp->current_color.r == color.r && cp->current_color.g == color.g && cp->current_color.b == color.b)
+   if (cp->current_color.r == color.r && cp->current_color.g == color.g && cp->current_color.b == color.b && cp->current_color.a == color.a)
       return;
    
    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_A]), color.a);
    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->sliders[ETK_COLORPICKER_B]), color.b); //FIXME why this is out of the ignore? is right?
 }
 
 /**
@@ -247,7 +250,10 @@
 static void _etk_colorpicker_constructor(Etk_Colorpicker *cp)
 {
    Etk_Widget *cp_widget;
-   char *labels[6] = { _("H"), _("S"), _("V"), _("R"), _("G"), _("B") };
+   Etk_Widget *hbox;
+   Etk_Widget *label;
+   
+   char *labels[7] = { _("H"), _("S"), _("V"), _("R"), _("G"), _("B"), _("Alpha") };
    float values[6] = { 360.0, 1.0, 1.0, 255.0, 255.0, 255.0 };
    float steps[6] = { 1.0, 0.01, 0.01, 1.0, 1.0, 1.0 };
    int i;
@@ -368,6 +374,28 @@
    etk_widget_internal_set(cp->current_color_widget, ETK_TRUE);
    etk_widget_show(cp->current_color_widget);
    
+   /* Alpha slider */
+   hbox = etk_hbox_new(ETK_FALSE,2);
+   etk_table_attach(ETK_TABLE(cp->main_table), hbox, 1, 1, 1, 1,
+      0, 0, ETK_TABLE_FILL | ETK_TABLE_HEXPAND);
+   
+   label = etk_label_new(labels[6]);
+   etk_box_append(ETK_BOX(hbox),label, 
+      ETK_BOX_START, ETK_BOX_NONE, 0);
+   
+   cp->sliders[6] = etk_hslider_new (0, 255, 15, 1,20);
+   etk_box_append(ETK_BOX(hbox),cp->sliders[6], 
+      ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
+   
+   cp->value_labels[6] = etk_label_new("255");
+   etk_widget_size_request_set(cp->value_labels[6], 28, -1);
+   etk_box_append(ETK_BOX(hbox),cp->value_labels[6], 
+      ETK_BOX_START, ETK_BOX_NONE, 0);
+      
+   etk_signal_connect("value_changed", ETK_OBJECT(cp->sliders[6]),
+      ETK_CALLBACK(_etk_colorpicker_aslider_value_changed_cb), cp);
+   
+   
    
    cp_widget->size_request = _etk_colorpicker_size_request;
    cp_widget->size_allocate = _etk_colorpicker_size_allocate;
@@ -737,12 +765,13 @@
          }
          
          /* 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)
+         if (color.r != cp->current_color.r || color.g != cp->current_color.g || color.b != cp->current_color.b || color.a != cp->current_color.a )
          {
             cp->current_color.r = color.r;
             cp->current_color.g = color.g;
             cp->current_color.b = color.b;
-            evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, 255);
+            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);
          }
@@ -754,6 +783,36 @@
          return;
       }
    }
+}
+/* Called when the value of the alpha slider is changed */
+static void _etk_colorpicker_aslider_value_changed_cb(Etk_Object *object, double value, void *data)
+{
+   Etk_Colorpicker *cp;
+   Etk_Widget *slider;
+   Etk_Color color;
+   char string[10];
+   
+   if (!(slider = ETK_WIDGET(object)) || !(cp = ETK_COLORPICKER(data)))
+      return;
+   
+   snprintf(string, 10, "%d", (int)(value));
+   etk_label_set(ETK_LABEL(cp->value_labels[6]), string);
+   
+   if (cp->ignore_value_changed)
+      return;
+   
+   color.a = (int)(value);
+   color.r = cp->current_color.r;
+   color.g = cp->current_color.g;
+   color.b = cp->current_color.b;
+   
+   cp->current_color.a = color.a;
+   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);
 }
 
 /* Called when the color mode is changed with the radio buttons */
Index: etk_colorpicker.h
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.h,v
retrieving revision 1.11
diff -u -r1.11 etk_colorpicker.h
--- etk_colorpicker.h	6 Oct 2006 17:04:14 -0000	1.11
+++ etk_colorpicker.h	18 Jan 2007 05:58:13 -0000
@@ -28,7 +28,8 @@
    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_B,     /**< The "Blue" mode */
+   ETK_COLORPICKER_A      /**< The "Alpha" mode (can't be selected)*/
 } Etk_Colorpicker_Mode;
 
 /**
@@ -67,7 +68,7 @@
    Etk_Bool vp_cursor_needs_update;
    
    /* Sliders */
-   Etk_Widget *sliders[6];
+   Etk_Widget *sliders[7];
    Evas_Object *sliders_image[6];
    float sliders_max_value[6];
    int sliders_res;
@@ -76,7 +77,7 @@
    /* Component widgets */
    Etk_Widget *component_table;
    Etk_Widget *radios[6];
-   Etk_Widget *value_labels[6];
+   Etk_Widget *value_labels[7];
    
    /* Current color objects */
    Etk_Widget *color_table;
-------------------------------------------------------------------------
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-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to