From ead2822bfe368138f4646211a3dedfb7ad6151b4 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Fri, 19 Dec 2008 05:48:23 +0000 Subject: [PATCH] Work on a combo --- experimental/ecdb/trunk/TODO | 1 + .../trunk/data/themes/default/default.edc | 1 + .../data/themes/default/groups/combo.edc | 267 ++++++++++++++++++ .../data/themes/default/groups/erase_disc.edc | 22 ++ .../themes/default/images/combo_arrow.png | Bin 0 -> 467 bytes .../themes/default/images/combobox_button.png | Bin 0 -> 1047 bytes .../images/combobox_button_clicked.png | Bin 0 -> 1052 bytes .../images/combobox_button_disabled.png | Bin 0 -> 996 bytes .../themes/default/images/combobox_focus.png | Bin 0 -> 302 bytes .../data/themes/default/images/images.edc | 5 + experimental/ecdb/trunk/src/ecdb_gui.c | 15 +- experimental/ecdb/trunk/src/ecdb_widgets.c | 250 ++++++++++++---- experimental/ecdb/trunk/src/ecdb_widgets.h | 8 + 13 files changed, 509 insertions(+), 60 deletions(-) create mode 100644 experimental/ecdb/trunk/data/themes/default/groups/combo.edc create mode 100644 experimental/ecdb/trunk/data/themes/default/images/combo_arrow.png create mode 100644 experimental/ecdb/trunk/data/themes/default/images/combobox_button.png create mode 100644 experimental/ecdb/trunk/data/themes/default/images/combobox_button_clicked.png create mode 100644 experimental/ecdb/trunk/data/themes/default/images/combobox_button_disabled.png create mode 100644 experimental/ecdb/trunk/data/themes/default/images/combobox_focus.png diff --git a/experimental/ecdb/trunk/TODO b/experimental/ecdb/trunk/TODO index 5ab17680..4acee8ce 100644 --- a/experimental/ecdb/trunk/TODO +++ b/experimental/ecdb/trunk/TODO @@ -4,3 +4,4 @@ -> finish interface -> more flexible typebuf -> more configuration options (speed and drive choice) +-> fix combo theme diff --git a/experimental/ecdb/trunk/data/themes/default/default.edc b/experimental/ecdb/trunk/data/themes/default/default.edc index ae598867..5f034a7c 100644 --- a/experimental/ecdb/trunk/data/themes/default/default.edc +++ b/experimental/ecdb/trunk/data/themes/default/default.edc @@ -14,4 +14,5 @@ collections { #include "groups/check.edc" #include "groups/burn_image.edc" #include "groups/entry.edc" + #include "groups/combo.edc" } diff --git a/experimental/ecdb/trunk/data/themes/default/groups/combo.edc b/experimental/ecdb/trunk/data/themes/default/groups/combo.edc new file mode 100644 index 00000000..fcadbeb4 --- /dev/null +++ b/experimental/ecdb/trunk/data/themes/default/groups/combo.edc @@ -0,0 +1,267 @@ +/* vim: set sw=3 ts=3 sts=3 expandtab: */ +group { + name: "ecdb/combo/background"; + + parts { + part { + name: "base"; + type: RECT; + + description { + state: "default" 0.0; + color: 255 255 255 0; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 0.0 0.0; + offset: -1 -1; + } + } + + description { + state: "active" 0.0; + inherit: "default" 0.0; + color: 255 255 255 128; + } + } + } + + programs { + program { + name: "set_active"; + signal: "ecdb,combo,back,show"; + source: "ecbd"; + action: STATE_SET "active" 0.0; + target: "base"; + } + + program { + name: "set_default"; + signal: "ecdb,combo,back,hide"; + source: "ecdb"; + action: STATE_SET "default" 0.0; + target: "base"; + } + } +} + +group { + name: "ecdb/combo"; + + parts { + part { + name: "base"; + type: IMAGE; + mouse_events: 0; + + description { + state: "default" 0.0; + color: 255 255 255 178; + min: 0 24; + + image { + normal: "button_base.png"; + border: 7 7 7 7; + } + } + } + + part { + name: "focus_clip"; + type: RECT; + mouse_events: 0; + + description { + state: "default" 0.0; + color: 255 255 255 0; + + rel1 { + to: "combo_button"; + } + + rel2 { + to: "combo_button"; + } + } + + description { + state: "clicked" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + + part { + name: "focus"; + type: IMAGE; + mouse_events: 0; + clip_to: "focus_clip"; + + description { + state: "default" 0.0; + + rel1 { + to: "combo_button"; + } + + rel2 { + to: "combo_button"; + } + + image { + normal: "combobox_focus.png"; + border: 7 7 7 7; + } + } + } + + part { + name: "combo_button"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 0 22; + + rel1 { + to: "base"; + relative: 0.0 0.0; + offset: 3 1; + } + + rel2 { + to: "base"; + relative: 1.0 1.0; + offset: -4 -3; + } + + image { + normal: "combobox_button.png"; + border: 7 23 7 7; + } + } + + description { + state: "clicked" 0.0; + inherit: "default" 0.0; + + image { + normal: "combobox_button_clicked.png"; + } + } + + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + + image { + normal: "combobox_button_disabled.png"; + } + } + } + + part { + name: "combo_arrows"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 9 13; + max: 9 13; + align: 1.0 0.5; + + rel1 { + to: "combo_button"; + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -11 -1; + } + + image { + normal: "combo_arrow.png"; + } + + fill { + smooth: 0; + } + } + } + } + + programs { + program { + name: "clicked"; + action: STATE_SET "clicked" 0.0; + signal: "mouse,down,1"; + source: "*"; + target: "combo_button"; + } + + program { + name: "focus_in,mouse"; + signal: "mouse,down,1"; + action: STATE_SET "clicked" 0.0; + source: "*"; + target: "focus_clip"; + transition: DECELERATE 0.5; + } + + program { + name: "focus_in,ecdb"; + signal: "ecdb,focus,in"; + action: STATE_SET "clicked" 0.0; + source: "*"; + target: "focus_clip"; + transition: DECELERATE 0.5; + } + + program { + name: "unclick1"; + signal: "mouse,clicked,1"; + source: "*"; + action: STATE_SET "default" 0.0; + target: "combo_button"; + } + + program { + name: "unclick2"; + signal: "mouse,up,1"; + source: "*"; + action: STATE_SET "default" 0.0; + target: "combo_button"; + } + + program { + name: "focus_out"; + signal: "ecdb,focus,out"; + action: STATE_SET "default" 0.0; + source: "ecdb"; + target: "focus_clip"; + transition: DECELERATE 0.5; + } + + program { + name: "disable"; + signal: "ecdb,disable"; + action: STATE_SET "disabled" 0.0; + source: "ecdb"; + target: "combo_button"; + } + + program { + name: "enable"; + signal: "ecdb,enable"; + action: STATE_SET "default" 0.0; + source: "ecdb"; + target: "combo_button"; + } +} + diff --git a/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc b/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc index 26f204e6..e63fb35b 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc @@ -120,6 +120,28 @@ group { } } + part { + name: "ecdb/erase/drive"; + type: SWALLOW; + repeat_events: 1; + + description { + state: "default" 0.0; + + rel1 { + to: "ecdb/erase/speed"; + relative: 0.0 1.0; + offset: 0 5; + } + + rel2 { + to: "ecdb/erase/speed"; + relative: 1.0 1.0; + offset: 0 30; + } + } + } + part { name: "progress_outline"; type: IMAGE; diff --git a/experimental/ecdb/trunk/data/themes/default/images/combo_arrow.png b/experimental/ecdb/trunk/data/themes/default/images/combo_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..596bff7c4f816a945aaca94ca56acb9131abdeef GIT binary patch literal 467 zcmV;^0WAKBP)s(87-kg{HXu{04;Py zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj27VtF8FbaZe!FE3+na%E&LZ*pg!6A0}9 z00AdSL_t&-(~Z!*N&`_4#qs~l%?5X~O16nyOoFUM@)ClLomg9>xA!@$eFG~yZOtR3 zH3&%~ghUWFgeADwY_3g$AC3NCx>KAphA#p{z#g#P902B9V7J@tUUfR1had>XS(ZHm zt8GYtFiq2oMx${pA|{HW)1oLIm&@fVuvQ>wwOS|E+8Ys30Aoy?rs-WA$A^G1*4q7M zvv~_d-un;lz4P8X5ve9gax|Sz?**s;yFitnJn#^bM&46t4-7LyxPG9Qn}=kxje z30Q5PxyrI^RIAmBFbt1pv)ScjGU)^EcRvB5BuSdU&aZxd`vkZ#WAORc_p|^2002ov JPDHLkV1jh0yQBaB literal 0 HcmV?d00001 diff --git a/experimental/ecdb/trunk/data/themes/default/images/combobox_button.png b/experimental/ecdb/trunk/data/themes/default/images/combobox_button.png new file mode 100644 index 0000000000000000000000000000000000000000..c4bfff9b27d0780734c06ebe5f6bff6229533187 GIT binary patch literal 1047 zcmV+y1nB#TP)z21nT zsMTmRe%#&N-7gl4WdLx_!59PY{YFLzA&|@EAf*HV%x1I6Xf*oJ@ArR^QvNm=4Eg|k z5JeG~xfDgwi~arm*GET3m6MYbs#dEAg5VBltJT8U+1bX-SZgsH4$J4~=igskT)YP0 zopZm&aXb#%?KVYG)NC{wuMQ6nD=$w^$y$qH{29)<6)^7|KJ^D186u@bE)4PV^pw&x z-5rm|uLgs`?{OSY1pp$VuPT+wv*Y6vnk940XA4+k!Jh930D!Tw|5&lcVm@17mdtT{ zd_t8<;h!sWI@pE-CpD zch;}e7+gOF4FICmYVl|^nmOm-o&O@WOH(!s&290{!#Ri1Xp{ipKx+-Hwb5ELGq0tc zpCB|@c(vB7wKf1a$m)al9@aS!(ON}*OGAhV*10>i=}w_w@9-EE?A>;3Jg^tsr|Ui& zMD!%DW*u&jZ4l8_vNGSjL=Q2togtZy+j@e0J`VuM=ksK&fe-?On@bOQzs>W_Soh8& zpU+d~Y7mBD)*;C=K)5>lPxcw`TjeT&afK0vA>HH%5rhx~B6#m01g#lG7`$acV`g~o zkm>f`BkAnHknvD5a1j$!8)m03ei75JDtMskiUm{pplam`)R}TiP#{GqeAf;S7 zH6D-u84ibUyWQ@aUa$8zfb^kqB>|MAlx1elZ#t)bX?`Ul?VOtcNB}H*#lId(q@^^Q RG|m73002ovPDHLkV1nTJ*@XZA literal 0 HcmV?d00001 diff --git a/experimental/ecdb/trunk/data/themes/default/images/combobox_button_clicked.png b/experimental/ecdb/trunk/data/themes/default/images/combobox_button_clicked.png new file mode 100644 index 0000000000000000000000000000000000000000..f39885f8fd6628954a95717613c0c3bb1d559e06 GIT binary patch literal 1052 zcmV+%1mpXOP)WFU8GbZ8()Nlj27VtF8FbaZe!FE3+na%E&LZ*pg!6A0}9 z00VGIL_t(Y$F)|mZsSG}eX~oE3Uy*23Qp|EEOd2zjo~tlf%}a^iWCQ=%qQd%a!8pj z{)1FGxV|8`#!hV&zQPtv)0Vi9xa97nkSJS{MeC$w0fNBpV)pHuw{J#bc@O|G{r_L1 zJmblQa)@@j-Edv^Ya$AmS!%8Ia5x-kt&6JYuIoCBdsfXgo6Rp=*L8`=F!NwM9`}yMHbUMvWr}M+!-ri496xE|Bg6p~v;z?FqC1`Yu7Jg?Jgwcd2QUGL!4D_CP-jD_XZ%!FZxVVZ6PNC*MH(LlT1 zhT}MOrPSMgzyC*)B&h>{nE8e8`@2U+M};s5}(S`AW4SZk>S#95Y&h=?06ny4ECW_~tY ztJQ+ei!EP2!*M2@7-O;-pd?9BV~qVW2v8IT0HX>MGb0Q`j7HgJ343HVwVDfK4By}1 zD*)^OK$c~>)|!34fudON)9?ryN1I}*Wh9B8dM%d&h1XsRO^Yayh3Hf3cX5@KsW zg)wt}<;!h{QtFO~a+K9k2%+LQe*fXaUnY)Yq^W||1+*?; zEtb9qGyVLpjGLwkaU5fM=AS|cHDf5x^R(CN{qphS-{0kV_VVE1KsFkUl?@sIoSd8> z2!f5$Wvzu$3g_qN=Ire3;^N}sU7qLZqRY6uySv|ZyWJndFnk>ZK{P8V6&(N(K}tDS z1FPoBOAZEu%iG)A_q|^4-PP6AKLGSowkH8Jq?Ao&_MYpdHyzX7Iy1%$0Vn{o8uTx* W|Nk*SZd=Cy0000WFU8GbZ8()Nlj27VtF8FbaZe!FE3+na%E&LZ*pg!6A0}9 z00THlL_t(Y$E{Y&Zqq;%J@fFmPFz(@Yo)T9dV$nRmEb2}!2%)vgg<~T5I@2nu;5b= zu|%UTh)6BBN=VcAF&-ApSQE!iLd!_j%$?_%bI-jVhSfp=utg033jeR@y;t@nMw=fV z9(uNIpA$m5N+~N%)7f}D9;a!VtlOP2#-)^blP!d>_xASogb*!4NT!q;&FAwUaU72T z2$z3FBj|5@Aq+bcJ^q$D5W5!BsVuVw&OVO02ETn z_i-Hmq5!DlI4?ZUd*yi^dc7WO+Xes>MX~fzO5wWhO8>Us!c90nK8ELc#P|I-tyb$C z0Ot#x9JJeQD+mGyK zIp<)EK}wmHjNIMb%>cl09OQYvHac9_#m>&olNqrr3rZ>6-`~#wD82}(JkN6oA;1_b z{aFP;DTU)W5JHstF>kxhu7)yW40)bok#CgFBgpf-j0|1ZF~S&I8mkI=ldWAWrPS;z zGoh^{FS9lilG$gj(cqeFbG;5_v+%kQ+tg>;b->rvO-wa1vMC>I1G4F2b!7>NPG%-* zO=I&R6`BqUa~3G%j6}W!WeU!w&}s2Vay@RuBYB zKfraq-qzNj(lo`@)fK`p%=-QQMV4iw>YLT|egEz0>FGz$^PcVR@3X3l);$l*Id!(y z$nEW|jH2i=48x1zaQGF#v|gW!U_%O?XxI14-? ziy0XB6G519h5hnOpdfpRr>`sfbv9vkSt(8@4pyL$Zi#C|iF1B#Zfaf$gL6@8Vo7R> zLV0FMhJw4NZ-7Elr9wtYNr9EVesX?MYKmTdQTlvgj<-OKO`a}}As)xyUSG(|vNftrH-msoQ1CxUuXFx)_Ook^}xCr>zk$r{#UWM6IUHm@aaESn$P*) z&*o}9>)N_ax8h0F%xe-i5>HsXT3-C_iPimWk?E`&4vbs@4NM{nshmain_win_ee)); edje_object_file_set(swallow, em->theme_path, "ecdb/erase_page"); @@ -767,6 +769,17 @@ ecdb_erase_page_show(void) b = ecdb_check_add(swallow, "ecdb/erase/speed"); ecdb_check_label_set(b, "Quick Erase"); evas_object_show(b); + + b = ecdb_combo_add(swallow, "ecdb/erase/drive"); + ecdb_combo_header_set(b, "Drive"); + + EINA_LIST_FOREACH(em->drives, l, drive) + { + d = ecdb_button_add(swallow, NULL); + ecdb_button_label_set(d, drive->location); + ecdb_combo_append(b, d); + evas_object_show(d); + } } else if (edje_object_part_swallow_get(gui, "action_area") != swallow) diff --git a/experimental/ecdb/trunk/src/ecdb_widgets.c b/experimental/ecdb/trunk/src/ecdb_widgets.c index d54db787..883af398 100644 --- a/experimental/ecdb/trunk/src/ecdb_widgets.c +++ b/experimental/ecdb/trunk/src/ecdb_widgets.c @@ -1,9 +1,6 @@ /* vim: set sw=3 ts=3 sts=3 expandtab: */ #include "ecdb.h" -static char *ecdb_entry_markup_to_text(const char *mkup); -static char *_str_append(char *str, const char *txt, int *len, int *alloc); - Evas_Object * ecdb_widget_add(Evas_Object *parent, const char *name) { @@ -11,15 +8,28 @@ ecdb_widget_add(Evas_Object *parent, const char *name) int x, y, w, h; o = edje_object_add(evas_object_evas_get(parent)); - evas_object_name_set(o, name); - edje_object_part_geometry_get(parent, name, &x, &y, &w, &h); - evas_object_move(o, x, y); - evas_object_resize(o, w, h); - edje_object_part_swallow(parent, name, o); + + if (name) + { + evas_object_name_set(o, name); + edje_object_part_geometry_get(parent, name, &x, &y, &w, &h); + evas_object_move(o, x, y); + evas_object_resize(o, w, h); + edje_object_part_swallow(parent, name, o); + } return o; } +/************************** BUTTON ******************************************/ + +void +_button_click_cb_call(void *data, Evas_Object *obj, const char *emission, + const char *source) +{ + evas_object_smart_callback_call(obj, "clicked", NULL); +} + Evas_Object * ecdb_button_add(Evas_Object *parent, const char *name) { @@ -27,6 +37,8 @@ ecdb_button_add(Evas_Object *parent, const char *name) b = ecdb_widget_add(parent, name); edje_object_file_set(b, em->theme_path, "ecdb/button"); + edje_object_signal_callback_add(b, "ecdb,button,clicked", "ecdb", + _button_click_cb_call, b); return b; } @@ -47,6 +59,8 @@ ecdb_button_icon_set(Evas_Object *b, const char *group) evas_object_show(icon); } +/************************* CHECK *********************************************/ + Evas_Object * ecdb_check_add(Evas_Object *parent, const char *name) { @@ -84,34 +98,32 @@ ecdb_check_state_set(Evas_Object *c, int state) } } -Evas_Object * -ecdb_entry_add(Evas_Object *parent, const char *name) -{ - Evas_Object *e; - - e = ecdb_widget_add(parent, name); - edje_object_file_set(e, em->theme_path, "ecdb/entry"); - em->dnd_candidates = eina_list_append(em->dnd_candidates, e); - evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set); - - return e; -} - -void -ecdb_entry_text_set(Evas_Object *e, const char *text) -{ - edje_object_part_text_set(e, "ecdb.text", text); -} - -char * -ecdb_entry_text_get(Evas_Object *e) -{ - return ecdb_entry_markup_to_text(edje_object_part_text_get(e, "ecdb.text")); -} +/************************** ENTRY *******************************************/ /* Shamelessly stolen from Elementary... */ static char * -ecdb_entry_markup_to_text(const char *mkup) +_entry_str_append(char *str, const char *txt, int *len, int *alloc) +{ + int txt_len = strlen(txt); + if (txt_len <= 0) return str; + if ((*len + txt_len) >= *alloc) + { + char *str2; + int alloc2; + + alloc2 = *alloc + txt_len + 128; + str2 = realloc(str, alloc2); + if (!str2) return str; + *alloc = alloc2; + str = str2; + } + strcpy(str + *len, txt); + *len += txt_len; + return str; +} + +static char * +_entry_markup_to_text(const char *mkup) { char *str = NULL; int str_len = 0, str_alloc = 0; @@ -142,13 +154,17 @@ ecdb_entry_markup_to_text(const char *mkup) str = _str_append(str, "\n", &str_len, &str_alloc); */ if (!strcmp(ttag, "\n")) - str = _str_append(str, "\n", &str_len, &str_alloc); + str = _entry_str_append(str, "\n", &str_len, + &str_alloc); else if (!strcmp(ttag, "\\n")) - str = _str_append(str, "\n", &str_len, &str_alloc); + str = _entry_str_append(str, "\n", &str_len, + &str_alloc); else if (!strcmp(ttag, "\t")) - str = _str_append(str, "\t", &str_len, &str_alloc); + str = _entry_str_append(str, "\t", &str_len, + &str_alloc); else if (!strcmp(ttag, "\\t")) - str = _str_append(str, "\t", &str_len, &str_alloc); + str = _entry_str_append(str, "\t", &str_len, + &str_alloc); free(ttag); } tag_start = tag_end = NULL; @@ -163,7 +179,8 @@ ecdb_entry_markup_to_text(const char *mkup) ts[esc_end - esc_start] = 0; esc = evas_textblock_escape_string_get(ts); if (esc) - str = _str_append(str, esc, &str_len, &str_alloc); + str = _entry_str_append(str, esc, &str_len, + &str_alloc); free(ts); } esc_start = esc_end = NULL; @@ -175,7 +192,7 @@ ecdb_entry_markup_to_text(const char *mkup) { strncpy(ts, s, p - s); ts[p - s] = 0; - str = _str_append(str, ts, &str_len, &str_alloc); + str = _entry_str_append(str, ts, &str_len, &str_alloc); free(ts); } s = NULL; @@ -194,7 +211,7 @@ ecdb_entry_markup_to_text(const char *mkup) { strncpy(ts, s, p - s); ts[p - s] = 0; - str = _str_append(str, ts, &str_len, &str_alloc); + str = _entry_str_append(str, ts, &str_len, &str_alloc); free(ts); } s = NULL; @@ -219,7 +236,7 @@ ecdb_entry_markup_to_text(const char *mkup) { strncpy(ts, s, p - s); ts[p - s] = 0; - str = _str_append(str, ts, &str_len, &str_alloc); + str = _entry_str_append(str, ts, &str_len, &str_alloc); free(ts); } s = NULL; @@ -238,23 +255,138 @@ ecdb_entry_markup_to_text(const char *mkup) return str; } -static char * -_str_append(char *str, const char *txt, int *len, int *alloc) +Evas_Object * +ecdb_entry_add(Evas_Object *parent, const char *name) { - int txt_len = strlen(txt); - if (txt_len <= 0) return str; - if ((*len + txt_len) >= *alloc) - { - char *str2; - int alloc2; - - alloc2 = *alloc + txt_len + 128; - str2 = realloc(str, alloc2); - if (!str2) return str; - *alloc = alloc2; - str = str2; - } - strcpy(str + *len, txt); - *len += txt_len; - return str; + Evas_Object *e; + + e = ecdb_widget_add(parent, name); + edje_object_file_set(e, em->theme_path, "ecdb/entry"); + em->dnd_candidates = eina_list_append(em->dnd_candidates, e); + evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set); + + return e; } + +void +ecdb_entry_text_set(Evas_Object *e, const char *text) +{ + edje_object_part_text_set(e, "ecdb.text", text); +} + +char * +ecdb_entry_text_get(Evas_Object *e) +{ + return _entry_markup_to_text(edje_object_part_text_get(e, "ecdb.text")); +} + +/****************************** COMBO ****************************************/ + +// Axis preferential -- for now vertical +const char * +_combo_best_location(Evas_Object *c) +{ + int x, y, w, h; + int ww, wh; + + ecore_evas_geometry_get(em->main_win_ee, NULL, NULL, &ww, &wh); + evas_object_geometry_get(c, &x, &y, &w, &h); + + if ((w) > (ww - x - w)) + { + return "top"; + } + else + { + return "bottom"; + } +} + +static void +_combo_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Evas_Object *c, *back; + int w, h; + + // Deal with popup? + c = data; + back = evas_object_data_get(c, "back"); + evas_object_move(back, 0, 0); + ecore_evas_geometry_get(em->main_win_ee, NULL, NULL, &w, &h); + evas_object_resize(back, w, h); +} + +static void +_combo_hide(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + ecdb_combo_collapse(data); +} + +static void +_combo_clicked(void *data, Evas_Object *obj, void *event_info) +{ + ecdb_combo_collapse(data); +} + +Evas_Object * +ecdb_combo_add(Evas_Object *parent, const char *name) +{ + Evas_Object *c, *back; + + c = ecdb_widget_add(parent, name); + edje_object_file_set(c, em->theme_path, "ecdb/combo"); + evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _combo_resize, + c); + evas_object_event_callback_add(parent, EVAS_CALLBACK_HIDE, _combo_hide, c); + evas_object_event_callback_add(parent, EVAS_CALLBACK_HIDE, _combo_hide, c); + + back = edje_object_add(evas_object_evas_get(parent)); + edje_object_file_set(back, em->theme_path, "ecdb/combo/background"); + evas_object_data_set(c, "back", back); + evas_object_show(back); + + return c; +} + +void +ecdb_combo_header_set(Evas_Object *c, const char *text) +{ + edje_object_part_text_set(c, "ecdb.header", text); +} + +void +ecdb_combo_append(Evas_Object *c, Evas_Object *o) +{ + edje_object_part_box_append(c, "ecdb.box", o); + evas_object_smart_callback_add(o, "clicked", _combo_clicked, c); +} + +void +ecdb_combo_expand(Evas_Object *c) +{ + Evas_Object *back; + const char *location; + char buf[1024]; + int w, h; + + location = _combo_best_location(c); + snprintf(buf, sizeof(buf), "ecdb,combo,expand,%s", location); + edje_object_signal_emit(c, buf, "ecdb"); + + back = evas_object_data_get(c, "back"); + evas_object_move(back, 0, 0); + ecore_evas_geometry_get(em->main_win_ee, NULL, NULL, &w, &h); + evas_object_resize(back, w, h); + edje_object_signal_emit(back, "ecdb,combo,back,show", "ecdb"); +} + +void +ecdb_combo_collapse(Evas_Object *c) +{ + Evas_Object *back; + + back = evas_object_data_get(c, "back"); + edje_object_signal_emit(back, "ecdb,combo,back,hide", "ecdb"); + edje_object_signal_emit(c, "ecdb,combo,collapse", "ecdb"); +} + diff --git a/experimental/ecdb/trunk/src/ecdb_widgets.h b/experimental/ecdb/trunk/src/ecdb_widgets.h index 098d3619..081d4998 100644 --- a/experimental/ecdb/trunk/src/ecdb_widgets.h +++ b/experimental/ecdb/trunk/src/ecdb_widgets.h @@ -16,4 +16,12 @@ Evas_Object *ecdb_entry_add(Evas_Object *parent, const char *name); void ecdb_entry_text_set(Evas_Object *e, const char *text); char *ecdb_entry_text_get(Evas_Object *e); +// I am unsure about whether to use elementary here or not... It would be nice +Evas_Object *ecdb_combo_add(Evas_Object *parent, const char *name); +void ecdb_combo_header_set(Evas_Object *c, const char *text); +void ecdb_combo_append(Evas_Object *c, Evas_Object *o); +void ecdb_combo_expand(Evas_Object *c); +void ecdb_combo_collapse(Evas_Object *c); + + #endif