elm-theme-viewer/src/bin/gui_mobile.c

192 lines
5.5 KiB
C

#include <Elementary.h>
#include "common.h"
void gui_mobile_description_set(void);
Evas_Object *bt_desc;
extern Gui_Data *gd;
extern ETV_Data *ed;
static void
_block_clicked(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
evas_object_hide(obj);
}
static void
_option_finger_size_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *o, *box;
elm_layout_signal_emit(gd->elm_layout, "c,option,set,clicked", "c.swallow.option");
// outer box
box = o = elm_box_add(gd->win);
elm_layout_content_set(gd->elm_layout, "c.swallow.option_set", o);
evas_object_show(o);
option_gui_finger_size_create(box);
}
static void
_option_scale_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *o, *box;
elm_layout_signal_emit(gd->elm_layout, "c,option,set,clicked", "c.swallow.option");
// outer box
box = o = elm_box_add(gd->win);
elm_layout_content_set(gd->elm_layout, "c.swallow.option_set", o);
evas_object_show(o);
option_gui_scale_create(box);
}
static void
_option_size_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *o, *box;
elm_layout_signal_emit(gd->elm_layout, "c,option,set,clicked", "c.swallow.option");
// outer box
box = o = elm_box_add(gd->win);
elm_layout_content_set(gd->elm_layout, "c.swallow.option_set", o);
evas_object_show(o);
option_gui_force_resize_create(box);
option_gui_width_size_create(box);
option_gui_height_size_create(box);
}
static void
_desc_btn_clicked_cb(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
gui_mobile_description_set();
}
static void
_toolbar_item_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Evas_Object *option_obj = NULL;
if (!event_info) return;
if (!elm_toolbar_item_selected_get(event_info))
{
option_obj = elm_layout_content_get(gd->elm_layout, "c.swallow.option_set");
if (option_obj)
evas_object_del(option_obj);
}
}
static void
_mobile_option_create(ETV_Data *ed, Evas_Object *parent)
{
Evas_Object *tb;
tb = elm_toolbar_add(parent);
elm_layout_content_set(gd->elm_layout, "c.swallow.option", tb);
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
evas_object_smart_callback_add(tb, "clicked", _toolbar_item_clicked_cb, NULL);
evas_object_show(tb);
if (ed->tizen) elm_object_style_set(tb, "tabbar");
elm_toolbar_item_append(tb, NULL, "finger", _option_finger_size_sel_cb,
NULL);
elm_toolbar_item_append(tb, NULL, "scale", _option_scale_sel_cb, NULL);
elm_toolbar_item_append(tb, NULL, "size", _option_size_sel_cb, NULL);
}
void
gui_mobile_create(const char *edje_file)
{
Evas_Object *o, *conform, *ic, *box;
char buf[PATH_MAX];
if (!edje_file) return;
elm_win_conformant_set(gd->win, EINA_TRUE);
elm_win_indicator_mode_set(gd->win, ELM_WIN_INDICATOR_SHOW);
conform = o = elm_conformant_add(gd->win);
EXPAND(o);
elm_win_resize_object_add(gd->win, o);
evas_object_show(o);
gd->elm_layout = o = elm_layout_add(conform);
snprintf(buf, sizeof(buf), "%s/themes/layout_mobile.edj",
elm_app_data_dir_get());
elm_layout_file_set(o, buf, "etv/main/layout");
elm_object_content_set(conform, o);
evas_object_show(o);
box = o = elm_box_add(gd->elm_layout);
elm_box_horizontal_set(o, EINA_TRUE);
elm_layout_content_set(gd->elm_layout, "c.swallow.title", o);
evas_object_show(o);
ic = elm_icon_add(box);
snprintf(buf, sizeof(buf), "%s/images/ETV_logo_s.png", elm_app_data_dir_get());
EXPAND(ic); FILL(ic);
elm_image_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_box_pack_end(box, ic);
evas_object_show(ic);
o = elm_label_add(box);
EXPAND(o); FILL(o);
elm_object_text_set(o, "Elm-Theme-Viewer");
elm_box_pack_end(box, o);
evas_object_show(o);
// c.swallow.button_description
ic = elm_icon_add(gd->win);
elm_icon_standard_set(ic, "media_player/info");
evas_object_show(o);
bt_desc = o = elm_button_add(gd->elm_layout);
elm_object_content_set(bt_desc, ic);
evas_object_show(o);
elm_layout_content_set(gd->elm_layout, "c.swallow.button_description", o);
evas_object_smart_callback_add(o, "clicked",
_desc_btn_clicked_cb, NULL);
// panes for preview and menu
o = elm_panes_add(gd->elm_layout);
elm_panes_horizontal_set(o, EINA_TRUE);
evas_object_show(o);
evas_object_smart_callback_add(o, "clicked,double",
gui_panes_clicked_double_cb, o);
elm_layout_content_set(gd->elm_layout, "c.swallow.preview", o);
// preview_frame
elm_object_part_content_set(o, PANES_TOP, gui_preview_create(gd->win));
// widget_list
elm_object_part_content_set(o, PANES_BOTTOM, gui_widget_menu_create(gd->win));
_mobile_option_create(ed, gd->win);
}
void
gui_mobile_description_set(void)
{
Evas_Object *popup;
popup = elm_popup_add(gd->win);
elm_object_part_text_set(popup, "title,text", "Description of Widget");
elm_object_content_set(popup, gui_description_label_get());
evas_object_smart_callback_add(popup, "block,clicked",
_block_clicked, NULL);
evas_object_show(popup);
}