diff --git a/TODO b/TODO index 5ccdfce74..bef80d1e9 100644 --- a/TODO +++ b/TODO @@ -8,6 +8,8 @@ Some of the things (in very short form) that need to be done to E17... BUGS / FIXES ------------------------------------------------------------------------------- +* BUG: dnd to ibar of an icon that isnt a .eap (app provided for example) drop + indicator doesnt stop after error dialog report. * BUG: dnd to ibar is broken if u did an icon that isn't IN the ibar yet (from a window border) to either the very start or end of the ibar. * BUG: some bug if u flip desktops fast enough window s vanish (how the hell diff --git a/data/themes/Makefile.am b/data/themes/Makefile.am index d85535c97..8fb32e586 100644 --- a/data/themes/Makefile.am +++ b/data/themes/Makefile.am @@ -40,7 +40,11 @@ default_about.edc \ default_theme_about.edc \ default_entry.edc \ default_scrollbar.edc \ -default_fileman.edc +default_fileman.edc \ +default_check.edc \ +default_radio.edc \ +default_frame.edc + default.edj: Makefile $(EXTRA_DIST) $(EDJE_CC) $(EDJE_FLAGS) \ $(top_srcdir)/data/themes/default.edc \ diff --git a/data/themes/default.edc b/data/themes/default.edc index 22971e0e6..1cff647dd 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -49,5 +49,8 @@ collections { #include "default_entry.edc" #include "default_fileman.edc" #include "default_scrollbar.edc" +#include "default_check.edc" +#include "default_radio.edc" +#include "default_frame.edc" } diff --git a/data/themes/default_check.edc b/data/themes/default_check.edc new file mode 100644 index 000000000..08aa369dd --- /dev/null +++ b/data/themes/default_check.edc @@ -0,0 +1,127 @@ +images { + image: "e17_menu_check1.png" COMP; + image: "e17_menu_check2.png" COMP; +} +group { + name: "widgets/check"; + parts { + part { + name: "outline"; + mouse_events: 0; + description { + state: "default" 0.0; + min: 16 16; + max: 16 16; + align: 0.0 0.5; + fixed: 1 1; + rel1 { + relative: 0.0 0.0; + offset: 4 4; + } + rel2 { + relative: 0.0 1.0; + offset: 4 -5; + } + image { + normal: "e17_menu_check1.png"; + } + } + } + part { + name: "item1"; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + rel1 { + to: "outline"; + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + to: "outline"; + relative: 1.0 1.0; + offset: -1 -1; + } + image { + normal: "e17_menu_check2.png"; + } + } + description { + state: "active" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "label"; + type: TEXT; + effect: SHADOW; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to_x: "outline"; + relative: 1.0 0.0; + offset: 2 4; + } + rel2 { + relative: 1.0 1.0; + offset: -5 -5; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Check Button"; + font: "Edje-Vera"; + size: 10; + min: 1 1; + align: 0.0 0.5; + } + } + } + part { + name: "event"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + } + programs { + program { + name: "turn_on1"; + signal: "toggle_on"; + source: ""; + action: STATE_SET "active" 0.0; + target: "item1"; + } + program { + name: "turn_off1"; + signal: "toggle_off"; + source: ""; + action: STATE_SET "default" 0.0; + target: "item1"; + } + program { + name: "click"; + signal: "mouse,down,1"; + source: "event"; + script { + new buf[100]; + new Float:val; + + get_state(PART:"item1", buf, sizeof(buf), val); + if (!strcmp(buf, "default")) { + set_state(PART:"item1", "active", 0.0); + emit("toggled", "on"); + } + else { + set_state(PART:"item1", "default", 0.0); + emit("toggled", "off"); + } + } + } + } +} diff --git a/data/themes/default_frame.edc b/data/themes/default_frame.edc new file mode 100644 index 000000000..f88ff6dba --- /dev/null +++ b/data/themes/default_frame.edc @@ -0,0 +1,127 @@ +images { + image: "e17_frame_label_over.png" COMP; + image: "e17_frame_label_under.png" COMP; + image: "e17_frame_outline.png" COMP; +} +group { + name: "widgets/frame"; + parts { + part { + name: "items"; + mouse_events: 0; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { + to_x: "outline"; + to_y: "label_over"; + relative: 0.0 1.0; + offset: 4 2; + } + rel2 { + to: "outline"; + relative: 1.0 1.0; + offset: -5 -5; + } + color: 0 0 0 0; + } + } + part { + name: "outline"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to_y: "label"; + relative: 0.0 0.5; + offset: 3 -1; + } + rel2 { + relative: 1.0 1.0; + offset: -4 -4; + } + image { + normal: "e17_frame_outline.png"; + border: 7 7 7 7; + middle: 0; + } + fill { + smooth: 0; + } + } + } + part { + name: "label_under"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to: "label_over"; + relative: 0.0 0.0; + offset: 1 1; + } + rel2 { + to: "label_over"; + relative: 1.0 1.0; + offset: -2 -2; + } + image { + normal: "e17_frame_label_under.png"; + border: 3 3 3 3; + } + fill { + smooth: 0; + } + } + } + part { + name: "label"; + type: TEXT; + mouse_events: 0; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { + relative: 0.0 0.0; + offset: 16 6; + } + rel2 { + relative: 0.0 0.0; + offset: 16 6; + } + color: 0 0 0 80; + text { + text: "Frame Label"; + font: "Edje-Vera-Bold"; + size: 10; + min: 1 1; + align: 0.0 0.5; + } + } + } + part { + name: "label_over"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to: "label"; + relative: 0.0 0.0; + offset: -4 -4; + } + rel2 { + to: "label"; + relative: 1.0 1.0; + offset: 5 3; + } + image { + normal: "e17_frame_label_over.png"; + border: 7 7 7 7; + } + fill { + smooth: 0; + } + } + } + } +} diff --git a/data/themes/default_menu.edc b/data/themes/default_menu.edc index 4bdc0cb12..13a3b5798 100644 --- a/data/themes/default_menu.edc +++ b/data/themes/default_menu.edc @@ -171,26 +171,6 @@ group { group { name: "widgets/menu/default/check"; parts { - part { - name: "background"; - mouse_events: 0; - type: RECT; - description { - state: "default" 0.0; - visible: 0; - min: 18 18; - max: 18 18; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - color: 0 0 0 0; - } - } part { name: "outline"; mouse_events: 0; @@ -200,11 +180,11 @@ group { max: 16 16; rel1 { relative: 0.0 0.0; - offset: 0 0; + offset: 1 1; } rel2 { relative: 1.0 1.0; - offset: -1 -1; + offset: -2 -2; } image { normal: "e17_menu_check1.png"; @@ -220,10 +200,12 @@ group { max: 16 16; visible: 0; rel1 { + to: "outline"; relative: 0.0 0.0; offset: 0 0; } rel2 { + to: "outline"; relative: 1.0 1.0; offset: -1 -1; } @@ -237,10 +219,12 @@ group { max: 16 16; visible: 1; rel1 { + to: "outline"; relative: 0.0 0.0; offset: 0 0; } rel2 { + to: "outline"; relative: 1.0 1.0; offset: -1 -1; } @@ -270,26 +254,6 @@ group { group { name: "widgets/menu/default/radio"; parts { - part { - name: "background"; - mouse_events: 0; - type: RECT; - description { - state: "default" 0.0; - visible: 0; - min: 18 18; - max: 18 18; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - color: 0 0 0 0; - } - } part { name: "outline"; mouse_events: 0; @@ -299,11 +263,11 @@ group { max: 16 16; rel1 { relative: 0.0 0.0; - offset: 0 0; + offset: 1 1; } rel2 { relative: 1.0 1.0; - offset: -1 -1; + offset: -2 -2; } image { normal: "e17_menu_radio1.png"; @@ -319,10 +283,12 @@ group { max: 16 16; visible: 0; rel1 { + to: "outline"; relative: 0.0 0.0; offset: 0 0; } rel2 { + to: "outline"; relative: 1.0 1.0; offset: -1 -1; } @@ -336,10 +302,12 @@ group { max: 16 16; visible: 1; rel1 { + to: "outline"; relative: 0.0 0.0; offset: 0 0; } rel2 { + to: "outline"; relative: 1.0 1.0; offset: -1 -1; } @@ -883,26 +851,6 @@ group { group { name: "widgets/menu/default/submenu"; parts { - part { - name: "background"; - mouse_events: 0; - type: RECT; - description { - state: "default" 0.0; - visible: 0; - min: 12 12; - max: 12 12; - rel1 { - relative: 0.0 0.0; - offset: 0 0; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } - color: 0 0 0 0; - } - } part { name: "arrow"; mouse_events: 0; @@ -912,13 +860,11 @@ group { max: 6 12; rel1 { relative: 0.0 0.0; - offset: 0 0; - to: "background"; + offset: 3 0; } rel2 { relative: 1.0 1.0; - offset: -1 -1; - to: "background"; + offset: -4 -1; } image { normal: "e17_menu_arrow.png"; diff --git a/data/themes/default_radio.edc b/data/themes/default_radio.edc new file mode 100644 index 000000000..3b224de76 --- /dev/null +++ b/data/themes/default_radio.edc @@ -0,0 +1,127 @@ +images { + image: "e17_menu_radio1.png" COMP; + image: "e17_menu_radio2.png" COMP; +} +group { + name: "widgets/radio"; + parts { + part { + name: "outline"; + mouse_events: 0; + description { + state: "default" 0.0; + min: 16 16; + max: 16 16; + align: 0.0 0.5; + fixed: 1 1; + rel1 { + relative: 0.0 0.0; + offset: 1 1; + } + rel2 { + relative: 1.0 1.0; + offset: -2 -2; + } + image { + normal: "e17_menu_radio1.png"; + } + } + } + part { + name: "item1"; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + rel1 { + to: "outline"; + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + to: "outline"; + relative: 1.0 1.0; + offset: -1 -1; + } + image { + normal: "e17_menu_radio2.png"; + } + } + description { + state: "active" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { + name: "label"; + type: TEXT; + effect: SHADOW; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to_x: "outline"; + relative: 1.0 0.0; + offset: 1 1; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -2; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Radio Button"; + font: "Edje-Vera"; + size: 10; + min: 1 1; + align: 0.0 0.5; + } + } + } + part { + name: "event"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + } + programs { + program { + name: "turn_on1"; + signal: "toggle_on"; + source: ""; + action: STATE_SET "active" 0.0; + target: "item1"; + } + program { + name: "turn_off1"; + signal: "toggle_off"; + source: ""; + action: STATE_SET "default" 0.0; + target: "item1"; + } + program { + name: "click"; + signal: "mouse,down,1"; + source: "event"; + script { + new buf[100]; + new Float:val; + + get_state(PART:"item1", buf, sizeof(buf), val); + if (!strcmp(buf, "default")) { + set_state(PART:"item1", "active", 0.0); + emit("toggled", "on"); + } + else { + set_state(PART:"item1", "default", 0.0); + emit("toggled", "off"); + } + } + } + } +} diff --git a/data/themes/images/Makefile.am b/data/themes/images/Makefile.am index 56e22f3a1..7fdbb8341 100644 --- a/data/themes/images/Makefile.am +++ b/data/themes/images/Makefile.am @@ -363,4 +363,8 @@ e17_button_detail_delete.png \ e17_button_detail_view_details.png \ e17_button_detail_view_name.png \ e17_button_detail_view.png \ -e17_button_detail_open.png +e17_button_detail_open.png \ +e17_frame_label_over.png \ +e17_frame_label_under.png \ +e17_frame_outline.png + diff --git a/data/themes/images/e17_dialog_watermark.png b/data/themes/images/e17_dialog_watermark.png index c5d6d3852..1496dd522 100644 Binary files a/data/themes/images/e17_dialog_watermark.png and b/data/themes/images/e17_dialog_watermark.png differ diff --git a/data/themes/images/e17_frame_label_over.png b/data/themes/images/e17_frame_label_over.png new file mode 100644 index 000000000..4c9d864bb Binary files /dev/null and b/data/themes/images/e17_frame_label_over.png differ diff --git a/data/themes/images/e17_frame_label_under.png b/data/themes/images/e17_frame_label_under.png new file mode 100644 index 000000000..15d9126ab Binary files /dev/null and b/data/themes/images/e17_frame_label_under.png differ diff --git a/data/themes/images/e17_frame_outline.png b/data/themes/images/e17_frame_outline.png new file mode 100644 index 000000000..e277af83b Binary files /dev/null and b/data/themes/images/e17_frame_outline.png differ diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 706274bec..c4880a540 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -82,7 +82,9 @@ e_apps_cache.h \ e_entry.h \ e_fileman.h \ e_scrollbar.h \ -e_fileman_smart.h +e_fileman_smart.h \ +e_widget.h \ +e_widget_check.h enlightenment_src = \ e_user.c \ @@ -147,6 +149,8 @@ e_entry.c \ e_fileman.c \ e_scrollbar.c \ e_fileman_smart.c \ +e_widget.c \ +e_widget_check.c \ $(ENLIGHTENMENTHEADERS) enlightenment_SOURCES = \ diff --git a/src/bin/e_dialog.c b/src/bin/e_dialog.c index d7c8ca3d9..150325864 100644 --- a/src/bin/e_dialog.c +++ b/src/bin/e_dialog.c @@ -61,13 +61,6 @@ e_dialog_new(E_Container *con) evas_object_move(o, 0, 0); evas_object_show(o); - o = edje_object_add(e_win_evas_get(dia->win)); - dia->text_object = o; - e_theme_edje_object_set(o, "base/theme/dialog", - "widgets/dialog/text"); - edje_object_part_swallow(dia->bg_object, "content_swallow", o); - evas_object_show(o); - o = e_box_add(e_win_evas_get(dia->win)); dia->box_object = o; e_box_orientation_set(o, 1); @@ -207,20 +200,38 @@ e_dialog_title_set(E_Dialog *dia, char *title) void e_dialog_text_set(E_Dialog *dia, char *text) { + if (!dia->text_object) + { + Evas_Object *o; + + o = edje_object_add(e_win_evas_get(dia->win)); + dia->text_object = o; + e_theme_edje_object_set(o, "base/theme/dialog", + "widgets/dialog/text"); + edje_object_part_swallow(dia->bg_object, "content_swallow", o); + evas_object_show(o); + } edje_object_part_text_set(dia->text_object, "text", text); } void e_dialog_icon_set(E_Dialog *dia, char *icon, Evas_Coord size) { - if (icon) - { - dia->icon_object = edje_object_add(e_win_evas_get(dia->win)); - e_util_edje_icon_set(dia->icon_object, icon); - edje_extern_object_min_size_set(dia->icon_object, size, size); - edje_object_part_swallow(dia->bg_object, "icon_swallow", dia->icon_object); - evas_object_show(dia->icon_object); - } + if (!icon) return; + + dia->icon_object = edje_object_add(e_win_evas_get(dia->win)); + e_util_edje_icon_set(dia->icon_object, icon); + edje_extern_object_min_size_set(dia->icon_object, size, size); + edje_object_part_swallow(dia->bg_object, "icon_swallow", dia->icon_object); + evas_object_show(dia->icon_object); +} + +void +e_dialog_content_set(E_Dialog *dia, Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) +{ + edje_extern_object_min_size_set(obj, minw, minh); + edje_object_part_swallow(dia->bg_object, "content_swallow", obj); + evas_object_show(obj); } void @@ -230,9 +241,12 @@ e_dialog_show(E_Dialog *dia) Evas_Object *o; o = dia->text_object; - edje_object_size_min_calc(o, &mw, &mh); - edje_extern_object_min_size_set(o, mw, mh); - edje_object_part_swallow(dia->bg_object, "content_swallow", o); + if (o) + { + edje_object_size_min_calc(o, &mw, &mh); + edje_extern_object_min_size_set(o, mw, mh); + edje_object_part_swallow(dia->bg_object, "content_swallow", o); + } o = dia->box_object; e_box_min_size_get(o, &mw, &mh); @@ -305,7 +319,6 @@ _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *even e_dialog_button_focus_button(dia, db); } -/* TODO: Implement shift-tab and left arrow */ static void _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event) { diff --git a/src/bin/e_dialog.h b/src/bin/e_dialog.h index fcab6d977..061d73b6b 100644 --- a/src/bin/e_dialog.h +++ b/src/bin/e_dialog.h @@ -27,14 +27,15 @@ struct _E_Dialog void *data; }; -EAPI E_Dialog *e_dialog_new (E_Container *con); -EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data); -EAPI int e_dialog_button_focus_num(E_Dialog *dia, int button); -EAPI int e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button); -EAPI void e_dialog_title_set (E_Dialog *dia, char *title); -EAPI void e_dialog_text_set (E_Dialog *dia, char *text); -EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size); -EAPI void e_dialog_show (E_Dialog *dia); +EAPI E_Dialog *e_dialog_new (E_Container *con); +EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data); +EAPI int e_dialog_button_focus_num (E_Dialog *dia, int button); +EAPI int e_dialog_button_focus_button (E_Dialog *dia, E_Dialog_Button *button); +EAPI void e_dialog_title_set (E_Dialog *dia, char *title); +EAPI void e_dialog_text_set (E_Dialog *dia, char *text); +EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size); +EAPI void e_dialog_content_set (E_Dialog *dia, Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); +EAPI void e_dialog_show (E_Dialog *dia); #endif #endif diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index b3bc2a4b6..4e0ffb636 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -64,3 +64,5 @@ #include "e_scrollbar.h" #include "e_fileman.h" #include "e_fileman_smart.h" +#include "e_widget.h" +#include "e_widget_check.h" diff --git a/src/bin/e_test.c b/src/bin/e_test.c index 422082b24..1dfbfe480 100644 --- a/src/bin/e_test.c +++ b/src/bin/e_test.c @@ -308,6 +308,34 @@ _e_test_internal(E_Container *con) e_dialog_show(dia); } #elif 0 +static int my_val = 0; + +static void +_e_test_internal(E_Container *con) +{ + E_Dialog *dia; + + dia = e_dialog_new(con); + e_dialog_title_set(dia, "A Test Dialog"); + { + Evas_Object *o; + Evas_Coord mw, mh; + + o = e_widget_checkbox_add(e_win_evas_get(dia->win), + "My checkbox widget which on toggles is modifying my_val", + &my_val); + e_widget_min_size_get(o, &mw, &mh); + e_dialog_content_set(dia, o, mw, mh); +// e_theme_edje_object_set(o, "base/theme/dialog", +// "widgets/frame"); + } + e_dialog_button_add(dia, "OK", NULL, NULL, NULL); + e_dialog_button_add(dia, "Apply", "enlightenment/reset", NULL, NULL); + e_dialog_button_add(dia, "Cancel", "enlightenment/exit", NULL, NULL); + e_win_centered_set(dia->win, 1); + e_dialog_show(dia); +} +#elif 0 #else static void _e_test_internal(E_Container *con) diff --git a/src/bin/e_widget.c b/src/bin/e_widget.c new file mode 100644 index 000000000..ca58e0af2 --- /dev/null +++ b/src/bin/e_widget.c @@ -0,0 +1,266 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +#define SMART_NAME "e_widget" +#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) +#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return; +typedef struct _E_Smart_Data E_Smart_Data; + +struct _E_Smart_Data +{ + Evas_Coord x, y, w, h; + Evas_Coord minw, minh, maxw, maxh; + Evas_List *subobjs; + Evas_Object *resize_obj; + void (*del_func) (Evas_Object *obj); + void *data; +}; + +/* local subsystem functions */ +static void _e_smart_reconfigure(E_Smart_Data *sd); +static void _e_smart_add(Evas_Object *obj); +static void _e_smart_del(Evas_Object *obj); +static void _e_smart_layer_set(Evas_Object *obj, int layer); +static void _e_smart_raise(Evas_Object *obj); +static void _e_smart_lower(Evas_Object *obj); +static void _e_smart_stack_above(Evas_Object *obj, Evas_Object *above); +static void _e_smart_stack_below(Evas_Object *obj, Evas_Object *below); +static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y); +static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); +static void _e_smart_show(Evas_Object *obj); +static void _e_smart_hide(Evas_Object *obj); +static void _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a); +static void _e_smart_clip_set(Evas_Object *obj, Evas_Object * clip); +static void _e_smart_clip_unset(Evas_Object *obj); +static void _e_smart_init(void); + +/* local subsystem globals */ +static Evas_Smart *_e_smart = NULL; + +/* externally accessible functions */ +Evas_Object * +e_widget_add(Evas *evas) +{ + _e_smart_init(); + return evas_object_smart_add(evas, _e_smart); +} + +void +e_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)) +{ + API_ENTRY return; + sd->del_func = func; +} + +void +e_widget_data_set(Evas_Object *obj, void *data) +{ + API_ENTRY return; + sd->data = data; +} + +void * +e_widget_data_get(Evas_Object *obj) +{ + API_ENTRY return NULL; + return sd->data; +} + +void +e_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) +{ + API_ENTRY return; + sd->minw = minw; + sd->minh = minh; +} + +void +e_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) +{ + API_ENTRY return; + if (minw) *minw = sd->minw; + if (minh) *minh = sd->minh; +} + +void +e_widget_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh) +{ + API_ENTRY return; + sd->minw = maxw; + sd->maxh = maxh; +} + +void +e_widget_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) +{ + API_ENTRY return; + if (maxw) *maxw = sd->maxw; + if (maxh) *maxh = sd->maxh; +} + +void +e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) +{ + API_ENTRY return; + sd->subobjs = evas_list_append(sd->subobjs, sobj); +} + +void +e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj) +{ + API_ENTRY return; + sd->subobjs = evas_list_remove(sd->subobjs, sobj); +} + +void +e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) +{ + API_ENTRY return; + if (sd->resize_obj) evas_object_smart_member_del(sd->resize_obj); + sd->resize_obj = sobj; + evas_object_smart_member_add(obj, sobj); + _e_smart_reconfigure(sd); +} + +/* local subsystem functions */ +static void +_e_smart_reconfigure(E_Smart_Data *sd) +{ + if (sd->resize_obj) + { + evas_object_move(sd->resize_obj, sd->x, sd->y); + evas_object_resize(sd->resize_obj, sd->w, sd->h); + } +} + +static void +_e_smart_add(Evas_Object *obj) +{ + E_Smart_Data *sd; + + sd = calloc(1, sizeof(E_Smart_Data)); + if (!sd) return; + sd->x = 0; + sd->y = 0; + sd->w = 0; + sd->h = 0; + evas_object_smart_data_set(obj, sd); +} + +static void +_e_smart_del(Evas_Object *obj) +{ + INTERNAL_ENTRY; + if (sd->del_func) sd->del_func(obj); + while (sd->subobjs) + { + evas_object_del(sd->subobjs->data); + sd->subobjs = evas_list_remove_list(sd->subobjs, sd->subobjs); + } + free(sd); +} + +static void +_e_smart_layer_set(Evas_Object *obj, int layer) +{ + INTERNAL_ENTRY; + evas_object_layer_set(sd->resize_obj, layer); +} + +static void +_e_smart_raise(Evas_Object *obj) +{ + INTERNAL_ENTRY; + evas_object_raise(sd->resize_obj); +} + +static void +_e_smart_lower(Evas_Object *obj) +{ + INTERNAL_ENTRY; + evas_object_lower(sd->resize_obj); +} + +static void +_e_smart_stack_above(Evas_Object *obj, Evas_Object *above) +{ + INTERNAL_ENTRY; + evas_object_stack_above(sd->resize_obj, above); +} + +static void +_e_smart_stack_below(Evas_Object *obj, Evas_Object *below) +{ + INTERNAL_ENTRY; + evas_object_stack_below(sd->resize_obj, below); +} + +static void +_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + INTERNAL_ENTRY; + sd->x = x; + sd->y = y; + _e_smart_reconfigure(sd); +} + +static void +_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) +{ + INTERNAL_ENTRY; + sd->w = w; + sd->h = h; + _e_smart_reconfigure(sd); +} + +static void +_e_smart_show(Evas_Object *obj) +{ + INTERNAL_ENTRY; + evas_object_show(sd->resize_obj); +} + +static void +_e_smart_hide(Evas_Object *obj) +{ + INTERNAL_ENTRY; + evas_object_hide(sd->resize_obj); +} + +static void +_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a) +{ + INTERNAL_ENTRY; + evas_object_color_set(sd->resize_obj, r, g, b, a); +} + +static void +_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip) +{ + INTERNAL_ENTRY; + evas_object_clip_set(sd->resize_obj, clip); +} + +static void +_e_smart_clip_unset(Evas_Object *obj) +{ + INTERNAL_ENTRY; + evas_object_clip_unset(sd->resize_obj); +} + +/* never need to touch this */ + +static void +_e_smart_init(void) +{ + if (_e_smart) return; + _e_smart = evas_smart_new + (SMART_NAME, _e_smart_add, _e_smart_del, _e_smart_layer_set, + _e_smart_raise, _e_smart_lower, _e_smart_stack_above, + _e_smart_stack_below, _e_smart_move, _e_smart_resize, + _e_smart_show, _e_smart_hide, _e_smart_color_set, + _e_smart_clip_set, _e_smart_clip_unset, NULL); +} + diff --git a/src/bin/e_widget.h b/src/bin/e_widget.h new file mode 100644 index 000000000..c9b3bbb23 --- /dev/null +++ b/src/bin/e_widget.h @@ -0,0 +1,22 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS +#else +#ifndef E_WIDGET_H +#define E_WIDGET_H + +EAPI Evas_Object *e_widget_add(Evas *evas); +EAPI void e_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void e_widget_data_set(Evas_Object *obj, void *data); +EAPI void *e_widget_data_get(Evas_Object *obj); +EAPI void e_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); +EAPI void e_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); +EAPI void e_widget_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh); +EAPI void e_widget_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh); +EAPI void e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); +EAPI void e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); +EAPI void e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj); + +#endif +#endif diff --git a/src/bin/e_widget_check.c b/src/bin/e_widget_check.c new file mode 100644 index 000000000..6a4fad2ac --- /dev/null +++ b/src/bin/e_widget_check.c @@ -0,0 +1,69 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +typedef struct _E_Widget_Data E_Widget_Data; +struct _E_Widget_Data +{ + int *valptr; +}; + +static void _e_wid_del_hook(Evas_Object *obj); +static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source); +/* local subsystem functions */ + +/* externally accessible functions */ +Evas_Object * +e_widget_checkbox_add(Evas *evas, char *label, int *val) +{ + Evas_Object *obj, *o; + E_Widget_Data *wd; + Evas_Coord mw, mh; + + obj = e_widget_add(evas); + + e_widget_del_hook_set(obj, _e_wid_del_hook); + wd = calloc(1, sizeof(E_Widget_Data)); + wd->valptr = val; + e_widget_data_set(obj, wd); + + o = edje_object_add(evas); + e_theme_edje_object_set(o, "base/theme/widgets", + "widgets/check"); + edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj); + edje_object_part_text_set(o, "label", label); + edje_object_size_min_calc(o, &mw, &mh); + e_widget_min_size_set(obj, mw, mh); + if (wd->valptr) + { + if (*(wd->valptr)) edje_object_signal_emit(o, "toggle_on", ""); + } + + e_widget_sub_object_add(obj, o); + e_widget_resize_object_set(obj, o); + + return obj; +} + +static void +_e_wid_del_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + free(wd); +} + +static void +_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(data); + if (wd->valptr) + { + if (!strcmp(source, "on")) *(wd->valptr) = 1; + else *(wd->valptr) = 0; + } +} diff --git a/src/bin/e_widget_check.h b/src/bin/e_widget_check.h new file mode 100644 index 000000000..908cac318 --- /dev/null +++ b/src/bin/e_widget_check.h @@ -0,0 +1,12 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS +#else +#ifndef E_WIDGET_CHECK_H +#define E_WIDGET_CHECK_H + +EAPI Evas_Object *e_widget_checkbox_add(Evas *evas, char *label, int *val); + +#endif +#endif