From: Hyoyoung Chang <hyoyoung@gmail.com>

Subject: [E-devel] [patch] elm_toolbar - add elm_toolbar_select_mode_set

As already sent genlist select_mode_set patch,
I applied same apis to elm_toolbar.

+EAPI void
+elm_toolbar_select_mode_set(Evas_Object *obj,
Elm_Object_Select_Mode_Type mode)


+EAPI Elm_Object_Select_Mode_Type
+elm_toolbar_select_mode_get(const Evas_Object *obj)



SVN revision: 68945
This commit is contained in:
Hyoyoung Chang 2012-03-07 13:23:22 +00:00 committed by Carsten Haitzler
parent 0e50d5d966
commit e479d536d6
4 changed files with 166 additions and 81 deletions

View File

@ -529,7 +529,7 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
evas_object_size_hint_weight_set(tb, 0.0, 0.0);
evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
elm_toolbar_no_select_mode_set(tb, EINA_TRUE);
elm_toolbar_select_mode_set(tb, ELM_OBJECT_NO_SELECT);
ph1 = elm_photo_add(win);
ph2 = elm_photo_add(win);

View File

@ -5948,6 +5948,70 @@ EINA_DEPRECATED EAPI int elm_diskselector_side_label_length_g
*/
EINA_DEPRECATED EAPI void elm_diskselector_side_label_length_set(Evas_Object *obj, int len);
/**
* Set whether the toolbar should always have an item selected.
*
* @param obj The toolbar object.
* @param always_select @c EINA_TRUE to enable always-select mode or @c EINA_FALSE to
* disable it.
*
* This will cause the toolbar to always have an item selected, and clicking
* the selected item will not cause a selected event to be emitted. Enabling this mode
* will immediately select the first toolbar item.
*
* Always-selected is disabled by default.
*
* @see elm_toolbar_always_select_mode_get().
*
* @ingroup Toolbar
*/
EINA_DEPRECATED EAPI void elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select);
/**
* Get whether the toolbar should always have an item selected.
*
* @param obj The toolbar object.
* @return @c EINA_TRUE means an item will always be selected, @c EINA_FALSE indicates
* that it is possible to have no items selected. If @p obj is @c NULL, @c EINA_FALSE is returned.
*
* @see elm_toolbar_always_select_mode_set() for details.
*
* @ingroup Toolbar
*/
EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_always_select_mode_get(const Evas_Object *obj);
/**
* Set whether the toolbar items' should be selected by the user or not.
*
* @param obj The toolbar object.
* @param no_select @c EINA_TRUE to disable selection or @c EINA_FALSE to
* enable it.
*
* This will turn off the ability to select items entirely and they will
* neither appear selected nor emit selected signals. The clicked
* callback function will still be called.
*
* Selection is enabled by default.
*
* @see elm_toolbar_no_select_mode_get().
*
* @ingroup Toolbar
*/
EINA_DEPRECATED EAPI void elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select);
/**
* Set whether the toolbar items' should be selected by the user or not.
*
* @param obj The toolbar object.
* @return @c EINA_TRUE means items can be selected. @c EINA_FALSE indicates
* they can't. If @p obj is @c NULL, @c EINA_FALSE is returned.
*
* @see elm_toolbar_no_select_mode_set() for details.
*
* @ingroup Toolbar
*/
EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_no_select_mode_get(const Evas_Object *obj);
/**
* @}
*/

View File

@ -18,9 +18,8 @@ struct _Widget_Data
int icon_size;
unsigned int item_count;
double align;
Elm_Object_Select_Mode_Type select_mode;
Eina_Bool homogeneous : 1;
Eina_Bool no_select : 1;
Eina_Bool always_select : 1;
Eina_Bool vertical : 1;
Eina_Bool long_press : 1;
Ecore_Timer *long_timer;
@ -174,11 +173,11 @@ _item_select(Elm_Toolbar_Item *it)
if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object)) return;
sel = it->selected;
if (!wd->no_select)
if (wd->select_mode != ELM_OBJECT_NO_SELECT)
{
if (sel)
{
if (wd->always_select) return;
if (wd->select_mode == ELM_OBJECT_ALWAYS_SELECT) return;
_item_unselect(it);
}
else
@ -908,7 +907,8 @@ _item_del_pre_hook(Elm_Object_Item *it)
wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
wd->item_count--;
if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
if (wd->always_select && item->selected && next) _item_select(next);
if ((wd->select_mode == ELM_OBJECT_ALWAYS_SELECT) &&
item->selected && next) _item_select(next);
_item_del(item);
_theme_hook(obj2);
@ -1022,7 +1022,8 @@ _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb f
evas_object_size_hint_max_set(VIEW(it), -1, -1);
evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
_resize_item, obj);
if ((!wd->items) && wd->always_select) _item_select(it);
if ((!wd->items) && (wd->select_mode == ELM_OBJECT_ALWAYS_SELECT))
_item_select(it);
wd->item_count++;
return it;
}
@ -2099,42 +2100,62 @@ elm_toolbar_item_cursor_engine_only_get(const Elm_Object_Item *it)
return elm_object_item_cursor_engine_only_get(it);
}
EAPI void
EINA_DEPRECATED EAPI void
elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (always_select && (!wd->always_select) && wd->items)
_item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
wd->always_select = always_select;
if (always_select)
elm_toolbar_select_mode_set(obj, ELM_OBJECT_ALWAYS_SELECT);
else
{
Elm_Object_Select_Mode_Type oldmode = elm_toolbar_select_mode_get(obj);
if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
elm_toolbar_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
}
}
EAPI Eina_Bool
EINA_DEPRECATED EAPI Eina_Bool
elm_toolbar_always_select_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->always_select;
Elm_Object_Select_Mode_Type oldmode = elm_toolbar_select_mode_get(obj);
if (oldmode == ELM_OBJECT_ALWAYS_SELECT)
return EINA_TRUE;
else
return EINA_FALSE;
}
EAPI void
EINA_DEPRECATED EAPI void
elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->no_select = no_select;
if (no_select)
elm_toolbar_select_mode_set(obj, ELM_OBJECT_NO_SELECT);
else
{
Elm_Object_Select_Mode_Type oldmode = elm_toolbar_select_mode_get(obj);
if (oldmode == ELM_OBJECT_NO_SELECT)
elm_toolbar_select_mode_set(obj, ELM_OBJECT_NORMAL_SELECT);
}
}
EAPI Eina_Bool
EINA_DEPRECATED EAPI Eina_Bool
elm_toolbar_no_select_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->no_select;
Elm_Object_Select_Mode_Type oldmode = elm_toolbar_select_mode_get(obj);
if (oldmode == ELM_OBJECT_NO_SELECT)
return EINA_TRUE;
else
return EINA_FALSE;
}
EAPI void
@ -2216,3 +2237,29 @@ elm_toolbar_mode_shrink_get(const Evas_Object *obj)
{
return elm_toolbar_shrink_mode_get(obj);
}
EAPI void
elm_toolbar_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode_Type mode)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
return;
if ((mode == ELM_OBJECT_ALWAYS_SELECT) &&
(wd->select_mode != ELM_OBJECT_ALWAYS_SELECT) &&
wd->items)
_item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
if (wd->select_mode != mode)
wd->select_mode = mode;
}
EAPI Elm_Object_Select_Mode_Type
elm_toolbar_select_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
return wd->select_mode;
}

