forked from enlightenment/efl
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.
This commit is contained in:
parent
bd9c752d3f
commit
fb797611ed
|
@ -210,7 +210,7 @@ _list_item_cb5(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
|
||||||
|
|
||||||
btn = elm_button_add(sc);
|
btn = elm_button_add(sc);
|
||||||
elm_object_text_set(btn, "Enlightenment");
|
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);
|
elm_object_content_set(sc, btn);
|
||||||
|
|
||||||
|
|
|
@ -732,6 +732,35 @@ _elm_scroll_scroll_bar_v_visibility_adjust(
|
||||||
return scroll_v_vis_change;
|
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
|
static void
|
||||||
_elm_scroll_scroll_bar_visibility_adjust(
|
_elm_scroll_scroll_bar_visibility_adjust(
|
||||||
Elm_Scrollable_Smart_Interface_Data *sid)
|
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_h_visibility_adjust(sid);
|
||||||
_elm_scroll_scroll_bar_v_visibility_adjust(sid);
|
_elm_scroll_scroll_bar_v_visibility_adjust(sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_elm_scroll_scroll_bar_auto_visibility_adjust(sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue