Re: [E-devel] [PATCH] E Button Widget

2007-10-05 Thread The Rasterman
On Tue, 18 Sep 2007 03:11:31 +0200 lok [EMAIL PROTECTED] babbled:

 Hi,
 
 I've got a small problem recently on a theme. If the theme use a min 
 size for
 it's buttons, way larger than the default theme's. It's impossible to
 have the icon centered on a button with no text. (For exemple into the File
 Properties dialog in EFM).
 
 Currently the button theme only know when an icon is visible or not. My 
 patch
 replace the two e,action,show/hide,icon signals by e,state,icon/text/combo.
 That way the theme knows how justify the icon.
 
 Any comments is welcome.

sounds good to me - in cvs it goes! :)

-- 
- Codito, ergo sum - I code, therefore I am --
The Rasterman (Carsten Haitzler)[EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now  http://get.splunk.com/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] [PATCH] E Button Widget

2007-09-17 Thread lok

Hi,

I've got a small problem recently on a theme. If the theme use a min 
size for

it's buttons, way larger than the default theme's. It's impossible to
have the icon centered on a button with no text. (For exemple into the File
Properties dialog in EFM).

Currently the button theme only know when an icon is visible or not. My 
patch

replace the two e,action,show/hide,icon signals by e,state,icon/text/combo.
That way the theme knows how justify the icon.

Any comments is welcome.

lok
Index: e/data/themes/default_button.edc
===
RCS file: /cvs/e/e17/apps/e/data/themes/default_button.edc,v
retrieving revision 1.12
diff -u -r1.12 default_button.edc
--- e/data/themes/default_button.edc	7 Jul 2007 02:04:19 -	1.12
+++ e/data/themes/default_button.edc	18 Sep 2007 00:33:09 -
@@ -78,7 +78,7 @@
 	}
 	 }
 	 description {
-	state: visible 0.0;
+	state: combo 0.0;
 	inherit: default 0.0;
 	aspect: 1.0 1.0;
 	aspect_preference: VERTICAL;
@@ -94,6 +94,23 @@
 	   to: button_image;
 	}
 	 }
+	 description {
+	state: icon 0.0;
+	inherit: default 0.0;
+	aspect: 1.0 1.0;
+	aspect_preference: BOTH;
+	align: 0.5 0.5;
+	rel1 {
+	   relative: 0.0 0.0;
+	   offset:   8  8;
+	   to: button_image;
+	}
+	rel2 {
+	   relative: 1.0 1.0;
+	   offset:   -9   -9;
+	   to: button_image;
+	}
+	 }
   }
   part {
 	 name:  e.text.label;
@@ -117,7 +134,7 @@
 	color3: 255 255 255 128;
 	color_class: button_text;
 	text {
-	   text: OK;
+	   text: ;
 	   font: Edje-Vera;
 	   size: 10;
 	   min:  1 1;
@@ -132,6 +149,11 @@
 	color3: 255 255 255 64;
 	color_class: button_text_disabled;
 	 }
+	 description {
+	state:icon 0.0;
+	inherit:  default 0.0;
+	visible: 0;
+	 }
   }
   part {
 	 name: glint_clip;
@@ -330,18 +352,28 @@
 	 action: SIGNAL_EMIT e,action,click ;
   }
   program {
-	 name:   icon_visible;
-	 signal: e,action,show,icon;
+	 name: text_state;
+	 signal: e,state,text;
 	 source: e;
-	 action: STATE_SET visible 0.0;
+	 action: STATE_SET default 0.0;
 	 target: e.swallow.icon;
+	 target: e.text.label;
   }
   program {
-	 name:   icon_invisible;
-	 signal: e,action,hide,icon;
+	 name: icon_state;
+	 signal: e,state,icon;
 	 source: e;
-	 action: STATE_SET default 0.0;
+	 action: STATE_SET icon 0.0;
+	 target: e.swallow.icon;
+	 target: e.text.label;
+  }
+  program {
+	 name: combo_state;
+	 signal: e,state,combo;
+	 source: e;
+	 action: STATE_SET combo 0.0;
 	 target: e.swallow.icon;
+	 target: e.text.label;
   }
   program {
 	 name: button_in;
Index: e/src/bin/e_widget_button.c
===
RCS file: /cvs/e/e17/apps/e/src/bin/e_widget_button.c,v
retrieving revision 1.16
diff -u -r1.16 e_widget_button.c
--- e/src/bin/e_widget_button.c	7 Aug 2007 14:20:47 -	1.16
+++ e/src/bin/e_widget_button.c	18 Sep 2007 00:33:49 -
@@ -3,6 +3,13 @@
  */
 #include e.h
 
+typedef enum _E_Widget_Button_Type E_Widget_Button_Type;
+enum _E_Widget_Button_Type
+{
+   E_WIDGET_BUTTON_TEXT = 1  0,
+   E_WIDGET_BUTTON_ICON = 1  1
+};
+
 typedef struct _E_Widget_Data E_Widget_Data;
 struct _E_Widget_Data
 {
@@ -11,6 +18,7 @@
void (*func) (void *data, void *data2);
void *data;
void *data2;   
+   E_Widget_Button_Type type;
 };
 
 static void _e_wid_del_hook(Evas_Object *obj);
@@ -19,6 +27,7 @@
 static void _e_wid_disable_hook(Evas_Object *obj);
 static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _e_wid_button_state_send(E_Widget_Data *wd);
 /* local subsystem functions */
 
 /* externally accessible functions */
@@ -46,7 +55,11 @@
e_theme_edje_object_set(o, base/theme/widgets,
 			   e/widgets/button);
edje_object_signal_callback_add(o, e,action,click, , _e_wid_signal_cb1, obj);
-   edje_object_part_text_set(o, e.text.label, label);
+   if (label  label[0] != 0)
+ {
+	edje_object_part_text_set(o, e.text.label, label);
+	wd-type |= E_WIDGET_BUTTON_TEXT;
+ }
evas_object_show(o);

e_widget_sub_object_add(obj, o);
@@ -59,12 +72,12 @@
 	wd-o_icon = o;
 	e_util_edje_icon_set(o, icon);
 	edje_object_part_swallow(wd-o_button, e.swallow.icon, o);
-	edje_object_signal_emit(wd-o_button, e,action,show,icon, e);
-	edje_object_message_signal_process(wd-o_button);
 	evas_object_show(o);
 	e_widget_sub_object_add(obj, o);
+	wd-type |= E_WIDGET_BUTTON_ICON;
  }
-   
+
+   _e_wid_button_state_send(wd);
edje_object_size_min_calc(wd-o_button, mw, mh);
e_widget_min_size_set(obj, mw, mh);

@@ -78,6 +91,11 @@
 
wd = e_widget_data_get(obj);
edje_object_part_text_set(wd-o_button, e.text.label, label);
+   if