forked from enlightenment/enlightenment
Make illume-mode-toggle from e_button to edje
SVN revision: 49921
This commit is contained in:
parent
21e6cc0488
commit
d8326f3fc1
|
@ -35515,6 +35515,216 @@ collections {
|
|||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/*** MOD: ILLUME-MODE-TOGGLE ***/
|
||||
|
||||
group {
|
||||
name: "e/modules/illume_mode_toggle/main";
|
||||
images.image: "illume-mode-single.png" COMP;
|
||||
images.image: "illume-mode-dual-left.png" COMP;
|
||||
images.image: "illume-mode-dual-top.png" COMP;
|
||||
images {
|
||||
image: "bt_base1.png" COMP;
|
||||
image: "bt_base2.png" COMP;
|
||||
image: "bt_hilight.png" COMP;
|
||||
image: "bt_shine.png" COMP;
|
||||
image: "bt_glow.png" COMP;
|
||||
}
|
||||
min: 16 16;
|
||||
max: 128 128;
|
||||
parts {
|
||||
part {
|
||||
name: "button_image";
|
||||
mouse_events: 1;
|
||||
scale: 1;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
fixed: 1 1;
|
||||
align: 0.5 0.5;
|
||||
min: 32 16;
|
||||
image {
|
||||
normal: "bt_base2.png";
|
||||
border: 7 7 7 7;
|
||||
}
|
||||
}
|
||||
description {
|
||||
state: "clicked" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
image.normal: "bt_base1.png";
|
||||
}
|
||||
program {
|
||||
name: "button_down";
|
||||
signal: "mouse,down,1";
|
||||
source: "button_image";
|
||||
action: STATE_SET "clicked" 0.0;
|
||||
target: "button_image";
|
||||
target: "over3";
|
||||
}
|
||||
program {
|
||||
name: "button_up";
|
||||
signal: "mouse,up,1";
|
||||
source: "button_image";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "button_image";
|
||||
target: "over3";
|
||||
}
|
||||
program {
|
||||
name: "enable";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "button_image";
|
||||
action: SIGNAL_EMIT "e,action,mode,dual,top" "";
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "icon";
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: BOTH;
|
||||
image.normal: "illume-mode-single.png";
|
||||
rel1 {
|
||||
to: "button_image";
|
||||
relative: 0.0 0.0;
|
||||
offset: 3 3;
|
||||
}
|
||||
rel2 {
|
||||
relative: 1.0 1.0;
|
||||
offset: -4 -4;
|
||||
to: "button_image";
|
||||
}
|
||||
}
|
||||
description { state: "dual_left" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
image.normal: "illume-mode-dual-left.png";
|
||||
}
|
||||
description { state: "dual_top" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
image.normal: "illume-mode-dual-top.png";
|
||||
}
|
||||
program { name: "state_single";
|
||||
signal: "e,mode,single";
|
||||
source: "e";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "icon";
|
||||
target: "dual_left";
|
||||
target: "dual_top";
|
||||
}
|
||||
program { name: "state_dual_left";
|
||||
signal: "e,mode,dual,left";
|
||||
source: "e";
|
||||
action: STATE_SET "dual_left" 0.0;
|
||||
target: "icon";
|
||||
target: "dual_left";
|
||||
target: "dual_top";
|
||||
}
|
||||
program { name: "state_dual_top";
|
||||
signal: "e,mode,dual,top";
|
||||
source: "e";
|
||||
action: STATE_SET "dual_top" 0.0;
|
||||
target: "icon";
|
||||
target: "dual_left";
|
||||
target: "dual_top";
|
||||
}
|
||||
}
|
||||
part { name: "dual_top";
|
||||
type: RECT;
|
||||
mouse_events: 1;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
color: 0 0 0 0;
|
||||
rel1.to: "button_image";
|
||||
rel2.to: "button_image";
|
||||
}
|
||||
description { state: "dual_top" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 1;
|
||||
}
|
||||
description { state: "dual_left" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 0;
|
||||
}
|
||||
program { name: "dual_top";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "dual_top";
|
||||
action: SIGNAL_EMIT "e,action,mode,dual,left" "";
|
||||
}
|
||||
}
|
||||
part { name: "dual_left";
|
||||
type: RECT;
|
||||
mouse_events: 1;
|
||||
description { state: "default" 0.0;
|
||||
visible: 0;
|
||||
color: 0 0 0 0;
|
||||
rel1.to: "button_image";
|
||||
rel2.to: "button_image";
|
||||
}
|
||||
description { state: "dual_top" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 0;
|
||||
}
|
||||
description { state: "dual_left" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 1;
|
||||
}
|
||||
program { name: "dual_left";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "dual_left";
|
||||
action: SIGNAL_EMIT "e,action,mode,single" "";
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "over1";
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
rel1.to: "button_image";
|
||||
rel2.to: "button_image";
|
||||
rel2.relative: 1.0 0.5;
|
||||
image {
|
||||
normal: "bt_hilight.png";
|
||||
border: 7 7 7 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "over2";
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
rel1.to: "button_image";
|
||||
rel2.to: "button_image";
|
||||
image {
|
||||
normal: "bt_shine.png";
|
||||
border: 7 7 7 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "over3";
|
||||
mouse_events: 0;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
rel1.to: "button_image";
|
||||
rel2.to: "button_image";
|
||||
visible: 0;
|
||||
color: 255 255 255 0;
|
||||
image {
|
||||
normal: "bt_glow.png";
|
||||
border: 12 12 12 12;
|
||||
}
|
||||
fill.smooth : 0;
|
||||
}
|
||||
description {
|
||||
state: "clicked" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 1;
|
||||
color: 255 255 255 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/*** MOD: COMP ***/
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 676 B |
Binary file not shown.
After Width: | Height: | Size: 732 B |
Binary file not shown.
After Width: | Height: | Size: 680 B |
Binary file not shown.
|
@ -6,7 +6,7 @@ typedef struct _Instance Instance;
|
|||
struct _Instance
|
||||
{
|
||||
E_Gadcon_Client *gcc;
|
||||
Evas_Object *o_btn;
|
||||
Evas_Object *o_toggle;
|
||||
Ecore_Event_Handler *hdl;
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,12 @@ static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
|||
static char *_gc_label(E_Gadcon_Client_Class *cc);
|
||||
static Evas_Object *_gc_icon(E_Gadcon_Client_Class *cc, Evas *evas);
|
||||
static const char *_gc_id_new(E_Gadcon_Client_Class *cc);
|
||||
static void _cb_btn_click(void *data, void *data2);
|
||||
static void _cb_action_mode_single(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _cb_action_mode_dual_top(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static void _cb_action_mode_dual_left(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||
static Eina_Bool _cb_event_client_message(void *data, int type, void *event);
|
||||
static void _set_icon(Instance *inst);
|
||||
static void _mode_set(Instance *inst, Ecore_X_Illume_Mode mode);
|
||||
|
||||
/* local variables */
|
||||
static Eina_List *instances = NULL;
|
||||
|
@ -63,18 +66,25 @@ e_modapi_save(E_Module *m)
|
|||
static E_Gadcon_Client *
|
||||
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||
{
|
||||
Instance *inst;
|
||||
Instance *inst = E_NEW(Instance, 1);
|
||||
|
||||
inst = E_NEW(Instance, 1);
|
||||
inst->o_toggle = edje_object_add(gc->evas);
|
||||
e_theme_edje_object_set(inst->o_toggle, "base/theme/modules/illume_mode_toggle",
|
||||
"e/modules/illume_mode_toggle/main");
|
||||
|
||||
inst->o_btn = e_widget_button_add(gc->evas, NULL, NULL,
|
||||
_cb_btn_click, inst, NULL);
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_btn);
|
||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_toggle);
|
||||
inst->gcc->data = inst;
|
||||
|
||||
edje_object_signal_callback_add(inst->o_toggle, "e,action,mode,single", "",
|
||||
_cb_action_mode_single, inst);
|
||||
edje_object_signal_callback_add(inst->o_toggle, "e,action,mode,dual,top", "",
|
||||
_cb_action_mode_dual_top, inst);
|
||||
edje_object_signal_callback_add(inst->o_toggle, "e,action,mode,dual,left", "",
|
||||
_cb_action_mode_dual_left, inst);
|
||||
|
||||
_set_icon(inst);
|
||||
|
||||
inst->hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
|
||||
inst->hdl = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
|
||||
_cb_event_client_message, inst);
|
||||
|
||||
instances = eina_list_append(instances, inst);
|
||||
|
@ -88,7 +98,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
|
||||
if (!(inst = gcc->data)) return;
|
||||
instances = eina_list_remove(instances, inst);
|
||||
if (inst->o_btn) evas_object_del(inst->o_btn);
|
||||
if (inst->o_toggle) evas_object_del(inst->o_toggle);
|
||||
if (inst->hdl) ecore_event_handler_del(inst->hdl);
|
||||
inst->hdl = NULL;
|
||||
E_FREE(inst);
|
||||
|
@ -129,22 +139,22 @@ _gc_id_new(E_Gadcon_Client_Class *cc)
|
|||
return buff;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_btn_click(void *data, void *data2)
|
||||
static void
|
||||
_cb_action_mode_single(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
Instance *inst;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_X_Illume_Mode mode;
|
||||
_mode_set(data, ECORE_X_ILLUME_MODE_SINGLE);
|
||||
}
|
||||
|
||||
if (!(inst = data)) return;
|
||||
static void
|
||||
_cb_action_mode_dual_top(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
_mode_set(data, ECORE_X_ILLUME_MODE_DUAL_TOP);
|
||||
}
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
mode = ecore_x_e_illume_mode_get(xwin);
|
||||
mode += 1;
|
||||
if (mode > ECORE_X_ILLUME_MODE_DUAL_LEFT)
|
||||
mode = ECORE_X_ILLUME_MODE_SINGLE;
|
||||
ecore_x_e_illume_mode_set(xwin, mode);
|
||||
ecore_x_e_illume_mode_send(xwin, mode);
|
||||
static void
|
||||
_cb_action_mode_dual_left(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||
{
|
||||
_mode_set(data, ECORE_X_ILLUME_MODE_DUAL_LEFT);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -160,25 +170,32 @@ _cb_event_client_message(void *data, __UNUSED__ int type, void *event)
|
|||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static void
|
||||
_set_icon(Instance *inst)
|
||||
static void
|
||||
_set_icon(Instance *inst)
|
||||
{
|
||||
Evas_Object *icon;
|
||||
Ecore_X_Window xwin;
|
||||
Ecore_X_Illume_Mode mode;
|
||||
char buff[PATH_MAX];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%s/e-module-illume-mode-toggle.edj", mod_dir);
|
||||
icon = e_icon_add(evas_object_evas_get(inst->o_btn));
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
mode = ecore_x_e_illume_mode_get(xwin);
|
||||
if (mode <= ECORE_X_ILLUME_MODE_SINGLE)
|
||||
e_icon_file_edje_set(icon, buff, "single");
|
||||
else if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP)
|
||||
e_icon_file_edje_set(icon, buff, "dual_top");
|
||||
else if (mode == ECORE_X_ILLUME_MODE_DUAL_LEFT)
|
||||
e_icon_file_edje_set(icon, buff, "dual_left");
|
||||
|
||||
e_widget_button_icon_set(inst->o_btn, icon);
|
||||
if (mode == ECORE_X_ILLUME_MODE_DUAL_TOP)
|
||||
edje_object_signal_emit(inst->o_toggle, "e,mode,dual,top", "e");
|
||||
else if (mode == ECORE_X_ILLUME_MODE_DUAL_LEFT)
|
||||
edje_object_signal_emit(inst->o_toggle, "e,mode,dual,left", "e");
|
||||
else
|
||||
edje_object_signal_emit(inst->o_toggle, "e,mode,single", "e");
|
||||
}
|
||||
|
||||
static void
|
||||
_mode_set(Instance *inst, Ecore_X_Illume_Mode mode)
|
||||
{
|
||||
Ecore_X_Window xwin;
|
||||
|
||||
if (!inst) return;
|
||||
|
||||
xwin = inst->gcc->gadcon->zone->black_win;
|
||||
|
||||
ecore_x_e_illume_mode_set(xwin, mode);
|
||||
ecore_x_e_illume_mode_send(xwin, mode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue