elementary/widget - revised orientation mode code.

now if applying the orientation style is failed, it tries to apply the original style. if it fails again then default theme.

also it fixed a logic error when theme changed is happened.

It will try to apply the original style if the orientation style is invalid on theme changing.




SVN revision: 84082
This commit is contained in:
ChunEon Park 2013-02-19 08:22:15 +00:00
parent ff3150ee09
commit 0a71cd2727
9 changed files with 91 additions and 75 deletions

View File

@ -291,19 +291,23 @@ void _elm_win_translate(void);
Ecore_X_Window _elm_ee_xwin_get(const Ecore_Evas *ee);
Eina_Bool _elm_theme_object_set(Evas_Object *parent,
int _elm_theme_object_set(Evas_Object *parent,
Evas_Object *o,
const char *clas,
const char *group,
const char *style);
const char *style,
Eina_Bool orient_on,
int orient_mode);
Eina_Bool _elm_theme_object_icon_set(Evas_Object *o,
const char *group,
const char *style);
Eina_Bool _elm_theme_set(Elm_Theme *th,
int _elm_theme_set(Elm_Theme *th,
Evas_Object *o,
const char *clas,
const char *group,
const char *style);
const char *style,
Eina_Bool orient_on,
int orient_mode);
Eina_Bool _elm_theme_icon_set(Elm_Theme *th,
Evas_Object *o,
const char *group,

View File

@ -438,7 +438,7 @@ _elm_slider_smart_theme(Eo *obj, void *_pd, va_list *list)
if (sd->popup)
_elm_theme_set(NULL, sd->popup,
"slider", "horizontal/popup",
elm_widget_style_get(obj));
elm_widget_style_get(obj), EINA_FALSE, 0);
}
else
{
@ -446,7 +446,7 @@ _elm_slider_smart_theme(Eo *obj, void *_pd, va_list *list)
if (sd->popup)
_elm_theme_set(NULL, sd->popup,
"slider", "vertical/popup",
elm_widget_style_get(obj));
elm_widget_style_get(obj), EINA_FALSE, 0);
}
eo_do_super(obj, elm_wdg_theme(&int_ret));
@ -784,7 +784,7 @@ _elm_slider_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
priv->popup = edje_object_add(evas_object_evas_get(obj));
_elm_theme_set(NULL, priv->popup,
"slider", "horizontal/popup",
elm_widget_style_get(obj));
elm_widget_style_get(obj), EINA_FALSE, 0);
edje_object_scale_set(priv->popup, elm_widget_scale_get(obj) *
elm_config_scale_get());
edje_object_signal_callback_add(priv->popup, "popup,hide,done", "elm",

View File

@ -223,18 +223,18 @@ _elm_theme_reload(void *data __UNUSED__, Evas_Object *obj,
evas_object_event_callback_add(elm, EVAS_CALLBACK_DEL, _elm_theme_idler_clean, NULL);
evas_object_data_set(elm, "elm-theme-reload-idler", ecore_idler_add(_elm_theme_reload_idler, elm));
}
}
}
Eina_Bool
_elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, const char *group, const char *style)
int
_elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, const char *group, const char *style, Eina_Bool orient_on, int orient_mode)
{
Elm_Theme *th = NULL;
void *test;
Eina_Bool success;
int ret;
if (parent) th = elm_widget_theme_get(parent);
success = _elm_theme_set(th, o, clas, group, style);
if (!success) return EINA_FALSE;
ret = _elm_theme_set(th, o, clas, group, style, orient_on, orient_mode);
if (ret == -1) return -1;
test = evas_object_data_get(o, "edje,theme,watcher");
if (!test)
@ -243,7 +243,7 @@ _elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, con
_elm_theme_reload, NULL);
evas_object_data_set(o, "edje,theme,watcher", (void*) -1);
}
return EINA_TRUE;
return ret;
}
/* only issued by elm_icon.c */
@ -257,33 +257,57 @@ _elm_theme_object_icon_set(Evas_Object *o,
return _elm_theme_icon_set(th, o, group, style);
}
Eina_Bool
_elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *group, const char *style)
int
_elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *group, const char *style, Eina_Bool orient_on, int orient_mode)
{
const char *file;
char buf2[1024];
Eina_Bool ok;
if ((!clas) || (!group) || (!style)) return EINA_FALSE;
if ((!clas) || (!group) || (!style)) return -1;
if (!th) th = &(theme_default);
//First Try. Apply orient mode.
if (orient_mode > 0)
{
snprintf(buf2, sizeof(buf2), "elm/%s/%s/%d/%s", clas, group,
orient_mode, style);
file = _elm_theme_group_file_find(th, buf2);
if (file)
{
if (edje_object_file_set(o, file, buf2)) return orient_mode;
else
{
DBG("could not set theme group '%s' from file '%s': %s",
buf2, file,
edje_load_error_str(edje_object_load_error_get(o)));
}
}
if (orient_on && evas_object_data_get(o, "edje,theme,watcher"))
return orient_mode;
}
//Second Try. Use the default group.
snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, group, style);
file = _elm_theme_group_file_find(th, buf2);
if (file)
{
ok = edje_object_file_set(o, file, buf2);
if (ok) return EINA_TRUE;
if (edje_object_file_set(o, file, buf2)) return 0;
else
DBG("could not set theme group '%s' from file '%s': %s",
buf2, file, edje_load_error_str(edje_object_load_error_get(o)));
{
DBG("could not set theme group '%s' from file '%s': %s",
buf2, file, edje_load_error_str(edje_object_load_error_get(o)));
}
}
//Third Try. Use the elementary default theme.
snprintf(buf2, sizeof(buf2), "elm/%s/%s/default", clas, group);
file = _elm_theme_group_file_find(th, buf2);
if (!file) return EINA_FALSE;
ok = edje_object_file_set(o, file, buf2);
if (!ok)
DBG("could not set theme group '%s' from file '%s': %s",
buf2, file, edje_load_error_str(edje_object_load_error_get(o)));
return ok;
if (!file) return -1;
if (edje_object_file_set(o, file, buf2)) return 0;
DBG("could not set theme group '%s' from file '%s': %s",
buf2, file, edje_load_error_str(edje_object_load_error_get(o)));
return -1;
}
Eina_Bool

