fix another elm bug where arrows are not "clickable" for scrolling to

next/prev item - needed to add a feature to scrolelr (and accidentally
also to scrolled interface too :)) to make this work. now works.



SVN revision: 74969
This commit is contained in:
Carsten Haitzler 2012-08-07 10:20:30 +00:00
parent 55f0bc9da1
commit fee7a0c645
6 changed files with 295 additions and 36 deletions

View File

@ -8,8 +8,8 @@ group { name: "elm/toolbar/base/default";
image: "bt_dis_base.png" COMP;
image: "bt_dis_hilight.png" COMP;
image: "bt_dis_shine.png" COMP;
image: "icon_left_arrow.png" COMP;
image: "icon_right_arrow.png" COMP;
image: "arrow_right.png" COMP;
image: "arrow_left.png" COMP;
}
parts {
part { name: "base";
@ -76,39 +76,34 @@ group { name: "elm/toolbar/base/default";
}
}
part { name: "left_arrow";
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
image.normal: "icon_left_arrow.png";
aspect: 1.0 1.0;
aspect_preference: VERTICAL;
image.normal: "arrow_left.png";
align: 0.0 0.5;
min: 32 32;
max: 32 32;
}
description { state: "hidden" 0.0;
inherit: "default" 0.0;
min: 22 22;
max: 22 22;
visible: 0;
color: 255 255 255 0;
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "right_arrow";
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
image.normal: "icon_right_arrow.png";
aspect: 1.0 1.0;
aspect_preference: VERTICAL;
image.normal: "arrow_right.png";
align: 1.0 0.5;
min: 32 32;
max: 32 32;
}
description { state: "hidden" 0.0;
inherit: "default" 0.0;
min: 22 22;
max: 22 22;
visible: 0;
color: 255 255 255 0;
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "event";
type: RECT;
part { name: "event"; type: RECT;
mouse_events: 1;
repeat_events: 1;
description { state: "default" 0.0;
@ -117,21 +112,39 @@ group { name: "elm/toolbar/base/default";
}
}
programs {
program { name: "sb_hbar_show";
signal: "elm,action,show,hbar";
program { name: "left_show";
signal: "elm,action,show,left";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "left_arrow";
}
program { name: "left_hide";
signal: "elm,action,hide,left";
source: "elm";
action: STATE_SET "default" 0.0;
transition: LINEAR 0.5;
target: "left_arrow";
}
program { name: "right_show";
signal: "elm,action,show,right";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "right_arrow";
}
program { name: "sb_hbar_hide";
signal: "elm,action,hide,hbar";
program { name: "right_hide";
signal: "elm,action,hide,right";
source: "elm";
action: STATE_SET "hidden" 0.0;
target: "left_arrow";
action: STATE_SET "default" 0.0;
target: "right_arrow";
transition: LINEAR 0.5;
}
program { name: "left_go";
signal: "mouse,down,1";
source: "left_arrow";
action: SIGNAL_EMIT "elm,action,left" "elm";
}
program { name: "right_go";
signal: "mouse,down,1";
source: "right_arrow";
action: SIGNAL_EMIT "elm,action,right" "elm";
}
}
}

View File

@ -99,7 +99,7 @@ test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
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_object_scale_set(tb, 0.9);
// elm_object_scale_set(tb, 0.9);
ph1 = elm_photo_add(win);
ph2 = elm_photo_add(win);

View File

@ -508,6 +508,58 @@ _elm_scroll_smooth_debug_shutdown(void)
DBG(" Standard deviation of Y-axis velocity: %9.3f\n", sqrt(y_dev));
}
static void
_elm_direction_arrows_eval(Elm_Scrollable_Smart_Interface_Data *sid)
{
Eina_Bool go_left = EINA_TRUE, go_right = EINA_TRUE;
Eina_Bool go_up = EINA_TRUE, go_down = EINA_TRUE;
Evas_Coord x = 0, y = 0, mx = 0, my = 0, minx = 0, miny = 0;
if (!sid->edje_obj || !sid->pan_obj) return;
ELM_PAN_DATA_GET(sid->pan_obj, psd);
psd->api->pos_max_get(sid->pan_obj, &mx, &my);
psd->api->pos_min_get(sid->pan_obj, &minx, &miny);
psd->api->pos_get(sid->pan_obj, &x, &y);
if (x == minx) go_left = EINA_FALSE;
if (x == (mx + minx)) go_right = EINA_FALSE;
if (y == miny) go_up = EINA_FALSE;
if (y == (my + miny)) go_down = EINA_FALSE;
if (go_left != sid->go_left)
{
if (go_left)
edje_object_signal_emit(sid->edje_obj, "elm,action,show,left", "elm");
else
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,left", "elm");
sid->go_left = go_left;
}
if (go_right != sid->go_right)
{
if (go_right)
edje_object_signal_emit(sid->edje_obj, "elm,action,show,right", "elm");
else
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,right", "elm");
sid->go_right= go_right;
}
if (go_up != sid->go_up)
{
if (go_up)
edje_object_signal_emit(sid->edje_obj, "elm,action,show,up", "elm");
else
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,up", "elm");
sid->go_up = go_up;
}
if (go_down != sid->go_down)
{
if (go_down)
edje_object_signal_emit(sid->edje_obj, "elm,action,show,down", "elm");
else
edje_object_signal_emit(sid->edje_obj, "elm,action,hide,down", "elm");
sid->go_down= go_down;
}
}
void
_elm_scroll_smooth_debug_movetime_add(int x,
int y)
@ -647,7 +699,8 @@ _elm_scroll_scroll_bar_h_visibility_adjust(
if (sid->cb_func.content_min_limit)
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
}
_elm_direction_arrows_eval(sid);
return scroll_h_vis_change;
}
@ -737,6 +790,7 @@ _elm_scroll_scroll_bar_v_visibility_adjust(
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
}
_elm_direction_arrows_eval(sid);
return scroll_v_vis_change;
}
@ -877,7 +931,9 @@ _elm_scroll_scroll_bar_read_and_update(
psd->api->pos_get(sid->pan_obj, &px, &py);
psd->api->pos_set(sid->pan_obj, x, y);
if ((px != x) || (py != y))
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
{
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
}
}
static void
@ -1411,11 +1467,13 @@ _elm_scroll_content_pos_set(Evas_Object *obj,
{
if (sid->cb_func.edge_left)
sid->cb_func.edge_left(obj, NULL);
edje_object_signal_emit(sid->edje_obj, "elm,edge,left", "elm");
}
if (x == (mx + minx))
{
if (sid->cb_func.edge_right)
sid->cb_func.edge_right(obj, NULL);
edje_object_signal_emit(sid->edje_obj, "elm,edge,right", "elm");
}
}
if (y != py)
@ -1424,13 +1482,17 @@ _elm_scroll_content_pos_set(Evas_Object *obj,
{
if (sid->cb_func.edge_top)
sid->cb_func.edge_top(obj, NULL);
edje_object_signal_emit(sid->edje_obj, "elm,edge,top", "elm");
}
if (y == my + miny)
{
if (sid->cb_func.edge_bottom)
sid->cb_func.edge_bottom(obj, NULL);
edje_object_signal_emit(sid->edje_obj, "elm,edge,bottom", "elm");
}
}
_elm_direction_arrows_eval(sid);
}
static void
@ -3233,6 +3295,7 @@ _elm_scroll_scroll_bar_reset(Elm_Scrollable_Smart_Interface_Data *sid)
}
if ((px != minx) || (py != miny))
edje_object_signal_emit(sid->edje_obj, "elm,action,scroll", "elm");
_elm_direction_arrows_eval(sid);
}
/* even external pan objects get this */
@ -3642,6 +3705,7 @@ _elm_scroll_policy_set(Evas_Object *obj,
_elm_scroll_scroll_bar_size_adjust(sid);
if (sid->cb_func.content_min_limit)
sid->cb_func.content_min_limit(sid->obj, sid->min_w, sid->min_h);
_elm_direction_arrows_eval(sid);
}
static void

View File

@ -303,6 +303,10 @@ struct _Elm_Scrollable_Smart_Interface_Data
Eina_Bool hold : 1;
Eina_Bool min_w : 1;
Eina_Bool min_h : 1;
Eina_Bool go_left : 1;
Eina_Bool go_right : 1;
Eina_Bool go_up : 1;
Eina_Bool go_down : 1;
};
typedef struct _Elm_Scrollable_Smart_Interface Elm_Scrollable_Smart_Interface;

View File

@ -1598,6 +1598,110 @@ _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas
return it_state;
}
static void
_elm_toolbar_action_left_cb(void *data, Evas_Object *o __UNUSED__, const char *sig __UNUSED__, const char *src __UNUSED__)
{
Evas_Object *obj = data;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Toolbar_Item *it, *it2;
Eina_Bool done = EINA_FALSE;
if (!wd) return;
EINA_INLIST_FOREACH(wd->items, it)
{
if (it->selected)
{
Eina_Bool found = EINA_FALSE;
EINA_INLIST_REVERSE_FOREACH(wd->items, it2)
{
if (elm_object_item_disabled_get((Elm_Object_Item *)it2))
continue;
if (it2 == it)
{
found = EINA_TRUE;
continue;
}
if (!found) continue;
if (it2->separator) continue;
_item_unselect(it);
_item_select(it2);
break;
}
done = EINA_TRUE;
break;
}
}
if (!done)
{
EINA_INLIST_FOREACH(wd->items, it)
{
if (elm_object_item_disabled_get((Elm_Object_Item *)it)) continue;
if (it->separator) continue;
_item_select(it);
break;
}
}
}
static void
_elm_toolbar_action_right_cb(void *data, Evas_Object *o __UNUSED__, const char *sig __UNUSED__, const char *src __UNUSED__)
{
Evas_Object *obj = data;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Toolbar_Item *it, *it2;
Eina_Bool done = EINA_FALSE;
if (!wd) return;
EINA_INLIST_FOREACH(wd->items, it)
{
if (it->selected)
{
Eina_Bool found = EINA_FALSE;
EINA_INLIST_FOREACH(wd->items, it2)
{
if (elm_object_item_disabled_get((Elm_Object_Item *)it2))
continue;
if (it2 == it)
{
found = EINA_TRUE;
continue;
}
if (!found) continue;
if (it2->separator) continue;
_item_unselect(it);
_item_select(it2);
break;
}
done = EINA_TRUE;
break;
}
}
if (!done)
{
EINA_INLIST_REVERSE_FOREACH(wd->items, it)
{
if (elm_object_item_disabled_get((Elm_Object_Item *)it)) continue;
if (it->separator) continue;
_item_select(it);
break;
}
}
}
static void
_elm_toolbar_action_up_cb(void *data, Evas_Object *o, const char *sig, const char *src)
{
_elm_toolbar_action_left_cb(data, o, sig, src);
}
static void
_elm_toolbar_action_down_cb(void *data, Evas_Object *o, const char *sig, const char *src)
{
_elm_toolbar_action_right_cb(data, o, sig, src);
}
EAPI Evas_Object *
elm_toolbar_add(Evas_Object *parent)
{
@ -1632,7 +1736,19 @@ elm_toolbar_add(Evas_Object *parent)
elm_smart_scroller_policy_set(wd->scr,
ELM_SMART_SCROLLER_POLICY_AUTO,
ELM_SMART_SCROLLER_POLICY_OFF);
edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,left", "elm",
_elm_toolbar_action_left_cb, obj);
edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,right", "elm",
_elm_toolbar_action_right_cb, obj);
edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,up", "elm",
_elm_toolbar_action_up_cb, obj);
edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,down", "elm",
_elm_toolbar_action_down_cb, obj);
wd->shrink_mode = ELM_TOOLBAR_SHRINK_NONE;
wd->icon_size = _elm_toolbar_icon_size_get(wd);

View File

@ -269,6 +269,10 @@ struct _Smart_Data
Eina_Bool bounce_animator_disabled :1;
Eina_Bool is_mirrored : 1;
Eina_Bool wheel_disabled : 1;
Eina_Bool go_left : 1;
Eina_Bool go_right : 1;
Eina_Bool go_up : 1;
Eina_Bool go_down : 1;
};
/* local subsystem functions */
@ -318,6 +322,57 @@ elm_smart_scroller_add(Evas *evas)
return evas_object_smart_add(evas, _smart);
}
static void
_elm_direction_arrows_eval(Smart_Data *sd)
{
Eina_Bool go_left = EINA_TRUE, go_right = EINA_TRUE;
Eina_Bool go_up = EINA_TRUE, go_down = EINA_TRUE;
Evas_Coord x = 0, y = 0, mx = 0, my = 0, minx = 0, miny = 0;
if (!sd->edje_obj || !sd->pan_obj) return;
sd->pan_func.max_get(sd->pan_obj, &mx, &my);
sd->pan_func.min_get(sd->pan_obj, &minx, &miny);
sd->pan_func.get(sd->pan_obj, &x, &y);
if (x == minx) go_left = EINA_FALSE;
if (x == (mx + minx)) go_right = EINA_FALSE;
if (y == miny) go_up = EINA_FALSE;
if (y == (my + miny)) go_down = EINA_FALSE;
if (go_left != sd->go_left)
{
if (go_left)
edje_object_signal_emit(sd->edje_obj, "elm,action,show,left", "elm");
else
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,left", "elm");
sd->go_left = go_left;
}
if (go_right != sd->go_right)
{
if (go_right)
edje_object_signal_emit(sd->edje_obj, "elm,action,show,right", "elm");
else
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,right", "elm");
sd->go_right= go_right;
}
if (go_up != sd->go_up)
{
if (go_up)
edje_object_signal_emit(sd->edje_obj, "elm,action,show,up", "elm");
else
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,up", "elm");
sd->go_up = go_up;
}
if (go_down != sd->go_down)
{
if (go_down)
edje_object_signal_emit(sd->edje_obj, "elm,action,show,down", "elm");
else
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,down", "elm");
sd->go_down= go_down;
}
}
static Evas_Coord
_elm_smart_scroller_x_mirrored_get(Evas_Object *obj, Evas_Coord x)
{
@ -490,6 +545,7 @@ elm_smart_scroller_custom_edje_file_set(Evas_Object *obj, char *file, char *grou
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
else
edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
_elm_direction_arrows_eval(sd);
}
Eina_Bool
@ -1240,6 +1296,7 @@ elm_smart_scroller_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
if (y == my + miny)
evas_object_smart_callback_call(obj, "edge,bottom", NULL);
}
_elm_direction_arrows_eval(sd);
}
void
@ -1438,6 +1495,7 @@ elm_smart_scroller_policy_set(Evas_Object *obj, Elm_Smart_Scroller_Policy hbar,
else
edje_object_signal_emit(sd->edje_obj, "elm,action,show_notalways,vbar", "elm");
_smart_scrollbar_size_adjust(sd);
_elm_direction_arrows_eval(sd);
}
void
@ -2728,6 +2786,7 @@ _smart_scrollbar_read(Smart_Data *sd)
sd->pan_func.set(sd->pan_obj, x, y);
if ((px != x) || (py != y))
edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
_elm_direction_arrows_eval(sd);
}
static void
@ -2750,6 +2809,7 @@ _smart_scrollbar_reset(Smart_Data *sd)
}
if ((px != minx) || (py != miny))
edje_object_signal_emit(sd->edje_obj, "elm,action,scroll", "elm");
_elm_direction_arrows_eval(sd);
}
static int
@ -2818,6 +2878,7 @@ _smart_scrollbar_bar_v_visibility_adjust(Smart_Data *sd)
else
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,vbar", "elm");
}
_elm_direction_arrows_eval(sd);
return scroll_v_vis_change;
}
@ -2888,6 +2949,7 @@ _smart_scrollbar_bar_h_visibility_adjust(Smart_Data *sd)
edje_object_signal_emit(sd->edje_obj, "elm,action,hide,hbar", "elm");
_smart_scrollbar_size_adjust(sd);
}
_elm_direction_arrows_eval(sd);
return scroll_h_vis_change;
}