theme stuff is done properly now with a style (always default - onyl one

available for all widgets for now) and icons emit callback.



SVN revision: 36522
This commit is contained in:
Carsten Haitzler 2008-10-08 09:33:05 +00:00
parent 2a39e68ad8
commit a0fd0771f5
14 changed files with 91 additions and 83 deletions

View File

@ -1,7 +1,7 @@
collections {
///////////////////////////////////////////////////////////////////////////////
group { name: "bg";
group { name: "elm/bg/base/default";
images {
image: "dia_grad.png" COMP;
image: "dia_topshad.png" COMP;
@ -67,7 +67,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "scroller";
group { name: "elm/scroller/base/default";
images {
image: "shelf_inset.png" COMP;
image: "bt_sm_base2.png" COMP;
@ -350,7 +350,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "label";
group { name: "elm/label/base/default";
styles
{
style { name: "textblock_style";
@ -377,7 +377,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "button";
group { name: "elm/button/base/default";
images {
image: "bt_base1.png" COMP;
image: "bt_base2.png" COMP;
@ -513,7 +513,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "toggle";
group { name: "elm/toggle/base/default";
images {
image: "shelf_inset.png" COMP;
image: "bt_basew.png" COMP;
@ -802,7 +802,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "flipdigit";
group { name: "elm/clock/flipdigit/default";
images {
image: "flip_base.png" COMP;
image: "flip_base_shad.png" COMP;
@ -1388,7 +1388,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "flipampm";
group { name: "elm/clock/flipampm/default";
images {
image: "flip_base.png" COMP;
image: "flip_base_shad.png" COMP;
@ -1697,7 +1697,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "clock/all";
group { name: "elm/clock/base-all/default";
parts {
part { name: "d0";
type: SWALLOW;
@ -1792,7 +1792,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "clock/seconds";
group { name: "elm/clock/base-seconds/default";
parts {
part { name: "d0";
type: SWALLOW;
@ -1879,7 +1879,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "clock/am_pm";
group { name: "elm/clock/base-am_pm/default";
parts {
part { name: "d0";
type: SWALLOW;
@ -1939,7 +1939,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "clock";
group { name: "elm/clock/base/default";
parts {
part { name: "d0";
type: SWALLOW;
@ -1991,50 +1991,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "pad";
parts {
part { name: "t";
type: RECT;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
visible: 0;
align: 0.0 0.0;
min: 4 4;
max: 4 4;
rel1.relative: 0.0 0.0;
rel2.relative: 0.0 0.0;
rel2.offset: 0 0;
}
}
part { name: "b";
type: RECT;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
visible: 0;
align: 1.0 1.0;
min: 4 4;
max: 4 4;
rel1.relative: 1.0 1.0;
rel1.offset: -1 -1;
rel2.relative: 1.0 1.0;
}
}
part { name: "elm.swallow.content";
type: SWALLOW;
description { state: "default" 0.0;
rel1.to: "t";
rel1.relative: 1.0 1.0;
rel2.to: "b";
rel2.relative: 0.0 0.0;
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
group { name: "frame";
group { name: "elm/frame/base/default";
images {
image: "frame_1.png" COMP;
image: "frame_2.png" COMP;
@ -2120,7 +2077,7 @@ collections {
}
///////////////////////////////////////////////////////////////////////////////
group { name: "hover";
group { name: "elm/hover/base/default";
images {
image: "shad_circ.png" COMP;
}
@ -2236,9 +2193,15 @@ collections {
}
}
}
///////////////////////////////////////////////////////////////////////////////
group { name: "elm/icon/base/default"; min: 10 10;
images.image: "bt_base1.png" COMP; parts { part { name: "base";
description { state: "default" 0.0; aspect: 1.0 1.0;
image.normal: "bt_base1.png"; } } } }
///////////////////////////////////////////////////////////////////////////////
group { name: "contact";
group { name: "elm/contact/base/default";
images {
image: "bt_base1.png" COMP;
image: "bt_base2.png" COMP;

View File

@ -103,6 +103,7 @@ extern "C" {
EAPI void elm_icon_scale_set(Evas_Object *obj, Evas_Bool scale_up, Evas_Bool scale_down);
EAPI void elm_icon_fill_outside_set(Evas_Object *obj, Evas_Bool fill_outside);
/* smart callbacks elm_win objects will call:
* "clicked" - the user clicked the icon
*/
EAPI Evas_Object *elm_box_add(Evas_Object *parent);

View File

@ -57,7 +57,7 @@ elm_bg_add(Evas_Object *parent)
elm_widget_can_focus_set(obj, 0);
wd->img = edje_object_add(e);
_elm_theme_set(wd->img, "bg", "bg");
_elm_theme_set(wd->img, "bg", "base", "default");
elm_widget_resize_object_set(obj, wd->img);
return obj;
}

View File

@ -78,7 +78,7 @@ elm_button_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->btn = edje_object_add(e);
_elm_theme_set(wd->btn, "button", "button");
_elm_theme_set(wd->btn, "button", "base", "default");
edje_object_signal_callback_add(wd->btn, "elm,action,click", "", _signal_clicked, obj);
elm_widget_resize_object_set(obj, wd->btn);

View File

@ -188,13 +188,13 @@ _time_update(Evas_Object *obj)
}
if ((wd->seconds) && (wd->am_pm))
_elm_theme_set(wd->clk, "clock", "clock/all");
_elm_theme_set(wd->clk, "clock", "base-all", "default");
else if (wd->seconds)
_elm_theme_set(wd->clk, "clock", "clock/seconds");
_elm_theme_set(wd->clk, "clock", "base-seconds", "default");
else if (wd->am_pm)
_elm_theme_set(wd->clk, "clock", "clock/am_pm");
_elm_theme_set(wd->clk, "clock", "base-am_pm", "default");
else
_elm_theme_set(wd->clk, "clock", "clock");
_elm_theme_set(wd->clk, "clock", "base", "default");
for (i = 0; i < 6; i++)
{
@ -202,7 +202,7 @@ _time_update(Evas_Object *obj)
if ((!wd->seconds) && (i >= 4)) break;
wd->digit[i] = edje_object_add(evas_object_evas_get(wd->clk));
_elm_theme_set(wd->digit[i], "clock", "flipdigit");
_elm_theme_set(wd->digit[i], "clock", "flipdigit", "default");
if (wd->edit)
edje_object_signal_emit(wd->digit[i], "elm,state,edit,on", "elm");
edje_object_signal_callback_add(wd->digit[i], "elm,action,up", "",
@ -218,7 +218,7 @@ _time_update(Evas_Object *obj)
if (wd->am_pm)
{
wd->ampm = edje_object_add(evas_object_evas_get(wd->clk));
_elm_theme_set(wd->ampm, "clock", "flipampm");
_elm_theme_set(wd->ampm, "clock", "flipampm", "default");
if (wd->edit)
edje_object_signal_emit(wd->ampm, "elm,state,edit,on", "elm");
edje_object_signal_callback_add(wd->ampm, "elm,action,up", "",

View File

@ -68,7 +68,7 @@ elm_frame_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->frm = edje_object_add(e);
_elm_theme_set(wd->frm, "frame", "frame");
_elm_theme_set(wd->frm, "frame", "base", "default");
elm_widget_resize_object_set(obj, wd->frm);
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);

View File

@ -140,8 +140,8 @@ elm_hover_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->hov = evas_object_rectangle_add(e);
evas_object_color_set(wd->hov, 0, 0, 0, 0);
evas_object_pass_events_set(wd->hov, 1);
evas_object_color_set(wd->hov, 0, 0, 0, 0);
elm_widget_resize_object_set(obj, wd->hov);
evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_MOVE, _hov_move, obj);
evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_RESIZE, _hov_resize, obj);
@ -149,7 +149,7 @@ elm_hover_add(Evas_Object *parent)
evas_object_event_callback_add(wd->hov, EVAS_CALLBACK_HIDE, _hov_hide, obj);
wd->cov = edje_object_add(e);
_elm_theme_set(wd->cov, "hover", "hover");
_elm_theme_set(wd->cov, "hover", "base", "default");
elm_widget_sub_object_add(obj, wd->cov);
edje_object_signal_callback_add(wd->cov, "elm,action,dismiss", "", _signal_dismiss, obj);

View File

@ -6,7 +6,6 @@ typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{
Evas_Object *img;
const char *file, *group;
Evas_Bool scale_up : 1;
Evas_Bool scale_down : 1;
Evas_Bool smooth : 1;
@ -16,6 +15,7 @@ struct _Widget_Data
static void _del_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _mouse_up(void *data, Evas_Object *obj, void *event_info);
static void
_del_hook(Evas_Object *obj)
@ -57,6 +57,12 @@ _sizing_eval(Evas_Object *obj)
evas_object_size_hint_max_set(obj, maxw, maxh);
}
static void
_mouse_up(void *data, Evas_Object *obj, void *event_info)
{
evas_object_smart_callback_call(data, "clicked", NULL);
}
EAPI Evas_Object *
elm_icon_add(Evas_Object *parent)
{
@ -72,6 +78,8 @@ elm_icon_add(Evas_Object *parent)
elm_widget_can_focus_set(obj, 0);
wd->img = _els_smart_icon_add(e);
evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
_mouse_up, obj);
evas_object_repeat_events_set(wd->img, 1);
elm_widget_resize_object_set(obj, wd->img);
@ -90,12 +98,6 @@ elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
const char *p;
if (!file) return;
if (wd->file) evas_stringshare_del(wd->file);
if (file) wd->file = evas_stringshare_add(file);
else wd->file = NULL;
if (wd->group) evas_stringshare_del(wd->group);
if (group) wd->group = evas_stringshare_add(group);
else wd->group = NULL;
if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
_els_smart_icon_file_edje_set(wd->img, file, group);
else
@ -103,6 +105,16 @@ elm_icon_file_set(Evas_Object *obj, const char *file, const char *group)
_sizing_eval(obj);
}
EAPI void
elm_icon_standard_set(Evas_Object *obj, const char *name)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!name) return;
_elm_theme_icon_set(wd->img, name, "default");
_sizing_eval(obj);
}
EAPI void
elm_icon_smooth_set(Evas_Object *obj, Evas_Bool smooth)
{

View File

@ -44,7 +44,7 @@ elm_label_add(Evas_Object *parent)
elm_widget_can_focus_set(obj, 0);
wd->lbl = edje_object_add(e);
_elm_theme_set(wd->lbl, "label", "label");
_elm_theme_set(wd->lbl, "label", "base", "default");
elm_widget_resize_object_set(obj, wd->lbl);
return obj;
}

View File

@ -34,6 +34,9 @@ struct _Elm_Config
void _elm_win_shutdown(void);
int _elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style);
int _elm_theme_icon_set(Evas_Object *o, const char *group, const char *style);
/* FIXME: should this be public? for now - private (but public symbols) */
EAPI Evas_Object *elm_widget_add(Evas *evas);
EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));

View File

@ -2,12 +2,38 @@
#include "elm_priv.h"
int
_elm_theme_set(Evas_Object *o, const char *clas, const char *group)
_elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style)
{
char buf[PATH_MAX];
char buf2[1024];
int ok;
// FIXME: actually handle themes for real
snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR,
"default");
return edje_object_file_set(o, buf, group);
snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR, "default");
snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, group, style);
ok = edje_object_file_set(o, buf, buf2);
if (ok) return 1;
snprintf(buf2, sizeof(buf2), "elm/%s/%s/default", clas, group);
ok = edje_object_file_set(o, buf, buf2);
return ok;
}
int
_elm_theme_icon_set(Evas_Object *o, const char *group, const char *style)
{
char buf[PATH_MAX];
char buf2[1024];
int w, h;
int ok;
// FIXME: actually handle themes for real
snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR, "default");
snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style);
_els_smart_icon_file_edje_set(o, buf, buf2);
_els_smart_icon_size_get(o, &w, &h);
if (w > 0) return 1;
snprintf(buf2, sizeof(buf2), "elm/icon/%s/default", group);
_els_smart_icon_file_edje_set(o, buf, buf2);
_els_smart_icon_size_get(o, &w, &h);
return (w > 0);
}

View File

@ -92,7 +92,7 @@ elm_toggle_add(Evas_Object *parent)
elm_widget_del_hook_set(obj, _del_hook);
wd->tgl = edje_object_add(e);
_elm_theme_set(wd->tgl, "toggle", "toggle");
_elm_theme_set(wd->tgl, "toggle", "base", "default");
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,on", "", _signal_toggle_on, obj);
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,off", "", _signal_toggle_off, obj);
elm_widget_resize_object_set(obj, wd->tgl);

View File

@ -87,7 +87,10 @@ _els_smart_icon_size_get(Evas_Object *obj, int *w, int *h)
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_image_size_get(sd->obj, &tw, &th);
if (!strcmp(evas_object_type_get(sd->obj), "edje"))
edje_object_size_min_get(sd->obj, &tw, &th);
else
evas_object_image_size_get(sd->obj, &tw, &th);
tw = ((double)tw) * sd->scale;
th = ((double)th) * sd->scale;
if (w) *w = tw;

View File

@ -931,7 +931,7 @@ _smart_add(Evas_Object *obj)
o = edje_object_add(evas_object_evas_get(obj));
sd->edje_obj = o;
_elm_theme_set(o, "scroller", "scroller");
_elm_theme_set(o, "scroller", "base", "default");
edje_object_signal_callback_add(o, "drag*", "elm.dragable.vbar", _smart_edje_drag_v, sd);
edje_object_signal_callback_add(o, "drag*", "elm.dragable.hbar", _smart_edje_drag_h, sd);
evas_object_smart_member_add(o, obj);