jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=fb797611ed7e0c7e593682ee9636f5ec49d9fdb8

commit fb797611ed7e0c7e593682ee9636f5ec49d9fdb8
Author: Jean-Philippe Andre <[email protected]>
Date:   Wed Oct 26 20:11:10 2016 +0900

    scroller: Adjust rare case when content fits but bars are visible
    
    This was simply annoying me. A scroller packed inside a box 150x150
    should have enough space to hold an object of size 140x140. That's
    a whole lot of 10 pixels margin!
    
    This patch adds a special case code when the content "seems" to fit
    inside the box but still one or both bars are visible. One problem
    is that we can't know from the theme how much margin is used by a
    scroller even when its bars are hidden. So we have to try to remove
    them and then recalc to test.
    
    This definitely adds quite a few more calculations if the state of
    the scroll bars changes, but the result is way more pleasant :) This
    should be limited to corner cases anyway (when the content size is
    within 0 to ~20 pixels of the scroller size, depending on the theme
    of course).
    
    The test case is adjusted to show that same size content triggers
    a show on the bars (because of theme margins). See CtxPopup test.
---
 src/bin/elementary/test_ctxpopup.c            |  2 +-
 src/lib/elementary/elm_interface_scrollable.c | 31 +++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/bin/elementary/test_ctxpopup.c 
b/src/bin/elementary/test_ctxpopup.c
index fbc9042..187dba8 100644
--- a/src/bin/elementary/test_ctxpopup.c
+++ b/src/bin/elementary/test_ctxpopup.c
@@ -210,7 +210,7 @@ _list_item_cb5(void *data EINA_UNUSED, Evas_Object *obj, 
void *event_info EINA_U
 
    btn = elm_button_add(sc);
    elm_object_text_set(btn, "Enlightenment");
-   evas_object_size_hint_min_set(btn, 140, 140);
+   evas_object_size_hint_min_set(btn, 150, 150);
 
    elm_object_content_set(sc, btn);
 
diff --git a/src/lib/elementary/elm_interface_scrollable.c 
b/src/lib/elementary/elm_interface_scrollable.c
index 8d22b54..38501b0 100644
--- a/src/lib/elementary/elm_interface_scrollable.c
+++ b/src/lib/elementary/elm_interface_scrollable.c
@@ -732,6 +732,35 @@ _elm_scroll_scroll_bar_v_visibility_adjust(
    return scroll_v_vis_change;
 }
 
+static inline void
+_elm_scroll_scroll_bar_auto_visibility_adjust(Elm_Scrollable_Smart_Interface_Data
 *sid)
+{
+   int sw = 0, sh = 0, w, h;
+
+   if ((sid->vbar_flags != ELM_SCROLLER_POLICY_AUTO) ||
+       (sid->hbar_flags != ELM_SCROLLER_POLICY_AUTO) ||
+       !sid->hbar_visible || !sid->vbar_visible) return;
+
+   if (!sid->content && !sid->extern_pan) return;
+
+   w = sid->content_info.w;
+   h = sid->content_info.h;
+   efl_gfx_size_get(sid->edje_obj, &sw, &sh);
+
+   // Adjust when the content may fit but the bars are visible. The if() test
+   // does not guarantee that the content will fit (offsets & margins depend
+   // on the theme).
+   if ((w <= sw) && (h <= sh))
+     {
+        sid->hbar_visible = EINA_FALSE;
+        sid->vbar_visible = EINA_FALSE;
+        _elm_scroll_scroll_bar_h_visibility_apply(sid);
+        _elm_scroll_scroll_bar_v_visibility_apply(sid);
+        _elm_scroll_scroll_bar_h_visibility_adjust(sid);
+        _elm_scroll_scroll_bar_v_visibility_adjust(sid);
+     }
+}
+
 static void
 _elm_scroll_scroll_bar_visibility_adjust(
   Elm_Scrollable_Smart_Interface_Data *sid)
@@ -746,6 +775,8 @@ _elm_scroll_scroll_bar_visibility_adjust(
         _elm_scroll_scroll_bar_h_visibility_adjust(sid);
         _elm_scroll_scroll_bar_v_visibility_adjust(sid);
      }
+
+   _elm_scroll_scroll_bar_auto_visibility_adjust(sid);
 }
 
 static void

-- 


Reply via email to