View File

@ -4072,45 +4072,20 @@ _elm_widget_theme_object_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
const char *welement = va_arg(*list, const char *);
const char *wstyle = va_arg(*list, const char *);
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
Eina_Bool ret2 = EINA_FALSE;
Elm_Widget_Smart_Data *sd = _pd;
char buf[128];
int ret2;
//Apply orientation styles.
if (welement)
ret2 = _elm_theme_object_set(obj, edj, wname, welement, wstyle,
sd->orient_on, sd->orient_mode);
if (ret2 != -1)
{
switch (sd->orient_mode)
{
case 90:
snprintf(buf, sizeof(buf), "%s/90", welement);
break;
case 180:
snprintf(buf, sizeof(buf), "%s/180", welement);
break;
case 270:
snprintf(buf, sizeof(buf), "%s/270", welement);
break;
default:
strncpy(buf, welement, sizeof(buf));
break;
}
ret2 = _elm_theme_object_set(obj, edj, wname, buf, wstyle);
char buf[128];
snprintf(buf, sizeof(buf), "elm,state,orient,%d", ret2);
elm_object_signal_emit(obj, buf, "elm");
if (ret) *ret = EINA_TRUE;
}
//Fallback. Apply a default if the style doesnt applied anything.
//Otherwise, use the previous one.
if (!ret2)
{
if (!evas_object_data_get(edj, "edje,theme,watcher"))
ret2 = _elm_theme_object_set(obj, edj, wname, welement, wstyle);
else
ret2 = EINA_TRUE;
strncpy(buf, "elm,state,orient,0", sizeof(buf));
}
else
snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
elm_object_signal_emit(obj, buf, "elm");
if (ret) *ret = ret2;
if (ret) *ret = EINA_FALSE;
}
static void
@ -4546,7 +4521,9 @@ _elm_widget_orientation_set(Eo *obj __UNUSED__, void *_pd, va_list *list)
EINA_LIST_FOREACH (sd->subobjs, l, child)
elm_widget_orientation_set(child, orient_mode);
sd->orient_on = EINA_TRUE;
eo_do(obj, elm_wdg_theme(NULL));
sd->orient_on = EINA_FALSE;
if (ret) *ret = EINA_TRUE;
}

View File

@ -412,6 +412,7 @@ typedef struct _Elm_Widget_Smart_Data
int frozen;
int orient_mode; /* -1 is disabled */
Eina_Bool orient_on : 1;
Eina_Bool drag_x_locked : 1;
Eina_Bool drag_y_locked : 1;

View File

