Add selector to window.
Add channel focus function. Add code to create selector Signed-off-by: Chris Michael <devilhorns@comcast.net>
This commit is contained in:
parent
0e79b5ce2c
commit
80294d5700
246
src/bin/main.c
246
src/bin/main.c
|
@ -9,6 +9,9 @@ struct _Window
|
|||
Evas_Object *o_conform;
|
||||
Evas_Object *o_base;
|
||||
|
||||
Evas_Object *o_sel;
|
||||
Evas_Object *o_sel_bg;
|
||||
|
||||
Eina_List *channels;
|
||||
|
||||
Ecore_Job *size_job;
|
||||
|
@ -24,11 +27,13 @@ struct _Channel
|
|||
Evas_Object *o_base;
|
||||
Evas_Object *o_grid;
|
||||
Evas_Object *o_spacer;
|
||||
Evas_Object *o_img;
|
||||
|
||||
int step_x, step_y;
|
||||
int min_w, min_h;
|
||||
int req_w, req_h;
|
||||
|
||||
Eina_Bool unswallowed : 1;
|
||||
Eina_Bool focused : 1;
|
||||
Eina_Bool missed : 1;
|
||||
};
|
||||
|
@ -36,6 +41,7 @@ struct _Channel
|
|||
/* local prototypes */
|
||||
static void _main_window_free(Window *win);
|
||||
static Channel *_main_window_focused_channel_get(Window *win);
|
||||
static Eina_Bool _main_window_size_walk(Window *win, int *w, int *h);
|
||||
|
||||
/* external variables */
|
||||
int _log_dom = -1;
|
||||
|
@ -105,11 +111,205 @@ _main_window_free(Window *win)
|
|||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_go(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_main_selector_restore(Window *win)
|
||||
{
|
||||
Channel *chl;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(win->channels, l, chl)
|
||||
{
|
||||
if (chl->unswallowed)
|
||||
{
|
||||
#if (EVAS_VERSION_MAJOR > 1) || (EVAS_VERSION_MINOR >= 8)
|
||||
evas_object_image_source_visible_set(chl->o_img, EINA_TRUE);
|
||||
#endif
|
||||
edje_object_part_swallow(chl->o_bg, "content", chl->o_base);
|
||||
evas_object_show(chl->o_base);
|
||||
|
||||
chl->unswallowed = EINA_FALSE;
|
||||
chl->o_img = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
evas_object_del(win->o_sel_bg);
|
||||
win->o_sel_bg = NULL;
|
||||
|
||||
evas_object_del(win->o_sel);
|
||||
win->o_sel = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_main_channel_focus(Channel *chl)
|
||||
{
|
||||
Eina_List *l;
|
||||
Channel *ch;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
EINA_LIST_FOREACH(chl->window->channels, l, ch)
|
||||
{
|
||||
if (ch != chl)
|
||||
{
|
||||
if (ch->focused)
|
||||
{
|
||||
ch->focused = EINA_FALSE;
|
||||
edje_object_signal_emit(ch->o_bg, "focus,out", "express");
|
||||
edje_object_signal_emit(ch->o_base, "focus,out", "express");
|
||||
elm_object_focus_set(chl->o_grid, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chl->focused = EINA_TRUE;
|
||||
edje_object_signal_emit(chl->o_bg, "focus,in", "express");
|
||||
edje_object_signal_emit(chl->o_base, "focus,in", "express");
|
||||
elm_object_focus_set(chl->o_grid, EINA_TRUE);
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s - %s", elm_app_name_get(),
|
||||
_grid_name_get(chl->o_grid));
|
||||
elm_win_title_set(chl->window->o_win, buff);
|
||||
|
||||
if (chl->missed) chl->missed = EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_main_channel_focus_show(Channel *chl)
|
||||
{
|
||||
edje_object_part_swallow(chl->window->o_base, "base.content", chl->o_bg);
|
||||
evas_object_show(chl->o_bg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_selector_selected(void *data, Evas_Object *obj EINA_UNUSED, void *event)
|
||||
{
|
||||
Window *win;
|
||||
Channel *chl;
|
||||
Eina_List *l;
|
||||
|
||||
if (!(win = data)) return;
|
||||
|
||||
EINA_LIST_FOREACH(win->channels, l, chl)
|
||||
{
|
||||
if (chl->o_img == event)
|
||||
{
|
||||
_main_channel_focus(chl);
|
||||
_main_channel_focus_show(chl);
|
||||
_main_selector_restore(win);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_main_selector_restore(win);
|
||||
|
||||
if ((chl = _main_window_focused_channel_get(win)))
|
||||
{
|
||||
_main_channel_focus(chl);
|
||||
_main_channel_focus_show(chl);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_selector_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Window *win;
|
||||
Channel *chl;
|
||||
|
||||
if (!(win = data)) return;
|
||||
_main_selector_restore(win);
|
||||
if ((chl = _main_window_focused_channel_get(win)))
|
||||
{
|
||||
_main_channel_focus(chl);
|
||||
_main_channel_focus_show(chl);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_selector_ending(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
Window *win;
|
||||
|
||||
if (!(win = data)) return;
|
||||
edje_object_signal_emit(win->o_sel_bg, "end", "express");
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_chlcount_go(void *data, Evas_Object *obj EINA_UNUSED, const char *sig EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Channel *chl, *ch;
|
||||
Window *win;
|
||||
Eina_List *l;
|
||||
double z = 1.0;
|
||||
int count = 0;
|
||||
|
||||
if (!(chl = data)) return;
|
||||
if (!(win = chl->window)) return;
|
||||
|
||||
evas_object_hide(chl->o_bg);
|
||||
|
||||
/* create selector background */
|
||||
win->o_sel_bg = edje_object_add(win->evas);
|
||||
_theme_apply(win->o_sel_bg, "express/selector/background");
|
||||
if (_ex_cfg->gui.translucent)
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,on", "express");
|
||||
else
|
||||
edje_object_signal_emit(win->o_sel_bg, "translucent,off", "express");
|
||||
|
||||
edje_object_signal_emit(win->o_sel_bg, "begin", "express");
|
||||
|
||||
/* create selector */
|
||||
if (!(win->o_sel = _selector_add(win->o_win))) return;
|
||||
|
||||
EINA_LIST_FOREACH(win->channels, l, ch)
|
||||
{
|
||||
Evas_Coord w = 0, h = 0;
|
||||
|
||||
edje_object_part_unswallow(ch->o_bg, ch->o_base);
|
||||
evas_object_lower(ch->o_base);
|
||||
evas_object_move(ch->o_base, -9999, -9999);
|
||||
evas_object_show(ch->o_base);
|
||||
evas_object_clip_unset(ch->o_base);
|
||||
#if (EVAS_VERSION_MAJOR > 1) || (EVAS_VERSION_MINOR >= 8)
|
||||
evas_object_image_source_visible_set(ch->o_img, EINA_FALSE);
|
||||
#endif
|
||||
ch->unswallowed = EINA_TRUE;
|
||||
|
||||
ch->o_img = evas_object_image_filled_add(win->evas);
|
||||
evas_object_image_source_set(ch->o_img, ch->o_base);
|
||||
evas_object_geometry_get(ch->o_base, NULL, NULL, &w, &h);
|
||||
evas_object_resize(ch->o_img, w, h);
|
||||
evas_object_data_set(ch->o_img, "grid", ch->o_grid);
|
||||
|
||||
_selector_entry_add(win->o_sel, ch->o_img, (ch == chl), ch->missed);
|
||||
}
|
||||
|
||||
edje_object_part_swallow(win->o_sel_bg, "content", win->o_sel);
|
||||
evas_object_show(win->o_sel);
|
||||
edje_object_part_swallow(win->o_base, "base.content", win->o_sel_bg);
|
||||
evas_object_show(win->o_sel_bg);
|
||||
|
||||
evas_object_smart_callback_add(win->o_sel, "selected",
|
||||
_cb_selector_selected, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "exit",
|
||||
_cb_selector_exit, win);
|
||||
evas_object_smart_callback_add(win->o_sel, "ending",
|
||||
_cb_selector_ending, win);
|
||||
|
||||
_selector_go(win->o_sel);
|
||||
|
||||
count = eina_list_count(win->channels);
|
||||
if (count >= 1)
|
||||
z = (1.0 / (sqrt(count)) * 0.8);
|
||||
if (z > 1.0) z = 1.0;
|
||||
|
||||
_selector_zoom_set(win->o_sel, z);
|
||||
_selector_zoom(win->o_sel, z);
|
||||
|
||||
/* if (ch != chl) */
|
||||
/* { */
|
||||
/* _selector_entry_selected_set(win->o_sel, chl->o_img, EINA_TRUE); */
|
||||
/* _selector_exit(win->o_sel); */
|
||||
/* } */
|
||||
|
||||
elm_object_focus_set(win->o_sel, EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -144,6 +344,10 @@ _cb_focus_in(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
edje_object_signal_emit(chl->o_bg, "focus,in", "express");
|
||||
edje_object_signal_emit(chl->o_base, "focus,in", "express");
|
||||
elm_object_focus_set(chl->o_grid, EINA_TRUE);
|
||||
|
||||
elm_win_keyboard_mode_set(win->o_win, ELM_WIN_KEYBOARD_TERMINAL);
|
||||
|
||||
/* TODO: imf ? */
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -155,6 +359,8 @@ _cb_focus_out(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
|
|||
if (!(win = data)) return;
|
||||
|
||||
win->focused = EINA_FALSE;
|
||||
elm_win_keyboard_mode_set(win->o_win, ELM_WIN_KEYBOARD_OFF);
|
||||
/* TODO: imf ? */
|
||||
|
||||
if (!(chl = _main_window_focused_channel_get(win))) return;
|
||||
|
||||
|
@ -171,8 +377,10 @@ _cb_size_job(void *data)
|
|||
Window *win;
|
||||
Channel *chl;
|
||||
Evas_Coord mw = 0, mh = 0;
|
||||
int rw = 0, rh = 0;
|
||||
|
||||
if (!(win = data)) return;
|
||||
win->size_job = NULL;
|
||||
|
||||
if (!(chl = _main_window_focused_channel_get(win))) return;
|
||||
|
||||
|
@ -180,7 +388,9 @@ _cb_size_job(void *data)
|
|||
elm_win_size_base_set(win->o_win, mw - chl->step_x, mh - chl->step_y);
|
||||
elm_win_size_step_set(win->o_win, chl->step_x, chl->step_y);
|
||||
evas_object_size_hint_min_set(win->o_bg, mw, mh);
|
||||
evas_object_resize(win->o_win, chl->req_w, chl->req_h);
|
||||
|
||||
if (_main_window_size_walk(win, &rw, &rh))
|
||||
evas_object_resize(win->o_win, rw, rh);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -211,6 +421,27 @@ _cb_size_hint(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event
|
|||
chl->window->size_job = ecore_job_add(_cb_size_job, chl->window);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_main_window_size_walk(Window *win, int *w, int *h)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
if (!win) return EINA_FALSE;
|
||||
if (!(chl = _main_window_focused_channel_get(win)))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (w) *w = chl->req_w;
|
||||
if (h) *h = chl->req_h;
|
||||
|
||||
if (!evas_object_data_get(chl->o_grid, "sizedone"))
|
||||
{
|
||||
evas_object_data_set(chl->o_grid, "sizedone", chl->o_grid);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_main_channel_theme_reload(Channel *chl)
|
||||
{
|
||||
|
@ -304,7 +535,7 @@ _main_channel_count_update(Window *win, Channel *chl)
|
|||
}
|
||||
|
||||
static Channel *
|
||||
_main_channel_new(Window *win)
|
||||
_main_channel_new(Window *win, const char *name)
|
||||
{
|
||||
Channel *chl;
|
||||
|
||||
|
@ -335,7 +566,7 @@ _main_channel_new(Window *win)
|
|||
_main_channel_theme_reload(chl);
|
||||
|
||||
/* create channel textgrid */
|
||||
chl->o_grid = _grid_add(win->o_win);
|
||||
chl->o_grid = _grid_add(win->o_win, name);
|
||||
_grid_colors_init(chl->o_grid, chl->o_bg);
|
||||
evas_object_size_hint_weight_set(chl->o_grid,
|
||||
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -456,6 +687,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
|
||||
/* set elm app info */
|
||||
elm_app_info_set(elm_main, "express", "themes/default.edj");
|
||||
elm_app_name_set("Express");
|
||||
|
||||
/* set elm theme overlay */
|
||||
elm_theme_overlay_add(NULL, _theme_default_get());
|
||||
|
@ -465,13 +697,17 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
|||
goto win_new_err;
|
||||
|
||||
/* create default channel */
|
||||
chl = _main_channel_new(win);
|
||||
chl = _main_channel_new(win, "#Channel 1");
|
||||
edje_object_part_swallow(win->o_base, "base.content", chl->o_bg);
|
||||
_cb_size_hint(chl, NULL, chl->o_grid, NULL);
|
||||
|
||||
_main_channel_focus(chl);
|
||||
_main_window_sizing_handle(win);
|
||||
evas_object_show(win->o_win);
|
||||
|
||||
chl = _main_channel_new(win, "#Channel 2");
|
||||
_cb_size_hint(chl, NULL, chl->o_grid, NULL);
|
||||
|
||||
/* start main loop */
|
||||
elm_run();
|
||||
|
||||
|
|
Loading…
Reference in New Issue