View File

@ -139,70 +139,6 @@ EAPI void elm_toolbar_icon_order_lookup_set(Evas_Object
*/
EAPI Elm_Icon_Lookup_Order elm_toolbar_icon_order_lookup_get(const Evas_Object *obj);
/**
* Set whether the toolbar should always have an item selected.
*
* @param obj The toolbar object.
* @param always_select @c EINA_TRUE to enable always-select mode or @c EINA_FALSE to
* disable it.
*
* This will cause the toolbar to always have an item selected, and clicking
* the selected item will not cause a selected event to be emitted. Enabling this mode
* will immediately select the first toolbar item.
*
* Always-selected is disabled by default.
*
* @see elm_toolbar_always_select_mode_get().
*
* @ingroup Toolbar
*/
EAPI void elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select);
/**
* Get whether the toolbar should always have an item selected.
*
* @param obj The toolbar object.
* @return @c EINA_TRUE means an item will always be selected, @c EINA_FALSE indicates
* that it is possible to have no items selected. If @p obj is @c NULL, @c EINA_FALSE is returned.
*
* @see elm_toolbar_always_select_mode_set() for details.
*
* @ingroup Toolbar
*/
EAPI Eina_Bool elm_toolbar_always_select_mode_get(const Evas_Object *obj);
/**
* Set whether the toolbar items' should be selected by the user or not.
*
* @param obj The toolbar object.
* @param no_select @c EINA_TRUE to disable selection or @c EINA_FALSE to
* enable it.
*
* This will turn off the ability to select items entirely and they will
* neither appear selected nor emit selected signals. The clicked
* callback function will still be called.
*
* Selection is enabled by default.
*
* @see elm_toolbar_no_select_mode_get().
*
* @ingroup Toolbar
*/
EAPI void elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select);
/**
* Set whether the toolbar items' should be selected by the user or not.
*
* @param obj The toolbar object.
* @return @c EINA_TRUE means items can be selected. @c EINA_FALSE indicates
* they can't. If @p obj is @c NULL, @c EINA_FALSE is returned.
*
* @see elm_toolbar_no_select_mode_set() for details.
*
* @ingroup Toolbar
*/
EAPI Eina_Bool elm_toolbar_no_select_mode_get(const Evas_Object *obj);
/**
* Append item to the toolbar.
*
@ -920,6 +856,44 @@ EAPI Eina_Bool elm_toolbar_horizontal_get(const Evas_Object *
* @ingroup Toolbar
*/
EAPI unsigned int elm_toolbar_items_count(const Evas_Object *obj);
/**
* Set the toolbar select mode.
*
* @param obj The toolbar object
* @param mode The select mode
*
* elm_toolbar_select_mode_set() changes item select mode in the toolbar widget.
* - ELM_OBJECT_NORMAL_SELECT : Items will only call their selection func and
* callback when first becoming selected. Any further clicks will
* do nothing, unless you set always select mode.
* - ELM_OBJECT_ALWAYS_SELECT : This means that, even if selected,
* every click will make the selected callbacks be called.
* - ELM_OBJECT_NO_SELECT : This will turn off the ability to select items
* entirely and they will neither appear selected nor call selected
* callback functions.
*
* @see elm_toolbar_select_mode_get()
*
* @ingroup Toolbar
*/
EAPI void
elm_toolbar_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode_Type mode);
/**
* Get the toolbar select mode.
*
* @param obj The toolbar object
* @return The select mode
* (If getting mode is failed, it returns ELM_OBJECT_SELECT_MODE_MAX)
*
* @see elm_toolbar_select_mode_set()
*
* @ingroup Toolbar
*/
EAPI Elm_Object_Select_Mode_Type
elm_toolbar_select_mode_get(const Evas_Object *obj);
/**
* @}
*/