Added tab / focus support to e_dialog's buttons.
SVN revision: 16896
This commit is contained in:
parent
c8c78448bf
commit
98f2fa3399
|
@ -1,3 +1,149 @@
|
||||||
|
#define FOCUS_COLOR 255 255 255 200
|
||||||
|
|
||||||
|
#define FOCUS_RECT(x1, y1, x2, y2, offx1, offy1, offx2, offy2) \
|
||||||
|
part { \
|
||||||
|
name: "focus_rect_top"; \
|
||||||
|
mouse_events: 0; \
|
||||||
|
description { \
|
||||||
|
state: "default" 0.0; \
|
||||||
|
visible: 0; \
|
||||||
|
color: FOCUS_COLOR; \
|
||||||
|
rel1 { \
|
||||||
|
relative: x1 y1; \
|
||||||
|
offset: offx1 offy1; \
|
||||||
|
} \
|
||||||
|
rel2 { \
|
||||||
|
relative: x2 y1; \
|
||||||
|
offset: offx2 offy1; \
|
||||||
|
} \
|
||||||
|
image { \
|
||||||
|
normal: "focus.png"; \
|
||||||
|
} \
|
||||||
|
fill { \
|
||||||
|
smooth: 0; \
|
||||||
|
size { \
|
||||||
|
relative: 0 0; \
|
||||||
|
offset: 32 32; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
description { \
|
||||||
|
state: "focused" 0.0; \
|
||||||
|
inherit: "default" 0.0; \
|
||||||
|
visible: 1; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
part { \
|
||||||
|
name: "focus_rect_bottom"; \
|
||||||
|
mouse_events: 0; \
|
||||||
|
description { \
|
||||||
|
state: "default" 0.0; \
|
||||||
|
visible: 0; \
|
||||||
|
color: FOCUS_COLOR; \
|
||||||
|
rel1 { \
|
||||||
|
relative: x1 y2; \
|
||||||
|
offset: offx1 offy2; \
|
||||||
|
} \
|
||||||
|
rel2 { \
|
||||||
|
relative: x2 y2; \
|
||||||
|
offset: offx2 offy2; \
|
||||||
|
} \
|
||||||
|
image { \
|
||||||
|
normal: "focus.png"; \
|
||||||
|
} \
|
||||||
|
fill { \
|
||||||
|
smooth: 0; \
|
||||||
|
size { \
|
||||||
|
relative: 0 0; \
|
||||||
|
offset: 32 32; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
description { \
|
||||||
|
state: "focused" 0.0; \
|
||||||
|
inherit: "default" 0.0; \
|
||||||
|
visible: 1; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
part { \
|
||||||
|
name: "focus_rect_left"; \
|
||||||
|
mouse_events: 0; \
|
||||||
|
description { \
|
||||||
|
state: "default" 0.0; \
|
||||||
|
visible: 0; \
|
||||||
|
color: FOCUS_COLOR; \
|
||||||
|
rel1 { \
|
||||||
|
relative: x1 y1; \
|
||||||
|
offset: offx1 (offy1 + 1); \
|
||||||
|
} \
|
||||||
|
rel2 { \
|
||||||
|
relative: x1 y2; \
|
||||||
|
offset: offx1 (offy2 - 1); \
|
||||||
|
} \
|
||||||
|
image { \
|
||||||
|
normal: "focus.png"; \
|
||||||
|
} \
|
||||||
|
fill { \
|
||||||
|
smooth: 0; \
|
||||||
|
size { \
|
||||||
|
relative: 0 0; \
|
||||||
|
offset: 32 32; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
description { \
|
||||||
|
state: "focused" 0.0; \
|
||||||
|
inherit: "default" 0.0; \
|
||||||
|
visible: 1; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
part { \
|
||||||
|
name: "focus_rect_right"; \
|
||||||
|
mouse_events: 0; \
|
||||||
|
description { \
|
||||||
|
state: "default" 0.0; \
|
||||||
|
visible: 0; \
|
||||||
|
color: FOCUS_COLOR; \
|
||||||
|
rel1 { \
|
||||||
|
relative: x2 y1; \
|
||||||
|
offset: offx2 (offy1 + 1); \
|
||||||
|
} \
|
||||||
|
rel2 { \
|
||||||
|
relative: x2 y2; \
|
||||||
|
offset: offx2 (offy2 - 1); \
|
||||||
|
} \
|
||||||
|
image { \
|
||||||
|
normal: "focus.png"; \
|
||||||
|
} \
|
||||||
|
fill { \
|
||||||
|
smooth: 0; \
|
||||||
|
size { \
|
||||||
|
relative: 0 0; \
|
||||||
|
offset: 32 32; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
description { \
|
||||||
|
state: "focused" 0.0; \
|
||||||
|
inherit: "default" 0.0; \
|
||||||
|
visible: 1; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FOCUS_ACTION \
|
||||||
|
action: STATE_SET "focused" 0.0; \
|
||||||
|
target: "focus_rect_top"; \
|
||||||
|
target: "focus_rect_bottom"; \
|
||||||
|
target: "focus_rect_left"; \
|
||||||
|
target: "focus_rect_right";
|
||||||
|
|
||||||
|
#define UNFOCUS_ACTION \
|
||||||
|
action: STATE_SET "default" 0.0; \
|
||||||
|
target: "focus_rect_top"; \
|
||||||
|
target: "focus_rect_bottom"; \
|
||||||
|
target: "focus_rect_left"; \
|
||||||
|
target: "focus_rect_right";
|
||||||
|
|
||||||
images {
|
images {
|
||||||
image: "e17_menu_bg_border.png" COMP;
|
image: "e17_menu_bg_border.png" COMP;
|
||||||
// image: "e17_menu_bg.png" COMP;
|
// image: "e17_menu_bg.png" COMP;
|
||||||
|
@ -6,6 +152,7 @@ images {
|
||||||
image: "e17_button2.png" COMP;
|
image: "e17_button2.png" COMP;
|
||||||
image: "e17_button.png" COMP;
|
image: "e17_button.png" COMP;
|
||||||
image: "e17_dialog_watermark.png" COMP;
|
image: "e17_dialog_watermark.png" COMP;
|
||||||
|
image: "focus.png" COMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
styles
|
styles
|
||||||
|
@ -306,6 +453,7 @@ group {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FOCUS_RECT(0.0, 0.0, 1.0, 1.0, 7, 7, -8, -8)
|
||||||
}
|
}
|
||||||
programs {
|
programs {
|
||||||
program {
|
program {
|
||||||
|
@ -335,6 +483,18 @@ group {
|
||||||
action: STATE_SET "visible" 0.0;
|
action: STATE_SET "visible" 0.0;
|
||||||
target: "icon_swallow";
|
target: "icon_swallow";
|
||||||
}
|
}
|
||||||
|
program {
|
||||||
|
name: "button_focus";
|
||||||
|
signal: "focus";
|
||||||
|
source: "";
|
||||||
|
FOCUS_ACTION
|
||||||
|
}
|
||||||
|
program {
|
||||||
|
name: "button_unfocus";
|
||||||
|
signal: "unfocus";
|
||||||
|
source: "";
|
||||||
|
UNFOCUS_ACTION
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1131,6 +1131,7 @@ ACT_FN_GO(exit)
|
||||||
e_dialog_icon_set(dia, "enlightenment/exit", 64);
|
e_dialog_icon_set(dia, "enlightenment/exit", 64);
|
||||||
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok, NULL);
|
e_dialog_button_add(dia, _("Yes"), NULL, _e_actions_cb_exit_dialog_ok, NULL);
|
||||||
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
|
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
|
||||||
|
e_dialog_button_focus (dia, 1);
|
||||||
e_win_centered_set(dia->win, 1);
|
e_win_centered_set(dia->win, 1);
|
||||||
e_dialog_show(dia);
|
e_dialog_show(dia);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct _E_Dialog_Button
|
||||||
static void _e_dialog_free(E_Dialog *dia);
|
static void _e_dialog_free(E_Dialog *dia);
|
||||||
static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
static void _e_dialog_cb_delete(E_Win *win);
|
static void _e_dialog_cb_delete(E_Win *win);
|
||||||
|
static int _e_dialog_key_down_cb (void *data, int type, void *event);
|
||||||
|
|
||||||
/* local subsystem globals */
|
/* local subsystem globals */
|
||||||
|
|
||||||
|
@ -72,6 +73,9 @@ e_dialog_new(E_Container *con)
|
||||||
e_box_align_set(o, 0.5, 0.5);
|
e_box_align_set(o, 0.5, 0.5);
|
||||||
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o);
|
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
|
dia->focused = NULL;
|
||||||
|
dia->key_down_handler = ecore_event_handler_add (ECORE_X_EVENT_KEY_DOWN, _e_dialog_key_down_cb, dia);
|
||||||
|
|
||||||
return dia;
|
return dia;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +122,31 @@ e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *
|
||||||
dia->buttons = evas_list_append(dia->buttons, db);
|
dia->buttons = evas_list_append(dia->buttons, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
e_dialog_button_focus(E_Dialog *dia, int button)
|
||||||
|
{
|
||||||
|
E_Dialog_Button *db = NULL;
|
||||||
|
|
||||||
|
db = evas_list_nth (dia->buttons, button);
|
||||||
|
|
||||||
|
if (!db)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (dia->focused)
|
||||||
|
{
|
||||||
|
E_Dialog_Button *focused;
|
||||||
|
|
||||||
|
focused = dia->focused->data;
|
||||||
|
if (focused)
|
||||||
|
edje_object_signal_emit(focused->obj, "unfocus", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
dia->focused = evas_list_nth_list(dia->buttons, button);
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_dialog_title_set(E_Dialog *dia, char *title)
|
e_dialog_title_set(E_Dialog *dia, char *title)
|
||||||
{
|
{
|
||||||
|
@ -187,6 +216,7 @@ _e_dialog_free(E_Dialog *dia)
|
||||||
if (dia->icon_object) evas_object_del(dia->icon_object);
|
if (dia->icon_object) evas_object_del(dia->icon_object);
|
||||||
if (dia->box_object) evas_object_del(dia->box_object);
|
if (dia->box_object) evas_object_del(dia->box_object);
|
||||||
if (dia->bg_object) evas_object_del(dia->bg_object);
|
if (dia->bg_object) evas_object_del(dia->bg_object);
|
||||||
|
ecore_event_handler_del (dia->key_down_handler);
|
||||||
e_object_del(E_OBJECT(dia->win));
|
e_object_del(E_OBJECT(dia->win));
|
||||||
free(dia);
|
free(dia);
|
||||||
}
|
}
|
||||||
|
@ -203,6 +233,63 @@ _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission,
|
||||||
e_object_del(E_OBJECT(db->dialog));
|
e_object_del(E_OBJECT(db->dialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Implement shift-tab and left arrow */
|
||||||
|
static int
|
||||||
|
_e_dialog_key_down_cb (void *data, int type, void *event)
|
||||||
|
{
|
||||||
|
Ecore_X_Event_Key_Down *ev = event;
|
||||||
|
E_Dialog *dia = data;
|
||||||
|
|
||||||
|
if (!strcmp(ev->keyname, "Tab") || !strcmp(ev->keyname, "Right"))
|
||||||
|
{
|
||||||
|
if (dia->focused && dia->buttons)
|
||||||
|
{
|
||||||
|
if (dia->focused->next)
|
||||||
|
{
|
||||||
|
E_Dialog_Button *db;
|
||||||
|
|
||||||
|
db = dia->focused->data;
|
||||||
|
edje_object_signal_emit(db->obj, "unfocus", "");
|
||||||
|
|
||||||
|
dia->focused = dia->focused->next;
|
||||||
|
db = dia->focused->data;
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
E_Dialog_Button *db;
|
||||||
|
|
||||||
|
db = dia->focused->data;
|
||||||
|
edje_object_signal_emit(db->obj, "unfocus", "");
|
||||||
|
|
||||||
|
dia->focused = dia->buttons;
|
||||||
|
db = evas_list_data (dia->focused);
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
E_Dialog_Button *db;
|
||||||
|
|
||||||
|
dia->focused = dia->buttons;
|
||||||
|
|
||||||
|
db = dia->focused->data;
|
||||||
|
edje_object_signal_emit(db->obj, "focus", "");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!strcmp(ev->keyname, "Enter") || !strcmp(ev->keyname, "Return") ||
|
||||||
|
!strcmp(ev->keyname, "Space")) && dia->focused)
|
||||||
|
{
|
||||||
|
E_Dialog_Button *db;
|
||||||
|
|
||||||
|
db = evas_list_data (dia->focused);
|
||||||
|
edje_object_signal_emit(db->obj, "click", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_dialog_cb_delete(E_Win *win)
|
_e_dialog_cb_delete(E_Win *win)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,11 +21,14 @@ struct _E_Dialog
|
||||||
Evas_Object *text_object;
|
Evas_Object *text_object;
|
||||||
Evas_Object *icon_object;
|
Evas_Object *icon_object;
|
||||||
Evas_List *buttons;
|
Evas_List *buttons;
|
||||||
|
Evas_List *focused;
|
||||||
|
Ecore_Event_Handler *key_down_handler;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI E_Dialog *e_dialog_new (E_Container *con);
|
EAPI E_Dialog *e_dialog_new (E_Container *con);
|
||||||
EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data);
|
EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data);
|
||||||
|
EAPI int e_dialog_button_focus(E_Dialog *dia, int button);
|
||||||
EAPI void e_dialog_title_set (E_Dialog *dia, char *title);
|
EAPI void e_dialog_title_set (E_Dialog *dia, char *title);
|
||||||
EAPI void e_dialog_text_set (E_Dialog *dia, char *text);
|
EAPI void e_dialog_text_set (E_Dialog *dia, char *text);
|
||||||
EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size);
|
EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size);
|
||||||
|
|
Loading…
Reference in New Issue