--- /dev/null
+
+styles {
+ style {
+ /* Font size is changed from 24 to 20 because of resolution issues. */
+ name: "text_style";
+ base: "font=Tizen:style=Regular font_size=20 color=#ffffff align=center style=shadow shadow_color=#000000bf wrap=mixed ellipsis=-1";
+ tag: "br" "\n";
+ tag: "hilight" "+ font_weight=Bold";
+ tag: "b" "+ font_weight=Bold";
+ tag: "tab" "\t";
+ }
+}
+
+collections {
+ base_scale: 1.7;
+ group {
+ name: "item";
+ parts {
+ part {
+ name: "bg";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; }
+ rel2 { relative: 1.0 1.0; }
+ }
+ }
+ part {
+ name: "icon";
+ type: SWALLOW;
+ mouse_events: 1;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.1 0.1; to: "bg"; }
+ rel2 { relative: 0.9 0.66; to: "bg"; }
+ color: 255 255 255 255;
+ visible: 1;
+ }
+ description {
+ state: "pressed" 0.0;
+ inherit: "default" 0.0;
+ color: 100 100 100 255;
+ }
+ }
+ part {
+ name: "name";
+ type: TEXTBLOCK;
+ mouse_events: 1;
+ scale: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.7; to: "bg"; }
+ rel2 { relative: 1.0 1.0; to: "bg"; }
+ align: 0.5 0.0;
+ color: 0 0 0 100;
+ text {
+ style: "text_style";
+ align: 0.5 0.0;
+ }
+ visible: 1;
+ }
+ }
+ part {
+ name: "button";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0; to: "bg"; }
+ rel2 { relative: 1.0 1.0; to: "bg"; }
+ visible: 1;
+ }
+ }
+ } //parts
+ }
+} //collections
--- /dev/null
+#include <Elementary.h>
+#include <app.h>
+
+#include "util.h"
+#include "log.h"
+#include "item.h"
+#include "item_info.h"
+
+
+
+#define DEFAULT_ICON "/usr/share/icons/A01-1_icon_Menu.png"
+#define ITEM_ICON_WIDTH 112
+#define ITEM_ICON_HEIGHT 112
+
+
+
+const char *const ITEM_EDJE = "item.edj";
+
+
+
+static Evas_Object *__add_icon(Evas_Object *parent, const char *file)
+{
+ Evas_Object *icon = NULL;
+
+ retv_if(!parent, NULL);
+
+ icon = elm_icon_add(parent);
+ retv_if(!icon, NULL);
+
+ if (elm_image_file_set(icon, file, NULL) == EINA_FALSE) {
+ _E("Icon file is not accessible (%s)", file);
+ evas_object_del(icon);
+ return NULL;
+ }
+
+ evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(ITEM_ICON_WIDTH), ELM_SCALE_SIZE(ITEM_ICON_HEIGHT));
+
+ elm_image_preload_disabled_set(icon, EINA_TRUE);
+ elm_image_smooth_set(icon, EINA_TRUE);
+ elm_image_no_scale_set(icon, EINA_FALSE);
+ evas_object_show(icon);
+
+ return icon;
+}
+
+
+
+static void __item_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ item_info_s *item_info = data;
+
+ ret_if(!item_info);
+}
+
+
+
+Evas_Object *item_create(Evas_Object *parent, item_info_s *item_info)
+{
+ Evas_Object *item = NULL;
+ Evas_Object *item_bg = NULL;
+ Evas_Object *icon = NULL;
+ Evas_Object *button = NULL;
+ Evas *e = NULL;
+
+ char *path = NULL;
+ char *name = NULL;
+ char full_path[PATH_LEN] = {0, };
+
+ retv_if(!parent, NULL);
+
+ path = app_get_resource_path();
+ retv_if(!path, NULL);
+
+ snprintf(full_path, sizeof(full_path), "%s/edje/%s", path, ITEM_EDJE);
+ free(path);
+
+ item = elm_layout_add(parent);
+ retv_if(!item, NULL);
+ elm_layout_file_set(item, full_path, "item");
+
+ e = evas_object_evas_get(parent);
+ goto_if(!e, ERROR);
+
+ item_bg = evas_object_rectangle_add(e);
+ goto_if(!item_bg, ERROR);
+ evas_object_size_hint_weight_set(item_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_min_set(item_bg, ELM_SCALE_SIZE(item_info->width), ELM_SCALE_SIZE(item_info->height));
+ evas_object_color_set(item_bg, 0, 0, 0, 0);
+ evas_object_repeat_events_set(item_bg, EINA_TRUE);
+ evas_object_show(item_bg);
+ elm_object_part_content_set(item, "bg", item_bg);
+ evas_object_show(item);
+
+ icon = __add_icon(item, item_info->icon_path);
+ goto_if(!icon, ERROR);
+ elm_object_part_content_set(item, "icon", icon);
+
+ name = item_info->name;
+ goto_if(!name, ERROR);
+ elm_object_part_text_set(item, "name", name);
+
+ button = elm_button_add(item);
+ goto_if(!button, ERROR);
+
+ elm_object_style_set(button, "focus");
+ elm_object_part_content_set(item, "button", button);
+ evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(button);
+ evas_object_smart_callback_add(button, "clicked", __item_clicked_cb, item_info);
+
+ return item;
+
+ERROR:
+ item_destroy(item);
+ return NULL;
+
+}
+
+
+
+void item_destroy(Evas_Object *item)
+{
+ Evas_Object *bg = NULL;
+ Evas_Object *button = NULL;
+ Evas_Object *icon = NULL;
+
+ ret_if(!item);
+
+ button = elm_object_part_content_unset(item, "button");
+ if (button) {
+ evas_object_smart_callback_del(button, "clicked", __item_clicked_cb);
+ }
+
+ icon = elm_object_part_content_unset(item, "icon");
+ if (icon) {
+ evas_object_del(icon);
+ }
+ bg = elm_object_part_content_unset(item, "bg");
+ if (bg) {
+ evas_object_del(bg);
+ }
+ evas_object_del(item);
+}