summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-27 14:00:52 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-27 20:19:28 +0100
commit29e6d1d364856be926e285e53155c49d4b57bd7b (patch)
treeb4a28c8b7a77249542a6a1578979dd47cb64ba4a
parentb704db8f0780868c1a6f039c2e09e291f3387308 (diff)
efl_ui_widget: move show_region to legacy
summary_: show_region is simular to focus_region. However, it builds up on setting custom functions per setter to the widget, which are then executed. This can be solved better by overwriting the interest_region getter, and using a function like elm_widget_focus_region_show (This function still needs to find its place in the eo api). ref T7553 Depends on D8025 Reviewers: woohyun, cedric, Jaehyun_Cho, zmike, segfaultxavi Reviewed By: segfaultxavi Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T7553 Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D8026
-rw-r--r--src/lib/elementary/efl_ui_widget.c152
-rw-r--r--src/lib/elementary/efl_ui_widget.eo41
2 files changed, 80 insertions, 113 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index 8d2310fd20..614b4219b6 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -1342,20 +1342,6 @@ _efl_ui_widget_efl_ui_i18n_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data
1342 } 1342 }
1343} 1343}
1344 1344
1345EOLIAN static void
1346_efl_ui_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, void *data, Efl_Ui_Scrollable_On_Show_Region func, Eina_Free_Cb func_free_cb)
1347{
1348 if ((sd->on_show_region_data == data) && (sd->on_show_region == func))
1349 return;
1350
1351 if (sd->on_show_region_data && sd->on_show_region_data_free)
1352 sd->on_show_region_data_free(sd->on_show_region_data);
1353
1354 sd->on_show_region = func;
1355 sd->on_show_region_data = data;
1356 sd->on_show_region_data_free = func_free_cb;
1357}
1358
1359/* 1345/*
1360 * @internal 1346 * @internal
1361 * 1347 *
@@ -2422,66 +2408,6 @@ _efl_ui_widget_disabled_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd
2422 return pd->disabled > 0; 2408 return pd->disabled > 0;
2423} 2409}
2424 2410
2425EOLIAN static void
2426_efl_ui_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Rect sr, Eina_Bool forceshow)
2427{
2428 Evas_Object *parent_obj, *child_obj;
2429 Evas_Coord px, py, cx, cy, nx = 0, ny = 0;
2430
2431 evas_smart_objects_calculate(evas_object_evas_get(obj));
2432
2433 if (!forceshow && eina_rectangle_equal(&sr.rect, &sd->show_region.rect)) return;
2434
2435 sd->show_region = sr;
2436 if (sd->on_show_region)
2437 {
2438 sd->on_show_region(sd->on_show_region_data, obj, sr);
2439
2440 if (_elm_scrollable_is(obj))
2441 {
2442 if (elm_widget_is_legacy(obj))
2443 {
2444 elm_interface_scrollable_content_pos_get(obj, &nx, &ny);
2445 sr.x -= nx;
2446 sr.y -= ny;
2447 }
2448 else
2449 {
2450 Eina_Position2D pos;
2451 pos = efl_ui_scrollable_content_pos_get(obj);
2452 sr.x -= pos.x;
2453 sr.y -= pos.y;
2454 }
2455 }
2456 }
2457
2458 do
2459 {
2460 parent_obj = sd->parent_obj;
2461 child_obj = sd->obj;
2462 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
2463 sd = efl_data_scope_get(parent_obj, MY_CLASS);
2464 if (!sd) break;
2465
2466 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
2467 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
2468
2469 sr.x += (cx - px);
2470 sr.y += (cy - py);
2471 sd->show_region = sr;
2472
2473 if (sd->on_show_region)
2474 sd->on_show_region(sd->on_show_region_data, parent_obj, sr);
2475 }
2476 while (parent_obj);
2477}
2478
2479EOLIAN static Eina_Rect
2480_efl_ui_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2481{
2482 return (Eina_Rect) sd->show_region;
2483}
2484
2485/** 2411/**
2486 * @internal 2412 * @internal
2487 * 2413 *
@@ -5481,6 +5407,84 @@ _efl_ui_widget_efl_ui_focus_object_focus_set(Eo *obj, Elm_Widget_Smart_Data *pd,
5481 5407
5482/* Legacy APIs */ 5408/* Legacy APIs */
5483 5409
5410EAPI void
5411elm_widget_on_show_region_hook_set(Eo *obj, void *data, Efl_Ui_Scrollable_On_Show_Region func, Eina_Free_Cb func_free_cb)
5412{
5413 ELM_WIDGET_DATA_GET(obj, sd);
5414
5415 if ((sd->on_show_region_data == data) && (sd->on_show_region == func))
5416 return;
5417
5418 if (sd->on_show_region_data && sd->on_show_region_data_free)
5419 sd->on_show_region_data_free(sd->on_show_region_data);
5420
5421 sd->on_show_region = func;
5422 sd->on_show_region_data = data;
5423 sd->on_show_region_data_free = func_free_cb;
5424}
5425
5426EAPI void
5427elm_widget_show_region_set(Eo *obj, Eina_Rect sr, Eina_Bool forceshow)
5428{
5429 Evas_Object *parent_obj, *child_obj;
5430 Evas_Coord px, py, cx, cy, nx = 0, ny = 0;
5431
5432 ELM_WIDGET_DATA_GET_OR_RETURN(obj, sd);
5433
5434 evas_smart_objects_calculate(evas_object_evas_get(obj));
5435
5436 if (!forceshow && eina_rectangle_equal(&sr.rect, &sd->show_region.rect)) return;
5437
5438 sd->show_region = sr;
5439 if (sd->on_show_region)
5440 {
5441 sd->on_show_region(sd->on_show_region_data, obj, sr);
5442
5443 if (_elm_scrollable_is(obj))
5444 {
5445 if (elm_widget_is_legacy(obj))
5446 {
5447 elm_interface_scrollable_content_pos_get(obj, &nx, &ny);
5448 sr.x -= nx;
5449 sr.y -= ny;
5450 }
5451 else
5452 {
5453 Eina_Position2D pos;
5454 pos = efl_ui_scrollable_content_pos_get(obj);
5455 sr.x -= pos.x;
5456 sr.y -= pos.y;
5457 }
5458 }
5459 }
5460
5461 do
5462 {
5463 parent_obj = sd->parent_obj;
5464 child_obj = sd->obj;
5465 if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break;
5466 sd = efl_data_scope_get(parent_obj, MY_CLASS);
5467 if (!sd) break;
5468
5469 evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
5470 evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
5471
5472 sr.x += (cx - px);
5473 sr.y += (cy - py);
5474 sd->show_region = sr;
5475
5476 if (sd->on_show_region)
5477 sd->on_show_region(sd->on_show_region_data, parent_obj, sr);
5478 }
5479 while (parent_obj);
5480}
5481
5482EAPI Eina_Rect
5483elm_widget_show_region_get(const Eo *obj)
5484{
5485 ELM_WIDGET_DATA_GET_OR_RETURN(obj, sd, EINA_RECT_EMPTY());
5486 return (Eina_Rect) sd->show_region;
5487}
5484/* elm_object_content_xxx APIs are supposed to work on all objects for which 5488/* elm_object_content_xxx APIs are supposed to work on all objects for which
5485 * elm_object_widget_check() returns true. The below checks avoid printing out 5489 * elm_object_widget_check() returns true. The below checks avoid printing out
5486 * undesired ERR messages. */ 5490 * undesired ERR messages. */
diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo
index 815cb7761e..2e1e82ff26 100644
--- a/src/lib/elementary/efl_ui_widget.eo
+++ b/src/lib/elementary/efl_ui_widget.eo
@@ -329,43 +329,6 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje
329 theme or default theme was used.]] 329 theme or default theme was used.]]
330 } 330 }
331 331
332 /* Scroll API. */
333 @property on_show_region_hook @protected {
334 [[Hook function called when the @.show_region is changed.
335
336 See also @.show_region.
337 ]]
338 set {}
339 values {
340 func: Efl.Ui.Scrollable_On_Show_Region @nullable; [[Region hook function]]
341 }
342 }
343 @property show_region @protected {
344 [[Region inside the widget to show.
345
346 See also @.on_show_region_hook.
347 ]]
348 set {
349 [[Request parent scrollers to pan around so that this region
350 of the widget becomes visible.
351
352 If $force is $true this will trigger scroller changes and
353 the @.on_show_region_hook to be called even if the region is
354 unchanged.
355 ]]
356 values {
357 region: Eina.Rect; [[The region to show.]]
358 force: bool; [[Set to $true to force show even if unchanged.]]
359 }
360 }
361 get {
362 [[Returns the current region to show.]]
363 values {
364 region: Eina.Rect; [[The region to show.]]
365 }
366 }
367 }
368
369 /* FIXME: Scroll API. Not sure how those APIs should be exposed with 332 /* FIXME: Scroll API. Not sure how those APIs should be exposed with
370 * the new scrollable API. */ 333 * the new scrollable API. */
371 scroll_hold_push { 334 scroll_hold_push {
@@ -410,9 +373,9 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje
410 } 373 }
411 } 374 }
412 @property interest_region_mode { 375 @property interest_region_mode {
413 [[Defines how @.show_region should be calculated. 376 [[Defines how @.interest_region should be calculated.
414 377
415 It is up to the implementation of @.show_region.get to take this 378 It is up to the implementation of @.interest_region.get to take this
416 value into account (or ignore it). 379 value into account (or ignore it).
417 ]] 380 ]]
418 get { 381 get {