2012-08-12 19:52:52 -07:00
|
|
|
#include <Elementary.h>
|
2012-08-14 23:05:19 -07:00
|
|
|
#include "log.h"
|
2012-08-14 23:46:21 -07:00
|
|
|
#include "theme.h"
|
|
|
|
|
2012-11-29 09:37:24 -08:00
|
|
|
#define WEIGHT evas_object_size_hint_weight_set
|
|
|
|
#define ALIGN_ evas_object_size_hint_align_set
|
|
|
|
#define EXPAND(X) WEIGHT((X), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
|
|
|
|
#define FILL(X) ALIGN_((X), EVAS_HINT_FILL, EVAS_HINT_FILL)
|
|
|
|
|
2012-11-29 09:28:14 -08:00
|
|
|
Evas_Object *list;
|
|
|
|
|
2012-11-29 20:03:06 -08:00
|
|
|
typedef struct _Style_Data Style_Data;
|
|
|
|
struct _Style_Data
|
|
|
|
{
|
|
|
|
const char *widget;
|
|
|
|
const char *style;
|
|
|
|
};
|
|
|
|
|
2012-11-29 09:37:24 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_elm_min_set(Evas_Object *obj, Evas_Object *parent, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Evas_Object *table, *rect;
|
|
|
|
|
|
|
|
table = elm_table_add(parent);
|
|
|
|
evas_object_show(table);
|
|
|
|
|
|
|
|
rect = evas_object_rectangle_add(evas_object_evas_get(table));
|
|
|
|
evas_object_size_hint_min_set(rect, w, h);
|
|
|
|
EXPAND(rect); FILL(rect);
|
|
|
|
elm_table_pack(table, rect, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
EXPAND(obj); FILL(obj);
|
|
|
|
elm_table_pack(table, obj, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_right_content_create(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
o = elm_bg_add(parent);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2012-11-29 09:28:14 -08:00
|
|
|
static Evas_Object *
|
|
|
|
_left_menu_create(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *nf;
|
|
|
|
|
|
|
|
nf = elm_naviframe_add(parent);
|
|
|
|
evas_object_show(nf);
|
|
|
|
|
|
|
|
list = elm_list_add(parent);
|
2012-11-29 19:21:56 -08:00
|
|
|
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
2012-11-29 09:28:14 -08:00
|
|
|
evas_object_data_set(list, "nf", nf);
|
|
|
|
elm_naviframe_item_push(nf, "Widgets", NULL, NULL, list, NULL);
|
|
|
|
evas_object_show(list);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|
2012-08-12 19:52:52 -07:00
|
|
|
|
|
|
|
void
|
2012-11-29 08:53:38 -08:00
|
|
|
gui_create(const char *edje_file)
|
2012-08-12 19:52:52 -07:00
|
|
|
{
|
2012-08-13 03:44:17 -07:00
|
|
|
Evas_Object *win, *o;
|
2012-11-29 18:15:31 -08:00
|
|
|
Evas_Object *box, *btn, *box2, *table, *left;
|
2012-08-12 19:52:52 -07:00
|
|
|
|
2012-11-29 08:53:38 -08:00
|
|
|
if (!edje_file) return;
|
|
|
|
|
2012-08-13 04:23:09 -07:00
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
|
|
|
|
|
|
|
win = o = elm_win_util_standard_add("elm-theme-viewer", "Elm Theme Viewer");
|
|
|
|
elm_win_autodel_set(o, EINA_TRUE);
|
2012-11-29 11:22:55 -08:00
|
|
|
evas_object_resize(o, 500, 400);
|
2012-08-13 04:23:09 -07:00
|
|
|
evas_object_show(o);
|
2012-08-12 19:52:52 -07:00
|
|
|
|
2012-11-29 09:37:24 -08:00
|
|
|
// outer box
|
2012-08-12 19:52:52 -07:00
|
|
|
box = o = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
elm_win_resize_object_add(win, o);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
2012-11-29 18:15:31 -08:00
|
|
|
o = elm_label_add(win);
|
2012-11-29 08:53:38 -08:00
|
|
|
elm_object_text_set(o, edje_file);
|
2012-08-13 03:44:17 -07:00
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
elm_box_pack_end(box, o);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
btn = o = elm_button_add(win);
|
2012-11-29 11:22:55 -08:00
|
|
|
elm_object_disabled_set(btn, EINA_TRUE);
|
2012-08-13 03:44:17 -07:00
|
|
|
elm_object_text_set(o, "Select Theme");
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
elm_box_pack_end(box, o);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
2012-11-29 09:37:24 -08:00
|
|
|
// inner box
|
|
|
|
box2 = o = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(o, EINA_TRUE);
|
2012-08-13 03:44:17 -07:00
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-08-14 23:46:21 -07:00
|
|
|
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2012-08-13 03:44:17 -07:00
|
|
|
elm_box_pack_end(box, o);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
2012-11-29 09:37:24 -08:00
|
|
|
left = _left_menu_create(win);
|
2012-11-29 10:51:52 -08:00
|
|
|
table = o = _elm_min_set(left, box, 250, 0); // set min size hint
|
2012-11-29 09:37:24 -08:00
|
|
|
WEIGHT(o, 0.0, EVAS_HINT_EXPAND);
|
|
|
|
FILL(o);
|
|
|
|
elm_box_pack_end(box2, table);
|
|
|
|
|
2012-11-29 18:15:31 -08:00
|
|
|
o = _right_content_create(win);
|
2012-11-29 09:37:24 -08:00
|
|
|
EXPAND(o); FILL(o);
|
|
|
|
elm_box_pack_end(box2, o);
|
2012-08-14 23:46:21 -07:00
|
|
|
|
2012-08-14 23:05:19 -07:00
|
|
|
INF("GUI Creation Done");
|
|
|
|
|
2012-08-12 19:52:52 -07:00
|
|
|
return;
|
|
|
|
}
|
2012-08-14 23:46:21 -07:00
|
|
|
|
2012-11-29 20:03:06 -08:00
|
|
|
static void
|
|
|
|
_style_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Style_Data *sd = data;
|
|
|
|
|
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
INF("%s %s", sd->widget, sd->style);
|
|
|
|
}
|
|
|
|
|
2012-11-29 09:28:14 -08:00
|
|
|
static void
|
|
|
|
_widget_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Object *nf = evas_object_data_get(obj, "nf");
|
2012-11-29 11:20:38 -08:00
|
|
|
Evas_Object *li;
|
|
|
|
Elm_Object_Item *it;
|
2012-11-29 20:03:06 -08:00
|
|
|
Eina_List *styles, *l;
|
2012-11-29 11:20:38 -08:00
|
|
|
char *style;
|
2012-11-29 20:03:06 -08:00
|
|
|
Style_Data *sd;
|
2012-11-29 11:20:38 -08:00
|
|
|
|
2012-11-29 09:28:14 -08:00
|
|
|
if (!nf) return;
|
2012-11-29 11:20:38 -08:00
|
|
|
|
|
|
|
li = elm_list_add(nf);
|
2012-11-29 20:03:06 -08:00
|
|
|
evas_object_data_set(obj, "widget", data);
|
|
|
|
elm_list_select_mode_set(li, ELM_OBJECT_SELECT_MODE_ALWAYS);
|
2012-11-29 11:20:38 -08:00
|
|
|
styles = widget_styles_get((const char *)data);
|
|
|
|
EINA_LIST_FOREACH(styles, l, style)
|
2012-11-29 20:03:06 -08:00
|
|
|
{
|
|
|
|
// TODO: sd needs to be freed properly
|
|
|
|
sd = (Style_Data *)calloc(1, sizeof(Style_Data));
|
|
|
|
sd->widget = data;
|
|
|
|
sd->style = style;
|
|
|
|
elm_list_item_append(li, style, NULL, NULL, _style_list_sel_cb, sd);
|
|
|
|
}
|
2012-11-29 11:20:38 -08:00
|
|
|
|
|
|
|
it = elm_naviframe_item_push(nf, "Styles", NULL, NULL, li, NULL);
|
|
|
|
elm_object_item_part_text_set(it, "subtitle", (char *)data);
|
2012-11-29 09:28:14 -08:00
|
|
|
}
|
|
|
|
|
2012-08-14 23:46:21 -07:00
|
|
|
void
|
|
|
|
gui_widget_load(void)
|
|
|
|
{
|
2012-11-29 19:21:56 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Widget_Data *wd;
|
2012-08-14 23:46:21 -07:00
|
|
|
|
2012-11-29 19:21:56 -08:00
|
|
|
EINA_LIST_FOREACH(widget_list, l, wd)
|
2012-08-14 23:46:21 -07:00
|
|
|
{
|
2012-11-29 19:21:56 -08:00
|
|
|
if (eina_list_count(wd->styles))
|
|
|
|
{
|
|
|
|
elm_list_item_append(list, wd->widget, NULL, NULL,
|
|
|
|
_widget_list_sel_cb, wd->widget);
|
|
|
|
}
|
2012-08-14 23:46:21 -07:00
|
|
|
}
|
|
|
|
}
|