handle changes in scaling... a bit...
SVN revision: 37654
This commit is contained in:
parent
de9e261ea8
commit
08c021a0c6
|
@ -7,9 +7,11 @@ struct _Widget_Data
|
|||
{
|
||||
Evas_Object *btn;
|
||||
Evas_Object *icon;
|
||||
const char *label;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
static void _theme_hook(Evas_Object *obj);
|
||||
static void _sizing_eval(Evas_Object *obj);
|
||||
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -19,9 +21,29 @@ static void
|
|||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (wd->label) eina_stringshare_del(wd->label);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_hook(Evas_Object *obj)
|
||||
{
|
||||
const char *label;
|
||||
Evas_Object *icon;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
// FIXME: this is wrong. edje needs to handle more of this.
|
||||
label = eina_stringshare_add(wd->label);
|
||||
icon = wd->icon;
|
||||
_elm_theme_set(wd->btn, "x", "base", "default");
|
||||
elm_button_label_set(obj, NULL);
|
||||
elm_button_icon_set(obj, NULL);
|
||||
_elm_theme_set(wd->btn, "button", "base", "default");
|
||||
elm_button_label_set(obj, label);
|
||||
elm_button_icon_set(obj, icon);
|
||||
eina_stringshare_del(label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
|
@ -76,6 +98,7 @@ elm_button_add(Evas_Object *parent)
|
|||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
elm_widget_theme_hook_set(obj, _theme_hook);
|
||||
|
||||
wd->btn = edje_object_add(e);
|
||||
_elm_theme_set(wd->btn, "button", "base", "default");
|
||||
|
@ -94,13 +117,16 @@ elm_button_label_set(Evas_Object *obj, const char *label)
|
|||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (wd->label) eina_stringshare_del(wd->label);
|
||||
if (label)
|
||||
{
|
||||
wd->label = eina_stringshare_add(label);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
wd->label = NULL;
|
||||
edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(wd->btn);
|
||||
}
|
||||
|
@ -114,9 +140,9 @@ elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
|||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if ((wd->icon != icon) && (wd->icon))
|
||||
elm_widget_sub_object_del(obj, wd->icon);
|
||||
wd->icon = icon;
|
||||
if (icon)
|
||||
if ((icon) && (wd->icon != icon))
|
||||
{
|
||||
wd->icon = icon;
|
||||
elm_widget_sub_object_add(obj, icon);
|
||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
|
||||
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
||||
|
@ -124,4 +150,6 @@ elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
|||
_changed_size_hints, obj);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
else
|
||||
wd->icon = icon;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
static int _elm_signal_exit(void *data, int ev_type, void *ev);
|
||||
static int _elm_window_property_change(void *data, int ev_type, void *ev);
|
||||
static void _elm_rescale(void);
|
||||
|
||||
char *_elm_appname = NULL;
|
||||
Elm_Config *_elm_config = NULL;
|
||||
Ecore_Event_Handler *_elm_event_property_change = NULL;
|
||||
Ecore_X_Atom _elm_atom_enlightenment_scale = 0;
|
||||
|
||||
static int
|
||||
_elm_signal_exit(void *data, int ev_type, void *ev)
|
||||
|
@ -11,6 +17,40 @@ _elm_signal_exit(void *data, int ev_type, void *ev)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_elm_window_property_change(void *data, int ev_type, void *ev)
|
||||
{
|
||||
Ecore_X_Event_Window_Property *event = ev;
|
||||
|
||||
if (event->win == ecore_x_window_root_first_get())
|
||||
{
|
||||
if (event->atom == _elm_atom_enlightenment_scale)
|
||||
{
|
||||
int val = 1000;
|
||||
|
||||
if (ecore_x_window_prop_card32_get(event->win,
|
||||
event->atom,
|
||||
&val, 1) > 0)
|
||||
{
|
||||
double pscale;
|
||||
|
||||
pscale = _elm_config->scale;
|
||||
if (val > 0) _elm_config->scale = (double)val / 1000.0;
|
||||
if (pscale != _elm_config->scale) _elm_rescale();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_rescale(void)
|
||||
{
|
||||
printf("Scale %3.3f\n", _elm_config->scale);
|
||||
edje_scale_set(_elm_config->scale);
|
||||
_elm_win_rescale();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_init(int argc, char **argv)
|
||||
{
|
||||
|
@ -47,8 +87,13 @@ elm_init(int argc, char **argv)
|
|||
int val = 1000;
|
||||
|
||||
ecore_x_init(NULL);
|
||||
_elm_atom_enlightenment_scale = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
|
||||
ecore_x_event_mask_set(ecore_x_window_root_first_get(),
|
||||
ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
|
||||
_elm_event_property_change = ecore_event_handler_add
|
||||
(ECORE_X_EVENT_WINDOW_PROPERTY, _elm_window_property_change, NULL);
|
||||
if (ecore_x_window_prop_card32_get(ecore_x_window_root_first_get(),
|
||||
ecore_x_atom_get("ENLIGHTENMENT_SCALE"),
|
||||
_elm_atom_enlightenment_scale,
|
||||
&val, 1) > 0)
|
||||
{
|
||||
if (val > 0) _elm_config->scale = (double)val / 1000.0;
|
||||
|
|
|
@ -35,6 +35,7 @@ struct _Elm_Config
|
|||
#define ELM_NEW(t) calloc(1, sizeof(t))
|
||||
|
||||
void _elm_win_shutdown(void);
|
||||
void _elm_win_rescale(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);
|
||||
|
@ -46,6 +47,8 @@ EAPI void elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Ev
|
|||
EAPI void elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
|
||||
EAPI void elm_widget_theme(Evas_Object *obj);
|
||||
EAPI void elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
|
||||
|
|
|
@ -19,6 +19,7 @@ struct _Smart_Data
|
|||
void (*focus_func) (Evas_Object *obj);
|
||||
void (*activate_func) (Evas_Object *obj);
|
||||
void (*disable_func) (Evas_Object *obj);
|
||||
void (*theme_func) (Evas_Object *obj);
|
||||
void (*on_focus_func) (void *data, Evas_Object *obj);
|
||||
void *on_focus_data;
|
||||
void (*on_change_func) (void *data, Evas_Object *obj);
|
||||
|
@ -110,6 +111,25 @@ elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
|||
sd->disable_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
|
||||
{
|
||||
API_ENTRY return;
|
||||
sd->theme_func = func;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_theme(Evas_Object *obj)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
API_ENTRY return;
|
||||
if (sd->theme_func) sd->theme_func(obj);
|
||||
for (l = sd->subobjs; l; l = l->next) elm_widget_theme(l->data);
|
||||
if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
|
||||
if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
|
||||
{
|
||||
|
|
|
@ -336,6 +336,14 @@ _elm_win_shutdown(void)
|
|||
while (_elm_win_list) evas_object_del(_elm_win_list->data);
|
||||
}
|
||||
|
||||
void
|
||||
_elm_win_rescale(void)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
for (l = _elm_win_list; l; l = l->next) elm_widget_theme(l->data);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue