guess what the cat dragged in... "tabs" in terminology. just a
selector right now that u call up from keybindings. if u switch terms it kicks in with some visuals too. theme stuff is currently not done/ready at all. just recycling terminolgy bg edje atm. havent done anything to: 1. track "window titles" per term and put into tab term previews 2. make preview look decent (some shadowing and spacing between terms etc.) 3. track/display things like bell alerts still need to have a way to suspend/unsuspend invisible terms so media stuff pauses in playback etc. etc.
This commit is contained in:
parent
53fcba486a
commit
e60db60b12
1
README
1
README
|
@ -55,6 +55,7 @@ Shift+Keypad-Divide = Copy highlight to Clipboard (same as ctrl+c in gui apps)
|
||||||
Ctrl+PgUp = switch focus to previous terminal inside a window
|
Ctrl+PgUp = switch focus to previous terminal inside a window
|
||||||
Ctrl+PgDn = switch focus to next terminal inside a window
|
Ctrl+PgDn = switch focus to next terminal inside a window
|
||||||
Ctrl+Shift+t = create new terminal on top of current inside window (tabs) (not implemented)
|
Ctrl+Shift+t = create new terminal on top of current inside window (tabs) (not implemented)
|
||||||
|
Ctrl+Shift+Home = bring up "tab" switcher
|
||||||
Ctrl+Shift+PgUp = split terminal horizontally (1 term above the other)
|
Ctrl+Shift+PgUp = split terminal horizontally (1 term above the other)
|
||||||
Ctrl+Shift+PgDn = split terminal vertically (1 term to the left of the other)
|
Ctrl+Shift+PgDn = split terminal vertically (1 term to the left of the other)
|
||||||
Alt+Home = Enter command mode (enter commands to control terminology itself)
|
Alt+Home = Enter command mode (enter commands to control terminology itself)
|
||||||
|
|
|
@ -26,6 +26,7 @@ options_helpers.c options_helpers.h \
|
||||||
options_video.c options_video.h \
|
options_video.c options_video.h \
|
||||||
options_theme.c options_theme.h \
|
options_theme.c options_theme.h \
|
||||||
options_wallpaper.c options_wallpaper.h \
|
options_wallpaper.c options_wallpaper.h \
|
||||||
|
sel.c sel.h \
|
||||||
termio.c termio.h \
|
termio.c termio.h \
|
||||||
termcmd.c termcmd.h \
|
termcmd.c termcmd.h \
|
||||||
termiolink.c termiolink.h \
|
termiolink.c termiolink.h \
|
||||||
|
|
162
src/bin/main.c
162
src/bin/main.c
|
@ -12,6 +12,7 @@
|
||||||
#include "media.h"
|
#include "media.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
#include "sel.h"
|
||||||
|
|
||||||
#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8)
|
#if (ELM_VERSION_MAJOR == 1) && (ELM_VERSION_MINOR < 8)
|
||||||
#define PANES_TOP "left"
|
#define PANES_TOP "left"
|
||||||
|
@ -50,6 +51,7 @@ struct _Term
|
||||||
Evas_Object *term;
|
Evas_Object *term;
|
||||||
Evas_Object *media;
|
Evas_Object *media;
|
||||||
Evas_Object *popmedia;
|
Evas_Object *popmedia;
|
||||||
|
Evas_Object *sel;
|
||||||
Eina_List *popmedia_queue;
|
Eina_List *popmedia_queue;
|
||||||
int poptype, mediatype;
|
int poptype, mediatype;
|
||||||
int step_x, step_y, min_w, min_h, req_w, req_h;
|
int step_x, step_y, min_w, min_h, req_w, req_h;
|
||||||
|
@ -58,6 +60,7 @@ struct _Term
|
||||||
} down;
|
} down;
|
||||||
Eina_Bool focused : 1;
|
Eina_Bool focused : 1;
|
||||||
Eina_Bool hold : 1;
|
Eina_Bool hold : 1;
|
||||||
|
Eina_Bool unswallowed : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Split
|
struct _Split
|
||||||
|
@ -68,6 +71,7 @@ struct _Split
|
||||||
Term *term; // if leaf node this is not null - the CURRENT term from terms list
|
Term *term; // if leaf node this is not null - the CURRENT term from terms list
|
||||||
Eina_List *terms; // list of terms in the "tabs"
|
Eina_List *terms; // list of terms in the "tabs"
|
||||||
Evas_Object *panes; // null if a leaf node
|
Evas_Object *panes; // null if a leaf node
|
||||||
|
Evas_Object *sel; // multi "tab" selector is active
|
||||||
Eina_Bool horizontal : 1;
|
Eina_Bool horizontal : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -449,7 +453,7 @@ _term_focus(Term *term)
|
||||||
{
|
{
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
Term *term2;
|
Term *term2;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(term->wn->terms, l, term2)
|
EINA_LIST_FOREACH(term->wn->terms, l, term2)
|
||||||
{
|
{
|
||||||
if (term2 != term)
|
if (term2 != term)
|
||||||
|
@ -588,6 +592,7 @@ _cb_focus_in(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
{
|
{
|
||||||
Win *wn = data;
|
Win *wn = data;
|
||||||
Term *term;
|
Term *term;
|
||||||
|
Split *sp;
|
||||||
|
|
||||||
if (!wn->focused) elm_win_urgent_set(wn->win, EINA_FALSE);
|
if (!wn->focused) elm_win_urgent_set(wn->win, EINA_FALSE);
|
||||||
wn->focused = EINA_TRUE;
|
wn->focused = EINA_TRUE;
|
||||||
|
@ -595,8 +600,16 @@ _cb_focus_in(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
elm_object_focus_set(wn->cmdbox, EINA_TRUE);
|
elm_object_focus_set(wn->cmdbox, EINA_TRUE);
|
||||||
term = main_win_focused_term_get(wn);
|
term = main_win_focused_term_get(wn);
|
||||||
if (!term) return;
|
if (!term) return;
|
||||||
edje_object_signal_emit(term->bg, "focus,in", "terminology");
|
sp = _split_find(wn->win, term->term);
|
||||||
if (!wn->cmdbox_up) elm_object_focus_set(term->term, EINA_TRUE);
|
if (sp->sel)
|
||||||
|
{
|
||||||
|
if (!wn->cmdbox_up) elm_object_focus_set(sp->sel, EINA_TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(term->bg, "focus,in", "terminology");
|
||||||
|
if (!wn->cmdbox_up) elm_object_focus_set(term->term, EINA_TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1036,6 +1049,113 @@ _cb_command(void *data, Evas_Object *obj __UNUSED__, void *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sel_restore(Split *sp)
|
||||||
|
{
|
||||||
|
Eina_List *l;
|
||||||
|
Term *tm;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(sp->terms, l, tm)
|
||||||
|
{
|
||||||
|
if (tm->unswallowed)
|
||||||
|
{
|
||||||
|
evas_object_image_source_visible_set(tm->sel, EINA_TRUE);
|
||||||
|
edje_object_part_swallow(tm->bg, "terminology.content", tm->term);
|
||||||
|
tm->unswallowed = EINA_FALSE;
|
||||||
|
evas_object_show(tm->term);
|
||||||
|
tm->sel = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
evas_object_del(sp->sel);
|
||||||
|
sp->sel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sel_cb_selected(void *data, Evas_Object *obj __UNUSED__, void *info)
|
||||||
|
{
|
||||||
|
Split *sp = data;
|
||||||
|
Eina_List *l;
|
||||||
|
Term *tm;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(sp->terms, l, tm)
|
||||||
|
{
|
||||||
|
if (tm->sel == info)
|
||||||
|
{
|
||||||
|
_term_focus(tm);
|
||||||
|
_term_focus_show(sp, tm);
|
||||||
|
_sel_restore(sp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_sel_restore(sp);
|
||||||
|
_term_focus(sp->term);
|
||||||
|
_term_focus_show(sp, sp->term);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sel_cb_exit(void *data, Evas_Object *obj __UNUSED__, void *info __UNUSED__)
|
||||||
|
{
|
||||||
|
Split *sp = data;
|
||||||
|
_sel_restore(sp);
|
||||||
|
_term_focus(sp->term);
|
||||||
|
_term_focus_show(sp, sp->term);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sel_go(Split *sp, Term *term)
|
||||||
|
{
|
||||||
|
Eina_List *l;
|
||||||
|
Term *tm;
|
||||||
|
double z;
|
||||||
|
|
||||||
|
evas_object_hide(sp->term->bg);
|
||||||
|
sp->sel = sel_add(sp->wn->win);
|
||||||
|
EINA_LIST_FOREACH(sp->terms, l, tm)
|
||||||
|
{
|
||||||
|
edje_object_part_unswallow(tm->bg, tm->term);
|
||||||
|
evas_object_lower(tm->term);
|
||||||
|
evas_object_move(tm->term, 0, 0);
|
||||||
|
evas_object_show(tm->term);
|
||||||
|
evas_object_clip_unset(tm->term);
|
||||||
|
evas_object_image_source_visible_set(tm->sel, EINA_FALSE);
|
||||||
|
tm->unswallowed = EINA_TRUE;
|
||||||
|
|
||||||
|
tm->sel = termio_mirror_add(tm->term);
|
||||||
|
sel_entry_add(sp->sel, tm->sel, (tm == sp->term), tm->config);
|
||||||
|
}
|
||||||
|
if (!sp->parent)
|
||||||
|
edje_object_part_swallow(sp->wn->base, "terminology.content", sp->sel);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sp == sp->parent->s1)
|
||||||
|
{
|
||||||
|
elm_object_part_content_unset(sp->parent->panes, PANES_TOP);
|
||||||
|
elm_object_part_content_set(sp->parent->panes, PANES_TOP, sp->sel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elm_object_part_content_unset(sp->parent->panes, PANES_BOTTOM);
|
||||||
|
elm_object_part_content_set(sp->parent->panes, PANES_BOTTOM, sp->sel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
evas_object_show(sp->sel);
|
||||||
|
z = 1.0;
|
||||||
|
sel_go(sp->sel);
|
||||||
|
if (eina_list_count(sp->terms) >= 1)
|
||||||
|
z = 1.0 / (sqrt(eina_list_count(sp->terms)) * 0.8);
|
||||||
|
if (z > 1.0) z = 1.0;
|
||||||
|
sel_orig_zoom_set(sp->sel, z);
|
||||||
|
sel_zoom(sp->sel, z);
|
||||||
|
if (term != sp->term)
|
||||||
|
{
|
||||||
|
sel_entry_selected_set(sp->sel, term->sel);
|
||||||
|
sel_exit(sp->sel);
|
||||||
|
}
|
||||||
|
elm_object_focus_set(sp->sel, EINA_TRUE);
|
||||||
|
evas_object_smart_callback_add(sp->sel, "selected", _sel_cb_selected, sp);
|
||||||
|
evas_object_smart_callback_add(sp->sel, "exit", _sel_cb_exit, sp);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_prev(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
_cb_prev(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -1045,11 +1165,17 @@ _cb_prev(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
if (term->focused) term2 = _term_prev_get(term);
|
if (term->focused) term2 = _term_prev_get(term);
|
||||||
if (term2)
|
if (term2)
|
||||||
{
|
{
|
||||||
Split *sp;
|
Split *sp, *sp0;
|
||||||
|
|
||||||
_term_focus(term2);
|
sp0 = _split_find(term->wn->win, term->term);
|
||||||
sp = _split_find(term2->wn->win, term2->term);
|
sp = _split_find(term2->wn->win, term2->term);
|
||||||
if (sp) _term_focus_show(sp, term2);
|
if (sp == sp0)
|
||||||
|
_sel_go(sp, term2);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_term_focus(term2);
|
||||||
|
if (sp) _term_focus_show(sp, term2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1062,11 +1188,17 @@ _cb_next(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
if (term->focused) term2 = _term_next_get(term);
|
if (term->focused) term2 = _term_next_get(term);
|
||||||
if (term2)
|
if (term2)
|
||||||
{
|
{
|
||||||
Split *sp;
|
Split *sp, *sp0;
|
||||||
|
|
||||||
_term_focus(term2);
|
sp0 = _split_find(term->wn->win, term->term);
|
||||||
sp = _split_find(term2->wn->win, term2->term);
|
sp = _split_find(term2->wn->win, term2->term);
|
||||||
if (sp) _term_focus_show(sp, term2);
|
if (sp == sp0)
|
||||||
|
_sel_go(sp, term2);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_term_focus(term2);
|
||||||
|
if (sp) _term_focus_show(sp, term2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,6 +1210,17 @@ _cb_new(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED
|
||||||
main_new(term->wn->win, term->term);
|
main_new(term->wn->win, term->term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cb_select(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
|
{
|
||||||
|
Term *term = data;
|
||||||
|
Split *sp;
|
||||||
|
|
||||||
|
sp = _split_find(term->wn->win, term->term);
|
||||||
|
_sel_go(sp, term);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cb_split_h(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
_cb_split_h(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -1669,6 +1812,7 @@ main_term_new(Win *wn, Config *config, const char *cmd,
|
||||||
evas_object_smart_callback_add(o, "prev", _cb_prev, term);
|
evas_object_smart_callback_add(o, "prev", _cb_prev, term);
|
||||||
evas_object_smart_callback_add(o, "next", _cb_next, term);
|
evas_object_smart_callback_add(o, "next", _cb_next, term);
|
||||||
evas_object_smart_callback_add(o, "new", _cb_new, term);
|
evas_object_smart_callback_add(o, "new", _cb_new, term);
|
||||||
|
evas_object_smart_callback_add(o, "select", _cb_select, term);
|
||||||
evas_object_smart_callback_add(o, "split,h", _cb_split_h, term);
|
evas_object_smart_callback_add(o, "split,h", _cb_split_h, term);
|
||||||
evas_object_smart_callback_add(o, "split,v", _cb_split_v, term);
|
evas_object_smart_callback_add(o, "split,v", _cb_split_v, term);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
|
@ -0,0 +1,519 @@
|
||||||
|
#include "private.h"
|
||||||
|
|
||||||
|
#include <Elementary.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "sel.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
typedef struct _Sel Sel;
|
||||||
|
typedef struct _Entry Entry;
|
||||||
|
|
||||||
|
struct _Sel
|
||||||
|
{
|
||||||
|
Evas_Object_Smart_Clipped_Data __clipped_data;
|
||||||
|
Evas_Object *clip, *o_event;
|
||||||
|
Ecore_Animator *anim;
|
||||||
|
Ecore_Timer *autozoom_timeout;
|
||||||
|
Eina_List *items;
|
||||||
|
double t_start, t_total;
|
||||||
|
double zoom, zoom0, zoom1;
|
||||||
|
double last_cmd;
|
||||||
|
double interp;
|
||||||
|
double orig_zoom;
|
||||||
|
Evas_Coord px, px0, px1;
|
||||||
|
Evas_Coord py, py0, py1;
|
||||||
|
int w, h;
|
||||||
|
struct {
|
||||||
|
Evas_Coord x, y;
|
||||||
|
Eina_Bool down : 1;
|
||||||
|
} down;
|
||||||
|
Eina_Bool select_me : 1;
|
||||||
|
Eina_Bool exit_me : 1;
|
||||||
|
Eina_Bool exit_on_sel : 1;
|
||||||
|
Eina_Bool exit_now : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Entry
|
||||||
|
{
|
||||||
|
Evas_Object *obj, *bg;
|
||||||
|
Eina_Bool selected : 1;
|
||||||
|
Eina_Bool selected_before : 1;
|
||||||
|
Eina_Bool selected_orig : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Evas_Smart *_smart = NULL;
|
||||||
|
static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
|
||||||
|
|
||||||
|
static void _smart_calculate(Evas_Object *obj);
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
||||||
|
{
|
||||||
|
Evas_Event_Mouse_Down *ev = event;
|
||||||
|
Sel *sd = evas_object_smart_data_get(data);
|
||||||
|
if (!sd) return;
|
||||||
|
|
||||||
|
if (sd->down.down) return;
|
||||||
|
if (ev->button != 1) return;
|
||||||
|
sd->down.x = ev->canvas.x;
|
||||||
|
sd->down.y = ev->canvas.y;
|
||||||
|
sd->down.down = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
||||||
|
{
|
||||||
|
Evas_Event_Mouse_Down *ev = event;
|
||||||
|
Sel *sd = evas_object_smart_data_get(data);
|
||||||
|
Evas_Coord dx, dy;
|
||||||
|
if (!sd) return;
|
||||||
|
|
||||||
|
if (!sd->down.down) return;
|
||||||
|
sd->down.down = EINA_FALSE;
|
||||||
|
dx = abs(ev->canvas.x - sd->down.x);
|
||||||
|
dy = abs(ev->canvas.y - sd->down.y);
|
||||||
|
if ((dx <= elm_config_finger_size_get()) &&
|
||||||
|
(dy <= elm_config_finger_size_get()))
|
||||||
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_autozoom_reset(void *data)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(data);
|
||||||
|
if (!sd) return EINA_FALSE;
|
||||||
|
sd->autozoom_timeout = NULL;
|
||||||
|
sel_zoom(data, sd->orig_zoom);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_autozoom(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
double t = ecore_loop_time_get();
|
||||||
|
if (!sd) return;
|
||||||
|
if ((t - sd->last_cmd) < 0.5)
|
||||||
|
{
|
||||||
|
sel_zoom(obj, sd->zoom * 0.9);
|
||||||
|
}
|
||||||
|
sd->last_cmd = t;
|
||||||
|
if (sd->autozoom_timeout) ecore_timer_del(sd->autozoom_timeout);
|
||||||
|
sd->autozoom_timeout = ecore_timer_add(0.5, _autozoom_reset, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
|
||||||
|
{
|
||||||
|
Evas_Event_Key_Down *ev = event;
|
||||||
|
Sel *sd = evas_object_smart_data_get(data);
|
||||||
|
Eina_List *l;
|
||||||
|
Entry *en;
|
||||||
|
if (!sd) return;
|
||||||
|
if ((!strcmp(ev->keyname, "Next")) ||
|
||||||
|
(!strcmp(ev->keyname, "Right")))
|
||||||
|
{
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->selected)
|
||||||
|
{
|
||||||
|
if (l->next)
|
||||||
|
{
|
||||||
|
en = l->next->data;
|
||||||
|
sel_entry_selected_set(obj, en->obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sd->exit_now = EINA_FALSE;
|
||||||
|
_autozoom(data);
|
||||||
|
}
|
||||||
|
else if ((!strcmp(ev->keyname, "Prior")) ||
|
||||||
|
(!strcmp(ev->keyname, "Left")))
|
||||||
|
{
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->selected)
|
||||||
|
{
|
||||||
|
if (l->prev)
|
||||||
|
{
|
||||||
|
en = l->prev->data;
|
||||||
|
sel_entry_selected_set(obj, en->obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sd->exit_now = EINA_FALSE;
|
||||||
|
_autozoom(data);
|
||||||
|
}
|
||||||
|
else if ((!strcmp(ev->keyname, "Return")) ||
|
||||||
|
(!strcmp(ev->keyname, "KP_Enter")) ||
|
||||||
|
(!strcmp(ev->keyname, "space")))
|
||||||
|
{
|
||||||
|
sd->select_me = EINA_TRUE;
|
||||||
|
sd->exit_me = EINA_FALSE;
|
||||||
|
if (sd->autozoom_timeout)
|
||||||
|
{
|
||||||
|
ecore_timer_del(sd->autozoom_timeout);
|
||||||
|
sd->autozoom_timeout = NULL;
|
||||||
|
}
|
||||||
|
sel_zoom(data, 1.0);
|
||||||
|
}
|
||||||
|
else if (!strcmp(ev->keyname, "Escape"))
|
||||||
|
{
|
||||||
|
Evas_Object *entry = NULL;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->selected_orig) entry = en->obj;
|
||||||
|
}
|
||||||
|
if (entry) sel_entry_selected_set(obj, entry);
|
||||||
|
sd->select_me = EINA_FALSE;
|
||||||
|
sd->exit_me = EINA_TRUE;
|
||||||
|
if (sd->autozoom_timeout)
|
||||||
|
{
|
||||||
|
ecore_timer_del(sd->autozoom_timeout);
|
||||||
|
sd->autozoom_timeout = NULL;
|
||||||
|
}
|
||||||
|
sel_zoom(data, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_layout(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
int iw, ih, x, y;
|
||||||
|
Evas_Coord ox, oy, ow, oh, w, h, px, py, ww, hh;
|
||||||
|
Eina_List *l;
|
||||||
|
Entry *en;
|
||||||
|
if (!sd) return;
|
||||||
|
iw = sqrt(eina_list_count(sd->items));
|
||||||
|
if (iw < 1) iw = 1;
|
||||||
|
ih = (eina_list_count(sd->items) + (iw - 1)) / iw;
|
||||||
|
if (ih < 1) ih = 1;
|
||||||
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
||||||
|
w = ow * sd->zoom;
|
||||||
|
h = oh * sd->zoom;
|
||||||
|
x = y = 0;
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->selected_before)
|
||||||
|
{
|
||||||
|
sd->px0 = (x * w);
|
||||||
|
sd->py0 = (y * h);
|
||||||
|
}
|
||||||
|
if (en->selected)
|
||||||
|
{
|
||||||
|
sd->px1 = (x * w);
|
||||||
|
sd->py1 = (y * h);
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
if (x >= iw)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sd->px = sd->px0 + ((sd->px1 - sd->px0) * sd->interp);
|
||||||
|
sd->py = sd->py0 + ((sd->py1 - sd->py0) * sd->interp);
|
||||||
|
|
||||||
|
px = sd->px;
|
||||||
|
py = sd->py;
|
||||||
|
|
||||||
|
if ((iw > 0) && (w > 0) && (ih > 0) && (h > 0))
|
||||||
|
{
|
||||||
|
ww = iw * w;
|
||||||
|
hh = ih * h;
|
||||||
|
if (ww <= w) px = (ww - ow) / 2;
|
||||||
|
else px = px - ((px * (ow - w)) / (ww - w));
|
||||||
|
if (hh <= h) py = (hh - oh) / 2;
|
||||||
|
else py = py - ((py * (oh - h)) / (hh - h));
|
||||||
|
}
|
||||||
|
x = y = 0;
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
evas_object_move(en->bg, ox + (x * w) - px, oy + (y * h) - py);
|
||||||
|
evas_object_resize(en->bg, w, h);
|
||||||
|
evas_object_show(en->obj);
|
||||||
|
evas_object_show(en->bg);
|
||||||
|
x++;
|
||||||
|
if (x >= iw)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_anim_cb(void *data)
|
||||||
|
{
|
||||||
|
Evas_Object *obj = data;
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
double t = 1.0;
|
||||||
|
if (!sd) return EINA_FALSE;
|
||||||
|
if (sd->t_total > 0.0)
|
||||||
|
{
|
||||||
|
t = (ecore_loop_time_get() - sd->t_start) / sd->t_total;
|
||||||
|
if (t < 0.0) t = 0.0;
|
||||||
|
else if (t > 1.0) t = 1.0;
|
||||||
|
}
|
||||||
|
sd->interp = ecore_animator_pos_map(t, ECORE_POS_MAP_DECELERATE, 0, 0);
|
||||||
|
sd->zoom = sd->zoom0 + ((sd->zoom1 - sd->zoom0) * sd->interp);
|
||||||
|
_layout(obj);
|
||||||
|
if (t >= 1.0)
|
||||||
|
{
|
||||||
|
sd->anim = NULL;
|
||||||
|
if ((sd->exit_on_sel) && (!sd->exit_now))
|
||||||
|
{
|
||||||
|
if (sd->autozoom_timeout)
|
||||||
|
{
|
||||||
|
ecore_timer_del(sd->autozoom_timeout);
|
||||||
|
sd->autozoom_timeout = NULL;
|
||||||
|
}
|
||||||
|
sd->exit_now = EINA_TRUE;
|
||||||
|
sel_zoom(obj, 1.0);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
if ((sd->select_me) || (sd->exit_now))
|
||||||
|
{
|
||||||
|
Eina_List *l;
|
||||||
|
Entry *en;
|
||||||
|
Evas_Object *entry = NULL;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->selected) entry = en->obj;
|
||||||
|
}
|
||||||
|
if (entry) evas_object_smart_callback_call(obj, "selected", entry);
|
||||||
|
}
|
||||||
|
else if (sd->exit_me)
|
||||||
|
evas_object_smart_callback_call(obj, "exit", NULL);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_transit(Evas_Object *obj, double tim)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
sd->px0 = sd->px;
|
||||||
|
sd->py0 = sd->py;
|
||||||
|
sd->zoom0 = sd->zoom;
|
||||||
|
sd->t_start = ecore_loop_time_get();
|
||||||
|
sd->t_total = tim;
|
||||||
|
sd->interp = 0.0;
|
||||||
|
if (!sd->anim) sd->anim = ecore_animator_add(_anim_cb, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_smart_add(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd;
|
||||||
|
Evas_Object *o;
|
||||||
|
|
||||||
|
sd = calloc(1, sizeof(Sel));
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(sd);
|
||||||
|
evas_object_smart_data_set(obj, sd);
|
||||||
|
|
||||||
|
_parent_sc.add(obj);
|
||||||
|
|
||||||
|
o = evas_object_rectangle_add(evas_object_evas_get(obj));
|
||||||
|
evas_object_smart_member_add(o, obj);
|
||||||
|
sd->clip = o;
|
||||||
|
evas_object_color_set(o, 255, 255, 255, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_smart_del(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
Entry *en;
|
||||||
|
if (!sd) return;
|
||||||
|
if (sd->clip) evas_object_del(sd->clip);
|
||||||
|
if (sd->o_event) evas_object_del(sd->o_event);
|
||||||
|
if (sd->anim) ecore_animator_del(sd->anim);
|
||||||
|
if (sd->autozoom_timeout) ecore_timer_del(sd->autozoom_timeout);
|
||||||
|
EINA_LIST_FREE(sd->items, en)
|
||||||
|
{
|
||||||
|
evas_object_del(en->obj);
|
||||||
|
evas_object_del(en->bg);
|
||||||
|
free(en);
|
||||||
|
}
|
||||||
|
_parent_sc.del(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
Evas_Coord ox, oy, ow, oh;
|
||||||
|
if (!sd) return;
|
||||||
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
||||||
|
if ((ow == w) && (oh == h)) return;
|
||||||
|
evas_object_smart_changed(obj);
|
||||||
|
evas_object_resize(sd->clip, ow, oh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_smart_calculate(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
Evas_Coord ox, oy, ow, oh;
|
||||||
|
|
||||||
|
if (!sd) return;
|
||||||
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
||||||
|
sd->w = ow;
|
||||||
|
sd->h = oh;
|
||||||
|
evas_object_move(sd->clip, ox, oy);
|
||||||
|
evas_object_resize(sd->clip, ow, oh);
|
||||||
|
_layout(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_smart_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
evas_object_smart_changed(obj);
|
||||||
|
}
|
||||||
|
static void
|
||||||
|
_smart_init(void)
|
||||||
|
{
|
||||||
|
static Evas_Smart_Class sc;
|
||||||
|
|
||||||
|
evas_object_smart_clipped_smart_set(&_parent_sc);
|
||||||
|
sc = _parent_sc;
|
||||||
|
sc.name = "media";
|
||||||
|
sc.version = EVAS_SMART_CLASS_VERSION;
|
||||||
|
sc.add = _smart_add;
|
||||||
|
sc.del = _smart_del;
|
||||||
|
sc.resize = _smart_resize;
|
||||||
|
sc.move = _smart_move;
|
||||||
|
sc.calculate = _smart_calculate;
|
||||||
|
_smart = evas_smart_class_new(&sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
sel_add(Evas_Object *parent)
|
||||||
|
{
|
||||||
|
Evas *e;
|
||||||
|
Evas_Object *obj;
|
||||||
|
Sel *sd;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
||||||
|
e = evas_object_evas_get(parent);
|
||||||
|
if (!e) return NULL;
|
||||||
|
|
||||||
|
if (!_smart) _smart_init();
|
||||||
|
obj = evas_object_smart_add(e, _smart);
|
||||||
|
sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return obj;
|
||||||
|
|
||||||
|
sd->o_event = evas_object_rectangle_add(e);
|
||||||
|
evas_object_color_set(sd->o_event, 0, 0, 0, 0);
|
||||||
|
evas_object_repeat_events_set(sd->o_event, EINA_TRUE);
|
||||||
|
evas_object_smart_member_add(sd->o_event, obj);
|
||||||
|
evas_object_clip_set(sd->o_event, sd->clip);
|
||||||
|
evas_object_show(sd->o_event);
|
||||||
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
|
_mouse_down_cb, obj);
|
||||||
|
evas_object_event_callback_add(sd->o_event, EVAS_CALLBACK_MOUSE_UP,
|
||||||
|
_mouse_up_cb, obj);
|
||||||
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
|
||||||
|
_key_down_cb, obj);
|
||||||
|
sd->zoom = 1.0;
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Config *config)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
Entry *en = calloc(1, sizeof(Entry));
|
||||||
|
if (!en) return;
|
||||||
|
sd->items = eina_list_append(sd->items, en);
|
||||||
|
en->obj = entry;
|
||||||
|
en->selected = selected;
|
||||||
|
en->selected_before = selected;
|
||||||
|
en->selected_orig = selected;
|
||||||
|
en->bg = edje_object_add(evas_object_evas_get(obj));
|
||||||
|
theme_apply(en->bg, config, "terminology/background");
|
||||||
|
evas_object_smart_member_add(en->bg, obj);
|
||||||
|
evas_object_clip_set(en->bg, sd->clip);
|
||||||
|
edje_object_part_swallow(en->bg, "terminology.content", en->obj);
|
||||||
|
evas_object_show(en->obj);
|
||||||
|
evas_object_stack_below(en->bg, sd->o_event);
|
||||||
|
if (en->selected)
|
||||||
|
edje_object_signal_emit(en->bg, "focus,in", "terminology");
|
||||||
|
sd->interp = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_go(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
_layout(obj);
|
||||||
|
evas_object_show(sd->clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_entry_selected_set(Evas_Object *obj, Evas_Object *entry)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
Eina_List *l;
|
||||||
|
Entry *en;
|
||||||
|
if (!sd) return;
|
||||||
|
EINA_LIST_FOREACH(sd->items, l, en)
|
||||||
|
{
|
||||||
|
if (en->obj == entry)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(en->bg, "focus,in", "terminology");
|
||||||
|
en->selected = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else if (en->obj != entry)
|
||||||
|
{
|
||||||
|
if (en->selected)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(en->bg, "focus,out", "terminology");
|
||||||
|
en->selected = EINA_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
en->selected_before = EINA_FALSE;
|
||||||
|
}
|
||||||
|
_transit(obj, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_zoom(Evas_Object *obj, double zoom)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
sd->zoom1 = zoom;
|
||||||
|
_transit(obj, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_orig_zoom_set(Evas_Object *obj, double zoom)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
sd->orig_zoom = zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sel_exit(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Sel *sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
sd->exit_on_sel = EINA_TRUE;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef _SEL_H__
|
||||||
|
#define _SEL_H__ 1
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
Evas_Object *sel_add(Evas_Object *parent);
|
||||||
|
void sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Config *config);
|
||||||
|
void sel_go(Evas_Object *obj);
|
||||||
|
void sel_entry_selected_set(Evas_Object *obj, Evas_Object *entry);
|
||||||
|
void sel_zoom(Evas_Object *obj, double zoom);
|
||||||
|
void sel_orig_zoom_set(Evas_Object *obj, double zoom);
|
||||||
|
void sel_exit(Evas_Object *obj);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1372,6 +1372,11 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
||||||
evas_object_smart_callback_call(data, "new", NULL);
|
evas_object_smart_callback_call(data, "new", NULL);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(ev->keyname, "Home"))
|
||||||
|
{
|
||||||
|
evas_object_smart_callback_call(data, "select", NULL);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) &&
|
||||||
(!evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
(!evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
|
||||||
|
@ -3503,12 +3508,15 @@ termio_mirror_add(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
Evas_Object *img;
|
Evas_Object *img;
|
||||||
Termio *sd = evas_object_smart_data_get(obj);
|
Termio *sd = evas_object_smart_data_get(obj);
|
||||||
|
Evas_Coord w = 0, h = 0;
|
||||||
if (!sd) return NULL;
|
if (!sd) return NULL;
|
||||||
img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
img = evas_object_image_filled_add(evas_object_evas_get(obj));
|
||||||
evas_object_image_source_set(img, obj);
|
evas_object_image_source_set(img, obj);
|
||||||
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||||
|
evas_object_resize(img, w, h);
|
||||||
sd->mirrors = eina_list_append(sd->mirrors, img);
|
sd->mirrors = eina_list_append(sd->mirrors, img);
|
||||||
evas_object_data_set(img, "termio", obj);
|
evas_object_data_set(img, "termio", obj);
|
||||||
evas_object_event_callback_add(img, EVAS_CALLBACK_DEL,
|
evas_object_event_callback_add(img, EVAS_CALLBACK_DEL,
|
||||||
_smart_mirror_del, obj);
|
_smart_mirror_del, obj);
|
||||||
return obj;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue