add support for tabs to channels
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
352cd4365c
commit
2981ba11f9
|
@ -16,6 +16,9 @@ struct _Channel
|
|||
Evas_Object *o_bg;
|
||||
Evas_Object *o_grid;
|
||||
Evas_Object *o_spacer;
|
||||
Evas_Object *o_tab_spacer;
|
||||
Evas_Object *o_tabregion_bg;
|
||||
Evas_Object *o_tabregion_base;
|
||||
Evas_Object *o_img;
|
||||
Evas_Object *o_entry;
|
||||
|
||||
|
@ -28,10 +31,20 @@ struct _Channel
|
|||
Eina_Bool visible : 1;
|
||||
} userlist;
|
||||
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
Evas_Object *o_box;
|
||||
Eina_List *tabs;
|
||||
} l, r;
|
||||
} tabbar;
|
||||
|
||||
int step_x, step_y;
|
||||
int min_w, min_h;
|
||||
int req_w, req_h;
|
||||
|
||||
Eina_Bool active : 1;
|
||||
Eina_Bool size_done : 1;
|
||||
Eina_Bool translucent : 1;
|
||||
Eina_Bool focused : 1;
|
||||
|
@ -81,7 +94,7 @@ _cb_size_hint(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event
|
|||
chl->req_w = (w - mw + rw);
|
||||
chl->req_h = (h - mh + rh);
|
||||
|
||||
if (chl->focused) _window_size_update();
|
||||
if (chl->active) _window_size_update();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -90,7 +103,7 @@ _cb_prev(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
Channel *chl, *pchl = NULL;
|
||||
|
||||
chl = data;
|
||||
if (chl->focused)
|
||||
if (chl->active)
|
||||
{
|
||||
if ((pchl = _window_channel_previous_get(chl)))
|
||||
_window_channel_switch(chl, pchl);
|
||||
|
@ -103,7 +116,7 @@ _cb_next(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
Channel *chl, *nchl = NULL;
|
||||
|
||||
chl = data;
|
||||
if (chl->focused)
|
||||
if (chl->active)
|
||||
{
|
||||
if ((nchl = _window_channel_next_get(chl)))
|
||||
_window_channel_switch(chl, nchl);
|
||||
|
@ -196,7 +209,7 @@ _cb_options_done(void *data)
|
|||
Channel *chl;
|
||||
|
||||
chl = data;
|
||||
if (chl->focused) elm_object_focus_set(chl->o_grid, EINA_TRUE);
|
||||
if (chl->active) elm_object_focus_set(chl->o_grid, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -235,6 +248,19 @@ _cb_entry_go(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_tabregion_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED)
|
||||
{
|
||||
Channel *chl;
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
||||
chl = data;
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
evas_object_size_hint_min_set(chl->o_tabregion_base, w, h);
|
||||
edje_object_part_swallow(chl->o_base, "channel.tabregion",
|
||||
chl->o_tabregion_base);
|
||||
}
|
||||
|
||||
static void
|
||||
_channel_userlist_create(Channel *chl)
|
||||
{
|
||||
|
@ -329,6 +355,21 @@ _channel_create(Evas *evas, Evas_Object *win, const char *name, const char *serv
|
|||
evas_object_data_set(chl->o_bg, "theme_reload_func", _cb_theme_reload);
|
||||
evas_object_data_set(chl->o_bg, "theme_reload_func_data", chl);
|
||||
|
||||
/* add tabregion */
|
||||
chl->o_tabregion_bg = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(chl->o_tabregion_bg, 0, 0, 0, 0);
|
||||
evas_object_event_callback_add(chl->o_tabregion_bg, EVAS_CALLBACK_MOVE,
|
||||
_cb_tabregion_change, chl);
|
||||
evas_object_event_callback_add(chl->o_tabregion_bg, EVAS_CALLBACK_RESIZE,
|
||||
_cb_tabregion_change, chl);
|
||||
edje_object_part_swallow(chl->o_bg, "channel.tabregion",
|
||||
chl->o_tabregion_bg);
|
||||
|
||||
chl->o_tabregion_base = evas_object_rectangle_add(evas);
|
||||
evas_object_color_set(chl->o_tabregion_base, 0, 0, 0, 0);
|
||||
edje_object_part_swallow(chl->o_base, "channel.tabregion",
|
||||
chl->o_tabregion_base);
|
||||
|
||||
/* add grid */
|
||||
chl->o_grid = _grid_add(evas);
|
||||
WEIGHT_SET(chl->o_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -367,6 +408,12 @@ _channel_create(Evas *evas, Evas_Object *win, const char *name, const char *serv
|
|||
void
|
||||
_channel_destroy(Channel *chl)
|
||||
{
|
||||
/* delete tabregion stuff */
|
||||
_channel_tabbar_clear(chl);
|
||||
if (chl->o_tabregion_bg) evas_object_del(chl->o_tabregion_bg);
|
||||
if (chl->o_tabregion_base) evas_object_del(chl->o_tabregion_base);
|
||||
if (chl->o_tab_spacer) evas_object_del(chl->o_tab_spacer);
|
||||
|
||||
/* delete channel userlist objects */
|
||||
if (chl->userlist.o_dismiss) evas_object_del(chl->userlist.o_dismiss);
|
||||
if (chl->userlist.o_list) evas_object_del(chl->userlist.o_list);
|
||||
|
@ -434,13 +481,24 @@ _channel_unfocus(Channel *chl)
|
|||
if (!chl->focused) return;
|
||||
|
||||
elm_object_focus_set(chl->o_entry, EINA_FALSE);
|
||||
|
||||
edje_object_signal_emit(chl->o_bg, "focus,out", PACKAGE_NAME);
|
||||
edje_object_signal_emit(chl->o_base, "focus,out", PACKAGE_NAME);
|
||||
|
||||
chl->focused = EINA_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_channel_active_set(Channel *chl, Eina_Bool active)
|
||||
{
|
||||
chl->active = active;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_channel_active_get(Channel *chl)
|
||||
{
|
||||
return chl->active;
|
||||
}
|
||||
|
||||
const char *
|
||||
_channel_name_get(Channel *chl)
|
||||
{
|
||||
|
@ -664,7 +722,7 @@ _channel_text_append(Channel *chl, const char *user, const char *txt)
|
|||
|
||||
_grid_text_append(chl->o_grid, txt, strlen(txt));
|
||||
|
||||
if (!chl->focused) chl->missed = EINA_TRUE;
|
||||
if (!chl->active) chl->missed = EINA_TRUE;
|
||||
else chl->missed = EINA_FALSE;
|
||||
|
||||
_window_channel_count_update();
|
||||
|
@ -736,3 +794,107 @@ _channel_userlist_go(Channel *chl)
|
|||
{
|
||||
elm_list_go(chl->userlist.o_list);
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabbar_lbox_create(Channel *chl, Evas_Object *win)
|
||||
{
|
||||
if (!chl->tabbar.l.o_box)
|
||||
{
|
||||
chl->tabbar.l.o_box = elm_box_add(win);
|
||||
elm_box_horizontal_set(chl->tabbar.l.o_box, EINA_TRUE);
|
||||
elm_box_homogeneous_set(chl->tabbar.l.o_box, EINA_TRUE);
|
||||
WEIGHT_SET(chl->tabbar.l.o_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
FILL_SET(chl->tabbar.l.o_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
edje_object_part_swallow(chl->o_bg, "tabl.content", chl->tabbar.l.o_box);
|
||||
evas_object_show(chl->tabbar.l.o_box);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabbar_rbox_create(Channel *chl, Evas_Object *win)
|
||||
{
|
||||
if (!chl->tabbar.r.o_box)
|
||||
{
|
||||
chl->tabbar.r.o_box = elm_box_add(win);
|
||||
elm_box_horizontal_set(chl->tabbar.r.o_box, EINA_TRUE);
|
||||
elm_box_homogeneous_set(chl->tabbar.r.o_box, EINA_TRUE);
|
||||
WEIGHT_SET(chl->tabbar.r.o_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
FILL_SET(chl->tabbar.r.o_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
edje_object_part_swallow(chl->o_bg, "tabr.content", chl->tabbar.r.o_box);
|
||||
evas_object_show(chl->tabbar.r.o_box);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabbar_lbox_append(Channel *chl, Evas_Object *o)
|
||||
{
|
||||
chl->tabbar.l.tabs = eina_list_append(chl->tabbar.l.tabs, o);
|
||||
elm_box_pack_end(chl->tabbar.l.o_box, o);
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabbar_rbox_append(Channel *chl, Evas_Object *o)
|
||||
{
|
||||
chl->tabbar.r.tabs = eina_list_append(chl->tabbar.r.tabs, o);
|
||||
elm_box_pack_end(chl->tabbar.r.o_box, o);
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabbar_clear(Channel *chl)
|
||||
{
|
||||
Evas_Object *o;
|
||||
|
||||
if (chl->tabbar.l.o_box)
|
||||
{
|
||||
EINA_LIST_FREE(chl->tabbar.l.tabs, o)
|
||||
evas_object_del(o);
|
||||
evas_object_del(chl->tabbar.l.o_box);
|
||||
chl->tabbar.l.o_box = NULL;
|
||||
}
|
||||
|
||||
if (chl->tabbar.r.o_box)
|
||||
{
|
||||
EINA_LIST_FREE(chl->tabbar.r.tabs, o)
|
||||
evas_object_del(o);
|
||||
evas_object_del(chl->tabbar.r.o_box);
|
||||
chl->tabbar.r.o_box = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabspacer_create(Channel *chl, double v1, double v2)
|
||||
{
|
||||
if (!chl->o_tab_spacer)
|
||||
{
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
||||
chl->o_tab_spacer = evas_object_rectangle_add(chl->evas);
|
||||
evas_object_color_set(chl->o_tab_spacer, 0, 0, 0, 0);
|
||||
elm_coords_finger_size_adjust(1, &w, 1, &h);
|
||||
evas_object_size_hint_min_set(chl->o_tab_spacer, w, h);
|
||||
edje_object_part_swallow(chl->o_bg, "tab", chl->o_tab_spacer);
|
||||
edje_object_part_drag_value_set(chl->o_bg, "tabl", v1, 0.0);
|
||||
edje_object_part_drag_value_set(chl->o_bg, "tabr", v2, 0.0);
|
||||
edje_object_part_text_set(chl->o_bg, "tab.title", chl->name);
|
||||
edje_object_signal_emit(chl->o_bg, "tabbar,on", PACKAGE_NAME);
|
||||
edje_object_message_signal_process(chl->o_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_part_drag_value_set(chl->o_bg, "tabl", v1, 0.0);
|
||||
edje_object_part_drag_value_set(chl->o_bg, "tabr", v2, 0.0);
|
||||
edje_object_message_signal_process(chl->o_bg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_channel_tabspacer_destroy(Channel *chl)
|
||||
{
|
||||
if (chl->o_tab_spacer)
|
||||
{
|
||||
edje_object_signal_emit(chl->o_bg, "tabbar,off", PACKAGE_NAME);
|
||||
evas_object_del(chl->o_tab_spacer);
|
||||
chl->o_tab_spacer = NULL;
|
||||
edje_object_message_signal_process(chl->o_bg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue