diff options
author | Michal Skorupinski <m.skorupinsk@samsung.com> | 2018-07-09 19:09:08 +0200 |
---|---|---|
committer | Michal Skorupinski <m.skorupinsk@samsung.com> | 2018-07-13 18:26:55 +0200 |
commit | f1ed544165c14e74410de46443ebff10c9d8e9dc (patch) | |
tree | 7dd066e2151b131504ab966cd6e18917ef9159ea | |
parent | e7ddc2cb5216757972cae801113a34ea37830d0a (diff) | |
download | gear-racing-controller-f1ed544165c14e74410de46443ebff10c9d8e9dc.tar.gz gear-racing-controller-f1ed544165c14e74410de46443ebff10c9d8e9dc.tar.bz2 gear-racing-controller-f1ed544165c14e74410de46443ebff10c9d8e9dc.zip |
Custom style created for buttons
Change-Id: I1b8005900a8cdaea5a42dc184da8616293ebd62d
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
-rw-r--r-- | edje/images/button_bottom.png | bin | 0 -> 17144 bytes | |||
-rw-r--r-- | edje/images/button_left.png | bin | 0 -> 11062 bytes | |||
-rw-r--r-- | edje/images/button_left_pressed.png | bin | 0 -> 11065 bytes | |||
-rw-r--r-- | edje/images/button_right.png | bin | 0 -> 10900 bytes | |||
-rw-r--r-- | edje/images/button_right_pressed.png | bin | 0 -> 10876 bytes | |||
-rw-r--r-- | inc/utils.h | 3 | ||||
-rw-r--r-- | inc/view/view_base.h | 2 | ||||
-rw-r--r-- | res/edje/button_style.edc | 119 | ||||
-rw-r--r-- | res/edje/gear-racing-controller.edc | 37 | ||||
-rw-r--r-- | res/images/no.png | bin | 0 -> 500 bytes | |||
-rw-r--r-- | res/images/yes.png | bin | 0 -> 639 bytes | |||
-rw-r--r-- | src/view/view_base.c | 31 | ||||
-rw-r--r-- | src/view/view_car_selection.c | 4 | ||||
-rw-r--r-- | src/view/view_connect_to_car.c | 5 | ||||
-rw-r--r-- | src/view/view_connection_successed.c | 4 | ||||
-rw-r--r-- | src/view/view_help.c | 4 | ||||
-rw-r--r-- | src/view/view_name_input.c | 4 | ||||
-rw-r--r-- | src/view/view_network_failure.c | 4 | ||||
-rw-r--r-- | src/view/view_reset.c | 4 | ||||
-rw-r--r-- | src/view_manager/view_manager.c | 9 |
20 files changed, 193 insertions, 37 deletions
diff --git a/edje/images/button_bottom.png b/edje/images/button_bottom.png Binary files differnew file mode 100644 index 0000000..f0ad2ad --- /dev/null +++ b/edje/images/button_bottom.png diff --git a/edje/images/button_left.png b/edje/images/button_left.png Binary files differnew file mode 100644 index 0000000..8484c6c --- /dev/null +++ b/edje/images/button_left.png diff --git a/edje/images/button_left_pressed.png b/edje/images/button_left_pressed.png Binary files differnew file mode 100644 index 0000000..835abda --- /dev/null +++ b/edje/images/button_left_pressed.png diff --git a/edje/images/button_right.png b/edje/images/button_right.png Binary files differnew file mode 100644 index 0000000..9962dc6 --- /dev/null +++ b/edje/images/button_right.png diff --git a/edje/images/button_right_pressed.png b/edje/images/button_right_pressed.png Binary files differnew file mode 100644 index 0000000..b7c9e1e --- /dev/null +++ b/edje/images/button_right_pressed.png diff --git a/inc/utils.h b/inc/utils.h index fff49aa..f0fa69e 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -19,7 +19,8 @@ #define UTILS_H_ void app_get_resource(const char *edj_file_in, char *edj_path_out); -Evas_Object *create_button(Evas_Object *parent, char *part, char *text, Evas_Smart_Cb callback, void *data); +Evas_Object *create_button(Evas_Object *parent, char *part, char *text, char *image_path, char *style, Evas_Smart_Cb callback, void *data); +Evas_Object *create_image(Evas_Object *parent, char *path); Evas_Object *create_layout(Evas_Object *parent, char *edj_file, char *group); void get_screen_size(int *width, int *height); diff --git a/inc/view/view_base.h b/inc/view/view_base.h index cd5e0f0..d4a5e5b 100644 --- a/inc/view/view_base.h +++ b/inc/view/view_base.h @@ -43,7 +43,7 @@ typedef struct _s_view_base { void view_base_init(Evas_Object *parent); void view_base_get_resource(const char *edj_file_in, char *edj_path_out); -Evas_Object *view_base_create_button(Evas_Object *parent, char *part, char *text, Evas_Smart_Cb callback, void *data); +Evas_Object *view_base_create_button(Evas_Object *parent, char *part, char *text, char *image_path, char *style, Evas_Smart_Cb callback, void *data); Evas_Object *view_base_create_layout(Evas_Object *parent, char *edj_file, char *group); void view_base_set_position(Evas_Object *image, int pos_X, int pos_Y, e_horizontal_align horizontal_align, e_vertical_align vertical_align); diff --git a/res/edje/button_style.edc b/res/edje/button_style.edc new file mode 100644 index 0000000..36e5ca1 --- /dev/null +++ b/res/edje/button_style.edc @@ -0,0 +1,119 @@ +collections { + base_scale: 1.0; + group { "elm/button/base/racing_bottom"; + images { + image: "button_bottom.png" COMP; + image: "bg.png" COMP; + } + parts { + image { "background" + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + image.normal: "button_bottom.png"; + } + desc { "pressed"; + image.normal: "bg.png"; + } + } + swallow { "elm.swallow.content"; + desc { "default"; + rel1.relative: 0.4601 0.2923; + rel2.relative: 0.5435 0.8462; + } + } + text { "elm.text"; + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + text { + text: ""; + size: 20; + } + } + } + rect { "event"; + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + color: 0 0 0 0; + } + } + } + programs { + program { "pressed"; + signal: "mouse,down,*"; + source: "event"; + sequence { + action: SIGNAL_EMIT "elm,action,press" "elm"; + action: STATE_SET "pressed"; + target: background; + } + } + program { "unpressed"; + signal: "mouse,up,*"; + source: "event"; + sequence { + action: SIGNAL_EMIT "elm,action,unpress" "elm"; + action: STATE_SET "default"; + target: "background"; + } + } + program { + signal: "mouse,clicked,1"; + source: "event"; + action: SIGNAL_EMIT "elm,action,click" "elm"; + } + } + } + group { "elm/button/base/racing_left"; + inherit: "elm/button/base/racing_bottom"; + images { + image: "button_left.png" COMP; + image: "button_left_pressed.png" COMP; + } + parts { + image { "background" + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + image.normal: "button_left.png"; + } + desc { "pressed"; + image.normal: "button_left_pressed.png"; + } + } + swallow { "elm.swallow.content"; + desc { "default"; + rel1.relative: 0.2089 0.4456; + rel2.relative: 0.6567 0.5471; + } + } + } + } + group { "elm/button/base/racing_right"; + inherit: "elm/button/base/racing_bottom"; + images { + image: "button_right.png" COMP; + image: "button_right_pressed.png" COMP; + } + parts { + image { "background" + desc { "default"; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + image.normal: "button_right.png"; + } + desc { "pressed"; + image.normal: "button_right_pressed.png"; + } + } + swallow { "elm.swallow.content"; + desc { "default"; + rel1.relative: 0.2923 0.4601; + rel2.relative: 0.8462 0.5435; + } + } + } + } +}
\ No newline at end of file diff --git a/res/edje/gear-racing-controller.edc b/res/edje/gear-racing-controller.edc index 920aaa1..a7c9f79 100644 --- a/res/edje/gear-racing-controller.edc +++ b/res/edje/gear-racing-controller.edc @@ -1,40 +1,39 @@ collections { + styles { + style { "main_style"; + base: "font='SamsungOne' font_size=36 font_width='condensed' color=#F8EECC valign=0.5 align=center wrap=word"; + } + } group { name: "main"; parts { - part { name: "txt_title"; - type: TEXT; + text { "txt_title"; + type: TEXTBLOCK; mouse_events: 0; - description { state: "default" 0.0; + desc { "default"; + rel1.relative: 0.20 0.00; + rel2.relative: 0.80 1.00; text { - text: "Hello Tizen"; - font: "Tizen:style=regular"; - size: 20; - min: 1 1; - align: 0.5 0.5; - ellipsis: -1; + text: ""; + style: "main_style"; } - color: 0 255 255 255; } } - swallow { "Button_Ok"; - scale: 1; + swallow { "Button_Cancel"; desc { "default"; visible: 1; align: 0.5 0.5; - rel1.relative: 0.0686 0.7029; - rel2.relative: 0.4886 0.8729; + rel1.relative: 0.0000 0.1167; + rel2.relative: 0.1805 0.8834; } } - swallow { "Button_Cancel"; - scale: 1; + swallow { "Button_Ok"; desc { "default"; visible: 1; align: 0.5 0.5; - rel1.relative: 0.5429 0.7029; - rel2.relative: 0.9629 0.8729; + rel1.relative: 0.8194 0.1167; + rel2.relative: 1.0000 0.8834; } } - } } } diff --git a/res/images/no.png b/res/images/no.png Binary files differnew file mode 100644 index 0000000..ec8d120 --- /dev/null +++ b/res/images/no.png diff --git a/res/images/yes.png b/res/images/yes.png Binary files differnew file mode 100644 index 0000000..0540264 --- /dev/null +++ b/res/images/yes.png diff --git a/src/view/view_base.c b/src/view/view_base.c index 4240536..7e90139 100644 --- a/src/view/view_base.c +++ b/src/view/view_base.c @@ -47,7 +47,22 @@ Evas_Object *view_base_create_layout(Evas_Object *parent, char *edj_file, char * return layout; } -Evas_Object *view_base_create_button(Evas_Object *parent, char *part, char *text, Evas_Smart_Cb callback, void *data) +Evas_Object *view_base_create_image(Evas_Object *parent, char *path) +{ + char edj_path[PATH_MAX] = { 0 }; + view_base_get_resource(path, edj_path); + + Evas_Object *image = elm_image_add(parent); + evas_object_size_hint_weight_set(parent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (!elm_image_file_set(image, edj_path, NULL)) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to load file: %s", path); + } + + return image; +} + +Evas_Object *view_base_create_button(Evas_Object *parent, char *part, char *text, char *image_path, char *style, Evas_Smart_Cb callback, void *data) { Evas_Object *button = elm_button_add(parent); if (!button) { @@ -55,7 +70,19 @@ Evas_Object *view_base_create_button(Evas_Object *parent, char *part, char *text } evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_text_set(button, text); + + if (style && !elm_object_style_set(button, style)) { + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set style: %s", style); + } + + if (text) { + elm_object_text_set(button, text); + } + + if (image_path) { + Evas_Object *image = view_base_create_image(button, image_path); + elm_object_content_set(button, image); + } if (callback) { evas_object_smart_callback_add(button, "clicked", callback, data); diff --git a/src/view/view_car_selection.c b/src/view/view_car_selection.c index a721755..6a2e139 100644 --- a/src/view/view_car_selection.c +++ b/src/view/view_car_selection.c @@ -42,8 +42,8 @@ static void _car_selection_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Car selection"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_car_selection_init(Evas_Object *parent) diff --git a/src/view/view_connect_to_car.c b/src/view/view_connect_to_car.c index ab97b10..6a29840 100644 --- a/src/view/view_connect_to_car.c +++ b/src/view/view_connect_to_car.c @@ -41,8 +41,9 @@ static void connect_to_car_create_gui(Evas_Object *parent) s_info.view_base.layout = view_base_create_layout(parent, EDJ_FILE, GRP_MAIN); eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Connect to a car?"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + + view_base_create_button(s_info.view_base.layout, "Button_Cancel", NULL, "images/no.png", "racing_left", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", NULL, "images/yes.png", "racing_right", _ok_button_clicked_cb, NULL); } diff --git a/src/view/view_connection_successed.c b/src/view/view_connection_successed.c index ece5a97..ea010ca 100644 --- a/src/view/view_connection_successed.c +++ b/src/view/view_connection_successed.c @@ -42,8 +42,8 @@ static void _view_connection_successed_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Connection successed"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_connection_successed_init(Evas_Object *parent) diff --git a/src/view/view_help.c b/src/view/view_help.c index 088afd9..648f210 100644 --- a/src/view/view_help.c +++ b/src/view/view_help.c @@ -42,8 +42,8 @@ static void _view_help_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Help"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_help_init(Evas_Object *parent) diff --git a/src/view/view_name_input.c b/src/view/view_name_input.c index 5bfc6e0..24bbe02 100644 --- a/src/view/view_name_input.c +++ b/src/view/view_name_input.c @@ -42,8 +42,8 @@ static void _view_name_input_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Name input"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_name_input_init(Evas_Object *parent) diff --git a/src/view/view_network_failure.c b/src/view/view_network_failure.c index 207c60f..6734608 100644 --- a/src/view/view_network_failure.c +++ b/src/view/view_network_failure.c @@ -42,8 +42,8 @@ static void _view_network_failure_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Network failure"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_network_failure_init(Evas_Object *parent) diff --git a/src/view/view_reset.c b/src/view/view_reset.c index 5d9fc57..4b01cf2 100644 --- a/src/view/view_reset.c +++ b/src/view/view_reset.c @@ -43,8 +43,8 @@ static void _view_reset_create_gui(Evas_Object *parent) eext_object_event_callback_add(s_info.view_base.layout, EEXT_CALLBACK_BACK, _layout_back_cb, NULL); elm_layout_text_set(s_info.view_base.layout, "txt_title", "Reset"); - view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", _ok_button_clicked_cb, NULL); - view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Ok", "Ok", NULL, NULL, _ok_button_clicked_cb, NULL); + view_base_create_button(s_info.view_base.layout, "Button_Cancel", "Cancel", NULL, NULL, NULL, NULL); } s_view_base *view_reset_init(Evas_Object *parent) diff --git a/src/view_manager/view_manager.c b/src/view_manager/view_manager.c index 835d006..06abacb 100644 --- a/src/view_manager/view_manager.c +++ b/src/view_manager/view_manager.c @@ -15,6 +15,7 @@ */ #include <assert.h> +#include "gear-racing-controller.h" #include "view_manager/view_manager.h" typedef struct _s_ui { @@ -62,6 +63,13 @@ static void _create_naviframe(void) evas_object_show(s_info.conform); } +static void _create_theme_extension(void) +{ + char edj_path[PATH_MAX] = { 0 }; + view_base_get_resource("edje/button_style.edj", edj_path); + elm_theme_extension_add(NULL, edj_path); +} + void view_manager_set_view(view_id id) { view_base_hide(s_info.current_view); @@ -76,6 +84,7 @@ void view_manager_set_view(view_id id) void view_manager_initialize_ui(void) { + _create_theme_extension(); _create_window(); _create_conformant(); _create_naviframe(); |