#define NOTIFICATION_CATEGORY_PADDING_X 62
#define NOTIFICATION_CATEGORY_PADDING_Y 0
-#define NOTIFICATION_CATEGORY_HEIGHT 620
+#define NOTIFICATION_CATEGORY_WIDTH (1920 - NOTIFICATION_CATEGORY_PADDING_X)
+#define NOTIFICATION_CATEGORY_HEIGHT 614
+#define NOTIFICATION_CATEGORY_STEP_SIZE 70
#define NOTIFICATION_ITEM_WIDTH 489
#define NOTIFICATION_ITEM_HEIGHT 134
#define NOTIFICATION_ITEM_PADDING 26
CATEGORY_MAX
};
+struct _category {
+ Evas_Object *title;
+ Evas_Object *grid;
+};
+
struct _priv {
Evas_Object *base;
Evas_Object *clear_btn;
Evas_Object *category_container;
- Evas_Object *category[CATEGORY_MAX];
Elm_Gengrid_Item_Class *grid_class;
+ struct _category *category[CATEGORY_MAX];
};
static void _base_key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
static void _clear_mouse_up_cb(int id, void *data,
Evas *e, Evas_Object *obj, Evas_Event_Mouse_Up *ev);
+static void _category_unfocused_cb(int id, void *data,
+ Evas_Object *obj, Elm_Object_Item *it);
static input_handler base_handler = {
.key_up = _base_key_up_cb,
.key_up = _clear_key_up_cb,
.mouse_up = _clear_mouse_up_cb
};
+static input_handler category_handler = {
+ .unfocused = _category_unfocused_cb,
+};
static const char *_get_category_title(int category)
{
}
}
-static void _draw_category_title(Evas_Object *base, int category)
+static Evas_Object *_add_category_title(Evas_Object *base, int category)
{
Evas_Object *btn;
btn = elm_button_add(base);
if (!btn) {
_ERR("failed to create button object");
- return;
+ return NULL;
}
elm_object_style_set(btn, STYLE_CATEGORY_TITLE);
elm_object_text_set(btn, _get_category_title(category));
+ elm_object_focus_allow_set(btn, EINA_TRUE);
elm_object_part_content_set(base,
PART_NOTIFICATION_CATEGORY_TITLE, btn);
+
+ return btn;
}
-static void _draw_category(struct _priv *priv, int category,
- notification_list_h noti_list)
+static Evas_Object *_add_category_grid(Evas_Object *base)
{
- notification_h noti;
- Evas_Object *ly;
- int count = 0, col, w;
+ Evas_Object *grid;
+
+ grid = elm_gengrid_add(base);
+ if (!grid) {
+ _ERR("failed to create grid object");
+ return NULL;
+ }
+
+ elm_gengrid_item_size_set(grid,
+ NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING,
+ NOTIFICATION_ITEM_HEIGHT + NOTIFICATION_ITEM_PADDING);
+ elm_gengrid_align_set(grid, 0.0, 0.0);
+ elm_gengrid_horizontal_set(grid, EINA_TRUE);
+ evas_object_size_hint_weight_set(grid,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ elm_object_content_set(base, grid);
+
+ return grid;
+}
+
+static void _draw_category(struct _priv *priv, int category)
+{
+ Evas_Object *ly, *title, *grid;
if (category < CATEGORY_FIRST ||
category >= CATEGORY_MAX) {
return;
}
+ priv->category[category] =
+ calloc(1, sizeof(*priv->category[category]));
+
+ if (!priv->category[category]) {
+ _ERR("failed to allocate category");
+ return;
+ }
+
ly = elm_layout_add(priv->category_container);
+ if (!ly) {
+ _ERR("failed to create category layout");
+ goto error;
+ }
elm_layout_file_set(ly, EDJEFILE, GRP_NOTIFICATION_CATEGORY);
evas_object_size_hint_align_set(ly, 0.0, 0.0);
- _draw_category_title(ly, category);
+ title = _add_category_title(ly, category);
+ if (!title) {
+ _ERR("failed to create title");
+ goto error;
+ }
- priv->category[category] = elm_gengrid_add(ly);
- elm_gengrid_item_size_set(priv->category[category],
- NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING,
- NOTIFICATION_ITEM_HEIGHT + NOTIFICATION_ITEM_PADDING);
- elm_gengrid_align_set(priv->category[category], 0.0, 0.0);
- elm_gengrid_horizontal_set(priv->category[category], EINA_TRUE);
- elm_scroller_policy_set(priv->category[category],
- ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
- evas_object_size_hint_weight_set(priv->category[category],
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(ly, priv->category[category]);
+ grid = _add_category_grid(ly);
+ if (!grid) {
+ _ERR("failed to create grid");
+ goto error;
+ }
+
+ elm_object_focus_next_object_set(title, priv->clear_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(grid, title, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(grid, grid, ELM_FOCUS_RIGHT);
+
+ inputmgr_add_callback(title, category, &category_handler, priv);
+ inputmgr_add_callback(grid, category, &category_handler, priv);
elm_box_pack_end(priv->category_container, ly);
+ evas_object_show(grid);
evas_object_show(ly);
+ priv->category[category]->title = title;
+ priv->category[category]->grid = grid;
+
+ return;
+
+error:
+ if (priv->category[category])
+ free(priv->category[category]);
+ if (ly)
+ evas_object_del(ly);
+}
+
+static void _draw_notification(struct _priv *priv, int category,
+ notification_list_h noti_list)
+{
+ notification_h noti;
+ int count = 0, col, w;
+
+ if (category < CATEGORY_FIRST ||
+ category >= CATEGORY_MAX) {
+ _ERR("Undefined category");
+ return;
+ }
+
+ if (!priv->category[category]) {
+ _ERR("failed to get category");
+ return;
+ }
+
+ elm_gengrid_clear(priv->category[category]->grid);
+
while (noti_list != NULL) {
noti = notification_list_get_data(noti_list);
- elm_gengrid_item_append(priv->category[category],
+ elm_gengrid_item_append(priv->category[category]->grid,
priv->grid_class, noti, NULL, noti);
noti_list = notification_list_remove(noti_list, noti);
}
col = ceil(count / NOTIFICATION_ITEMS_IN_COL);
- w = col * NOTIFICATION_ITEM_WIDTH
- + (col - 1) * NOTIFICATION_ITEM_PADDING;
- evas_object_size_hint_min_set(priv->category[category],
- w + NOTIFICATION_ITEM_PADDING,
+ w = col * (NOTIFICATION_ITEM_WIDTH + NOTIFICATION_ITEM_PADDING);
+ if (w > NOTIFICATION_CATEGORY_WIDTH)
+ w = NOTIFICATION_CATEGORY_WIDTH;
+ evas_object_size_hint_min_set(priv->category[category]->grid,
+ w,
NOTIFICATION_CATEGORY_HEIGHT +
NOTIFICATION_ITEM_PADDING);
}
static void _update_list(struct _priv *priv)
{
notification_list_h noti_list = NULL;
-
- elm_box_clear(priv->category_container);
+ Elm_Object_Item *it;
notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list);
- if (noti_list) {
- elm_object_signal_emit(priv->base,
- SIGNAL_NOTIFICATION, SOURCE_PROGRAM);
- elm_object_disabled_set(priv->clear_btn, EINA_FALSE);
-
- _draw_category(priv, CATEGORY_TODAY, noti_list);
- } else {
+ if (!noti_list) {
elm_object_signal_emit(priv->base,
SIGNAL_NO_NOTIFICATION, SOURCE_PROGRAM);
elm_object_disabled_set(priv->clear_btn, EINA_TRUE);
+ elm_object_focus_allow_set(priv->base, EINA_TRUE);
+ elm_object_focus_set(priv->base, EINA_TRUE);
+
+ return;
+ }
+
+ elm_object_signal_emit(priv->base,
+ SIGNAL_NOTIFICATION, SOURCE_PROGRAM);
+ elm_object_disabled_set(priv->clear_btn, EINA_FALSE);
+ elm_object_focus_allow_set(priv->base, EINA_FALSE);
+
+ if (!priv->category[CATEGORY_TODAY])
+ _draw_category(priv, CATEGORY_TODAY);
+
+ _draw_notification(priv, CATEGORY_TODAY, noti_list);
+
+ if (priv->category[CATEGORY_TODAY]) {
+ it = elm_gengrid_first_item_get(
+ priv->category[CATEGORY_TODAY]->grid);
+ if (it)
+ elm_object_item_focus_set(it, EINA_TRUE);
}
}
return NULL;
}
elm_layout_file_set(priv->base, EDJEFILE, GRP_NOTIFICATION_VIEW);
-
evas_object_size_hint_weight_set(priv->base,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, priv->base);
- elm_object_focus_allow_set(priv->base, EINA_TRUE);
inputmgr_add_callback(priv->base, 0, &base_handler, NULL);
scroller = elm_scroller_add(priv->base);
evas_object_size_hint_align_set(scroller, 0.0, 0.0);
elm_object_content_set(priv->base, scroller);
+ elm_scroller_step_size_set(scroller,
+ NOTIFICATION_CATEGORY_STEP_SIZE, 0);
- priv->category_container = elm_box_add(priv->base);
- elm_object_content_set(priv->base, priv->category_container);
+ priv->category_container = elm_box_add(scroller);
+ elm_object_content_set(scroller, priv->category_container);
elm_box_align_set(priv->category_container, 0.0, 0.0);
elm_box_horizontal_set(priv->category_container, EINA_TRUE);
elm_box_padding_set(priv->category_container,
NOTIFICATION_CATEGORY_PADDING_X,
NOTIFICATION_CATEGORY_PADDING_Y);
- evas_object_show(priv->category_container);
priv->clear_btn = elm_layout_add(priv->base);
elm_layout_file_set(priv->clear_btn, EDJEFILE, GRP_NOTIFICATION_CLEAR);
static void _destroy(void *view_data)
{
struct _priv *priv;
+ int i;
if (!view_data) {
_ERR("failed to get view data");
priv = (struct _priv *) view_data;
inputmgr_remove_callback(priv->clear_btn, &clear_handler);
+ inputmgr_remove_callback(priv->base, &base_handler);
evas_object_del(priv->base);
elm_gengrid_item_class_free(priv->grid_class);
+ for (i = CATEGORY_FIRST; i < CATEGORY_MAX; i++) {
+ if (priv->category[i]) {
+ inputmgr_remove_callback(priv->category[i]->title,
+ &category_handler);
+ inputmgr_remove_callback(priv->category[i]->grid,
+ &category_handler);
+ free(priv->category[i]);
+ }
+ }
+
free(priv);
}
notification_delete_all(NOTIFICATION_TYPE_NOTI);
}
+static void _category_unfocused_cb(int id, void *data,
+ Evas_Object *obj, Elm_Object_Item *it)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("failed to get data");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->category[id])
+ elm_object_focus_next_object_set(priv->clear_btn,
+ priv->category[id]->title, ELM_FOCUS_DOWN);
+}
+
view_class *notification_view_get_vclass(void)
{
return &vclass;