@ -2947,7 +2947,8 @@ _win_constructor(Eo *obj, void *_pd, va_list *list)
Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
_elm_theme_object_set(obj, o, "pointer", "base", "default");
_elm_theme_object_set(obj, o, "pointer", "base", "default", EINA_FALSE,
0);
edje_object_size_min_calc(o, &mw, &mh);
evas_object_resize(o, mw, mh);
edje_object_part_geometry_get(o, "elm.swallow.hotspot",
@ -2963,7 +2964,8 @@ _win_constructor(Eo *obj, void *_pd, va_list *list)
}
sd->layout = edje_object_add(sd->evas);
_elm_theme_object_set(obj, sd->layout, "win", "base", "default");
_elm_theme_object_set(obj, sd->layout, "win", "base", "default",
EINA_FALSE, 0);
sd->box = evas_object_box_add(sd->evas);
evas_object_box_layout_set(sd->box, _window_layout_stack, obj, NULL);
edje_object_part_swallow(sd->layout, "elm.swallow.contents", sd->box);

View File

@ -174,8 +174,9 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
if (!cur->obj)
return EINA_FALSE;
if (!_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
cur->style ? cur->style : "default"))
if (_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
cur->style ? cur->style : "default", EINA_FALSE,
0) == -1)
{
evas_object_del(cur->obj);
cur->obj = NULL;
@ -478,8 +479,8 @@ elm_object_cursor_style_set(Evas_Object *obj, const char *style)
}
else
{
if (!_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
style))
if (_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name,
style, EINA_FALSE, 0) == -1)
ERR("Could not apply the theme to the cursor style=%s", style);
else
_elm_cursor_set_hot_spots(cur);
@ -501,8 +502,9 @@ void
elm_cursor_theme(Elm_Cursor *cur)
{
if ((!cur) || (!cur->obj)) return;
if (!_elm_theme_object_set(cur->eventarea, cur->obj, "cursor",
cur->cursor_name, cur->style))
if (_elm_theme_object_set(cur->eventarea, cur->obj, "cursor",
cur->cursor_name, cur->style, EINA_FALSE, 0)
== -1)
ERR("Could not apply the theme to the cursor style=%s", cur->style);
else
_elm_cursor_set_hot_spots(cur);

View File

@ -275,7 +275,9 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
{
const char *style = tt->style ? tt->style : "default";
const char *str;
if (!_elm_theme_object_set(tt->tt_win ? NULL : tt->owner, tt->tooltip, "tooltip", "base", style))
if (_elm_theme_object_set(tt->tt_win ? NULL : tt->owner, tt->tooltip,
"tooltip", "base", style, EINA_FALSE, 0)
== -1)
{
ERR("Could not apply the theme to the tooltip! style=%s", style);
if (tt->tt_win) evas_object_del(tt->tt_win);

View File

@ -169,7 +169,8 @@ _elm_ews_border_config_apply(Ecore_Evas *ee, Evas_Object *o, Elm_Theme *th)
if (ecore_evas_borderless_get(ee))
style = "borderless";
_elm_theme_set(th, o, "ews", "decoration", style ? style : "default");
_elm_theme_set(th, o, "ews", "decoration", style ? style : "default",
EINA_FALSE, 0);
if (ecore_evas_shaped_get(ee) || ecore_evas_alpha_get(ee) ||
ecore_evas_transparent_get(ee))
@ -446,7 +447,8 @@ _elm_ews_wm_rescale(Elm_Theme *th, Eina_Bool use_theme)
_elm_ews_wm_border_theme_set(*(void**)tp->key, tp->data, NULL);
if (_ews_bg)
_elm_theme_set(NULL, _ews_bg, "ews", "background", "default");
_elm_theme_set(NULL, _ews_bg, "ews", "background", "default",
EINA_FALSE, 0);
}
else
{
@ -454,7 +456,8 @@ _elm_ews_wm_rescale(Elm_Theme *th, Eina_Bool use_theme)
_elm_ews_wm_border_theme_set(*(void**)tp->key, tp->data, th);
if (_ews_bg)
_elm_theme_set(th, _ews_bg, "ews", "background", "default");
_elm_theme_set(th, _ews_bg, "ews", "background", "default",
EINA_FALSE, 0);
}
eina_iterator_free(it);
@ -477,7 +480,8 @@ _elm_ews_wm_init(void)
o = edje_object_add(e);
if (!o) return EINA_FALSE;
if (!_elm_theme_set(NULL, o, "ews", "background", "default"))
if (_elm_theme_set(NULL, o, "ews", "background", "default", EINA_FALSE, 0)
== -1)
{
ERR("Could not set background theme, fallback to rectangle");
evas_object_del(o);