2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-07-31 15:07:12 -07:00
|
|
|
#include "elm_widget_frame.h"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2012-07-31 15:07:12 -07:00
|
|
|
EAPI const char ELM_FRAME_SMART_NAME[] = "elm_frame";
|
2008-10-06 18:23:49 -07:00
|
|
|
|
2012-01-03 16:41:37 -08:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
2012-01-03 16:41:37 -08:00
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2012-05-03 15:41:53 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
2010-10-01 12:02:58 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
{"default", "elm.swallow.content"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2010-10-01 12:02:58 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
{"default", "elm.text"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
EVAS_SMART_SUBCLASS_NEW
|
2012-07-31 15:07:12 -07:00
|
|
|
(ELM_FRAME_SMART_NAME, _elm_frame, Elm_Frame_Smart_Class,
|
2012-05-03 15:41:53 -07:00
|
|
|
Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
|
2012-05-02 09:58:36 -07:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:53 -07:00
|
|
|
_sizing_eval(Evas_Object *obj,
|
|
|
|
Elm_Frame_Smart_Data *sd)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
|
|
|
Evas_Coord cminw = -1, cminh = -1;
|
|
|
|
|
|
|
|
edje_object_size_min_calc(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh);
|
|
|
|
evas_object_size_hint_min_get(obj, &cminw, &cminh);
|
|
|
|
if ((minw == cminw) && (minh == cminh)) return;
|
|
|
|
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 09:58:36 -07:00
|
|
|
static Eina_Bool
|
2012-05-03 15:41:53 -07:00
|
|
|
_elm_frame_smart_focus_next(const Evas_Object *obj,
|
|
|
|
Elm_Focus_Direction dir,
|
|
|
|
Evas_Object **next)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
Evas_Object *content;
|
2012-05-02 09:58:36 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
content = elm_layout_content_get(obj, NULL);
|
2012-05-02 09:58:36 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
if (!content) return EINA_FALSE;
|
|
|
|
|
|
|
|
/* attempt to follow focus cycle into sub-object */
|
|
|
|
return elm_widget_focus_next_get(content, dir, next);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 20:02:54 -07:00
|
|
|
static Eina_Bool
|
2012-05-03 15:41:53 -07:00
|
|
|
_elm_frame_smart_focus_direction(const Evas_Object *obj,
|
|
|
|
const Evas_Object *base,
|
|
|
|
double degree,
|
|
|
|
Evas_Object **direction,
|
|
|
|
double *weight)
|
2012-05-02 20:02:54 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
Evas_Object *content;
|
2012-05-02 20:02:54 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
content = elm_layout_content_get(obj, NULL);
|
2012-05-02 20:02:54 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
if (!content) return EINA_FALSE;
|
|
|
|
|
|
|
|
/* Try to cycle focus on content */
|
|
|
|
return elm_widget_focus_direction_get
|
|
|
|
(content, base, degree, direction, weight);
|
2012-05-02 20:02:54 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
static void
|
2012-05-03 15:41:53 -07:00
|
|
|
_recalc(void *data,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
void *event_info __UNUSED__)
|
2008-10-06 23:55:11 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_layout_sizing_eval(data);
|
2008-10-06 23:55:11 -07:00
|
|
|
}
|
|
|
|
|
2011-06-29 02:11:45 -07:00
|
|
|
static void
|
2012-05-03 15:41:53 -07:00
|
|
|
_on_recalc_done(void *data,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
const char *sig __UNUSED__,
|
|
|
|
const char *src __UNUSED__)
|
2011-06-29 02:11:45 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
evas_object_smart_callback_del
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, "recalc", _recalc);
|
|
|
|
sd->anim = EINA_FALSE;
|
|
|
|
|
|
|
|
elm_layout_sizing_eval(data);
|
2011-06-29 02:11:45 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 09:58:36 -07:00
|
|
|
static void
|
2012-05-03 15:41:53 -07:00
|
|
|
_on_frame_clicked(void *data,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
const char *sig __UNUSED__,
|
|
|
|
const char *src __UNUSED__)
|
2011-06-29 02:11:45 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (sd->anim) return;
|
|
|
|
|
|
|
|
if (sd->collapsible)
|
2012-05-02 09:58:36 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
evas_object_smart_callback_add
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, "recalc", _recalc, data);
|
|
|
|
elm_layout_signal_emit(data, "elm,action,toggle", "elm");
|
|
|
|
sd->collapsed++;
|
|
|
|
sd->anim = EINA_TRUE;
|
2012-05-02 09:58:36 -07:00
|
|
|
}
|
2012-05-03 15:41:53 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
|
2011-06-29 02:11:45 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
/* using deferred sizing evaluation, just like the parent */
|
2011-10-28 21:32:24 -07:00
|
|
|
static void
|
2012-05-03 15:41:53 -07:00
|
|
|
_elm_frame_smart_calculate(Evas_Object *obj)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_DATA_GET(obj, sd);
|
2012-05-02 09:58:36 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
if (ELM_LAYOUT_DATA(sd)->needs_size_calc)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
/* calling OWN sizing evaluate code here */
|
|
|
|
_sizing_eval(obj, sd);
|
|
|
|
ELM_LAYOUT_DATA(sd)->needs_size_calc = EINA_FALSE;
|
2011-10-28 21:32:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
static void
|
|
|
|
_elm_frame_smart_add(Evas_Object *obj)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
EVAS_SMART_DATA_ALLOC(obj, Elm_Frame_Smart_Data);
|
2012-02-20 05:06:18 -08:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_WIDGET_CLASS(_elm_frame_parent_sc)->base.add(obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
edje_object_signal_callback_add
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, "elm,anim,done", "elm",
|
|
|
|
_on_recalc_done, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,click", "elm",
|
|
|
|
_on_frame_clicked, obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2012-01-03 20:22:20 -08:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_layout_theme_set(obj, "frame", "base", elm_widget_style_get(obj));
|
2012-07-17 11:46:12 -07:00
|
|
|
|
|
|
|
elm_layout_sizing_eval(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2012-01-03 20:22:20 -08:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-07-31 15:07:12 -07:00
|
|
|
_elm_frame_smart_set_user(Elm_Frame_Smart_Class *sc)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->base.add = _elm_frame_smart_add;
|
|
|
|
ELM_WIDGET_CLASS(sc)->base.calculate = _elm_frame_smart_calculate;
|
2012-05-02 09:58:36 -07:00
|
|
|
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->focus_next = _elm_frame_smart_focus_next;
|
|
|
|
ELM_WIDGET_CLASS(sc)->focus_direction = _elm_frame_smart_focus_direction;
|
|
|
|
|
2012-07-31 15:07:12 -07:00
|
|
|
ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
|
|
|
|
ELM_LAYOUT_CLASS(sc)->text_aliases = _text_aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const Elm_Frame_Smart_Class *
|
|
|
|
elm_frame_smart_class_get(void)
|
|
|
|
{
|
|
|
|
static Elm_Frame_Smart_Class _sc =
|
|
|
|
ELM_FRAME_SMART_CLASS_INIT_NAME_VERSION(ELM_FRAME_SMART_NAME);
|
|
|
|
static const Elm_Frame_Smart_Class *class = NULL;
|
|
|
|
Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
|
|
|
|
|
|
|
|
if (class)
|
|
|
|
return class;
|
|
|
|
|
|
|
|
_elm_frame_smart_set(&_sc);
|
|
|
|
esc->callbacks = _smart_callbacks;
|
|
|
|
class = &_sc;
|
|
|
|
|
|
|
|
return class;
|
2012-01-03 16:41:37 -08:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_frame_add(Evas_Object *parent)
|
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
|
2012-07-18 14:03:39 -07:00
|
|
|
obj = elm_widget_add(_elm_frame_smart_class_new(), parent);
|
|
|
|
if (!obj) return NULL;
|
2012-05-03 15:41:53 -07:00
|
|
|
|
|
|
|
if (!elm_widget_sub_object_add(parent, obj))
|
|
|
|
ERR("could not add %p as sub object of %p", obj, parent);
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2012-01-03 19:03:15 -08:00
|
|
|
EAPI void
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_frame_autocollapse_set(Evas_Object *obj,
|
|
|
|
Eina_Bool autocollapse)
|
2012-01-03 19:03:15 -08:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_CHECK(obj);
|
|
|
|
ELM_FRAME_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
|
|
|
sd->collapsible = !!autocollapse;
|
2012-01-03 19:03:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2012-02-20 04:54:14 -08:00
|
|
|
elm_frame_autocollapse_get(const Evas_Object *obj)
|
2012-01-03 19:03:15 -08:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_CHECK(obj) EINA_FALSE;
|
|
|
|
ELM_FRAME_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
|
|
|
|
|
|
|
|
return sd->collapsible;
|
2012-01-03 19:03:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_frame_collapse_set(Evas_Object *obj,
|
|
|
|
Eina_Bool collapse)
|
2012-01-13 20:12:45 -08:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_CHECK(obj);
|
|
|
|
ELM_FRAME_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
2012-01-13 20:24:02 -08:00
|
|
|
collapse = !!collapse;
|
2012-05-03 15:41:53 -07:00
|
|
|
if (sd->collapsed == collapse) return;
|
|
|
|
|
|
|
|
elm_layout_signal_emit(obj, "elm,action,switch", "elm");
|
|
|
|
edje_object_message_signal_process(ELM_WIDGET_DATA(sd)->resize_obj);
|
|
|
|
sd->collapsed = !!collapse;
|
|
|
|
sd->anim = EINA_FALSE;
|
|
|
|
|
|
|
|
_sizing_eval(obj, sd);
|
2012-01-13 20:12:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-05-03 15:41:53 -07:00
|
|
|
elm_frame_collapse_go(Evas_Object *obj,
|
|
|
|
Eina_Bool collapse)
|
2012-01-03 19:03:15 -08:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_CHECK(obj);
|
|
|
|
ELM_FRAME_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
2012-01-13 20:24:02 -08:00
|
|
|
collapse = !!collapse;
|
2012-05-03 15:41:53 -07:00
|
|
|
if (sd->collapsed == collapse) return;
|
|
|
|
|
|
|
|
elm_layout_signal_emit(obj, "elm,action,toggle", "elm");
|
|
|
|
evas_object_smart_callback_add
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, "recalc", _recalc, obj);
|
|
|
|
sd->collapsed = collapse;
|
|
|
|
sd->anim = EINA_TRUE;
|
2012-01-03 19:03:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2012-02-20 04:54:14 -08:00
|
|
|
elm_frame_collapse_get(const Evas_Object *obj)
|
2012-01-03 19:03:15 -08:00
|
|
|
{
|
2012-05-03 15:41:53 -07:00
|
|
|
ELM_FRAME_CHECK(obj) EINA_FALSE;
|
|
|
|
ELM_FRAME_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
|
|
|
|
|
|
|
|
return sd->collapsed;
|
2012-01-03 19:03:15 -08:00
|
|
|
}
|