scrollable_interface: fixed logic for calcualting position to scroll.

Summary:
When width of parameter(w) is bigger than or equal to scroller's width(pw),
scrollable object must be scrolled to x position.

Test Plan: elementary_test -> focus 4

Reviewers: woohyun, SanghyeonLee, Hermet, cedric, jpeg, raster

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4491
This commit is contained in:
Hosang Kim 2016-12-16 15:25:18 -08:00 committed by Cedric BAIL
parent 763478c091
commit 2b3bee1301
4 changed files with 101 additions and 10 deletions

View File

@ -860,4 +860,25 @@ collections {
}
}
}
group { name: "layout3";
parts {
part { name: "bg";
type: RECT;
scale: 1;
description { state: "default" 0.0;
min: 4000 4000;
color: 0 255 0 100;
}
}
part { name: "swallow";
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
min: 100 100;
rel1.relative: 0.3 0.3;
rel2.relative: 0.325 0.325;
}
}
}
}
}

View File

@ -231,6 +231,7 @@ void test_focus_part(void *data, Evas_Object *obj, void *event_info);
void test_focus3(void *data, Evas_Object *obj, void *event_info);
void test_focus_object_style(void *data, Evas_Object *obj, void *event_info);
void test_focus_object_policy(void *data, Evas_Object *obj, void *event_info);
void test_focus4(void *data, Evas_Object *obj, void *event_info);
void test_flipselector(void *data, Evas_Object *obj, void *event_info);
void test_diskselector(void *data, Evas_Object *obj, void *event_info);
void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@ -954,6 +955,7 @@ add_tests:
ADD_TEST(NULL, "Focus", "Focus 3", test_focus3);
ADD_TEST(NULL, "Focus", "Focus Object Style", test_focus_object_style);
ADD_TEST(NULL, "Focus", "Focus Object Policy", test_focus_object_policy);
ADD_TEST(NULL, "Focus", "Focus 4", test_focus4);
//------------------------------//
ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);

View File

@ -900,3 +900,68 @@ test_focus3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
evas_object_show(win);
}
static void
btn_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *bt = data;
elm_object_focus_set(bt, EINA_FALSE);
elm_object_focus_set(bt, EINA_TRUE);
}
static Eina_Bool toggle = EINA_FALSE;
static void
btn_clicked2(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *bt = data;
toggle = !toggle;
if (toggle)
evas_object_size_hint_min_set(bt, 500, 500);
else
evas_object_size_hint_min_set(bt, 100, 100);
}
void
test_focus4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *box, *sc, *btn, *ly, *btn2;
char buf[PATH_MAX];
win = elm_win_util_standard_add("focus4", "Focus 5");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
sc = elm_scroller_add(box);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.9);
evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end (box, sc);
evas_object_show(sc);
btn = elm_button_add(box);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.1);
evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, btn);
elm_object_text_set(btn, "Focus to Button");
evas_object_show(btn);
ly = elm_layout_add(sc);
snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
elm_layout_file_set(ly, buf, "layout3");
elm_object_content_set(sc, ly);
evas_object_show(ly);
btn2 = elm_button_add(ly);
elm_object_text_set(btn2, "Button Resize");
elm_object_part_content_set(ly, "swallow", btn2);
evas_object_show(btn2);
evas_object_smart_callback_add(btn, "clicked", btn_clicked, btn2);
evas_object_smart_callback_add(btn2, "clicked", btn_clicked2, btn2);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}

View File

@ -1702,27 +1702,30 @@ _elm_scroll_content_region_show_internal(Evas_Object *obj,
Evas_Coord w,
Evas_Coord h)
{
Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny,
Evas_Coord cw = 0, ch = 0, px = 0, py = 0, nx, ny,
minx = 0, miny = 0, pw = 0, ph = 0, x = *_x, y = *_y;
ELM_SCROLL_IFACE_DATA_GET_OR_RETURN_VAL(obj, sid, EINA_FALSE);
if (!sid->pan_obj) return EINA_FALSE;
elm_obj_pan_pos_max_get(sid->pan_obj, &mx, &my);
elm_obj_pan_pos_min_get(sid->pan_obj, &minx, &miny);
elm_obj_pan_content_size_get(sid->pan_obj, &cw, &ch);
elm_obj_pan_pos_get(sid->pan_obj, &px, &py);
evas_object_geometry_get(sid->pan_obj, NULL, NULL, &pw, &ph);
nx = px;
if ((x < px) && ((x + w) < (px + (cw - mx)))) nx = x;
else if ((x > px) && ((x + w) > (px + (cw - mx))))
nx = x + w - (cw - mx);
ny = py;
if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y;
else if ((y > py) && ((y + h) > (py + (ch - my))))
ny = y + h - (ch - my);
nx = x;
if ((x > px) && (w < pw))
{
if ((px + pw) < (x + w)) nx = x - pw + w;
else nx = px;
}
ny = y;
if ((y > py) && (h < ph))
{
if ((py + ph) < (y + h)) ny = y - ph + h;
else ny = py;
}
if ((sid->down.bounce_x_animator) || (sid->down.bounce_y_animator) ||
(sid->scrollto.x.animator) || (sid->scrollto.y.animator))