From: Agnieszka Janowicz Date: Wed, 10 Feb 2016 12:43:41 +0000 (+0100) Subject: Widgets creating utils func X-Git-Tag: accepted/tizen/tv/20160218.005609~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F93%2F59093%2F4;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git Widgets creating utils func (slider, hoversel, datetime, flipselector) Change-Id: Iba2b5890666d2cbf751bdb55882bc9319fed13fd Signed-off-by: Agnieszka Janowicz --- diff --git a/include/common/utils.h b/include/common/utils.h index 23c0356..4e48cfa 100644 --- a/include/common/utils.h +++ b/include/common/utils.h @@ -17,6 +17,8 @@ #ifndef __AIR_SETTINGS_UTILS_H__ #define __AIR_SETTINGS_UTILS_H__ +#define DATA_KEY_PRIV "DATA_KEY_PRIV" + Evas_Object *utils_add_layout(Evas_Object *parent, const char *group, Eina_Bool win_resize); Evas_Object *utils_add_box(Evas_Object *parent, const char *part, @@ -36,5 +38,16 @@ Evas_Object *utils_add_entry(Evas_Object *parent, const char *part, const char *text_style, Eina_Bool is_password); Evas_Object *utils_add_radio(Evas_Object *parent, const char *part, const char *style, const char *text); +Evas_Object *utils_add_slider(Evas_Object *parent, const char *part, + int value, int min_value, int max_value, int step); +Evas_Object *utils_add_hoversel(Evas_Object *parent, const char *part, + int opt_count, int *opt_id, const char **opt_text, int selected_opt, + Evas_Smart_Cb, void *data); +Evas_Object *utils_add_datetime(Evas_Object *parent, const char *part, + Eina_Bool field_year, Eina_Bool field_month, Eina_Bool field_date, + Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm); +Evas_Object *utils_add_flipselector(Evas_Object *parent, const char *part, + int opt_count, int *opt_id, const char **opt_text, int selected_opt, + Evas_Smart_Cb opt_handler, void *data); #endif /* __AIR_SETTINGS_UTILS_H__ */ diff --git a/include/define.h b/include/define.h index c28f601..0ca04dd 100644 --- a/include/define.h +++ b/include/define.h @@ -57,16 +57,12 @@ #define PART_BUTTON "part.button" #define PART_PROGRESSBAR "part.progressbar" #define PART_MENU_VALUE "part.menu.value" -#define PART_POPUP_BTN1 "button1" -#define PART_POPUP_BTN2 "button2" #define PART_GUIDE "part.guide" #define PART_MAIN_LABEL_SETUP "part.main.label.setup" #define PART_MAIN_LABEL_DATE "part.main.label.date" #define PART_MAIN_LABEL_24HOUR "part.main.label.24hour" #define PART_MAIN_LABEL_TIME "part.main.label.time" -#define PART_BOTTOM_BTN_CANCEL "part.bottom.btn.cancel" -#define PART_BOTTOM_BTN_DONE "part.bottom.btn.done" #define PART_MAIN_ITEM_SETUP "part.main.item.setup" #define PART_MAIN_ITEM_DATE "part.main.item.date" #define PART_MAIN_ITEM_24HOUR "part.main.item.24hour" @@ -79,6 +75,14 @@ #define PART_POPUP_BUTTON5 "part.popup.btn5" #define PART_POPUP_BUTTON6 "part.popup.btn6" +#define PART_POPUP_NAME "part.popup.name" + +#define PART_POPUP_BOTTOM_BTN1 "part.popup.bottom.btn1" +#define PART_POPUP_BOTTOM_BTN2 "part.popup.bottom.btn2" + +#define PART_VIEW_BOTTOM_BTN1 "part.view.bottom.btn1" +#define PART_VIEW_BOTTOM_BTN2 "part.view.bottom.btn2" + /* Style */ #define STYLE_MENU_BTN "style.menu.button" #define STYLE_BASE_BTN "style.base.button" @@ -134,6 +138,7 @@ #define STR_CLOCK "Clock" #define STR_CLOCK_DES "If you set Clock Manual, You can set date and time." + #define STR_SETUP "Setup" #define STR_AUTO "Auto" #define STR_MANUAL "Manual" @@ -162,7 +167,7 @@ /* Transition */ #define TRANSITION_FOCUS DECELERATE 0.20 -/* scale and resolution */ +/* Scale and resolution */ #define APP_BASE_SCALE 2.0 #define BASE_RESOLUTION_X 1920.0 #define BASE_RESOLUTION_Y 1080.0 diff --git a/include/layout/system.h b/include/layout/system.h index e8f5e95..d276186 100644 --- a/include/layout/system.h +++ b/include/layout/system.h @@ -25,16 +25,11 @@ /* part */ #define PART_SYSTEM "part.system" -#define PART_POPUP_BUTTON_X "part.popup.btn%d" -#define PART_POPUP_NAME "part.popup.name" - #define POPUP_SLEEP_TIMER_BTN_COUNT 6 #define POPUP_LANGUAGE_BTN_COUNT 2 #define PART_LOCATION_TEXT "part.location.text" #define PART_LOCATION_MENU1 "part.location.menu1" #define PART_LOCATION_MENU2 "part.location.menu2" -#define PART_LOCATION_BTN1 "part.location.btn1" -#define PART_LOCATION_BTN2 "part.location.btn2" #endif diff --git a/res/view/system/clock.edc b/res/view/system/clock.edc index 729385b..037e679 100644 --- a/res/view/system/clock.edc +++ b/res/view/system/clock.edc @@ -285,7 +285,7 @@ group { } part { - name, PART_BOTTOM_BTN_CANCEL; + name, PART_VIEW_BOTTOM_BTN1; type, SWALLOW; scale, 1; description { @@ -302,7 +302,7 @@ group { } part { - name, PART_BOTTOM_BTN_DONE; + name, PART_VIEW_BOTTOM_BTN2; type, SWALLOW; scale, 1; description { diff --git a/res/view/system/location.edc b/res/view/system/location.edc index 8a0dacb..85800c1 100644 --- a/res/view/system/location.edc +++ b/res/view/system/location.edc @@ -79,7 +79,7 @@ group { fixed, 0 1; } } - + ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ group { part { - name, PART_LOCATION_BTN1; + name, PART_VIEW_BOTTOM_BTN1; type, SWALLOW; scale, 1; description { @@ -173,7 +173,7 @@ group { } part { - name, PART_LOCATION_BTN2; + name, PART_VIEW_BOTTOM_BTN2; type, SWALLOW; scale, 1; description { @@ -186,7 +186,7 @@ group { to, "bg.bottom"; relative, 0.55 0.0; - + } rel2 { to, "bg.bottom"; @@ -199,7 +199,7 @@ group { /////////////////////////////////////////////////////// - + part { name, PART_LOCATION_TEXT; type, TEXT; diff --git a/src/common/utils.c b/src/common/utils.c index 88b5cd6..a5a4437 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -20,6 +20,7 @@ #include "app_debug.h" #include "app_string.h" #include "define.h" +#include "common/utils.h" Evas_Object *utils_add_layout(Evas_Object *parent, const char *group, Eina_Bool win_resize) @@ -249,7 +250,6 @@ Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size, int *opt_id, return ctxpopup; } - Evas_Object *utils_add_gengrid(Evas_Object *parent, Eina_Bool horizontal, int width, int height) { @@ -351,3 +351,129 @@ Evas_Object *utils_add_radio(Evas_Object *parent, const char *part, return radio; } + +Evas_Object *utils_add_slider(Evas_Object *parent, const char *part, + int value, int min_value, int max_value, int step) +{ + Evas_Object *slider = NULL; + + if (!parent) { + _ERR("Invalid argument."); + return NULL; + } + + slider = elm_slider_add(parent); + + elm_slider_step_set(slider, step); + elm_slider_min_max_set(slider, min_value, max_value); + elm_slider_value_set(slider, value); + elm_slider_indicator_show_set(slider, EINA_FALSE); + + if (part) + elm_object_part_content_set(parent, part, slider); + + return slider; +} + +Evas_Object *utils_add_hoversel(Evas_Object *parent, const char *part, + int opt_count, int *opt_id, const char **opt_text, int selected_opt, + Evas_Smart_Cb opt_handler, void *data) +{ + Evas_Object *hoversel = NULL; + int i; + + if (!parent || opt_count <= 0 || !opt_text || !opt_id || + selected_opt < 0 || selected_opt >= opt_count) { + _ERR("Invalid argument."); + return NULL; + } + + hoversel = elm_hoversel_add(parent); + if (!hoversel) { + _ERR("Add hoversel failed."); + return NULL; + } + + elm_hoversel_hover_parent_set(hoversel, parent); + elm_hoversel_horizontal_set(hoversel, EINA_FALSE); + elm_object_text_set(hoversel, opt_text[selected_opt]); + evas_object_data_set(hoversel, DATA_KEY_PRIV, data); + + for (i = 0; i < opt_count; i++) { + elm_hoversel_item_add(hoversel, opt_text[i], NULL, ELM_ICON_NONE, + opt_handler, (void*)opt_id[i]); + } + + if (part) + elm_object_part_content_set(parent, part, hoversel); + + return hoversel; +} + +Evas_Object *utils_add_datetime(Evas_Object *parent, const char *part, + Eina_Bool field_year, Eina_Bool field_month, Eina_Bool field_date, + Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm) +{ + Evas_Object *dtime = NULL; + + if (!parent) { + _ERR("Invalid argument."); + return NULL; + } + + dtime = elm_datetime_add(parent); + if (!dtime) { + _ERR("Add datetime failed."); + return NULL; + } + + elm_datetime_field_visible_set(dtime, ELM_DATETIME_YEAR, field_year); + elm_datetime_field_visible_set(dtime, ELM_DATETIME_MONTH, field_month); + elm_datetime_field_visible_set(dtime, ELM_DATETIME_DATE, field_date); + elm_datetime_field_visible_set(dtime, ELM_DATETIME_HOUR, field_hour); + elm_datetime_field_visible_set(dtime, ELM_DATETIME_MINUTE, field_minute); + elm_datetime_field_visible_set(dtime, ELM_DATETIME_AMPM, field_ampm); + + /*@TODO: Temporary */ + elm_object_scale_set(dtime, 1.0 / APP_BASE_SCALE); + + if (part) + elm_object_part_content_set(parent, part, dtime); + + return dtime; +} + +Evas_Object *utils_add_flipselector(Evas_Object *parent, const char *part, + int opt_count, int *opt_id, const char **opt_text, int selected_opt, + Evas_Smart_Cb opt_handler, void *data) +{ + Evas_Object *fs = NULL; + int i; + + if (!parent || opt_count <= 0 || !opt_text || !opt_id || + selected_opt < 0 || selected_opt >= opt_count) { + _ERR("Invalid argument."); + return NULL; + } + + fs = elm_flipselector_add(parent); + if (!fs) { + _ERR("Add flipselector failed."); + return NULL; + } + + evas_object_data_set(fs, DATA_KEY_PRIV, data); + + for (i = 0; i < opt_count; i++) { + Elm_Flipselector_Item *it = elm_flipselector_item_append(fs, opt_text[i], + opt_handler, (void*)opt_id[i]); + + if (i == selected_opt) + elm_flipselector_item_selected_set(it, EINA_TRUE); + } + + if (part) + elm_object_part_content_set(parent, part, fs); + + return fs; +} diff --git a/src/layout/layout_network.c b/src/layout/layout_network.c index d5be6c9..0d655d0 100644 --- a/src/layout/layout_network.c +++ b/src/layout/layout_network.c @@ -762,14 +762,14 @@ static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name) elm_object_content_set(popup, ly); - btn1 = utils_add_button(popup, PART_POPUP_BTN1, NULL, STR_CANCEL); + btn1 = utils_add_button(popup, PART_POPUP_BOTTOM_BTN1, NULL, STR_CANCEL); if (!btn1) { _ERR("Add button failed."); evas_object_del(popup); return false; } - btn2 = utils_add_button(popup, PART_POPUP_BTN2, NULL, STR_OK); + btn2 = utils_add_button(popup, PART_POPUP_BOTTOM_BTN2, NULL, STR_OK); if (!btn2) { _ERR("Add button failed."); evas_object_del(popup); diff --git a/src/layout/layout_system.c b/src/layout/layout_system.c index 17233b6..23fe551 100644 --- a/src/layout/layout_system.c +++ b/src/layout/layout_system.c @@ -40,6 +40,8 @@ #define TIMER_ON "On" #define LOCALE_UNKNOWN "Unknown" +#define PART_POPUP_BUTTON_X "part.popup.btn%d" + struct _priv { Evas_Object *base; Evas_Object *ly; diff --git a/src/view/system/view_clock.c b/src/view/system/view_clock.c index 3711785..982262d 100644 --- a/src/view/system/view_clock.c +++ b/src/view/system/view_clock.c @@ -193,13 +193,13 @@ static bool _add_clock_setting(clock_view_priv_data *priv) elm_object_part_text_set(priv->base, PART_MAIN_LABEL_TIME, STR_TIME); /* Add screen bottom buttons */ - done = utils_add_button(priv->base, PART_BOTTOM_BTN_DONE, "elm/button/base/style.normal.button", STR_DONE); + done = utils_add_button(priv->base, PART_VIEW_BOTTOM_BTN2, "elm/button/base/style.normal.button", STR_DONE); if (!done) { _ERR("failed to add done btn"); return false; } - cancel = utils_add_button(priv->base, PART_BOTTOM_BTN_CANCEL, NULL, STR_CANCEL); + cancel = utils_add_button(priv->base, PART_VIEW_BOTTOM_BTN1, NULL, STR_CANCEL); if (!cancel) { _ERR("failed to add cancel btn"); evas_object_del(done); @@ -212,25 +212,16 @@ static bool _add_clock_setting(clock_view_priv_data *priv) /* item - SETUP (clock auto/manual) */ priv->auto_manual_setup_btn = utils_add_button(priv->base, PART_MAIN_ITEM_SETUP, STYLE_OPTION_BTN, _(STR_MANUAL)); - priv->date_part = elm_datetime_add(priv->base); - elm_datetime_field_visible_set(priv->date_part, ELM_DATETIME_HOUR, EINA_FALSE); - elm_datetime_field_visible_set(priv->date_part, ELM_DATETIME_MINUTE, EINA_FALSE); - elm_datetime_field_visible_set(priv->date_part, ELM_DATETIME_AMPM, EINA_FALSE); - elm_object_part_content_set(priv->base, PART_MAIN_ITEM_DATE, priv->date_part); - elm_object_scale_set(priv->date_part, 1.0 / APP_BASE_SCALE); + priv->date_part = utils_add_datetime(priv->base, PART_MAIN_ITEM_DATE, + EINA_TRUE, EINA_TRUE, EINA_TRUE, EINA_FALSE, EINA_FALSE, EINA_FALSE); /* 24/12h check: */ priv->check_24 = elm_check_add(priv->base); elm_object_part_content_set(priv->base, PART_MAIN_ITEM_24HOUR, priv->check_24); elm_object_scale_set(priv->check_24, 1.0 / APP_BASE_SCALE); - priv->time_part = elm_datetime_add(priv->base); - elm_datetime_field_visible_set(priv->time_part, ELM_DATETIME_YEAR, EINA_FALSE); - elm_datetime_field_visible_set(priv->time_part, ELM_DATETIME_MONTH, EINA_FALSE); - elm_datetime_field_visible_set(priv->time_part, ELM_DATETIME_DATE, EINA_FALSE); - elm_datetime_field_visible_set(priv->time_part, ELM_DATETIME_AMPM, EINA_TRUE); - elm_object_part_content_set(priv->base, PART_MAIN_ITEM_TIME, priv->time_part); - elm_object_scale_set(priv->time_part, 1.0 / APP_BASE_SCALE); + priv->time_part = utils_add_datetime(priv->base, PART_MAIN_ITEM_TIME, + EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_TRUE, EINA_TRUE, EINA_TRUE); inputmgr_add_callback(done, INPUT_HANDLER_TYPE_BTN_DONE, &done_btn_handler, priv); inputmgr_add_callback(cancel, INPUT_HANDLER_TYPE_BTN_CANCEL, &cancel_btn_handler, priv); diff --git a/src/view/system/view_location.c b/src/view/system/view_location.c index 8632a10..cb9cf9d 100644 --- a/src/view/system/view_location.c +++ b/src/view/system/view_location.c @@ -160,13 +160,13 @@ static bool _draw_menu_area(struct _priv *priv) - btn1 = utils_add_button(priv->base, PART_LOCATION_BTN1, NULL, _("Cancel")); + btn1 = utils_add_button(priv->base, PART_VIEW_BOTTOM_BTN1, NULL, _("Cancel")); if (!btn1) { _ERR("Add button failed."); return false; } - btn2 = utils_add_button(priv->base, PART_LOCATION_BTN2, NULL, _("Location")); + btn2 = utils_add_button(priv->base, PART_VIEW_BOTTOM_BTN2, NULL, _("Location")); if (!btn2) { _ERR("Add button failed."); return false;