2009-10-06 08:08:41 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Toolbar Toolbar
|
|
|
|
*
|
|
|
|
* A toolbar is a widget that displays a list of buttons inside
|
|
|
|
* a box. It is scrollable, and only one item can be selected at a time.
|
|
|
|
*/
|
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *scr, *bx;
|
|
|
|
Eina_List *items;
|
|
|
|
int icon_size;
|
2009-06-17 08:35:19 -07:00
|
|
|
Eina_Bool scrollable : 1;
|
2009-10-06 08:08:41 -07:00
|
|
|
Evas_Object *menu_parent;
|
2009-10-02 12:22:40 -07:00
|
|
|
Eina_Bool homogeneous : 1;
|
2009-10-06 13:14:46 -07:00
|
|
|
double align;
|
2008-12-18 05:38:58 -08:00
|
|
|
};
|
|
|
|
|
2009-02-25 07:54:26 -08:00
|
|
|
struct _Elm_Toolbar_Item
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas_Object *base;
|
|
|
|
const char *label;
|
|
|
|
Evas_Object *icon;
|
2010-03-16 08:31:38 -07:00
|
|
|
Evas_Smart_Cb func;
|
|
|
|
Evas_Smart_Cb del_cb;
|
2008-12-18 05:38:58 -08:00
|
|
|
const void *data;
|
2009-06-17 08:35:19 -07:00
|
|
|
Eina_Bool selected : 1;
|
2009-08-25 15:46:19 -07:00
|
|
|
Eina_Bool disabled : 1;
|
2009-08-30 09:54:15 -07:00
|
|
|
Eina_Bool separator : 1;
|
2009-10-06 08:08:41 -07:00
|
|
|
Eina_Bool menu;
|
2009-10-07 10:11:41 -07:00
|
|
|
Evas_Object *o_menu;
|
2008-12-18 05:38:58 -08:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2009-08-25 15:46:19 -07:00
|
|
|
static void _item_show(Elm_Toolbar_Item *it);
|
|
|
|
static void _item_select(Elm_Toolbar_Item *it);
|
|
|
|
static void _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled);
|
2009-11-14 17:52:40 -08:00
|
|
|
static void _del_pre_hook(Evas_Object *obj);
|
2008-12-18 05:38:58 -08:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _theme_hook(Evas_Object *obj);
|
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
2009-11-14 17:52:40 -08:00
|
|
|
static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2009-10-06 08:08:41 -07:00
|
|
|
static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2009-10-11 06:37:01 -07:00
|
|
|
static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2009-11-14 17:52:40 -08:00
|
|
|
static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
|
2009-10-06 08:08:41 -07:00
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
static void
|
2009-02-25 07:54:26 -08:00
|
|
|
_item_show(Elm_Toolbar_Item *it)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Evas_Coord x, y, w, h, bx, by;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
|
|
|
|
evas_object_geometry_get(it->base, &x, &y, &w, &h);
|
|
|
|
elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
|
|
|
|
}
|
|
|
|
|
2008-12-18 20:26:24 -08:00
|
|
|
static void
|
2009-02-25 07:54:26 -08:00
|
|
|
_item_select(Elm_Toolbar_Item *it)
|
2008-12-18 20:26:24 -08:00
|
|
|
{
|
2009-02-25 07:54:26 -08:00
|
|
|
Elm_Toolbar_Item *it2;
|
2008-12-18 20:26:24 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
Evas_Object *obj2;
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2009-08-25 15:46:19 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2009-08-30 09:54:15 -07:00
|
|
|
if ((it->selected) || (it->disabled) || (it->separator)) return;
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(wd->items, l, it2)
|
2008-12-18 20:26:24 -08:00
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (it2->selected)
|
|
|
|
{
|
|
|
|
it2->selected = EINA_FALSE;
|
|
|
|
edje_object_signal_emit(it2->base, "elm,state,unselected", "elm");
|
|
|
|
break;
|
|
|
|
}
|
2008-12-18 20:26:24 -08:00
|
|
|
}
|
2009-06-17 08:35:19 -07:00
|
|
|
it->selected = EINA_TRUE;
|
2008-12-18 20:26:24 -08:00
|
|
|
edje_object_signal_emit(it->base, "elm,state,selected", "elm");
|
|
|
|
_item_show(it);
|
|
|
|
obj2 = it->obj;
|
2009-10-06 08:08:41 -07:00
|
|
|
if(it->menu)
|
2009-10-18 10:20:18 -07:00
|
|
|
{
|
|
|
|
evas_object_show(it->o_menu);
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(it->base, EVAS_CALLBACK_RESIZE,
|
2009-10-18 10:20:18 -07:00
|
|
|
_menu_move_resize, it);
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOVE,
|
2009-10-18 10:20:18 -07:00
|
|
|
_menu_move_resize, it);
|
2009-10-07 10:11:41 -07:00
|
|
|
|
2009-10-18 10:20:18 -07:00
|
|
|
_menu_move_resize(it, NULL, NULL, NULL);
|
|
|
|
}
|
2009-01-13 01:20:53 -08:00
|
|
|
if (it->func) it->func((void *)(it->data), it->obj, it);
|
2009-01-07 13:08:36 -08:00
|
|
|
evas_object_smart_callback_call(obj2, "clicked", it);
|
2008-12-18 20:26:24 -08:00
|
|
|
}
|
|
|
|
|
2009-10-06 08:08:41 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-10-06 08:08:41 -07:00
|
|
|
{
|
2009-10-18 10:20:18 -07:00
|
|
|
Elm_Toolbar_Item *it = data;
|
|
|
|
elm_toolbar_item_unselect_all(it->obj);
|
2009-10-06 08:08:41 -07:00
|
|
|
}
|
|
|
|
|
2009-11-13 14:22:05 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-11-13 14:22:05 -08:00
|
|
|
{
|
|
|
|
// avoid hide being emitted during object deletion
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
|
|
|
|
}
|
|
|
|
|
2009-10-06 08:08:41 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-10-06 13:14:46 -07:00
|
|
|
{
|
2009-10-22 15:10:23 -07:00
|
|
|
Elm_Toolbar_Item *it = data;
|
|
|
|
Evas_Coord x,y,w,h;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
2009-10-18 10:20:18 -07:00
|
|
|
|
2009-11-09 18:03:52 -08:00
|
|
|
if ((!wd) || (!wd->menu_parent)) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_geometry_get(it->base, &x, &y, &w, &h);
|
|
|
|
elm_menu_move(it->o_menu, x, y+h);
|
2009-10-06 08:08:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-06 13:14:46 -07:00
|
|
|
static void
|
2009-08-25 15:46:19 -07:00
|
|
|
_item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2009-08-25 15:46:19 -07:00
|
|
|
if (it->disabled == disabled) return;
|
|
|
|
it->disabled = disabled;
|
2009-10-06 13:14:46 -07:00
|
|
|
if (it->disabled)
|
2009-08-25 15:46:19 -07:00
|
|
|
edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
|
|
|
|
}
|
|
|
|
|
2009-10-18 10:20:18 -07:00
|
|
|
static void
|
2009-10-15 13:48:00 -07:00
|
|
|
_del_pre_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
|
|
|
|
if (!wd) return;
|
|
|
|
EINA_LIST_FREE(wd->items, it)
|
2009-11-13 14:22:05 -08:00
|
|
|
{
|
2009-11-21 08:21:35 -08:00
|
|
|
if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
|
2009-11-13 14:22:05 -08:00
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
if (it->icon) evas_object_del(it->icon);
|
|
|
|
if ((!wd->menu_parent) && (it->o_menu)) evas_object_del(it->o_menu);
|
|
|
|
evas_object_del(it->base);
|
|
|
|
free(it);
|
|
|
|
}
|
2009-10-15 13:48:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-25 15:46:19 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2008-12-18 05:38:58 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
2008-12-18 20:26:24 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2009-02-25 07:54:26 -08:00
|
|
|
Elm_Toolbar_Item *it;
|
2009-04-22 21:03:27 -07:00
|
|
|
const char *style = elm_widget_style_get(obj);
|
2010-05-11 18:03:46 -07:00
|
|
|
double scale = 0;
|
2009-04-22 21:03:27 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
|
2009-08-30 09:54:15 -07:00
|
|
|
scale = (elm_widget_scale_get(obj) * _elm_config->scale);
|
2010-03-22 21:46:53 -07:00
|
|
|
// edje_object_scale_set(wd->scr, scale);
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
2008-12-18 20:26:24 -08:00
|
|
|
{
|
2009-08-30 09:54:15 -07:00
|
|
|
Evas_Coord mw, mh;
|
|
|
|
|
|
|
|
edje_object_scale_set(it->base, scale);
|
2009-10-06 13:14:46 -07:00
|
|
|
if (!it->separator)
|
2009-08-30 09:54:15 -07:00
|
|
|
{
|
2009-10-06 13:14:46 -07:00
|
|
|
if (it->selected)
|
2009-08-30 09:54:15 -07:00
|
|
|
edje_object_signal_emit(it->base, "elm,state,selected", "elm");
|
|
|
|
if (it->disabled)
|
|
|
|
edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, it->base, "toolbar", "item", style);
|
2009-08-30 09:54:15 -07:00
|
|
|
if (it->icon)
|
|
|
|
{
|
|
|
|
int ms = 0;
|
|
|
|
|
|
|
|
ms = ((double)wd->icon_size * _elm_config->scale);
|
2009-10-11 06:37:01 -07:00
|
|
|
evas_object_size_hint_min_set(it->icon, ms, ms);
|
|
|
|
evas_object_size_hint_max_set(it->icon, ms, ms);
|
2009-10-06 13:14:46 -07:00
|
|
|
edje_object_part_swallow(it->base, "elm.swallow.icon",
|
2009-08-30 09:54:15 -07:00
|
|
|
it->icon);
|
|
|
|
}
|
|
|
|
edje_object_part_text_set(it->base, "elm.text", it->label);
|
|
|
|
}
|
2009-10-06 13:14:46 -07:00
|
|
|
else
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, it->base, "toolbar", "separator", style);
|
2009-10-18 10:20:18 -07:00
|
|
|
|
2009-07-06 23:46:51 -07:00
|
|
|
mw = mh = -1;
|
2009-10-18 10:20:18 -07:00
|
|
|
if (!it->separator)
|
2009-10-11 06:37:01 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
2009-07-06 23:46:51 -07:00
|
|
|
edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
|
2009-10-18 10:20:18 -07:00
|
|
|
if (!it->separator)
|
2009-10-11 06:37:01 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
2009-08-30 09:57:14 -07:00
|
|
|
evas_object_size_hint_min_set(it->base, mw, mh);
|
2008-12-18 20:26:24 -08:00
|
|
|
}
|
2008-12-18 05:38:58 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-11-09 18:03:52 -08:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2008-12-18 05:38:58 -08:00
|
|
|
Evas_Coord vw = 0, vh = 0;
|
2009-09-30 04:26:26 -07:00
|
|
|
Evas_Coord w, h;
|
2008-12-18 05:38:58 -08:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_smart_calculate(wd->bx);
|
2009-10-06 13:14:46 -07:00
|
|
|
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
|
2009-08-30 09:33:03 -07:00
|
|
|
&minw, &minh);
|
2009-09-30 04:26:26 -07:00
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
2009-10-18 10:20:18 -07:00
|
|
|
if (w < minw) w = minw;
|
|
|
|
if (h < minh) h = minh;
|
2009-09-30 04:26:26 -07:00
|
|
|
|
|
|
|
evas_object_resize(wd->scr, w, h);
|
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_size_hint_min_get(wd->bx, &minw, &minh);
|
2009-10-18 10:20:18 -07:00
|
|
|
if (w > minw) minw = w;
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_resize(wd->bx, minw, minh);
|
|
|
|
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
|
|
|
|
if (wd->scrollable)
|
2009-11-09 18:03:52 -08:00
|
|
|
minw = w - vw;
|
2008-12-18 05:38:58 -08:00
|
|
|
else
|
2009-11-09 18:03:52 -08:00
|
|
|
minw = minw + (w - vw);
|
|
|
|
minh = minh + (h - vh);
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2009-11-09 18:03:52 -08:00
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
Evas_Coord mw, mh, vw, vh, w, h;
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2009-02-25 07:54:26 -08:00
|
|
|
Elm_Toolbar_Item *it;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2008-12-18 05:38:58 -08:00
|
|
|
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
|
|
|
|
evas_object_size_hint_min_get(wd->bx, &mw, &mh);
|
|
|
|
evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
|
|
|
|
if (vw >= mw)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (w != vw) evas_object_resize(wd->bx, vw, h);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (it->selected)
|
|
|
|
{
|
|
|
|
_item_show(it);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2008-12-18 20:26:24 -08:00
|
|
|
_item_select(data);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
static void
|
|
|
|
_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = data;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-10-02 12:22:40 -07:00
|
|
|
_els_box_layout(o, priv, 1, wd->homogeneous);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Add a toolbar object to @p parent.
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
*
|
|
|
|
* @return The created object, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_toolbar_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "toolbar");
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "toolbar");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-12-18 05:38:58 -08:00
|
|
|
elm_widget_data_set(obj, wd);
|
2009-10-15 13:48:00 -07:00
|
|
|
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
|
2008-12-18 05:38:58 -08:00
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
|
|
|
elm_widget_can_focus_set(obj, 0);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
wd->scr = elm_smart_scroller_add(e);
|
2010-05-07 06:24:29 -07:00
|
|
|
elm_smart_scroller_widget_set(wd->scr, obj);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
|
2009-09-28 21:35:35 -07:00
|
|
|
elm_smart_scroller_bounce_allow_set(wd->scr, 1, 0);
|
2008-12-18 05:38:58 -08:00
|
|
|
elm_widget_resize_object_set(obj, wd->scr);
|
2009-07-06 23:46:51 -07:00
|
|
|
elm_smart_scroller_policy_set(wd->scr,
|
|
|
|
ELM_SMART_SCROLLER_POLICY_AUTO,
|
|
|
|
ELM_SMART_SCROLLER_POLICY_OFF);
|
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
wd->icon_size = 32;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->scrollable = EINA_TRUE;
|
2009-10-02 12:22:40 -07:00
|
|
|
wd->homogeneous = EINA_TRUE;
|
2009-10-06 13:14:46 -07:00
|
|
|
wd->align = 0.5;
|
2009-10-22 15:10:23 -07:00
|
|
|
|
2009-10-02 12:22:40 -07:00
|
|
|
wd->bx = evas_object_box_add(e);
|
2009-10-06 13:14:46 -07:00
|
|
|
evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_box_layout_set(wd->bx, _layout, wd, NULL);
|
2008-12-18 05:38:58 -08:00
|
|
|
elm_widget_sub_object_add(obj, wd->bx);
|
|
|
|
elm_smart_scroller_child_set(wd->scr, wd->bx);
|
|
|
|
evas_object_show(wd->bx);
|
|
|
|
|
2009-08-30 09:33:03 -07:00
|
|
|
evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-18 05:38:58 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the icon size (in pixels) for the toolbar.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param icon_size The icon size in pixels
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
|
2009-08-25 17:30:55 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-08-25 17:30:55 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2009-08-25 17:47:31 -07:00
|
|
|
if (icon_size > 48) return;
|
|
|
|
if (wd->icon_size == icon_size) return;
|
2009-08-25 17:30:55 -07:00
|
|
|
wd->icon_size = icon_size;
|
|
|
|
_theme_hook(obj);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the icon size (in pixels) for the toolbar.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @return The icon size in pixels
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI int
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_toolbar_icon_size_get(const Evas_Object *obj)
|
2009-08-25 17:47:31 -07:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) 0;
|
2009-08-25 17:47:31 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return 0;
|
2009-08-25 17:47:31 -07:00
|
|
|
return wd->icon_size;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Add an item to the toolbar.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param icon The icon object of the item
|
|
|
|
* @param label The label of the item
|
|
|
|
* @param func The function to call when the item is clicked
|
|
|
|
* @param data The data to associate with the item
|
|
|
|
*
|
|
|
|
* @return The toolbar item, or NULL upon failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
EAPI Elm_Toolbar_Item *
|
2010-03-16 08:31:38 -07:00
|
|
|
elm_toolbar_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb func, const void *data)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2008-12-18 05:38:58 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord mw, mh;
|
2009-08-26 07:34:55 -07:00
|
|
|
Elm_Toolbar_Item *it;
|
2009-08-25 15:46:19 -07:00
|
|
|
|
2009-08-26 07:34:55 -07:00
|
|
|
if (!wd) return NULL;
|
2009-10-18 10:20:18 -07:00
|
|
|
it = ELM_NEW(Elm_Toolbar_Item);
|
2009-08-26 09:22:52 -07:00
|
|
|
if (!it) return NULL;
|
2008-12-18 05:38:58 -08:00
|
|
|
wd->items = eina_list_append(wd->items, it);
|
|
|
|
it->obj = obj;
|
|
|
|
it->label = eina_stringshare_add(label);
|
|
|
|
it->icon = icon;
|
|
|
|
it->func = func;
|
|
|
|
it->data = data;
|
2009-08-30 09:54:15 -07:00
|
|
|
it->separator = EINA_FALSE;
|
2008-12-18 05:38:58 -08:00
|
|
|
it->base = edje_object_add(evas_object_evas_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, it->base, "toolbar", "item", elm_widget_style_get(obj));
|
2008-12-18 05:38:58 -08:00
|
|
|
edje_object_signal_callback_add(it->base, "elm,action,click", "elm",
|
2009-07-06 23:46:51 -07:00
|
|
|
_select, it);
|
2008-12-23 06:05:56 -08:00
|
|
|
elm_widget_sub_object_add(obj, it->base);
|
2008-12-18 20:26:24 -08:00
|
|
|
if (it->icon)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2009-08-30 09:33:03 -07:00
|
|
|
int ms = 0;
|
|
|
|
|
|
|
|
ms = ((double)wd->icon_size * _elm_config->scale);
|
2009-10-11 06:37:01 -07:00
|
|
|
evas_object_size_hint_min_set(it->icon, ms, ms);
|
|
|
|
evas_object_size_hint_max_set(it->icon, ms, ms);
|
2009-07-06 23:46:51 -07:00
|
|
|
edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
|
|
|
|
evas_object_show(it->icon);
|
|
|
|
elm_widget_sub_object_add(obj, it->icon);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
2008-12-18 20:26:24 -08:00
|
|
|
edje_object_part_text_set(it->base, "elm.text", it->label);
|
2009-02-11 03:49:43 -08:00
|
|
|
mw = mh = -1;
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
|
|
|
edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
2009-11-09 05:14:05 -08:00
|
|
|
evas_object_size_hint_weight_set(it->base, -1.0, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(it->base, 0.5, EVAS_HINT_FILL);
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_size_hint_min_set(it->base, mw, mh);
|
2009-10-02 12:22:40 -07:00
|
|
|
evas_object_box_append(wd->bx, it->base);
|
2008-12-18 05:38:58 -08:00
|
|
|
evas_object_show(it->base);
|
|
|
|
_sizing_eval(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
return it;
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the icon associated with @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return The icon object
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-08-12 15:37:48 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_toolbar_item_icon_get(Elm_Toolbar_Item *item)
|
|
|
|
{
|
|
|
|
if (!item) return NULL;
|
|
|
|
return item->icon;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the label associated with @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return The label
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-08-12 15:37:48 -07:00
|
|
|
EAPI const char *
|
2010-03-31 09:38:37 -07:00
|
|
|
elm_toolbar_item_label_get(const Elm_Toolbar_Item *item)
|
2009-08-12 15:37:48 -07:00
|
|
|
{
|
|
|
|
if (!item) return NULL;
|
|
|
|
return item->label;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the selected state of @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return If true, the item is selected
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2010-03-31 09:38:37 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item)
|
|
|
|
{
|
|
|
|
if (!item) return EINA_FALSE;
|
|
|
|
return item->selected;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the label associated with @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @param label The label of @p item
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label)
|
2009-08-25 16:47:08 -07:00
|
|
|
{
|
2009-11-09 18:03:52 -08:00
|
|
|
Evas_Coord mw = -1, mh = -1;
|
|
|
|
|
2009-08-25 16:47:08 -07:00
|
|
|
if (!item) return;
|
2010-03-13 13:01:26 -08:00
|
|
|
eina_stringshare_replace(&item->label, label);
|
2009-08-25 16:47:08 -07:00
|
|
|
edje_object_part_text_set(item->base, "elm.text", item->label);
|
2009-10-30 07:10:41 -07:00
|
|
|
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
|
|
|
edje_object_size_min_restricted_calc(item->base, &mw, &mh, mw, mh);
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
2009-11-09 18:03:52 -08:00
|
|
|
evas_object_size_hint_weight_set(item->base, -1.0, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(item->base, 0.5, EVAS_HINT_FILL);
|
2009-10-30 07:10:41 -07:00
|
|
|
evas_object_size_hint_min_set(item->base, mw, mh);
|
2009-08-25 16:47:08 -07:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a toolbar item.
|
|
|
|
*
|
|
|
|
* @param it The toolbar item
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
EAPI void
|
2009-02-25 07:54:26 -08:00
|
|
|
elm_toolbar_item_del(Elm_Toolbar_Item *it)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2008-12-18 20:26:24 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Evas_Object *obj2 = it->obj;
|
2009-08-25 15:46:19 -07:00
|
|
|
|
2009-08-26 07:34:55 -07:00
|
|
|
if ((!wd) || (!it)) return;
|
2009-11-21 08:21:35 -08:00
|
|
|
if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
|
2008-12-18 20:26:24 -08:00
|
|
|
wd->items = eina_list_remove(wd->items, it);
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
if (it->icon) evas_object_del(it->icon);
|
|
|
|
evas_object_del(it->base);
|
|
|
|
free(it);
|
|
|
|
_theme_hook(obj2);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
|
2009-11-21 08:21:35 -08:00
|
|
|
/**
|
|
|
|
* Set the function called when a toolbar item is freed.
|
|
|
|
*
|
|
|
|
* @param it The item to set the callback on
|
|
|
|
* @param func The function called
|
|
|
|
*
|
2010-01-17 02:33:22 -08:00
|
|
|
* @ingroup Toolbar
|
2009-11-21 08:21:35 -08:00
|
|
|
*/
|
|
|
|
EAPI void
|
2010-03-16 08:31:38 -07:00
|
|
|
elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *it, Evas_Smart_Cb func)
|
2009-11-21 08:21:35 -08:00
|
|
|
{
|
|
|
|
it->del_cb = func;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Select the toolbar item @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_select(Elm_Toolbar_Item *item)
|
|
|
|
{
|
2009-08-30 09:33:03 -07:00
|
|
|
if (!item) return;
|
2008-12-18 20:26:24 -08:00
|
|
|
_item_select(item);
|
2008-12-18 05:38:58 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the disabled state of @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return If true, the item is disabled
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_toolbar_item_disabled_get(Elm_Toolbar_Item *item)
|
2009-08-25 15:46:19 -07:00
|
|
|
{
|
|
|
|
if (!item) return EINA_FALSE;
|
|
|
|
return item->disabled;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the disabled state of @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @param disabled If true, the item is disabled
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled)
|
2009-08-25 15:46:19 -07:00
|
|
|
{
|
2009-08-25 17:49:38 -07:00
|
|
|
if (!item) return;
|
2009-08-25 15:46:19 -07:00
|
|
|
_item_disable(item, disabled);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the separator state of @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @param separator If true, the item is a separator
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator)
|
2009-08-30 09:54:15 -07:00
|
|
|
{
|
|
|
|
if (!item) return;
|
|
|
|
if (item->separator == separator) return;
|
|
|
|
item->separator = separator;
|
|
|
|
_theme_hook(item->obj);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the separator state of @p item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return If true, the item is a separator
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_toolbar_item_separator_get(Elm_Toolbar_Item *item)
|
2009-08-30 09:54:15 -07:00
|
|
|
{
|
|
|
|
if (!item) return EINA_FALSE;
|
|
|
|
return item->separator;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the scrollable state of toolbar @p obj.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param scrollable If true, the toolbar will be scrollable
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2008-12-18 05:38:58 -08:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
|
2008-12-18 05:38:58 -08:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-12-18 05:38:58 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-25 15:46:19 -07:00
|
|
|
|
2009-08-26 07:29:18 -07:00
|
|
|
if (!wd) return;
|
2008-12-18 05:38:58 -08:00
|
|
|
wd->scrollable = scrollable;
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2009-09-30 03:53:08 -07:00
|
|
|
|
2010-04-26 22:43:54 -07:00
|
|
|
/**
|
|
|
|
* Get the scrollable state of toolbar @p obj.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @return If true, the toolbar is scrollable
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_toolbar_scrollable_get(Evas_Object *obj)
|
|
|
|
{
|
2010-06-05 06:12:45 -07:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2010-04-26 22:43:54 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
2010-06-05 06:12:45 -07:00
|
|
|
if (!wd) return EINA_FALSE;
|
2010-04-26 22:43:54 -07:00
|
|
|
return wd->scrollable;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the homogenous mode of toolbar @p obj.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param homogenous If true, the toolbar items will be uniform in size
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-09-30 03:53:08 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-30 03:53:08 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return;
|
2009-10-02 12:22:40 -07:00
|
|
|
wd->homogeneous = !!homogenous;
|
|
|
|
evas_object_smart_calculate(wd->bx);
|
2009-09-30 03:53:08 -07:00
|
|
|
}
|
|
|
|
|
2010-04-26 22:43:54 -07:00
|
|
|
/**
|
|
|
|
* Get the homogenous mode of toolbar @p obj.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @return If true, the toolbar items are uniform in size
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_toolbar_homogenous_get(Evas_Object *obj)
|
|
|
|
{
|
2010-06-05 06:12:45 -07:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2010-04-26 22:43:54 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
2010-06-05 06:12:45 -07:00
|
|
|
if (!wd) return EINA_FALSE;
|
2010-04-26 22:43:54 -07:00
|
|
|
return wd->homogeneous;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set the parent object of the toolbar menu
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param parent The parent of the menu object
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
2009-10-06 08:08:41 -07:00
|
|
|
elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
|
|
|
|
{
|
2009-10-18 10:20:18 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Elm_Toolbar_Item *it;
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-18 10:20:18 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-10-07 10:11:41 -07:00
|
|
|
|
2009-10-18 10:20:18 -07:00
|
|
|
if ((!wd) || (!parent)) return;
|
|
|
|
wd->menu_parent = parent;
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
2009-10-11 06:37:01 -07:00
|
|
|
if (it->o_menu)
|
2009-10-18 10:20:18 -07:00
|
|
|
elm_menu_parent_set(it->o_menu, wd->menu_parent);
|
|
|
|
}
|
2009-10-06 08:08:41 -07:00
|
|
|
}
|
|
|
|
|
2010-04-26 22:43:54 -07:00
|
|
|
/**
|
|
|
|
* Get the parent object of the toolbar menu
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @return The parent of the menu object
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_toolbar_menu_parent_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
|
|
|
|
return wd->menu_parent;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Unselect all of the items in the toolbar.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
2009-10-06 11:18:21 -07:00
|
|
|
elm_toolbar_item_unselect_all(Evas_Object *obj)
|
|
|
|
{
|
2009-10-18 10:20:18 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Elm_Toolbar_Item *it;
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-18 10:20:18 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return;
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
2009-10-06 11:18:21 -07:00
|
|
|
if (it->selected)
|
2009-10-18 10:20:18 -07:00
|
|
|
{
|
|
|
|
it->selected = EINA_FALSE;
|
|
|
|
edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-06 11:18:21 -07:00
|
|
|
}
|
2009-10-06 08:08:41 -07:00
|
|
|
|
2010-05-27 02:01:41 -07:00
|
|
|
/**
|
|
|
|
* Unselect the specified toolbar item.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_unselect(Elm_Toolbar_Item *item)
|
|
|
|
{
|
|
|
|
if ((!item) || (!item->selected)) return;
|
|
|
|
item->selected = EINA_FALSE;
|
|
|
|
edje_object_signal_emit(item->base, "elm,state,unselected", "elm");
|
|
|
|
}
|
|
|
|
|
2009-10-06 13:14:46 -07:00
|
|
|
/**
|
2010-04-12 01:12:02 -07:00
|
|
|
* Set the alignment of the items.
|
2009-10-06 13:14:46 -07:00
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
2009-10-22 15:10:23 -07:00
|
|
|
* @param align The new alignment. (left) 0.0 ... 1.0 (right)
|
2010-04-12 01:12:02 -07:00
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
2009-10-06 13:14:46 -07:00
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_toolbar_align_set(Evas_Object *obj, double align)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-18 10:20:18 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-10-06 13:14:46 -07:00
|
|
|
|
2009-10-18 10:20:18 -07:00
|
|
|
if (!wd) return;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (wd->align != align)
|
2009-10-18 10:20:18 -07:00
|
|
|
evas_object_size_hint_align_set(wd->bx, align, 0.5);
|
2010-03-09 03:42:53 -08:00
|
|
|
wd->align = align;
|
2009-10-06 13:14:46 -07:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Get the alignment of the items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @return The alignment. (left) 0.0 ... 1.0 (right)
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2010-03-30 13:42:01 -07:00
|
|
|
EAPI double
|
|
|
|
elm_toolbar_align_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return 0.0;
|
|
|
|
return wd->align;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set whether the toolbar item opens a menu.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @param menu If true, @p item will open a menu when selected
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-06 13:14:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu)
|
2009-10-06 08:08:41 -07:00
|
|
|
{
|
2009-10-18 10:20:18 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(item->obj);
|
|
|
|
|
|
|
|
if ((!wd) || (!item)) return;
|
2009-10-06 08:08:41 -07:00
|
|
|
if (item->menu == menu) return;
|
|
|
|
item->menu = menu;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (menu)
|
2009-10-15 13:48:00 -07:00
|
|
|
{
|
|
|
|
item->o_menu = elm_menu_add(item->base);
|
2009-10-18 10:20:18 -07:00
|
|
|
if (wd->menu_parent)
|
2009-10-15 13:48:00 -07:00
|
|
|
elm_menu_parent_set(item->o_menu, wd->menu_parent);
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
|
2009-10-18 10:20:18 -07:00
|
|
|
_menu_hide, item);
|
2009-11-13 14:22:05 -08:00
|
|
|
evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
|
|
|
|
_menu_del, item);
|
2009-10-15 13:48:00 -07:00
|
|
|
}
|
2009-10-18 10:20:18 -07:00
|
|
|
else if (item->o_menu)
|
2009-10-15 13:48:00 -07:00
|
|
|
{
|
|
|
|
evas_object_del(item->o_menu);
|
|
|
|
}
|
2009-10-06 08:08:41 -07:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether the toolbar item opens a menu.
|
|
|
|
*
|
|
|
|
* @param item The toolbar item
|
|
|
|
* @return If true, @p item opens a menu when selected
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
2009-10-18 10:20:18 -07:00
|
|
|
EAPI Evas_Object *
|
2009-10-11 06:37:01 -07:00
|
|
|
elm_toolbar_item_menu_get(Elm_Toolbar_Item *item)
|
2009-10-06 08:08:41 -07:00
|
|
|
{
|
2010-02-11 08:13:41 -08:00
|
|
|
if (!item) return NULL;
|
2009-10-11 06:37:01 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(item->obj);
|
2010-02-11 08:13:41 -08:00
|
|
|
if (!wd) return NULL;
|
2009-10-11 06:37:01 -07:00
|
|
|
elm_toolbar_item_menu_set(item, 1);
|
|
|
|
return item->o_menu;
|
2009-10-06 08:08:41 -07:00
|
|
|
}
|
2010-04-26 22:43:54 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of all toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return An Eina_List* of the toolbar items in @p obj
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Eina_List *
|
|
|
|
elm_toolbar_item_get_all(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
|
|
|
|
return wd->items;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the first toolbar item in the list of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The first toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_get_first(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!(it = eina_list_data_get(wd->items))) return NULL;
|
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the last toolbar item in the list of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The last toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_get_last(Evas_Object *obj)
|
|
|
|
{
|
2010-05-27 02:01:41 -07:00
|
|
|
Eina_List *last;
|
2010-04-26 22:43:54 -07:00
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!(last = eina_list_last(wd->items))) return NULL;
|
|
|
|
it = eina_list_data_get(last);
|
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the next toolbar item (relative to the currently selected
|
|
|
|
* toolbar item) in the list of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The next toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_get_next(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_List *l, *l2;
|
|
|
|
Elm_Toolbar_Item *it, *next;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return NULL;
|
|
|
|
EINA_LIST_FOREACH_SAFE(wd->items, l, l2, it)
|
|
|
|
{
|
|
|
|
if (it->selected)
|
|
|
|
{
|
|
|
|
if (!(next = eina_list_data_get(l2))) return NULL;
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the next non-disabled, non-separator toolbar item in the list
|
|
|
|
* of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The newly selected toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_select_next(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_List *l, *l2;
|
|
|
|
Elm_Toolbar_Item *it, *next;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return NULL;
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
|
|
|
if (it->selected)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(l, l2, next)
|
|
|
|
if ((!next->disabled) && (next->separator))
|
|
|
|
{
|
|
|
|
_item_select(next);
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the first non-disabled, non-separator toolbar item in the list
|
|
|
|
* of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The newly selected toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_select_first(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
|
|
|
if ((!it->disabled) && (!it->separator))
|
|
|
|
{
|
|
|
|
_item_select(it);
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the last non-disabled, non-separator toolbar item in the list
|
|
|
|
* of toolbar items.
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
*
|
|
|
|
* @return The newly selected toolbar item, or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_select_last(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
EINA_LIST_REVERSE_FOREACH(wd->items, l, it)
|
|
|
|
{
|
|
|
|
if ((!it->disabled) && (!it->separator))
|
|
|
|
{
|
|
|
|
_item_select(it);
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer to a toolbar item by its label
|
|
|
|
*
|
|
|
|
* @param obj The toolbar object
|
|
|
|
* @param label The label of the item to find
|
|
|
|
*
|
|
|
|
* @return The pointer to the toolbar item matching @p label
|
|
|
|
* Returns NULL on failure.
|
|
|
|
*
|
|
|
|
* @ingroup Toolbar
|
|
|
|
*/
|
|
|
|
EAPI Elm_Toolbar_Item *
|
|
|
|
elm_toolbar_item_find_by_label(Evas_Object *obj, const char *label)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Toolbar_Item *it;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return NULL;
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
|
|
|
if (!strcmp(it->label, label)) return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|