From 3fcb1a0fb79f3dd65348b9e751c44d902fa45d80 Mon Sep 17 00:00:00 2001 From: Jiyoun Park Date: Tue, 13 Nov 2012 17:27:39 +0000 Subject: [PATCH] Support elm_conformant deal with indicator service. if some app run indicator service using ecore, elm_conformant can deal with these kind of service automatically SVN revision: 79237 --- ChangeLog | 5 + NEWS | 1 + data/themes/widgets/conformant.edc | 42 +++- src/bin/Makefile.am | 1 + src/bin/test.c | 4 + src/bin/test_conform_indicator.c | 395 +++++++++++++++++++++++++++++++++++++ src/lib/elm_config.h | 28 +++ src/lib/elm_conform.c | 310 +++++++++++++++++++++++++++-- src/lib/elm_widget_conform.h | 9 +- 9 files changed, 774 insertions(+), 21 deletions(-) create mode 100644 src/bin/test_conform_indicator.c diff --git a/ChangeLog b/ChangeLog index c0dcad4..df22219 100644 --- a/ChangeLog +++ b/ChangeLog @@ -678,3 +678,8 @@ 2012-10-25 Michael Bouchaud (yoz) * Add missing selected event in elm_index (elm_index_item_selected_set) + +2012-11-13 Jiyoun Park (jypark) + + * Support indicator service in elm_conformant. elm conformant can manage + indicator(elm_plug). diff --git a/NEWS b/NEWS index 8a95a98..76fe45c 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ Improvements: * Plug widget handles image object deletion * Handle COMPOUND_TEXT cnp * Conformant widget handles displaymode change related with keypad. + * Conformant widget handles indicator service. Fixes: diff --git a/data/themes/widgets/conformant.edc b/data/themes/widgets/conformant.edc index 373d41d..5b44608 100644 --- a/data/themes/widgets/conformant.edc +++ b/data/themes/widgets/conformant.edc @@ -1,22 +1,36 @@ group { name: "elm/conformant/base/default"; parts { - part { name: "elm.swallow.indicator"; + part { name: "elm.swallow.bg"; type: SWALLOW; + scale: 1; description { state: "default" 0.0; - fixed: 0 1; - align: 0.0 0.0; - rel2.relative: 1.0 0.0; } } part { name: "elm.swallow.content"; type: SWALLOW; + scale: 1; description { state: "default" 0.0; - fixed: 0 1; align: 0.5 0.5; rel1.relative: 0.0 1.0; - rel1.to_y: "elm.swallow.indicator"; + rel1.to: "elm.swallow.indicator"; rel2.relative: 1.0 0.0; - rel2.to_y: "elm.swallow.clipboard"; + rel2.to: "elm.swallow.clipboard"; + } + } + part { name: "elm.swallow.indicator"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + fixed: 0 1; + align: 0.5 0.0; + min: 0 50; + rel2.relative: 1.0 0.0; + visible: 1; + } + description { state: "hide" 0.0; + inherit: "default" 0.0; + visible: 0; + min: 0 0; } } part { name: "elm.swallow.clipboard"; @@ -50,4 +64,18 @@ group { name: "elm/conformant/base/default"; } } } + programs { + program { name: "show_indicator"; + signal: "elm,state,indicator,show"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.indicator"; + } + program { name: "hide_indicator"; + signal: "elm,state,indicator,hide"; + source: "elm"; + action: STATE_SET "hide" 0.0; + target: "elm.swallow.indicator"; + } + } } diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 0488927..2a9e24c 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -50,6 +50,7 @@ test_clock.c \ test_cnp.c \ test_colorselector.c \ test_conform.c \ +test_conform_indicator.c \ test_ctxpopup.c \ test_cursor.c \ test_datetime.c \ diff --git a/src/bin/test.c b/src/bin/test.c index 32ae62e..02ee139 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -146,6 +146,8 @@ void test_label(void *data, Evas_Object *obj, void *event_info); void test_label2(void *data, Evas_Object *obj, void *event_info); void test_conformant(void *data, Evas_Object *obj, void *event_info); void test_conformant2(void *data, Evas_Object *obj, void *event_info); +void test_conformant_indicator(void *data, Evas_Object *obj, void *event_info); +void test_conformant_indicator_service(void *data, Evas_Object *obj, void *event_info); void test_multi(void *data, Evas_Object *obj, void *event_info); void test_floating(void *data, Evas_Object *obj, void *event_info); void test_launcher(void *data, Evas_Object *obj, void *event_info); @@ -699,6 +701,8 @@ add_tests: //------------------------------// ADD_TEST(NULL, "Standardization", "Conformant", test_conformant); ADD_TEST(NULL, "Standardization", "Conformant 2", test_conformant2); + ADD_TEST(NULL, "Standardization", "Conformant indicator", test_conformant_indicator); + ADD_TEST(NULL, "Standardization", "Conformant indicator service", test_conformant_indicator_service); //------------------------------// ADD_TEST(NULL, "Helpers", "Store", test_store); diff --git a/src/bin/test_conform_indicator.c b/src/bin/test_conform_indicator.c new file mode 100644 index 0000000..f3dc862 --- /dev/null +++ b/src/bin/test_conform_indicator.c @@ -0,0 +1,395 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#include +#ifndef ELM_LIB_QUICKLAUNCH + +static int vis = 0; +static int rotate_with_resize = 0; + +static void win_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + elm_exit(); +} + +static void +_rot_0(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win = data; + if (rotate_with_resize) + elm_win_rotation_with_resize_set(win, 0); + else + elm_win_rotation_set(win, 0); +} + +static void +_rot_90(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win = data; + if (rotate_with_resize) + elm_win_rotation_with_resize_set(win, 90); + else + elm_win_rotation_set(win, 90); +} + +static void +_rot_180(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win = data; + if (rotate_with_resize) + elm_win_rotation_with_resize_set(win, 180); + else + elm_win_rotation_set(win, 180); +} + +static void +_rot_270(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win = data; + if (rotate_with_resize) + elm_win_rotation_with_resize_set(win, 270); + else + elm_win_rotation_set(win, 270); +} + +static void _visible_change(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + printf("visible change before=%d\n",vis); + Evas_Object *win = (Evas_Object *) data; + if (vis == 0) + { + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); + vis = 1; + } + else + { + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); + vis = 0; + } + /*Add App code here*/ + printf("visible change after=%d\n",vis); +} + +void +test_conformant_indicator(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Evas_Object *win, *bg, *conform, *bt, *bx; + Evas_Object *plug_port = NULL; + Evas_Object *plug_land = NULL; + + win = elm_win_util_standard_add("conformant indicator", "Conformant 3"); + elm_win_autodel_set(win, EINA_TRUE); + elm_win_conformant_set(win, EINA_TRUE); + + //Create bg + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_bg_color_set(bg, 0, 255, 255); + evas_object_show(bg); + + //Create conformant + conform = elm_conformant_add(win); + elm_win_resize_object_add(win, conform); + evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(conform); + + bx = elm_box_add(conform); + elm_win_resize_object_add(win, bx); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Rot 0"); + evas_object_smart_callback_add(bt, "clicked", _rot_0, win); + evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Rot 90"); + evas_object_smart_callback_add(bt, "clicked", _rot_90, win); + evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Rot 180"); + evas_object_smart_callback_add(bt, "clicked", _rot_180, win); + evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Rot 270"); + evas_object_smart_callback_add(bt, "clicked", _rot_270, win); + evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + char *svr_name_port = "elm_indicator_portrait"; + char *svr_name_land = "elm_indicator_landscape"; + + plug_port = elm_plug_add(win); + if (!plug_port) + { + printf("fail to create plug to server[%s]\n", svr_name_port); + return; + } + + if (!elm_plug_connect(plug_port, svr_name_port, 0, EINA_FALSE)) + { + printf("fail to connect to server[%s]\n", svr_name_port); + return; + } + evas_object_size_hint_weight_set(plug_port, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(plug_port, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(plug_port); + elm_box_pack_end(bx, plug_port); + + plug_land = elm_plug_add(win); + if (!plug_land) + { + printf("fail to create plug to server[%s]\n", svr_name_land); + return; + } + if (!elm_plug_connect(plug_land, svr_name_land, 0, EINA_FALSE)) + { + printf("fail to connect to server[%s]\n", svr_name_land); + return; + } + evas_object_size_hint_weight_set(plug_land, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(plug_land, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(plug_land); + elm_box_pack_end(bx, plug_land); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Show/Hide"); + evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, 0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + evas_object_smart_callback_add(bt, "clicked", _visible_change, win); + + + + elm_object_content_set(conform, bx); + evas_object_show(bx); + + evas_object_resize(win, 400, 600); + evas_object_show(win); +} + +static Evas_Object *win_port = NULL; +static Evas_Object *win_land = NULL; + +static void +_mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Event_Mouse_Down *ev = event_info; + Evas_Object *sub_obj = data; + + printf("\nAPP mouse down [%d]x[%d] obj=%p type=%s\n", ev->canvas.x, ev->canvas.y,sub_obj,evas_object_type_get(sub_obj)); + + evas_object_move(sub_obj, ev->canvas.x, ev->canvas.y); +} + +static void +_mouse_move_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Event_Mouse_Move *ev = event_info; + Evas_Object *sub_obj = data; + if (!ev->buttons) return; + + printf("APP mouse move [%d]x[%d] obj=%p type=%s\n", ev->cur.canvas.x, ev->cur.canvas.y,sub_obj,evas_object_type_get(sub_obj)); + evas_object_move(sub_obj, ev->cur.canvas.x, ev->cur.canvas.y); +} + + +static Evas_Object * +_fill_portrait(Evas_Object *win) +{ + Evas_Object *btn; + Evas_Object *rect; + + rect = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_resize(rect, 720, 60); + evas_object_color_set(rect, 221, 187, 187, 255); + evas_object_move(rect, 0, 0); + evas_object_show(rect); + + btn = elm_button_add(rect); + if (!btn) + { + printf("fail to elm_button_add() \n"); + return NULL; + } + + + elm_object_text_set(btn, "portrait"); + + evas_object_resize(btn, 200, 50); + evas_object_move(btn, 260, 0); + evas_object_show(btn); + + // This check: indicator get mouse event well from application + evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn); + evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn); + + return rect; +} + +static Evas_Object * +_fill_landscape(Evas_Object *win) +{ + Evas_Object *btn; + Evas_Object *rect; + + rect = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_resize(rect, 1280, 60); + evas_object_color_set(rect, 207, 255, 255, 255); + evas_object_move(rect, 0, 0); + evas_object_show(rect); + + btn = elm_button_add(rect); + if (!btn) + { + printf("fail to elm_button_add() \n"); + return NULL; + } + + elm_object_text_set(btn, "landscape"); + + evas_object_resize(btn, 200, 50); + evas_object_move(btn, 580, 0); + evas_object_show(btn); + + // This check: indicator get mouse event well from application + evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, btn); + evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, btn); + + return rect; +} + +static Evas_Object * +_create_portrait(void) +{ + const char *port_indi_name; + + win_port = elm_win_add(NULL, "portrait_indicator", ELM_WIN_SOCKET_IMAGE); + if (!win_port) { + printf("fail to elm_win_add:port\n"); + return NULL; + } + + port_indi_name = elm_config_indicator_service_0_get(); + if (!port_indi_name) + { + printf("indicator cannot portrait service name: use default name\n"); + port_indi_name = "elm_indicator_portrait"; + } + + if (!elm_win_socket_listen(win_port, port_indi_name, 0, EINA_FALSE)) + { + printf("fail to elm_win_socket_listen():port \n"); + evas_object_del(win_port); + return NULL; + } + + elm_win_title_set(win_port, "win sock test:port"); + elm_win_borderless_set(win_port, EINA_TRUE); + + evas_object_smart_callback_add(win_port, "delete,request", win_del, NULL); + evas_object_move(win_port, 0, 0); + evas_object_resize(win_port, 720, 60); + + _fill_portrait(win_port); + return win_port; +} + +static Evas_Object * +_create_landscape(void) +{ + const char *land_indi_name; + + win_land = elm_win_add(NULL, "win_socket_test:land", ELM_WIN_SOCKET_IMAGE); + if (!win_land) + { + printf("fail to elm_win_add:land\n"); + return NULL; + } + + land_indi_name = elm_config_indicator_service_90_get(); + if (!land_indi_name) + { + printf("indicator cannot landscape service name: use default name\n"); + land_indi_name = "elm_indicator_landscape"; + } + + if (!elm_win_socket_listen(win_land, land_indi_name, 0, 0)) + { + printf("fail to elm_win_socket_listen():land\n"); + evas_object_del(win_land); + return NULL; + } + + elm_win_title_set(win_land, "win sock test:land"); + elm_win_borderless_set(win_land, EINA_TRUE); + + evas_object_smart_callback_add(win_land, "delete,request", win_del, NULL); + evas_object_move(win_land, 0, 0); + evas_object_resize(win_land, 1280, 60); + + _fill_landscape(win_land); + return win_land; +} + +static void +popobj(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + win_port = _create_portrait(); + if (!win_port) + return; + + win_land = _create_landscape(); + if (!win_land) + return; + + evas_object_show(win_port); + evas_object_show(win_land); + +} + +void +test_conformant_indicator_service(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + Evas_Object *win, *btn, *bx; + + win = elm_win_util_standard_add("conformant indicator service", "Conformant 4"); + elm_win_autodel_set(win, EINA_TRUE); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + btn = elm_button_add(win); + elm_object_focus_allow_set(btn, EINA_FALSE); + elm_object_text_set(btn, "start indicator service"); + evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, btn); + evas_object_show(btn); + + evas_object_smart_callback_add(btn, "clicked", popobj, win); + + evas_object_resize(win, 240, 480); + evas_object_show(win); +} + +#endif diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h index 3f22f2c..86b4451 100644 --- a/src/lib/elm_config.h +++ b/src/lib/elm_config.h @@ -1015,6 +1015,34 @@ EAPI Eina_Bool elm_config_mirrored_get(void); EAPI void elm_config_mirrored_set(Eina_Bool mirrored); /** + * Get the indicator service name when rotation degree is 0. + * + * @return The indicator service name when rotation degree is 0. + */ +EAPI const char *elm_config_indicator_service_0_get(void); + +/** + * Get the indicator service name when rotation degree is 90. + * + * @return The indicator service name when rotation degree is 90. + */ +EAPI const char *elm_config_indicator_service_90_get(void); + +/** + * Get the indicator service name when rotation degree is 180. + * + * @return The indicator service name when rotation degree is 180. + */ +EAPI const char *elm_config_indicator_service_180_get(void); + +/** + * Get the indicator service name when rotation degree is 270. + * + * @return The indicator service name when rotation degree is 270. + */ +EAPI const char *elm_config_indicator_service_270_get(void); + +/** * @} */ diff --git a/src/lib/elm_conform.c b/src/lib/elm_conform.c index 5dfef5c..d5c13fa 100644 --- a/src/lib/elm_conform.c +++ b/src/lib/elm_conform.c @@ -132,7 +132,10 @@ _conformant_part_sizing_eval(Evas_Object *obj, ; #endif } - _conformant_part_size_hints_set(obj, sd->indicator, sx, sy, sw, sh); + if (((sd->rot == 90) || (sd->rot == 270)) && sd->landscape_indicator) + _conformant_part_size_hints_set(obj, sd->landscape_indicator, sx, sy, sw, sh); + else if (((sd->rot == 0) || (sd->rot == 180)) && sd->portrait_indicator) + _conformant_part_size_hints_set(obj, sd->portrait_indicator, sx, sy, sw, sh); } if (part_type & ELM_CONFORMANT_VIRTUAL_KEYPAD_PART) @@ -199,17 +202,7 @@ _conformant_parts_swallow(Evas_Object *obj) sd->scroller = NULL; //Indicator - if (!sd->indicator) - { - sd->indicator = evas_object_rectangle_add(e); - evas_object_size_hint_min_set(sd->indicator, -1, 0); - evas_object_size_hint_max_set(sd->indicator, -1, 0); - } - else - _conformant_part_sizing_eval(obj, ELM_CONFORMANT_INDICATOR_PART); - - evas_object_color_set(sd->indicator, 0, 0, 0, 0); - elm_layout_content_set(obj, "elm.swallow.indicator", sd->indicator); + //Indicator swallow can occur Only indicator show or rotation change //Virtual Keyboard if (!sd->virtualkeypad) @@ -252,6 +245,264 @@ _conformant_parts_swallow(Evas_Object *obj) } static Eina_Bool +_indicator_connect_cb(void *data) +{ + const char *indicator_serv_name; + int rot = 0; + Elm_Conformant_Smart_Data *sd = data; + + if (!sd) return ECORE_CALLBACK_CANCEL; + if (sd->indmode != ELM_WIN_INDICATOR_SHOW) return ECORE_CALLBACK_CANCEL; + + rot = sd->rot; + + if ((rot == 90) || (rot == 270)) + { + indicator_serv_name = elm_config_indicator_service_90_get(); + if (!indicator_serv_name) + { + DBG("Conformant cannot find landscape indicator service name\n"); + return ECORE_CALLBACK_CANCEL; + } + + if (elm_plug_connect(sd->landscape_indicator, indicator_serv_name, 0, EINA_FALSE)) + { + DBG("Conformant connect to server[%s]\n", indicator_serv_name); + return ECORE_CALLBACK_CANCEL; + } + } + else + { + indicator_serv_name = elm_config_indicator_service_0_get(); + + if (!indicator_serv_name) + { + DBG("Conformant cannot find portrait indicator service name\n"); + return ECORE_CALLBACK_CANCEL; + } + + if (elm_plug_connect(sd->portrait_indicator, indicator_serv_name, 0, EINA_FALSE)) + { + DBG("Conformant connect to server[%s]\n", indicator_serv_name); + return ECORE_CALLBACK_CANCEL; + } + } + + ecore_timer_interval_set(sd->indi_timer, 1); + return ECORE_CALLBACK_RENEW; +} + +static void +_indicator_disconnected(void *data, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ + Evas_Object *conform = data; + + ELM_CONFORMANT_DATA_GET(conform, sd); + + sd->indi_timer = ecore_timer_add(1, _indicator_connect_cb, sd); + +} + +static Evas_Object * +_create_portrait_indicator(Evas_Object *obj) +{ + Evas_Object *port_indicator = NULL; + const char *port_indicator_serv_name; + + port_indicator_serv_name = elm_config_indicator_service_0_get(); + if (!port_indicator_serv_name) + { + DBG("Conformant cannot get portrait indicator service name\n"); + return NULL; + } + + port_indicator = elm_plug_add(obj); + if (!port_indicator) + { + DBG("Conformant cannot create plug to server[%s]\n", port_indicator_serv_name); + return NULL; + } + + if (!elm_plug_connect(port_indicator, port_indicator_serv_name, 0, EINA_FALSE)) + { + DBG("Conformant cannot connect to server[%s]\n", port_indicator_serv_name); + return NULL; + } + + elm_widget_sub_object_add(obj, port_indicator); + evas_object_smart_callback_add(port_indicator, "image.deleted", _indicator_disconnected, obj); + + evas_object_size_hint_min_set(port_indicator, -1, 0); + evas_object_size_hint_max_set(port_indicator, -1, 0); + + return port_indicator; +} + +static Evas_Object * +_create_landscape_indicator(Evas_Object *obj) +{ + Evas_Object *land_indicator = NULL; + const char *land_indicator_serv_name; + + land_indicator_serv_name = elm_config_indicator_service_90_get(); + if (!land_indicator_serv_name) + { + DBG("Conformant cannot get portrait indicator service name\n"); + return NULL; + } + + land_indicator = elm_plug_add(obj); + if (!land_indicator) + { + DBG("Conformant cannot create plug to server[%s]\n", land_indicator_serv_name); + return NULL; + } + + if (!elm_plug_connect(land_indicator, land_indicator_serv_name, 0, EINA_FALSE)) + { + DBG("Conformant cannot connect to server[%s]\n", land_indicator_serv_name); + return NULL; + } + + elm_widget_sub_object_add(obj, land_indicator); + evas_object_smart_callback_add(land_indicator, "image.deleted",_indicator_disconnected, obj); + + evas_object_size_hint_min_set(land_indicator, -1, 0); + evas_object_size_hint_max_set(land_indicator, -1, 0); + return land_indicator; +} + +static void +_indicator_mode_set(Evas_Object *conformant, Elm_Win_Indicator_Mode indmode) +{ + Evas_Object *old_indi = NULL; + ELM_CONFORMANT_DATA_GET(conformant, sd); + sd->indmode = indmode; + + if (indmode == ELM_WIN_INDICATOR_SHOW) + { + old_indi = elm_layout_content_get(conformant, "elm.swallow.indicator"); + + //create new indicator + if (!old_indi) + { + if ((sd->rot == 90)||(sd->rot == 270)) + { + if (!sd->landscape_indicator) + sd->landscape_indicator = _create_landscape_indicator(conformant); + + if (!sd->landscape_indicator) return; + + evas_object_show(sd->landscape_indicator); + elm_layout_content_set(conformant, "elm.swallow.indicator", sd->landscape_indicator); + } + else + { + if (!sd->portrait_indicator) + sd->portrait_indicator = _create_portrait_indicator(conformant); + + if (!sd->portrait_indicator) return; + + evas_object_show(sd->portrait_indicator); + elm_layout_content_set(conformant, "elm.swallow.indicator", sd->portrait_indicator); + } + + } + elm_object_signal_emit(conformant, "elm,state,indicator,show", "elm"); + } + else + { + old_indi = elm_layout_content_get(conformant, "elm.swallow.indicator"); + if (old_indi) + { + evas_object_hide(old_indi); + } + elm_object_signal_emit(conformant, "elm,state,indicator,hide", "elm"); + } +} + +static void +_indicator_opacity_set(Evas_Object *conformant, Elm_Win_Indicator_Opacity_Mode ind_o_mode) +{ + ELM_CONFORMANT_DATA_GET(conformant, sd); + sd->ind_o_mode = ind_o_mode; + //TODO: opacity change +} + +static void +_on_indicator_mode_changed(void *data, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + Evas_Object *conformant = data; + Evas_Object *win = obj; + + Elm_Win_Indicator_Mode indmode; + Elm_Win_Indicator_Opacity_Mode ind_o_mode; + + ELM_CONFORMANT_DATA_GET(conformant, sd); + + indmode = elm_win_indicator_mode_get(win); + ind_o_mode = elm_win_indicator_opacity_get(win); + if (indmode == sd->indmode) + { + if (ind_o_mode == sd->ind_o_mode) return; + else _indicator_opacity_set(conformant, ind_o_mode); + } + else + _indicator_mode_set(conformant, indmode); + +} + +static void +_on_rotation_changed(void *data, + Evas_Object *obj, + void *event_info __UNUSED__) +{ + int rot = 0; + Evas_Object *win = obj; + Evas_Object *conformant = data; + Evas_Object *old_indi = NULL; + + ELM_CONFORMANT_DATA_GET(data, sd); + + rot = elm_win_rotation_get(win); + + if (rot == sd->rot) return; + + sd->rot = rot; + old_indi = elm_layout_content_get(conformant, "elm.swallow.indicator"); + /* this means ELM_WIN_INDICATOR_SHOW never be set.we don't need to change indicator type*/ + if (!old_indi) return; + + if (old_indi) + evas_object_hide(elm_layout_content_unset(old_indi, "elm.swallow.indicator")); + + if ((rot == 90) || (rot == 270) || (rot == -90) || (rot == -270)) + { + if (!sd->landscape_indicator) + sd->landscape_indicator = _create_landscape_indicator(conformant); + + if (!sd->landscape_indicator) return; + + evas_object_show(sd->landscape_indicator); + elm_layout_content_set(conformant, "elm.swallow.indicator", sd->landscape_indicator); + } + else + { + if (!sd->portrait_indicator) + sd->portrait_indicator = _create_portrait_indicator(conformant); + + if (!sd->portrait_indicator) return; + + evas_object_show(sd->portrait_indicator); + elm_layout_content_set(conformant, "elm.swallow.indicator", sd->portrait_indicator); + } +} + +static Eina_Bool _elm_conformant_smart_theme(Evas_Object *obj) { if (!ELM_WIDGET_CLASS(_elm_conformant_parent_sc)->theme(obj)) @@ -518,6 +769,9 @@ _elm_conformant_smart_add(Evas_Object *obj) _conformant_parts_swallow(obj); + priv->landscape_indicator = NULL; + priv->portrait_indicator = NULL; + evas_object_event_callback_add (obj, EVAS_CALLBACK_RESIZE, _move_resize_cb, obj); evas_object_event_callback_add @@ -536,6 +790,22 @@ _elm_conformant_smart_del(Evas_Object *obj) #endif if (sd->show_region_job) ecore_job_del(sd->show_region_job); + if (sd->indi_timer) + { + ecore_timer_del(sd->indi_timer); + sd->indi_timer = NULL; + } + + if (sd->portrait_indicator) + { + evas_object_del(sd->portrait_indicator); + sd->portrait_indicator = NULL; + } + if (sd->landscape_indicator) + { + evas_object_del(sd->landscape_indicator); + sd->landscape_indicator = NULL; + } ELM_WIDGET_CLASS(_elm_conformant_parent_sc)->base.del(obj); } @@ -593,6 +863,7 @@ EAPI Evas_Object * elm_conformant_add(Evas_Object *parent) { Evas_Object *obj; + Evas_Object *top; EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); @@ -602,5 +873,20 @@ elm_conformant_add(Evas_Object *parent) if (!elm_widget_sub_object_add(parent, obj)) ERR("could not add %p as sub object of %p", obj, parent); + ELM_CONFORMANT_DATA_GET(obj, sd); + + top = elm_widget_top_get(obj); + _on_indicator_mode_changed(obj, top, NULL); + _on_rotation_changed(obj, top, NULL); + + sd->indmode = elm_win_indicator_mode_get(top); + sd->ind_o_mode = elm_win_indicator_opacity_get(top); + sd->rot = elm_win_rotation_get(top); + + evas_object_smart_callback_add + (top, "indicator,prop,changed", _on_indicator_mode_changed, obj); + evas_object_smart_callback_add + (top, "rotation,changed", _on_rotation_changed, obj); + return obj; } diff --git a/src/lib/elm_widget_conform.h b/src/lib/elm_widget_conform.h index 1e6125c..f7556c7 100644 --- a/src/lib/elm_widget_conform.h +++ b/src/lib/elm_widget_conform.h @@ -122,8 +122,8 @@ typedef struct _Elm_Conformant_Smart_Data Elm_Conformant_Smart_Data; struct _Elm_Conformant_Smart_Data { Elm_Layout_Smart_Data base; - - Evas_Object *indicator; + Evas_Object *portrait_indicator; + Evas_Object *landscape_indicator; Evas_Object *softkey; Evas_Object *virtualkeypad; Evas_Object *clipboard; @@ -141,6 +141,11 @@ struct _Elm_Conformant_Smart_Data Evas_Coord x, y; // current delta } delta; Ecore_Job *show_region_job; + Elm_Win_Indicator_Mode indmode; + Elm_Win_Indicator_Opacity_Mode ind_o_mode; + Ecore_Timer *indi_timer; + + int rot; }; /* Enum to identify conformant swallow parts */ -- 2.7.4