forked from enlightenment/efl
From: Kim Shinwoo <kimcinoo.efl@gmail.com>
Subject: [E-devel] [patch][elementary] diskselector - select option, disabling auto selection. datetime - show even number of items by default, an diskselector item which is right in the center of diskselector is selected automatically. and if the item style emit elm,action,click signal, the item is selected also. so there would be a case that item select callback is called by two ways. one is clicking the item, the other is locating item right in the center of diskselector (if number of displayed item is odd, then after scrolling the selected callback is called always). because of this reason, datetime module always set number of displayed item to even number. to resolve this issue, i add a api to enable or disable default behavior - the auto selection - that can be found on the attachment. moreover the second attachment is for datetime module, now the datetime can show even number of items. SVN revision: 75820
This commit is contained in:
parent
31575a5083
commit
3550d79869
|
@ -406,3 +406,8 @@
|
|||
* Track window states as a total count and be able to self-throttle
|
||||
or suspend rendering as a result.
|
||||
|
||||
2012-08-29 Shinwoo Kim (kimcinoo)
|
||||
|
||||
* Patch for selection of middle item in diskselector required adding
|
||||
API elm_diskselector_autoselect_set/get()
|
||||
|
||||
|
|
|
@ -186,6 +186,17 @@ group { name: "elm/diskselector/item/default";
|
|||
text.align: 0.8 0.5;
|
||||
}
|
||||
}
|
||||
part { name: "auto_select";
|
||||
type: RECT;
|
||||
mouse_events: 1;
|
||||
repeat_events: 1;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
}
|
||||
description {
|
||||
state: "disable" 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
programs {
|
||||
|
@ -223,6 +234,29 @@ group { name: "elm/diskselector/item/default";
|
|||
action: STATE_SET "icon_only" 0.0;
|
||||
target: "elm.swallow.icon";
|
||||
}
|
||||
program { name: "auto_select";
|
||||
signal: "elm,state,autoselect,default";
|
||||
source: "elm";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "auto_select";
|
||||
}
|
||||
program { name: "auto_select_disable";
|
||||
signal: "elm,state,autoselect,disable";
|
||||
source: "elm";
|
||||
action: STATE_SET "disable" 0.0;
|
||||
target: "auto_select";
|
||||
}
|
||||
program { name: "item_click";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "auto_select";
|
||||
script {
|
||||
new st[31];
|
||||
new Float:vl;
|
||||
get_state(PART:"auto_select", st, 30, vl);
|
||||
if (!strcmp(st, "disable"))
|
||||
emit("elm,action,click", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,13 +309,17 @@ group { name: "elm/diskselector/item/datetime/default";
|
|||
text.align: 0.8 0.5;
|
||||
}
|
||||
}
|
||||
part { name: "over1";
|
||||
part { name: "auto_select";
|
||||
type: RECT;
|
||||
mouse_events: 1;
|
||||
repeat_events: 1;
|
||||
ignore_flags: ON_HOLD;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
description { state: "default" 0.0;
|
||||
color: 0 0 0 0;
|
||||
}
|
||||
description { state: "disable" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
visible: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -362,10 +400,28 @@ group { name: "elm/diskselector/item/datetime/default";
|
|||
update_state();
|
||||
}
|
||||
}
|
||||
program { name: "auto_select";
|
||||
signal: "elm,state,autoselect,default";
|
||||
source: "elm";
|
||||
action: STATE_SET "default" 0.0;
|
||||
target: "auto_select";
|
||||
}
|
||||
program { name: "auto_select_disable";
|
||||
signal: "elm,state,autoselect,disable";
|
||||
source: "elm";
|
||||
action: STATE_SET "disable" 0.0;
|
||||
target: "auto_select";
|
||||
}
|
||||
program { name: "field_click";
|
||||
signal: "mouse,clicked,1";
|
||||
source: "over1";
|
||||
action: SIGNAL_EMIT "elm,action,click" "";
|
||||
source: "auto_select";
|
||||
script {
|
||||
new st[31];
|
||||
new Float:vl;
|
||||
get_state(PART:"auto_select", st, 30, vl);
|
||||
if (!strcmp(st, "disable"))
|
||||
emit("elm,action,click", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -535,6 +535,7 @@ _item_click_cb(void *data,
|
|||
}
|
||||
|
||||
if (it->func) it->func((void *)it->base.data, WIDGET(it), it);
|
||||
evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, it);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -614,6 +615,10 @@ _item_new(Evas_Object *obj,
|
|||
_item_content_set_hook((Elm_Object_Item *)it, "icon", icon);
|
||||
}
|
||||
|
||||
ELM_DISKSELECTOR_DATA_GET(obj, sd);
|
||||
if (!sd->auto_select)
|
||||
edje_object_signal_emit(VIEW(it), "elm,state,autoselect,disable", "elm");
|
||||
|
||||
//XXX: ACCESS
|
||||
_elm_access_widget_item_register((Elm_Widget_Item *)it);
|
||||
|
||||
|
@ -873,6 +878,8 @@ _scroll_animate_stop_cb(Evas_Object *obj,
|
|||
|
||||
if (sd->idler) return;
|
||||
|
||||
if (!sd->auto_select) return;
|
||||
|
||||
if (!sd->round)
|
||||
list = sd->items;
|
||||
else
|
||||
|
@ -1088,6 +1095,7 @@ _elm_diskselector_smart_add(Evas_Object *obj)
|
|||
priv->init = EINA_FALSE;
|
||||
priv->len_side = 3;
|
||||
priv->display_item_num_by_api = EINA_FALSE;
|
||||
priv->auto_select = EINA_TRUE;
|
||||
|
||||
_elm_diskselector_smart_theme(obj);
|
||||
priv->s_iface->policy_set
|
||||
|
@ -1647,3 +1655,39 @@ elm_diskselector_display_item_num_get(const Evas_Object *obj)
|
|||
|
||||
return sd->display_item_num;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_diskselector_autoselect_set(Evas_Object *obj, Eina_Bool enable)
|
||||
{
|
||||
Elm_Diskselector_Item *it;
|
||||
Eina_List *l, *list;
|
||||
|
||||
ELM_DISKSELECTOR_CHECK(obj);
|
||||
ELM_DISKSELECTOR_DATA_GET(obj, sd);
|
||||
|
||||
enable = !!enable;
|
||||
if (sd->auto_select == enable) return;
|
||||
sd->auto_select = enable;
|
||||
|
||||
if (!sd->round)
|
||||
list = sd->items;
|
||||
else
|
||||
list = sd->r_items;
|
||||
|
||||
EINA_LIST_FOREACH (list, l, it)
|
||||
{
|
||||
if (!sd->auto_select)
|
||||
edje_object_signal_emit(VIEW(it), "elm,state,autoselect,disable", "elm");
|
||||
else
|
||||
edje_object_signal_emit(VIEW(it), "elm,state,autoselect,default", "elm");
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
elm_diskselector_autoselect_get(const Evas_Object *obj)
|
||||
{
|
||||
ELM_DISKSELECTOR_CHECK(obj) EINA_TRUE;
|
||||
ELM_DISKSELECTOR_DATA_GET(obj, sd);
|
||||
|
||||
return sd->auto_select;
|
||||
}
|
||||
|
|
|
@ -174,6 +174,34 @@ EAPI void elm_diskselector_display_item_num_set(Evas_Object *o
|
|||
*/
|
||||
EAPI int elm_diskselector_display_item_num_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Set the auto select of the diskselector
|
||||
*
|
||||
* After scroll diskselector, an item which is right in the center of diskselector
|
||||
* is selected automatically. This is default behavior of diskselector.
|
||||
* If @p enable is @c EINA_FALSE, the automatic selection is disabled and
|
||||
* even though item is not right in the center user can select item by clicking.
|
||||
*
|
||||
* @param obj The diskselector object.
|
||||
* @param enable EINA_TRUE to enable auto select, EINA_FALSE to disable auto select.
|
||||
* default is EINA_TRUE.
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI void elm_diskselector_autoselect_set(Evas_Object *obj, Eina_Bool enable);
|
||||
|
||||
/**
|
||||
* Get the auto select of the diskselector object.
|
||||
*
|
||||
* @param obj The diskselector object.
|
||||
* @return The auto select set (EINA_TRUE by default)
|
||||
*
|
||||
* @ingroup Diskselector
|
||||
* @since 1.8
|
||||
*/
|
||||
EAPI Eina_Bool elm_diskselector_autoselect_get(const Evas_Object *obj);
|
||||
|
||||
/**
|
||||
* Set bouncing behaviour when the scrolled content reaches an edge.
|
||||
*
|
||||
|
|
|
@ -151,6 +151,7 @@ struct _Elm_Diskselector_Smart_Data
|
|||
Eina_Bool init : 1;
|
||||
Eina_Bool round : 1;
|
||||
Eina_Bool display_item_num_by_api : 1;
|
||||
Eina_Bool auto_select : 1;
|
||||
};
|
||||
|
||||
struct _Elm_Diskselector_Item
|
||||
|
|
|
@ -185,9 +185,9 @@ _field_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
|||
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
||||
evas_object_geometry_get(elm_widget_top_get(ctx_mod->mod_data.base), NULL, NULL, &width, NULL);
|
||||
evas_object_size_hint_min_set(ctx_mod->ctxpopup, width, -1);
|
||||
display_item_num = width / (w + elm_config_finger_size_get());
|
||||
// always display even number of items to avoid autoselection
|
||||
if (display_item_num % 2) display_item_num -= 1;
|
||||
display_item_num = w + elm_config_finger_size_get();
|
||||
|
||||
elm_diskselector_autoselect_set(diskselector, EINA_FALSE);
|
||||
if (display_item_num < DISKSELECTOR_MIN_ITEMS)
|
||||
display_item_num = DISKSELECTOR_MIN_ITEMS;
|
||||
elm_diskselector_display_item_num_set(diskselector, display_item_num);
|
||||
|
|
Loading…
Reference in New Issue