From: ChunEon Park Date: Wed, 14 Sep 2011 11:12:07 +0000 (+0900) Subject: partial merged with opensource for elm common APIs X-Git-Tag: REL_F_I9200_20110917_1~15^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fffccc7d7e06bfcd52890b84f08991ccdfc81ac;p=framework%2Fuifw%2Felementary.git partial merged with opensource for elm common APIs merged naviframe which uses elm common APIs --- diff --git a/data/themes/default.edc b/data/themes/default.edc index 116f98d..185ac30 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -37443,382 +37443,282 @@ collections { } } ///////////////////////////////////////////////////////////////////////// - group { name:"elm/naviframe/base/default"; - images { - image: "frame_1.png" COMP; - image: "frame_2.png" COMP; - image: "dia_grad.png" COMP; - } - parts { - part { name: "base0"; - mouse_events: 0; - description { state: "default" 0.0; - image.normal: "dia_grad.png"; - fill { - smooth: 0; - size { - relative: 0.0 1.0; - offset: 64 0; - } +group { name:"elm/naviframe/base/default"; + images { + image: "frame_1.png" COMP; + image: "frame_2.png" COMP; + image: "dia_grad.png" COMP; + } + parts { + part { name: "base0"; + mouse_events: 0; + description { state: "default" 0.0; + image.normal: "dia_grad.png"; + fill { + smooth: 0; + size { + relative: 0.0 1.0; + offset: 64 0; } } } - part { name: "base1"; - type: IMAGE; - description { state: "default" 0.0; - image { - normal: "frame_2.png"; - border: 5 5 32 26; - middle: 0; - } - fill.smooth : 0; + } + part { name: "base1"; + type: IMAGE; + description { state: "default" 0.0; + image { + normal: "frame_2.png"; + border: 5 5 32 26; + middle: 0; } + fill.smooth : 0; } - part { name: "over"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.offset: 4 4; - rel2.offset: 5 5; - image { - normal: "frame_1.png"; - border: 2 2 28 22; - middle: 0; - } - fill.smooth : 0; + } + part { name: "over"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.offset: 4 4; + rel2.offset: 5 5; + image { + normal: "frame_1.png"; + border: 2 2 28 22; + middle: 0; } + fill.smooth : 0; } } } - group { name:"elm/naviframe/item/basic/default"; - parts { - part { name: "title_clip"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - min: 1 50; - align: 0.0 0.0; - fixed: 0 1; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 0.0; } - } - description { state: "hide" 0.0; - inherit: "default" 0.0; - min: 0 0; - max: 0 0; - fixed: 1 1; - } - } - part { name: "content_clip"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to_y: "title_clip"; - } - } - part { name: "elm.swallow.content"; - type: SWALLOW; - scale: 1; - repeat_events: 0; - clip_to: "content_clip"; - description { state: "default" 0.0; - align: 0.0 0.0; - rel1.relative: 1.0 1.0; - rel1.to_y: "title_clip"; - rel2.relative: 2.0 1.0; - } - description { state: "show" 0.0; - inherit: "default" 0.0; - rel1.relative: 0.0 1.0; - rel2.relative: 1.0 1.0; - } - description { state: "pushed" 0.0; - inherit: "default" 0.0; - rel1.relative: -1.0 1.0; - rel2.relative: 0.0 1.0; - } - description { state: "popped" 0.0; - inherit: "default" 0.0; - rel1.relative: 1.0 1.0; - rel2.relative: 2.0 1.0; - } +} +group { name:"elm/naviframe/item/basic/default"; + images { + image: "flip_base.png" COMP; + image: "flip_shad.png" COMP; + } + parts { + part { name: "title_clip"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + min: 1 50; + align: 0.0 0.0; + fixed: 0 1; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 0.0; } } - part { name: "elm.swallow.title"; - type: SWALLOW; - scale: 1; - repeat_events: 0; - clip_to: "title_clip"; - description { state: "default" 0.0; - min: 1 50; - align: 0.0 0.0; - fixed: 0 1; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 0.0; } - } + description { state: "hide" 0.0; + inherit: "default" 0.0; + min: 0 0; + max: 0 0; + fixed: 1 1; } } - programs { - program { name: "show"; - signal: "elm,state,show"; - source: "elm"; - action: STATE_SET "show" 0.0; - target: "elm.swallow.content"; - transition: DECELERATE 0.5; - after: "show_finished"; - } - program { name: "pushed"; - signal: "elm,state,pushed"; - source: "elm"; - action: STATE_SET "pushed" 0.0; - target: "elm.swallow.content"; - transition: DECELERATE 0.5; - after: "pushed_finished"; - } - program { name: "popped"; - signal: "elm,state,popped"; - source: "elm"; - action: STATE_SET "popped" 0.0; - target: "elm.swallow.content"; - transition: DECELERATE 0.5; - after: "popped_finished"; - } - program { name: "visible"; - signal: "elm,state,visible"; - source: "elm"; - action: STATE_SET "show" 0.0; - target: "elm.swallow.content"; + part { name: "content_clip"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to_y: "title_clip"; + rel1.relative: 0 1; } - program { name: "title_show"; - signal: "elm,state,title,show"; - source: "elm"; - action: STATE_SET "default" 0.0; - target: "title_clip"; + } + part { name: "elm.swallow.content"; + type: SWALLOW; + scale: 1; + repeat_events: 0; + clip_to: "content_clip"; + description { state: "default" 0.0; + align: 0.0 0.0; + rel1.relative: 1.0 1.0; + rel1.to_y: "title_clip"; + rel2.relative: 2.0 1.0; } - program { name: "title_hide"; - signal: "elm,state,title,hide"; - source: "elm"; - action: STATE_SET "hide" 0.0; - target: "title_clip"; + description { state: "show" 0.0; + inherit: "default" 0.0; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; } - program { name: "show_finished"; - action: SIGNAL_EMIT "elm,action,show,finished" ""; + description { state: "pushed" 0.0; + inherit: "default" 0.0; + rel1.relative: -1.0 1.0; + rel2.relative: 0.0 1.0; } - program { name: "pushed_finished"; - action: SIGNAL_EMIT "elm,action,pushed,finished" ""; + description { state: "popped" 0.0; + inherit: "default" 0.0; + rel1.relative: 1.0 1.0; + rel2.relative: 2.0 1.0; } - program { name: "popped_finished"; - action: SIGNAL_EMIT "elm,action,popped,finished" ""; + } + part { name: "title_base"; + type: IMAGE; + scale: 1; + repeat_events: 0; + clip_to: "title_clip"; + description { state: "default" 0.0; + min: 1 50; + align: 0.0 0.0; + fixed: 0 1; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 0.0; } + image.normal: "flip_base.png"; + } + } + part { name: "elm.swallow.prev_btn"; + type: SWALLOW; + scale: 1; + clip_to: "title_clip"; + description { state: "default" 0.0; + min: 80 40; + max: 80 40; + align: 0 0; + fixed: 1 1; + rel1.offset: 5 5; + rel1.to: "title_base"; + rel2.offset: -1 -6; + rel2.to: "title_base"; + } + } + part { name: "elm.swallow.next_btn"; + type: SWALLOW; + scale: 1; + clip_to: "title_clip"; + description { state: "default" 0.0; + min: 80 40; + max: 80 40; + align: 1 0; + fixed: 1 1; + rel1.offset: 0 5; + rel1.to: "title_base"; + rel2.offset: -6 -6; + rel2.to: "title_base"; } } - } - group { name:"elm/naviframe/item/instant/default"; - parts { - part { name: "title_clip"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - min: 1 50; - align: 0.0 0.0; - fixed: 0 1; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 0.0; } - } - description { state: "hide" 0.0; - inherit: "default" 0.0; + part { name: "elm.swallow.icon"; + type: SWALLOW; + scale: 1; + clip_to: "title_clip"; + description { state: "default" 0.0; + min: 40 40; + max: 40 40; + align: 1 0.5; + rel1.to: "elm.text.title"; + rel1.relative: 0 0; + rel1.to: "title_base"; + rel2.to: "elm.text.title"; + rel2.relative: 0 1; + rel2.to: "title_base"; + } + } + part { name: "elm.text.title"; + type: TEXT; + scale: 1; + repeat_events: 1; + clip_to: "title_clip"; + description { state: "default" 0.0; + text { font: "Sans,Edje-Vera"; + size: 10; min: 0 0; - max: 0 0; - fixed: 1 1; - } - } - part { name: "content_clip"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to_y: "title_clip"; - } - } - part { name: "elm.swallow.content"; - type: SWALLOW; - scale: 1; - repeat_events: 0; - clip_to: "content_clip"; - description { state: "default" 0.0; - align: 0.0 0.0; - rel1.relative: 0.0 1.0; - rel1.to_y: "title_clip"; - rel2.relative: 1.0 1.0; - visible: 0; - } - description { state: "show" 0.0; - inherit: "default" 0.0; - visible: 1; + max: 1 0; + align: 0.5 0.5; } - } - part { name: "elm.swallow.title"; - type: SWALLOW; - scale: 1; - repeat_events: 0; - clip_to: "title_clip"; - description { state: "default" 0.0; - min: 1 50; - align: 0.5 0.0; - fixed: 0 1; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 0.0; } + color: 0 0 0 255; + align: 0.5 0.5; + rel1.to: "title_base"; + rel2.to: "title_base"; + } + } + part { name: "elm.text.subtitle"; + type: TEXT; + scale: 1; + repeat_events: 1; + clip_to: "title_clip"; + description { state: "default" 0.0; + text { font: "Sans,Edje-Vera"; + size: 8; + min: 0 0; + max: 1 0; + align: 0.5 1; } + rel1.to_y: "elm.text.title"; + rel1.relative: 0 1; + rel1.to: "title_base"; + rel2.to: "title_base"; + color: 50 50 50 255; + align: 0.5 0; } } - programs { - program { name: "show"; - signal: "elm,state,show"; - source: "elm"; - action: STATE_SET "show" 0.0; - target: "elm.swallow.content"; - after: "show_finished"; - } - program { name: "pushed"; - signal: "elm,state,pushed"; - source: "elm"; - action: STATE_SET "default" 0.0; - target: "elm.swallow.content"; - after: "pushed_finished"; - } - program { name: "popped"; - signal: "elm,state,popped"; - source: "elm"; - action: STATE_SET "default" 0.0; - target: "elm.swallow.content"; - after: "popped_finished"; - } - program { name: "visible"; - signal: "elm,state,visible"; - source: "elm"; - action: STATE_SET "show" 0.0; - target: "elm.swallow.content"; - } - program { name: "title_show"; - signal: "elm,state,title,show"; - source: "elm"; - action: STATE_SET "default" 0.0; - target: "title_clip"; - } - program { name: "title_hide"; - signal: "elm,state,title,hide"; - source: "elm"; - action: STATE_SET "hide" 0.0; - target: "title_clip"; - } - program { name: "show_finished"; - action: SIGNAL_EMIT "elm,action,show,finished" ""; - } - program { name: "pushed_finished"; - action: SIGNAL_EMIT "elm,action,pushed,finished" ""; - } - program { name: "popped_finished"; - action: SIGNAL_EMIT "elm,action,popped,finished" ""; + part { name: "shade"; + type: IMAGE; + mouse_events: 0; + clip_to: "title_clip"; + description { + align: 0.5 1; + rel1.to_y: "elm.text.title"; + rel1.relative: 0 1; + rel1.offset: 0 0; + rel1.to: "title_base"; + rel2.offset: -1 5; + rel2.to: "title_base"; + image.normal: "flip_shad.png"; } } } - group { name:"elm/naviframe/title/default"; - images { - image: "flip_base.png" COMP; - image: "flip_shad.png" COMP; + programs { + program { name: "show"; + signal: "elm,state,show"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "elm.swallow.content"; + transition: DECELERATE 0.5; + after: "show_finished"; + } + program { name: "pushed"; + signal: "elm,state,pushed"; + source: "elm"; + action: STATE_SET "pushed" 0.0; + target: "elm.swallow.content"; + transition: DECELERATE 0.5; + after: "pushed_finished"; + } + program { name: "popped"; + signal: "elm,state,popped"; + source: "elm"; + action: STATE_SET "popped" 0.0; + target: "elm.swallow.content"; + transition: DECELERATE 0.5; + after: "popped_finished"; + } + program { name: "visible"; + signal: "elm,state,visible"; + source: "elm"; + action: STATE_SET "show" 0.0; + target: "elm.swallow.content"; + } + program { name: "title_show"; + signal: "elm,state,title,show"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "title_clip"; } - parts { - part { name: "base"; - type: IMAGE; - description { - image.normal: "flip_base.png"; - } - } - part { name: "elm.swallow.prev_btn"; - type: SWALLOW; - scale: 1; - description { state: "default" 0.0; - min: 80 40; - max: 80 40; - align: 0 0; - fixed: 1 1; - rel1.offset: 5 5; - rel2.offset: -1 -6; - } - } - part { name: "elm.swallow.next_btn"; - type: SWALLOW; - scale: 1; - description { state: "default" 0.0; - min: 80 40; - max: 80 40; - align: 1 0; - fixed: 1 1; - rel1.offset: 0 5; - rel2.offset: -6 -6; - } - } - part { name: "elm.swallow.icon"; - type: SWALLOW; - scale: 1; - description { state: "default" 0.0; - min: 40 40; - max: 40 40; - align: 1 0.5; - rel1.to: "elm.text.title"; - rel1.relative: 0 0; - rel2.to: "elm.text.title"; - rel2.relative: 0 1; - } - } - part { name: "elm.text.title"; - type: TEXT; - scale: 1; - repeat_events: 1; - description { state: "default" 0.0; - text { font: "Sans,Edje-Vera"; - size: 10; - min: 0 0; - max: 1 0; - align: 0.5 0.5; - } - color: 0 0 0 255; - align: 0.5 0.5; - } - } - part { name: "elm.text.subtitle"; - type: TEXT; - scale: 1; - repeat_events: 1; - description { state: "default" 0.0; - text { font: "Sans,Edje-Vera"; - size: 8; - min: 0 0; - max: 1 0; - align: 0.5 1; - } - rel1.to_y: "elm.text.title"; - rel1.relative: 0 1; - color: 50 50 50 255; - align: 0.5 0; - } - } - part { name: "shade"; - type: IMAGE; - mouse_events: 0; - description { - align: 0.5 1; - rel1.to_y: "elm.text.title"; - rel1.relative: 0 1; - rel1.offset: 0 0; - rel2.offset: -1 5; - image.normal: "flip_shad.png"; - } - } + program { name: "title_hide"; + signal: "elm,state,title,hide"; + source: "elm"; + action: STATE_SET "hide" 0.0; + target: "title_clip"; } - programs { - program { - name: "title_clicked"; - signal: "mouse,clicked,1"; - source: "base"; - action: SIGNAL_EMIT "elm,action,clicked" "elm"; - } + program { + name: "title_clicked"; + signal: "mouse,clicked,1"; + source: "base"; + action: SIGNAL_EMIT "elm,action,clicked" "elm"; + } + program { name: "show_finished"; + action: SIGNAL_EMIT "elm,action,show,finished" ""; + } + program { name: "pushed_finished"; + action: SIGNAL_EMIT "elm,action,pushed,finished" ""; + } + program { name: "popped_finished"; + action: SIGNAL_EMIT "elm,action,popped,finished" ""; } } } + diff --git a/src/bin/test_naviframe.c b/src/bin/test_naviframe.c index 03dcae5..8cc9cd9 100644 --- a/src/bin/test_naviframe.c +++ b/src/bin/test_naviframe.c @@ -28,13 +28,13 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *bt, *bt2, *ic, *nf = data; char buf[PATH_MAX]; - Elm_Naviframe_Item *it; + Elm_Object_Item *it; bt = elm_button_add(nf); evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); ic = elm_icon_add(nf); - snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); elm_button_icon_set(bt, ic); @@ -44,7 +44,7 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) elm_object_text_set(bt2, "Naviframe Test"); ic = elm_icon_add(nf); - snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); @@ -54,8 +54,8 @@ _page4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) bt, bt2, NULL); - elm_naviframe_item_subtitle_label_set(it, "Here is sub-title part!"); - elm_naviframe_item_icon_set(it, ic); + elm_object_item_text_part_set(it, "elm.text.subtitle", "Here is sub-title part!"); + elm_object_item_content_part_set(it, "elm.swallow.icon", ic); elm_naviframe_item_title_visible_set(it, EINA_FALSE); evas_object_smart_callback_add(bt2, "clicked", _title_visible, it); } @@ -65,7 +65,7 @@ _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *bt, *bt2, *bt3, *ic, *nf = data; char buf[PATH_MAX]; - Elm_Naviframe_Item *it; + Elm_Object_Item *it; bt = elm_button_add(nf); evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -82,7 +82,7 @@ _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) elm_object_text_set(bt3, "Naviframe Test"); ic = elm_icon_add(nf); - snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); @@ -92,8 +92,8 @@ _page3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) bt2, bt3, NULL); - elm_naviframe_item_subtitle_label_set(it, "Here is sub-title part!"); - elm_naviframe_item_icon_set(it, ic); + elm_object_item_text_part_set(it, "elm.text.subtitle", "Here is sub-title part!"); + elm_object_item_content_part_set(it, "elm.swallow.icon", ic); } void @@ -101,7 +101,7 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { Evas_Object *bt, *bt2, *ic, *nf = data; char buf[PATH_MAX]; - Elm_Naviframe_Item *it; + Elm_Object_Item *it; bt = elm_button_add(nf); evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -112,7 +112,7 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) elm_object_text_set(bt2, "Naviframe Test"); ic = elm_icon_add(nf); - snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", PACKAGE_DATA_DIR); + snprintf(buf, sizeof(buf), "%s/images/icon_right_arrow.png", elm_app_data_dir_get()); elm_icon_file_set(ic, buf, NULL); evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); elm_button_icon_set(bt, ic); @@ -123,7 +123,7 @@ _page2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) bt, bt2, NULL); - elm_naviframe_item_subtitle_label_set(it, "Here is sub-title part!"); + elm_object_item_text_part_set(it, "elm.text.subtitle", "Here is sub-title part!"); } void diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index d0d8dd7..78f1819 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -329,6 +329,14 @@ extern "C" { /** + * @typedef Elm_Object_Item + * An Elementary Object item handle. + * @ingroup General + */ + typedef struct _Elm_Object_Item Elm_Object_Item; + + + /** * Called back when a widget's tooltip is activated and needs content. * @param data user-data given to elm_object_tooltip_content_cb_set() * @param obj owner widget. @@ -680,14 +688,14 @@ extern "C" { * Set a label of an object * * @param obj The Elementary object - * @param item The label id to set (NULL for the default label) + * @param part The text part name to set (NULL for the default label) * @param label The new text of the label * * @note Elementary objects may have many labels (e.g. Action Slider) * * @ingroup General */ - EAPI void elm_object_text_part_set(Evas_Object *obj, const char *item, const char *label); + EAPI void elm_object_text_part_set(Evas_Object *obj, const char *part, const char *label); #define elm_object_text_set(obj, label) elm_object_text_part_set((obj), NULL, (label)) @@ -695,19 +703,175 @@ extern "C" { * Get a label of an object * * @param obj The Elementary object - * @param item The label id to get (NULL for the default label) - * @return text of the label or - * NULL for any error + * @param part The text part name to get (NULL for the default label) + * @return text of the label or NULL for any error * * @note Elementary objects may have many labels (e.g. Action Slider) * * @ingroup General */ - EAPI const char *elm_object_text_part_get(const Evas_Object *obj, const char *item); + EAPI const char *elm_object_text_part_get(const Evas_Object *obj, const char *part); #define elm_object_text_get(obj) elm_object_text_part_get((obj), NULL) /** + * Set a content of an object + * + * @param obj The Elementary object + * @param part The content part name to set (NULL for the default content) + * @param content The new content of the object + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI void elm_object_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content); + +#define elm_object_content_set(obj, content) elm_object_content_part_set((obj), NULL, (content)) + + /** + * Get a content of an object + * + * @param obj The Elementary object + * @param item The content part name to get (NULL for the default content) + * @return content of the object or NULL for any error + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_content_part_get(const Evas_Object *obj, const char *part); + +#define elm_object_content_get(obj) elm_object_content_part_get((obj), NULL) + + /** + * Unset a content of an object + * + * @param obj The Elementary object + * @param item The content part name to unset (NULL for the default content) + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_content_part_unset(Evas_Object *obj, const char *part); + +#define elm_object_content_unset(obj) elm_object_content_part_unset((obj), NULL) + + /** + * Set a content of an object item + * + * @param it The Elementary object item + * @param part The content part name to set (NULL for the default content) + * @param content The new content of the object item + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI void elm_object_item_content_part_set(Elm_Object_Item *it, const char *part, Evas_Object *content); + +#define elm_object_item_content_set(it, content) elm_object_item_content_part_set((it), NULL, (content)) + + /** + * Get a content of an object item + * + * @param it The Elementary object item + * @param part The content part name to unset (NULL for the default content) + * @return content of the object item or NULL for any error + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_item_content_part_get(const Elm_Object_Item *it, const char *item); + +#define elm_object_item_content_get(it, content) elm_object_item_content_part_get((it), NULL, (content)) + + /** + * Unset a content of an object item + * + * @param it The Elementary object item + * @param part The content part name to unset (NULL for the default content) + * + * @note Elementary object items may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_item_content_part_unset(Elm_Object_Item *it, const char *part); + +#define elm_object_item_content_unset(it, content) elm_object_item_content_part_unset((it), (content)) + + /** + * Set a label of an objec itemt + * + * @param it The Elementary object item + * @param part The text part name to set (NULL for the default label) + * @param label The new text of the label + * + * @note Elementary object items may have many labels + * + * @ingroup General + */ + EAPI void elm_object_item_text_part_set(Elm_Object_Item *it, const char *part, const char *label); + +#define elm_object_item_text_set(it, label) elm_object_item_text_part_set((it), NULL, (label)) + + /** + * Get a label of an object + * + * @param it The Elementary object item + * @param part The text part name to get (NULL for the default label) + * @return text of the label or NULL for any error + * + * @note Elementary object items may have many labels + * + * @ingroup General + */ + EAPI const char *elm_object_item_text_part_get(const Elm_Object_Item *it, const char *part); + + /** + * Set the text to read out when in accessibility mode + * + * @param obj The object which is to be described + * @param txt The text that describes the widget to people with poor or no vision + * + * @ingroup General + */ + EAPI void elm_object_access_info_set(Evas_Object *obj, const char *txt); + + /** + * Set the text to read out when in accessibility mode + * + * @param it The object item which is to be described + * @param txt The text that describes the widget to people with poor or no vision + * + * @ingroup General + */ + EAPI void elm_object_item_access_info_set(Elm_Object_Item *it, const char *txt); + + +#define elm_object_item_text_get(it) elm_object_item_text_part_get((it), NULL) + + /** + * Get the data associated with an object item + * @param it The object item + * @return The data associated with @p it + * + * @ingroup General + */ + EAPI void *elm_object_item_data_get(const Elm_Object_Item *it); + + /** + * Set the data associated with an object item + * @param it The object item + * @param data The data to be associated with @p it + * + * @ingroup General + */ + EAPI void elm_object_item_data_set(Elm_Object_Item *it, void *data); + + /** * @} */ @@ -8070,10 +8234,8 @@ extern "C" { Eina_Bool elm_navigationbar_ex_title_object_visible_get(Elm_Navigationbar_ex_Item* item); /* naviframe */ - #define NAVIFRAME_OPTIONHEADER "elm.swallow.optionheader" - - typedef struct _Elm_Naviframe_Item Elm_Naviframe_Item; - + #define ELM_NAVIFRAME_ITEM_ICON "elm.swallow.icon" + #define ELM_NAVIFRAME_ITEM_OPTIONHEADER "elm.swallow.optionheader" typedef enum { ELM_NAVIFRAME_PREV_BUTTON, @@ -8081,30 +8243,20 @@ extern "C" { } Elm_Naviframe_Button_Type; EAPI Evas_Object *elm_naviframe_add(Evas_Object *parent) EINA_ARG_NONNULL(1); - EAPI Elm_Naviframe_Item *elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style) EINA_ARG_NONNULL(1, 5); + EAPI Elm_Object_Item *elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style) EINA_ARG_NONNULL(1, 5); EAPI Evas_Object *elm_naviframe_item_pop(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_naviframe_content_preserve_on_pop_set(Evas_Object *obj, Eina_Bool preserve) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_naviframe_content_preserve_on_pop_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_content_set(Elm_Naviframe_Item *item, Evas_Object *content) EINA_ARG_NONNULL(1, 2); - EAPI Evas_Object *elm_naviframe_item_content_get(const Elm_Naviframe_Item *item) EINA_ARG_NONNULL(1); - EAPI Evas_Object *elm_naviframe_item_content_unset(Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_title_label_set(Elm_Naviframe_Item *it, const char *label) EINA_ARG_NONNULL(1); - EAPI const char *elm_naviframe_item_title_label_get(const Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_subtitle_label_set(Elm_Naviframe_Item *it, const char *label) EINA_ARG_NONNULL(1); - EAPI const char *elm_naviframe_item_subtitle_label_get(const Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI Elm_Naviframe_Item *elm_naviframe_top_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - EAPI Elm_Naviframe_Item *elm_naviframe_bottom_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_button_set(Elm_Naviframe_Item *it, Evas_Object *btn, Elm_Naviframe_Button_Type btn_type) EINA_ARG_NONNULL(1); - EAPI Evas_Object *elm_naviframe_item_button_get(const Elm_Naviframe_Item *it, Elm_Naviframe_Button_Type btn_type) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_icon_set(Elm_Naviframe_Item *it, Evas_Object *icon) EINA_ARG_NONNULL(1); - EAPI Evas_Object *elm_naviframe_item_icon_get(const Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_style_set(Elm_Naviframe_Item *it, const char *item_style) EINA_ARG_NONNULL(1); - EAPI const char *elm_naviframe_item_style_get(const Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_title_visible_set(Elm_Naviframe_Item *it, Eina_Bool visible) EINA_ARG_NONNULL(1); - EAPI Eina_Bool elm_naviframe_item_title_visible_get(const Elm_Naviframe_Item *it) EINA_ARG_NONNULL(1); - EAPI void elm_naviframe_item_extension_set(Elm_Naviframe_Item *it, const char *swallow, Evas_Object *extension) EINA_ARG_NONNULL(1, 2); - EAPI Evas_Object *elm_naviframe_item_extension_unset(Elm_Naviframe_Item *it, const char *swallow) EINA_ARG_NONNULL(1); - EAPI Evas_Object *elm_naviframe_item_extension_get(const Elm_Naviframe_Item *it, const char *swallow) EINA_ARG_NONNULL(1); + EAPI void elm_naviframe_item_title_label_set(Elm_Object_Item *it, const char *label) EINA_ARG_NONNULL(1); + EAPI const char *elm_naviframe_item_title_label_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); + EAPI void elm_naviframe_item_subtitle_label_set(Elm_Object_Item *it, const char *label) EINA_ARG_NONNULL(1); + EAPI const char *elm_naviframe_item_subtitle_label_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_naviframe_top_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_naviframe_bottom_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI void elm_naviframe_item_style_set(Elm_Object_Item *it, const char *item_style) EINA_ARG_NONNULL(1); + EAPI const char *elm_naviframe_item_style_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); + EAPI void elm_naviframe_item_title_visible_set(Elm_Object_Item *it, Eina_Bool visible) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_naviframe_item_title_visible_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /* Control Bar */ #define CONTROLBAR_SYSTEM_ICON_ALBUMS "controlbar_albums" diff --git a/src/lib/elc_naviframe.c b/src/lib/elc_naviframe.c index 0c5435b..41aed8d 100644 --- a/src/lib/elc_naviframe.c +++ b/src/lib/elc_naviframe.c @@ -2,6 +2,9 @@ #include "elm_priv.h" typedef struct _Widget_Data Widget_Data; +typedef struct _Elm_Naviframe_Item Elm_Naviframe_Item; +typedef struct _Elm_Naviframe_Content_Item_Pair Elm_Naviframe_Content_Item_Pair; +typedef struct _Elm_Naviframe_Text_Item_Pair Elm_Naviframe_Text_Item_Pair; struct _Widget_Data { @@ -11,17 +14,27 @@ struct _Widget_Data Eina_Bool pass_events: 1; }; +struct _Elm_Naviframe_Content_Item_Pair +{ + const char *part; + Evas_Object *content; + Elm_Naviframe_Item *it; +}; + +struct _Elm_Naviframe_Text_Item_Pair +{ + const char *part; + const char *text; +}; + struct _Elm_Naviframe_Item { Elm_Widget_Item base; - Evas_Object *title; + Eina_List *content_list; + Eina_List *text_list; Evas_Object *content; - const char *title_label; - const char *title_sublabel; Evas_Object *title_prev_btn; Evas_Object *title_next_btn; - Evas_Object *title_icon; - Evas_Object *extension; const char *style; Eina_Bool back_btn: 1; Eina_Bool title_visible: 1; @@ -38,13 +51,21 @@ static const Evas_Smart_Cb_Description _signals[] = { {NULL, NULL} }; -#define ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, ...) \ - ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *) it, __VA_ARGS__); \ - ELM_CHECK_WIDTYPE(it->base.widget, widtype) __VA_ARGS__; - static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); static void _disable_hook(Evas_Object *obj); +static void _text_set_hook(Elm_Object_Item *it, + const char *part, + const char *label); +static const char *_text_get_hook(const Elm_Object_Item *it, + const char *part); +static void _content_set_hook(Elm_Object_Item *it, + const char *part, + Evas_Object *content); +static Evas_Object *_content_get_hook(const Elm_Object_Item *it, + const char *part); +static Evas_Object *_content_unset_hook(Elm_Object_Item *it, + const char *part); static void _sizing_eval(Evas_Object *obj); static void _item_sizing_eval(Elm_Naviframe_Item *it); static void _move(void *data, Evas *e, Evas_Object *obj, void *event_info); @@ -59,6 +80,14 @@ static void _back_btn_clicked(void *data, Evas_Object *obj, void *event_info); static Evas_Object *_back_btn_new(Evas_Object *obj); +static void _item_content_del(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _title_content_del(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); static void _title_prev_btn_del(void *data, Evas *e, Evas_Object *obj, @@ -67,18 +96,10 @@ static void _title_next_btn_del(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _title_icon_del(void *data, - Evas *e, - Evas_Object *obj, - void *event_info); -static void _content_del(void *data, - Evas *e, - Evas_Object *obj, - void *event_info); -static void _extension_del(void *data, - Evas *e, - Evas_Object *obj, - void *event_info); +static void _title_content_set(Elm_Naviframe_Item *it, + Elm_Naviframe_Content_Item_Pair *pair, + const char *part, + Evas_Object *content); static void _title_prev_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn, Eina_Bool back_btn); @@ -96,6 +117,8 @@ static void _show_finished(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _item_content_set(Elm_Naviframe_Item *navi_it, + Evas_Object *content); static void _del_hook(Evas_Object *obj) @@ -126,6 +149,187 @@ _disable_hook(Evas_Object *obj __UNUSED__) } static void +_text_set_hook(Elm_Object_Item *it, const char *part, const char *label) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + + Eina_List *l = NULL; + Elm_Naviframe_Text_Item_Pair *pair = NULL; + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + char buf[1024]; + + if (!part) return; + + EINA_LIST_FOREACH(navi_it->text_list, l, pair) + { + if (!strcmp(part, pair->part)) + { + if (pair->text) + { + if (!strcmp(pair->text, label)) + return; + } + break; + } + } + + if (!pair) + { + pair = ELM_NEW(Elm_Naviframe_Text_Item_Pair); + if (!pair) + { + ERR("Failed to allocate new text part of the item! : naviframe=%p", navi_it->base.widget); + return; + } + eina_stringshare_replace(&pair->part, part); + navi_it->text_list = eina_list_append(navi_it->text_list, pair); + } + + eina_stringshare_replace(&pair->text, label); + edje_object_part_text_set(navi_it->base.view, part, label); + + snprintf(buf, sizeof(buf), "elm,state,%s,show", part); + + if (label) + edje_object_signal_emit(navi_it->base.view, buf, "elm"); + else + edje_object_signal_emit(navi_it->base.view, buf, "elm"); + + _item_sizing_eval(navi_it); +} + +static const char * +_text_get_hook(const Elm_Object_Item *it, const char *part) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Eina_List *l = NULL; + Elm_Naviframe_Text_Item_Pair *pair = NULL; + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + + if (!part) return NULL; + + EINA_LIST_FOREACH(navi_it->text_list, l, pair) + { + if (!strcmp(part, pair->part)) + return pair->text; + } + return NULL; +} + +static void +_content_set_hook(Elm_Object_Item *it, + const char *part, + Evas_Object *content) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + + Elm_Naviframe_Content_Item_Pair *pair = NULL; + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + + if (!part) return; + + //specified parts + if (!strcmp(part, "elm.swallow.content")) + { + _item_content_set(navi_it, content); + return; + } + else if (!strcmp(part, "elm.swallow.prev_btn")) + { + _title_prev_btn_set(navi_it, content, EINA_FALSE); + return; + } + else if(!strcmp(part, "elm.swallow.next_btn")) + { + _title_next_btn_set(navi_it, content); + return; + } + + //common part + _title_content_set(navi_it, pair, part, content); +} + +/* + */ +static Evas_Object * +_content_get_hook(const Elm_Object_Item *it, + const char *part) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Eina_List *l = NULL; + Elm_Naviframe_Content_Item_Pair *pair = NULL; + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + + //specified parts + if (!strcmp(part, "elm.swallow.content")) + return navi_it->content; + else if (!strcmp(part, "elm.swallow.prev_btn")) + return navi_it->title_prev_btn; + else if(!strcmp(part, "elm.swallow.next_btn")) + return navi_it->title_next_btn; + + //common parts + EINA_LIST_FOREACH(navi_it->content_list, l, pair) + { + if (!strcmp(part, pair->part)) + return pair->content; + } + return NULL; +} + +static Evas_Object * +_content_unset_hook(Elm_Object_Item *it __UNUSED__, + const char *part __UNUSED__) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Eina_List *l = NULL; + Elm_Naviframe_Content_Item_Pair *pair = NULL; + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + Evas_Object *content = NULL; + char buf[1028]; + + if (!part) return NULL; + + //specified parts + //FIXME: could be unset the below specified contents also. + if (!strcmp(part, "elm.swallow.content") || + !strcmp(part, "elm.swallow.prev_btn") || + !strcmp(part, "elm.swallow.next_btn")) + { + WRN("You can not unset the content! : naviframe=%p", + navi_it->base.widget); + return NULL; + } + + //common parts + EINA_LIST_FOREACH(navi_it->content_list, l, pair) + { + if (!strcmp(part, pair->part)) + { + content = pair->content; + eina_stringshare_del(pair->part); + navi_it->content_list = eina_list_remove(navi_it->content_list, + pair); + free(pair); + break; + } + } + + if (!content) return NULL; + + elm_widget_sub_object_del(navi_it->base.widget, content); + edje_object_part_unswallow(navi_it->base.view, content); + snprintf(buf, sizeof(buf), "elm,state,%s,hide", part); + edje_object_signal_emit(navi_it->base.view, buf, "elm"); + evas_object_event_callback_del(content, + EVAS_CALLBACK_DEL, + _title_content_del); + _item_sizing_eval(navi_it); + + return content; +} + +static void _sizing_eval(Evas_Object *obj) { Widget_Data *wd; @@ -196,7 +400,7 @@ static Evas_Object * _back_btn_new(Evas_Object *obj) { Evas_Object *btn; - char buf[256]; //FIXME: How to guarantee the size of style name? + char buf[1024]; btn = elm_button_add(obj); if (!btn) return NULL; evas_object_smart_callback_add(btn, "clicked", _back_btn_clicked, obj); @@ -206,6 +410,22 @@ _back_btn_new(Evas_Object *obj) } static void +_title_content_del(void *data, + Evas *e __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + char buf[1024]; + Elm_Naviframe_Content_Item_Pair *pair = data; + Elm_Naviframe_Item *it = pair->it; + snprintf(buf, sizeof(buf), "elm,state,%s,hide", pair->part); + edje_object_signal_emit(it->base.view, buf, "elm"); + it->content_list = eina_list_remove(it->content_list, pair); + eina_stringshare_del(pair->part); + free(pair); +} + +static void _title_prev_btn_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, @@ -227,21 +447,10 @@ _title_next_btn_del(void *data, } static void -_title_icon_del(void *data, - Evas *e __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) -{ - Elm_Naviframe_Item *it = data; - it->title_icon = NULL; - edje_object_signal_emit(it->base.view, "elm,state,icon,hide", "elm"); -} - -static void -_content_del(void *data, - Evas *e __UNUSED__, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_item_content_del(void *data, + Evas *e __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) { Elm_Naviframe_Item *it = data; it->content = NULL; @@ -249,19 +458,61 @@ _content_del(void *data, } static void -_extension_del(void *data, - Evas *e, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) +_title_content_set(Elm_Naviframe_Item *it, + Elm_Naviframe_Content_Item_Pair *pair, + const char *part, + Evas_Object *content) { - Elm_Naviframe_Item *it = data; - it->extension = NULL; + Eina_List *l = NULL; + char buf[1024]; + + EINA_LIST_FOREACH(it->content_list, l, pair) + { + if (!strcmp(part, pair->part)) + { + if (pair->content == content) return; + break; + } + } + + if (!pair) + { + pair = ELM_NEW(Elm_Naviframe_Content_Item_Pair); + if (!pair) + { + ERR("Failed to allocate new content part of the item! : naviframe=%p", it->base.widget); + return; + } + pair->it = it; + eina_stringshare_replace(&pair->part, part); + it->content_list = eina_list_append(it->content_list, pair); + } + + if (pair->content) evas_object_del(pair->content); + pair->content = content; + + if (!content) + { + snprintf(buf, sizeof(buf), "elm,state,%s,hide", part); + edje_object_signal_emit(it->base.view, buf, "elm"); + return; + } + + elm_widget_sub_object_add(it->base.widget, content); + edje_object_part_swallow(it->base.view, part, content); + snprintf(buf, sizeof(buf), "elm,state,%s,show", part); + edje_object_signal_emit(it->base.view, buf, "elm"); + evas_object_event_callback_add(content, + EVAS_CALLBACK_DEL, + _title_content_del, + pair); + _item_sizing_eval(it); } static void _title_prev_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn, Eina_Bool back_btn) { - char buf[256]; //FIXME: How to guarantee the size of style name? + char buf[1024]; if (it->title_prev_btn == btn) return; @@ -272,27 +523,21 @@ _title_prev_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn, Eina_Bool back_btn if (!btn) return; - if (!back_btn) - { - snprintf(buf, - sizeof(buf), - "naviframe/prev_btn/%s", - elm_widget_style_get(it->base.widget)); - elm_object_style_set(btn, buf); - } elm_widget_sub_object_add(it->base.widget, btn); evas_object_event_callback_add(btn, EVAS_CALLBACK_DEL, _title_prev_btn_del, it); - edje_object_part_swallow(it->title, "elm.swallow.prev_btn", btn); + edje_object_part_swallow(it->base.view, "elm.swallow.prev_btn", btn); it->back_btn = back_btn; + + _item_sizing_eval(it); } static void _title_next_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn) { - char buf[256]; //FIXME: How to guarantee the size of style name? + char buf[1024]; if (it->title_next_btn == btn) return; @@ -303,23 +548,24 @@ _title_next_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn) if (!btn) return; - snprintf(buf, - sizeof(buf), - "naviframe/next_btn/%s", - elm_widget_style_get(it->base.widget)); elm_object_style_set(btn, buf); elm_widget_sub_object_add(it->base.widget, btn); evas_object_event_callback_add(btn, EVAS_CALLBACK_DEL, _title_next_btn_del, it); - edje_object_part_swallow(it->title, "elm.swallow.next_btn", btn); + edje_object_part_swallow(it->base.view, "elm.swallow.next_btn", btn); + + _item_sizing_eval(it); } static void _item_del(Elm_Naviframe_Item *it) { Widget_Data *wd; + Eina_List *l; + Elm_Naviframe_Content_Item_Pair *content_pair; + Elm_Naviframe_Text_Item_Pair *text_pair; if (!it) return; @@ -330,14 +576,21 @@ _item_del(Elm_Naviframe_Item *it) evas_object_del(it->title_prev_btn); if (it->title_next_btn) evas_object_del(it->title_next_btn); - if (it->title_icon) - evas_object_del(it->title_icon); - if ((it->content) && (!wd->preserve)) + if ((it->content) && (!wd->preserve)) evas_object_del(it->content); - if (it->extension) - evas_object_del(it->extension); - evas_object_del(it->title); + EINA_LIST_FOREACH(it->content_list, l, content_pair) + evas_object_del(content_pair->content); + + EINA_LIST_FOREACH(it->text_list, l, text_pair) + { + eina_stringshare_del(text_pair->part); + eina_stringshare_del(text_pair->text); + } + + eina_list_free(it->content_list); + eina_list_free(it->text_list); + evas_object_del(it->base.view); wd->stack = eina_list_remove(wd->stack, it); @@ -386,6 +639,29 @@ _show_finished(void *data, evas_object_pass_events_set(wd->base, EINA_FALSE); } +static void +_item_content_set(Elm_Naviframe_Item *navi_it, Evas_Object *content) +{ + if (navi_it->content == content) return; + if (navi_it->content) evas_object_del(navi_it->content); + elm_widget_sub_object_add(navi_it->base.widget, content); + edje_object_part_swallow(navi_it->base.view, "elm.swallow.content", content); + if (content) + edje_object_signal_emit(navi_it->base.view, + "elm,state,content,show", + "elm"); + else + edje_object_signal_emit(navi_it->base.view, + "elm,state,content,hide", + "elm"); + evas_object_event_callback_add(content, + EVAS_CALLBACK_DEL, + _item_content_del, + navi_it); + navi_it->content = content; + _item_sizing_eval(navi_it); +} + EAPI Evas_Object * elm_naviframe_add(Evas_Object *parent) { @@ -416,7 +692,7 @@ elm_naviframe_add(Evas_Object *parent) return obj; } -EAPI Elm_Naviframe_Item * +EAPI Elm_Object_Item * elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object *prev_btn, Evas_Object *next_btn, Evas_Object *content, const char *item_style) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -433,6 +709,13 @@ elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object * ERR("Failed to allocate new item! : naviframe=%p", obj); return NULL; } + + elm_widget_item_text_set_hook_set(it, _text_set_hook); + elm_widget_item_text_get_hook_set(it, _text_get_hook); + elm_widget_item_content_set_hook_set(it, _content_set_hook); + elm_widget_item_content_get_hook_set(it, _content_get_hook); + elm_widget_item_content_unset_hook_set(it, _content_unset_hook); + //item base layout it->base.view = edje_object_add(evas_object_evas_get(obj)); evas_object_smart_member_add(it->base.view, wd->base); @@ -449,21 +732,15 @@ elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object * "elm,action,popped,finished", "", _popped_finished, it); - elm_naviframe_item_style_set(it, item_style); + elm_naviframe_item_style_set(ELM_CAST(it), item_style); //title - it->title = edje_object_add(evas_object_evas_get(obj)); - elm_widget_sub_object_add(obj, it->title); - _elm_theme_object_set(obj, - it->title, "naviframe", - "title", - elm_widget_style_get(obj)); - edje_object_signal_callback_add(it->title, - "elm,action,clicked", + edje_object_signal_callback_add(it->base.view, + "elm,title,clicked", "elm", _title_clicked, it); - elm_naviframe_item_title_label_set(it, title_label); + _text_set_hook(ELM_CAST(it), "elm.text.title", title_label); //title buttons if ((!prev_btn) && (eina_list_count(wd->stack))) @@ -475,14 +752,13 @@ elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object * _title_prev_btn_set(it, prev_btn, EINA_FALSE); _title_next_btn_set(it, next_btn); - edje_object_part_swallow(it->base.view, "elm.swallow.title", it->title); - elm_naviframe_item_content_set(it, content); + _item_content_set(it, content); _item_sizing_eval(it); evas_object_show(it->base.view); - prev_it = elm_naviframe_top_item_get(obj); + prev_it = ELM_CAST(elm_naviframe_top_item_get(obj)); if (prev_it) { if (wd->pass_events) @@ -498,7 +774,7 @@ elm_naviframe_item_push(Evas_Object *obj, const char *title_label, Evas_Object * edje_object_signal_emit(it->base.view, "elm,state,visible", "elm"); it->title_visible = EINA_TRUE; wd->stack = eina_list_append(wd->stack, it); - return it; + return ELM_CAST(it); } EAPI Evas_Object * @@ -512,14 +788,14 @@ elm_naviframe_item_pop(Evas_Object *obj) wd = elm_widget_data_get(obj); if (!wd) return NULL; - it = elm_naviframe_top_item_get(obj); + it = ELM_CAST(elm_naviframe_top_item_get(obj)); if (!it) return NULL; wd->stack = eina_list_remove(wd->stack, it); if (wd->preserve) content = it->content; - prev_it = elm_naviframe_top_item_get(obj); + prev_it = ELM_CAST(elm_naviframe_top_item_get(obj)); if (prev_it) { if (wd->pass_events) @@ -555,83 +831,7 @@ elm_naviframe_content_preserve_on_pop_get(const Evas_Object *obj) return wd->preserve; } -EAPI void -elm_naviframe_item_content_set(Elm_Naviframe_Item *it, Evas_Object *content) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - - if (it->content == content) return; - if (it->content) evas_object_del(it->content); - elm_widget_sub_object_add(it->base.widget, content); - edje_object_part_swallow(it->base.view, "elm.swallow.content", content); - if (content) - edje_object_signal_emit(it->base.view, - "elm,state,content,show", - "elm"); - else - edje_object_signal_emit(it->base.view, - "elm,state,content,hide", - "elm"); - evas_object_event_callback_add(content, - EVAS_CALLBACK_DEL, - _content_del, - it); - it->content = content; - _item_sizing_eval(it); -} - -EAPI Evas_Object * -elm_naviframe_item_content_get(const Elm_Naviframe_Item *it) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return it->content; -} - -EAPI void -elm_naviframe_item_title_label_set(Elm_Naviframe_Item *it, const char *label) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - - edje_object_part_text_set(it->title, "elm.text.title", label); - if (label) - edje_object_signal_emit(it->title, "elm,state,title,show", "elm"); - else - edje_object_signal_emit(it->title, "elm,state,title,hidew", "elm"); - - eina_stringshare_replace(&it->title_label, label); - _item_sizing_eval(it); -} - -EAPI const char * -elm_naviframe_item_title_label_get(const Elm_Naviframe_Item *it) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return it->title_label; -} - -EAPI void -elm_naviframe_item_subtitle_label_set(Elm_Naviframe_Item *it, const char *label) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - - edje_object_part_text_set(it->title, "elm.text.subtitle", label); - if (label) - edje_object_signal_emit(it->title, "elm,state,subtitle,show", "elm"); - else - edje_object_signal_emit(it->title, "elm,state,subtitle,hide", "elm"); - - eina_stringshare_replace(&it->title_sublabel, label); - _item_sizing_eval(it); -} - -EAPI const char * -elm_naviframe_item_subtitle_label_get(const Elm_Naviframe_Item *it) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return it->title_sublabel; -} - -EAPI Elm_Naviframe_Item* +EAPI Elm_Object_Item* elm_naviframe_top_item_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -640,7 +840,7 @@ elm_naviframe_top_item_get(const Evas_Object *obj) return eina_list_last(wd->stack)->data; } -EAPI Elm_Naviframe_Item* +EAPI Elm_Object_Item* elm_naviframe_bottom_item_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -650,80 +850,10 @@ elm_naviframe_bottom_item_get(const Evas_Object *obj) } EAPI void -elm_naviframe_item_button_set(Elm_Naviframe_Item *it, Evas_Object *btn, Elm_Naviframe_Button_Type btn_type) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - - switch(btn_type) - { - case ELM_NAVIFRAME_PREV_BUTTON: - _title_prev_btn_set(it, btn, EINA_FALSE); - break; - case ELM_NAVIFRAME_NEXT_BUTTON: - _title_next_btn_set(it, btn); - break; - default: - WRN("Button type is invalid! : naviframe=%p", it->base.widget); - break; - } - _item_sizing_eval(it); -} - -EAPI Evas_Object * -elm_naviframe_item_button_get(const Elm_Naviframe_Item *it, Elm_Naviframe_Button_Type btn_type) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - - switch(btn_type) - { - case ELM_NAVIFRAME_PREV_BUTTON: - return it->title_prev_btn; - case ELM_NAVIFRAME_NEXT_BUTTON: - return it->title_next_btn; - default: - WRN("Button type is invalid! : naviframe=%p", it->base.widget); - break; - } - return NULL; -} - -EAPI void -elm_naviframe_item_icon_set(Elm_Naviframe_Item *it, Evas_Object *icon) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - - Widget_Data *wd = elm_widget_data_get(it->base.widget); - if (!wd) return; - - if (it->title_icon == icon) return; - if (it->title_icon) evas_object_del(it->title_icon); - it->title_icon = icon; - if (!icon) - { - edje_object_signal_emit(it->title, - "elm,state,icon,hide", - "elm"); - return; - } - elm_widget_sub_object_add(it->base.widget, icon); - edje_object_part_swallow(it->title, "elm.swallow.icon", icon); - edje_object_signal_emit(it->title, "elm,state,icon,show", "elm"); - - evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, _title_icon_del, it); - _item_sizing_eval(it); -} - -EAPI Evas_Object * -elm_naviframe_item_icon_get(const Elm_Naviframe_Item *it) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return it->title_icon; -} - -EAPI void -elm_naviframe_item_style_set(Elm_Naviframe_Item *it, const char *item_style) +elm_naviframe_item_style_set(Elm_Object_Item *it, const char *item_style) { - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Naviframe_Item *navi_it = ELM_CAST(it); char buf[256]; @@ -731,91 +861,47 @@ elm_naviframe_item_style_set(Elm_Naviframe_Item *it, const char *item_style) else { if (strlen(item_style) > sizeof(buf)) - WRN("too much long style name! : naviframe=%p", it->base.widget); + WRN("too much long style name! : naviframe=%p", navi_it->base.widget); else sprintf(buf, "item/%s", item_style); } - _elm_theme_object_set(it->base.widget, - it->base.view, + _elm_theme_object_set(navi_it->base.widget, + navi_it->base.view, "naviframe", buf, - elm_widget_style_get(it->base.widget)); + elm_widget_style_get(navi_it->base.widget)); } EAPI const char * -elm_naviframe_item_style_get(const Elm_Naviframe_Item *it) +elm_naviframe_item_style_get(const Elm_Object_Item *it) { - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return it->style; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + return navi_it->style; } EAPI void -elm_naviframe_item_title_visible_set(Elm_Naviframe_Item *it, Eina_Bool visible) +elm_naviframe_item_title_visible_set(Elm_Object_Item *it, Eina_Bool visible) { - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Naviframe_Item *navi_it = ELM_CAST(it); visible = !!visible; - if (it->title_visible == visible) return; + if (navi_it->title_visible == visible) return; if (visible) - edje_object_signal_emit(it->base.view, "elm,state,title,show", "elm"); + edje_object_signal_emit(navi_it->base.view, "elm,state,title,show", "elm"); else - edje_object_signal_emit(it->base.view, "elm,state,title,hide", "elm"); + edje_object_signal_emit(navi_it->base.view, "elm,state,title,hide", "elm"); - it->title_visible = visible; + navi_it->title_visible = visible; } EAPI Eina_Bool -elm_naviframe_item_title_visible_get(const Elm_Naviframe_Item *it) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, EINA_FALSE); - return it->title_visible; -} - -EAPI void -elm_naviframe_item_extension_set(Elm_Naviframe_Item *it, const char *swallow, Evas_Object *extension) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it); - Evas_Object *prev; - if (!swallow) - { - WRN("swallow part should not be NULL! : naviframe=%p", it->base.widget); - return; - } - if (it->extension) evas_object_del(it->extension); - it->extension = extension; - if (!extension) return; - evas_object_event_callback_add(extension, EVAS_CALLBACK_DEL, _extension_del, it); - if (!edje_object_part_swallow(it->base.view, swallow, extension)) - return; - elm_widget_sub_object_add(it->base.widget, extension); - edje_object_signal_emit(it->base.view, - "elm,state,extension,show", - "elm"); - _sizing_eval(it->base.view); -} - -EAPI Evas_Object * -elm_naviframe_item_extension_unset(Elm_Naviframe_Item *it, const char *swallow) +elm_naviframe_item_title_visible_get(const Elm_Object_Item *it) { - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - - Evas_Object *extension = it->extension; - if (!extension) return NULL; - edje_object_part_unswallow(it->base.view, extension); - elm_widget_sub_object_del(it->base.widget, extension); - evas_object_event_callback_del(extension, EVAS_CALLBACK_DEL, _extension_del); - edje_object_signal_emit(it->base.view, - "elm,state,extension,hide", - "elm"); - _sizing_eval(it->base.widget); - it->extension = NULL; - return extension; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + Elm_Naviframe_Item *navi_it = ELM_CAST(it); + return navi_it->title_visible; } -EAPI Evas_Object * -elm_naviframe_item_extension_get(const Elm_Naviframe_Item *it, const char *swallow) -{ - ELM_NAVIFRAME_ITEM_CHECK_RETURN(it, NULL); - return edje_object_part_swallow_get(it->base.view, swallow); -} diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index c404a7e..669a093 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1205,17 +1205,38 @@ elm_object_scale_get(const Evas_Object *obj) } EAPI void -elm_object_text_part_set(Evas_Object *obj, const char *item, const char *label) +elm_object_text_part_set(Evas_Object *obj, const char *part, const char *label) { EINA_SAFETY_ON_NULL_RETURN(obj); - elm_widget_text_part_set(obj, item, label); + elm_widget_text_part_set(obj, part, label); } EAPI const char * -elm_object_text_part_get(const Evas_Object *obj, const char *item) +elm_object_text_part_get(const Evas_Object *obj, const char *part) { EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); - return elm_widget_text_part_get(obj, item); + return elm_widget_text_part_get(obj, part); +} + +EAPI void +elm_object_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content) +{ + EINA_SAFETY_ON_NULL_RETURN(obj); + elm_widget_content_part_set(obj, part, content); +} + +EAPI Evas_Object * +elm_object_content_part_get(const Evas_Object *obj, const char *part) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); + return elm_widget_content_part_get(obj, part); +} + +EAPI Evas_Object * +elm_object_content_part_unset(Evas_Object *obj, const char *part) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); + return elm_widget_content_part_unset(obj, part); } /** @@ -3495,3 +3516,38 @@ elm_longpress_timeout_get(void) { return _elm_config->longpress_timeout; } + +EAPI void +elm_object_item_content_part_set(Elm_Object_Item *it, + const char *part, + Evas_Object *content) +{ + elm_widget_item_content_part_set(it, part, content); +} + +EAPI Evas_Object * +elm_object_item_content_part_get(const Elm_Object_Item *it, + const char *part) +{ + return elm_widget_item_content_part_get(it, part); +} + +EAPI Evas_Object * +elm_object_item_content_part_unset(Elm_Object_Item *it, const char *part) +{ + return elm_widget_item_content_part_unset(it, part); +} + +EAPI void +elm_object_item_text_part_set(Elm_Object_Item *it, + const char *part, + const char *label) +{ + elm_widget_item_text_part_set(it, part, label); +} + +EAPI const char * +elm_object_item_text_part_get(const Elm_Object_Item *it, const char *part) +{ + return elm_widget_item_text_part_get(it, part); +} diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index e73ddbc..0a61b9c 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -10,6 +10,12 @@ static const char SMART_NAME[] = "elm_widget"; Smart_Data * sd = evas_object_smart_data_get(obj); \ if (!sd) return; +#undef elm_widget_text_set_hook_set +#undef elm_widget_text_get_hook_set +#undef elm_widget_content_set_hook_set +#undef elm_widget_content_get_hook_set +#undef elm_widget_content_unset_hook_set + typedef struct _Smart_Data Smart_Data; typedef struct _Edje_Signal_Data Edje_Signal_Data; typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data; @@ -70,11 +76,11 @@ struct _Smart_Data Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); - void (*on_text_set_func)(Evas_Object *obj, - const char *item, - const char *text); - const char *(*on_text_get_func)(const Evas_Object *obj, - const char *item); + Elm_Widget_On_Text_Set_Cb on_text_set_func; + Elm_Widget_On_Text_Get_Cb on_text_get_func; + Elm_Widget_On_Content_Set_Cb on_content_set_func; + Elm_Widget_On_Content_Get_Cb on_content_get_func; + Elm_Widget_On_Content_Unset_Cb on_content_unset_func; void *data; Evas_Coord rx, ry, rw, rh; int scroll_hold; @@ -96,6 +102,7 @@ struct _Smart_Data Eina_Bool can_focus : 1; Eina_Bool child_can_focus : 1; Eina_Bool focused : 1; + Eina_Bool top_win_focused : 1; Eina_Bool tree_unfocusable : 1; Eina_Bool highlight_ignore : 1; Eina_Bool highlight_in_theme : 1; @@ -323,12 +330,13 @@ _parent_focus(Evas_Object *obj) focus_order++; sd->focus_order = focus_order; - sd->focused = EINA_TRUE; - if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj); - if (sd->focus_func) sd->focus_func(obj); - - _elm_widget_focus_region_show(obj); - + if (sd->top_win_focused) + { + sd->focused = EINA_TRUE; + if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj); + if (sd->focus_func) sd->focus_func(obj); + _elm_widget_focus_region_show(obj); + } sd->focus_order_on_calc = EINA_FALSE; } @@ -497,9 +505,7 @@ elm_widget_event_hook_set(Evas_Object *obj, EAPI void elm_widget_text_set_hook_set(Evas_Object *obj, - void (*func)(Evas_Object *obj, - const char *item, - const char *text)) + Elm_Widget_On_Text_Set_Cb func) { API_ENTRY return; sd->on_text_set_func = func; @@ -507,14 +513,37 @@ elm_widget_text_set_hook_set(Evas_Object *obj, EAPI void elm_widget_text_get_hook_set(Evas_Object *obj, - const char *(*func)(const Evas_Object *obj, - const char *item)) + Elm_Widget_On_Text_Get_Cb func) { API_ENTRY return; sd->on_text_get_func = func; } EAPI void +elm_widget_content_set_hook_set(Evas_Object *obj, + Elm_Widget_On_Content_Set_Cb func) +{ + API_ENTRY return; + sd->on_content_set_func = func; +} + +EAPI void +elm_widget_content_get_hook_set(Evas_Object *obj, + Elm_Widget_On_Content_Get_Cb func) +{ + API_ENTRY return; + sd->on_content_get_func = func; +} + +EAPI void +elm_widget_content_unset_hook_set(Evas_Object *obj, + Elm_Widget_On_Content_Unset_Cb func) +{ + API_ENTRY return; + sd->on_content_unset_func = func; +} + +EAPI void elm_widget_changed_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj)) { @@ -842,6 +871,7 @@ elm_widget_sub_object_add(Evas_Object *obj, if (sd2->parent_obj) elm_widget_sub_object_del(sd2->parent_obj, sobj); sd2->parent_obj = obj; + sd2->top_win_focused = sd->top_win_focused; if (!sd->child_can_focus && (_is_focusable(sobj))) sd->child_can_focus = EINA_TRUE; } @@ -986,7 +1016,11 @@ elm_widget_resize_object_set(Evas_Object *obj, if (_elm_widget_is(sd->resize_obj)) { Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj); - if (sd2) sd2->parent_obj = obj; + if (sd2) + { + sd2->parent_obj = obj; + sd2->top_win_focused = sd->top_win_focused; + } evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE, _sub_obj_hide, sd); } @@ -1856,6 +1890,30 @@ elm_widget_focus_restore(Evas_Object *obj) } } +void +_elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused) +{ + const Eina_List *l; + Evas_Object *child; + API_ENTRY return; + + if (sd->top_win_focused == top_win_focused) return; + if (sd->resize_obj) + _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused); + EINA_LIST_FOREACH(sd->subobjs, l, child) + { + _elm_widget_top_win_focused_set(child, top_win_focused); + } + sd->top_win_focused = top_win_focused; +} + +Eina_Bool +_elm_widget_top_win_focused_get(const Evas_Object *obj) +{ + API_ENTRY return EINA_FALSE; + return sd->top_win_focused; +} + EAPI void elm_widget_activate(Evas_Object *obj) { @@ -2116,6 +2174,33 @@ elm_widget_text_part_get(const Evas_Object *obj, const char *item) return sd->on_text_get_func(obj, item); } +EAPI void +elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content) +{ + API_ENTRY return; + + if (!sd->on_content_set_func) return; + sd->on_content_set_func(obj, part, content); +} + +EAPI Evas_Object * +elm_widget_content_part_get(const Evas_Object *obj, const char *part) +{ + API_ENTRY return NULL; + + if (!sd->on_content_get_func) return NULL; + return sd->on_content_get_func(obj, part); +} + +EAPI Evas_Object * +elm_widget_content_part_unset(Evas_Object *obj, const char *part) +{ + API_ENTRY return NULL; + + if (!sd->on_content_unset_func) return NULL; + return sd->on_content_unset_func(obj, part); +} + EAPI Elm_Theme * elm_widget_theme_get(const Evas_Object *obj) { @@ -2845,6 +2930,93 @@ _smart_reconfigure(Smart_Data *sd) } } +EAPI void +_elm_widget_item_content_part_set(Elm_Widget_Item *item, + const char *part, + Evas_Object *content) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if (!item->on_content_set_func) return; + item->on_content_set_func((Elm_Object_Item *) item, part, content); +} + +EAPI Evas_Object * +_elm_widget_item_content_part_get(const Elm_Widget_Item *item, + const char *part) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); + if (!item->on_content_get_func) return NULL; + return item->on_content_get_func((Elm_Object_Item *) item, part); +} + +EAPI Evas_Object * +_elm_widget_item_content_part_unset(Elm_Widget_Item *item, + const char *part) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); + if (!item->on_content_unset_func) return NULL; + return item->on_content_unset_func((Elm_Object_Item *) item, part); +} + +EAPI void +_elm_widget_item_text_part_set(Elm_Widget_Item *item, + const char *part, + const char *label) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if (!item->on_text_set_func) return; + item->on_text_set_func((Elm_Object_Item *) item, part, label); +} + +EAPI const char * +_elm_widget_item_text_part_get(const Elm_Widget_Item *item, + const char *part) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL); + if (!item->on_text_get_func) return NULL; + return item->on_text_get_func((Elm_Object_Item *) item, part); +} + +EAPI void +_elm_widget_item_content_set_hook_set(Elm_Widget_Item *item, + Elm_Widget_On_Content_Set_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + item->on_content_set_func = func; +} + +EAPI void +_elm_widget_item_content_get_hook_set(Elm_Widget_Item *item, + Elm_Widget_On_Content_Get_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + item->on_content_get_func = func; +} + +EAPI void +_elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item, + Elm_Widget_On_Content_Unset_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + item->on_content_unset_func = func; +} + +EAPI void +_elm_widget_item_text_set_hook_set(Elm_Widget_Item *item, + Elm_Widget_On_Text_Set_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + item->on_text_set_func = func; +} + +EAPI void +_elm_widget_item_text_get_hook_set(Elm_Widget_Item *item, + Elm_Widget_On_Text_Get_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + item->on_text_get_func = func; +} + static void _smart_add(Evas_Object *obj) { diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index 0580506..3f19026 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -192,6 +192,12 @@ typedef struct _Elm_Tooltip Elm_Tooltip; typedef struct _Elm_Cursor Elm_Cursor; typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */ +typedef void (*Elm_Widget_On_Text_Set_Cb)(void *data, const char *part, const char *text); +typedef void (*Elm_Widget_On_Content_Set_Cb)(void *data, const char *part, Evas_Object *content); +typedef const char *(*Elm_Widget_On_Text_Get_Cb)(const void *data, const char *part); +typedef Evas_Object *(*Elm_Widget_On_Content_Get_Cb)(const void *data, const char *part); +typedef Evas_Object *(*Elm_Widget_On_Content_Unset_Cb)(const void *data, const char *part); + struct _Elm_Widget_Item { /* ef1 ~~ efl, el3 ~~ elm */ @@ -202,12 +208,28 @@ struct _Elm_Widget_Item Evas_Object *view; /**< the base view object */ const void *data; /**< item specific data */ Evas_Smart_Cb del_cb; /**< used to notify the item is being deleted */ + Elm_Widget_On_Content_Set_Cb on_content_set_func; + Elm_Widget_On_Content_Get_Cb on_content_get_func; + Elm_Widget_On_Content_Unset_Cb on_content_unset_func; + Elm_Widget_On_Text_Set_Cb on_text_set_func; + Elm_Widget_On_Text_Get_Cb on_text_get_func; /* widget variations should have data from here and on */ /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */ }; +struct _Elm_Object_Item +{ + Elm_Widget_Item it; +}; + #define ELM_NEW(t) calloc(1, sizeof(t)) +#define ELM_CAST(p) ((void *)(p)) + +#define ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ...) \ + ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *) (it), __VA_ARGS__); \ + ELM_CHECK_WIDTYPE(it->it.widget, widtype) __VA_ARGS__; + EAPI Eina_Bool elm_widget_api_check(int ver); EAPI Evas_Object *elm_widget_add(Evas *evas); EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); @@ -228,8 +250,16 @@ EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data); EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data); EAPI void elm_widget_focus_region_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)); -EAPI void elm_widget_text_set_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, const char *item, const char *text)); -EAPI void elm_widget_text_get_hook_set(Evas_Object *obj, const char *(*func)(const Evas_Object *obj, const char *item)); +EAPI void elm_widget_text_set_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Set_Cb func); +#define elm_widget_text_set_hook_set(obj, func) elm_widget_text_set_hook_set(obj, (Elm_Widget_On_Text_Set_Cb)(func)) +EAPI void elm_widget_text_get_hook_set(Evas_Object *obj, Elm_Widget_On_Text_Get_Cb func); +#define elm_widget_text_get_hook_set(obj, func) elm_widget_text_get_hook_set(obj, (Elm_Widget_On_Text_Get_Cb)(func)) +EAPI void elm_widget_content_set_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Set_Cb func); +#define elm_widget_content_set_hook_set(obj, func) elm_widget_content_set_hook_set(obj, (Elm_Widget_On_Content_Set_Cb)(func)) +EAPI void elm_widget_content_get_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Get_Cb func); +#define elm_widget_content_get_hook_set(obj, func) elm_widget_content_get_hook_set(obj, (Elm_Widget_On_Content_Get_Cb)(func)) +EAPI void elm_widget_content_unset_hook_set(Evas_Object *obj, Elm_Widget_On_Content_Unset_Cb func); +#define elm_widget_content_unset_hook_set(obj, func) elm_widget_content_unset_hook_set(obj, (Elm_Widget_On_Content_Unset_Cb)(func)) EAPI void elm_widget_on_focus_region_hook_set(Evas_Object *obj, void (*func) (const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)); EAPI void elm_widget_data_set(Evas_Object *obj, void *data); EAPI void *elm_widget_data_get(const Evas_Object *obj); @@ -331,9 +361,11 @@ EAPI void elm_widget_focus_hide_handle(Evas_Object *obj); EAPI void elm_widget_focus_mouse_down_handle(Evas_Object *obj); EAPI void elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj); EAPI void elm_widget_focus_disabled_handle(Evas_Object *obj); -EAPI void elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label); -EAPI const char *elm_widget_text_part_get(const Evas_Object *obj, const char *item); - +EAPI void elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label); +EAPI const char *elm_widget_text_part_get(const Evas_Object *obj, const char *part); +EAPI void elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content); +EAPI Evas_Object *elm_widget_content_part_get(const Evas_Object *obj, const char *part); +EAPI Evas_Object *elm_widget_content_part_unset(Evas_Object *obj, const char *part); EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size); EAPI void _elm_widget_item_del(Elm_Widget_Item *item); EAPI void _elm_widget_item_pre_notify_del(Elm_Widget_Item *item); @@ -352,6 +384,16 @@ EAPI void _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, c EAPI const char *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item); EAPI void _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only); EAPI Eina_Bool _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item); +EAPI void _elm_widget_item_content_part_set(Elm_Widget_Item *item, const char *part, Evas_Object *content); +EAPI Evas_Object *_elm_widget_item_content_part_get(const Elm_Widget_Item *item, const char *part); +EAPI Evas_Object *_elm_widget_item_content_part_unset(Elm_Widget_Item *item, const char *part); +EAPI void _elm_widget_item_text_part_set(Elm_Widget_Item *item, const char *part, const char *label); +EAPI const char *_elm_widget_item_text_part_get(const Elm_Widget_Item *item, const char *part); +EAPI void _elm_widget_item_content_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Set_Cb func); +EAPI void _elm_widget_item_content_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Get_Cb func); +EAPI void _elm_widget_item_content_unset_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Content_Unset_Cb func); +EAPI void _elm_widget_item_text_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Set_Cb func); +EAPI void _elm_widget_item_text_get_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Text_Get_Cb func); /* debug function. don't use it unless you are tracking parenting issues */ EAPI void elm_widget_tree_dump(const Evas_Object *top); @@ -471,6 +513,66 @@ EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out */ #define elm_widget_item_cursor_engine_only_get(item) \ _elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item) +/** + * Convenience function to query item's content part set. + * @see _elm_widget_item_content_part_set() + */ +#define elm_widget_item_content_part_set(item, part, content) \ + _elm_widget_item_content_part_set((Elm_Widget_Item *)item, part, content) +/** + * Convenience function to query item's content part get. + * @see _elm_widget_item_content_part_get() + */ +#define elm_widget_item_content_part_get(item, part) \ + _elm_widget_item_content_part_get((const Elm_Widget_Item *)item, part) +/** + * Convenience function to query item's content part unset. + * @see _elm_widget_item_content_part_unset() + */ +#define elm_widget_item_content_part_unset(item, part) \ + _elm_widget_item_content_part_unset((Elm_Widget_Item *)item, part) +/** + * Convenience function to query item's text part set. + * @see _elm_widget_item_text_part_set() + */ +#define elm_widget_item_text_part_set(item, part, label) \ + _elm_widget_item_text_part_set((Elm_Widget_Item *)item, part, label) +/** + * Convenience function to query item's text part get. + * @see _elm_widget_item_text_part_get() + */ +#define elm_widget_item_text_part_get(item, part) \ + _elm_widget_item_text_part_get((const Elm_Widget_Item *)item, part) +/** + * Convenience function to query item's content set hook. + * @see _elm_widget_item_content_set_hook_set() + */ +#define elm_widget_item_content_set_hook_set(item, func) \ + _elm_widget_item_content_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Set_Cb)func) +/** + * Convenience function to query item's content get hook. + * @see _elm_widget_item_content_get_hook_set() + */ +#define elm_widget_item_content_get_hook_set(item, func) \ + _elm_widget_item_content_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Get_Cb)func) +/** + * Convenience function to query item's content unset hook. + * @see _elm_widget_item_content_unset_hook_set() + */ +#define elm_widget_item_content_unset_hook_set(item, func) \ + _elm_widget_item_content_unset_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Content_Unset_Cb)func) +/** + * Convenience function to query item's text set hook. + * @see _elm_widget_item_text_set_hook_set() + */ +#define elm_widget_item_text_set_hook_set(item, func) \ + _elm_widget_item_text_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Set_Cb)func) +/** + * Convenience function to query item's text get hook. + * @see _elm_widget_item_text_get_hook_set() + */ +#define elm_widget_item_text_get_hook_set(item, func) \ + _elm_widget_item_text_get_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Text_Get_Cb)func) /** * Cast and ensure the given pointer is an Elm_Widget_Item or return NULL.