Improve scrolled_entry a bit, it's still open for more love though.
authorIván Briano <sachieru@gmail.com>
Tue, 9 Feb 2010 15:43:17 +0000 (15:43 +0000)
committerIván Briano <sachieru@gmail.com>
Tue, 9 Feb 2010 15:43:17 +0000 (15:43 +0000)
Move test_conformant to use scrolled_entry.

SVN revision: 46012

src/bin/test_conform.c
src/lib/Elementary.h.in
src/lib/elc_scrolled_entry.c

index a44711f881cbeeef648d95ae660192c39bb6e02d..8e60281b8483f5a95336110b85aa03b84cd028e5 100644 (file)
@@ -4,7 +4,7 @@
 void 
 test_conformant(void *data, Evas_Object *obj, void *event) 
 {
-   Evas_Object *win, *bg, *conform, *btn, *bx, *sc, *en;
+   Evas_Object *win, *bg, *conform, *btn, *bx, *en;
 
    win = elm_win_add(NULL, "conformant", ELM_WIN_BASIC);
    elm_win_title_set(win, "Conformant");
@@ -25,24 +25,15 @@ test_conformant(void *data, Evas_Object *obj, void *event)
    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
    
-   sc = elm_scroller_add(win);
-   elm_scroller_content_min_limit(sc, 0, 1);
-   elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-   elm_scroller_bounce_set(sc, 1, 0);
-   evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.0);
-   evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, 0.5);
-   elm_box_pack_end(bx, sc);
-
-   en = elm_entry_add(win);
-   elm_entry_single_line_set(en, 1);
-   elm_entry_entry_set(en, "This is the top entry here");
+   en = elm_scrolled_entry_add(win);
+   elm_scrolled_entry_single_line_set(en, 1);
+   elm_scrolled_entry_bounce_set(en, 1, 0);
+   elm_scrolled_entry_entry_set(en, "This is the top entry here");
    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
-   elm_scroller_content_set(sc, en);
    evas_object_show(en);
+   elm_box_pack_end(bx, en);
   
-   evas_object_show(sc);
-   
    btn = elm_button_add(win);
    elm_button_label_set(btn, "Test Conformant");
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
@@ -50,24 +41,15 @@ test_conformant(void *data, Evas_Object *obj, void *event)
    elm_box_pack_end(bx, btn);
    evas_object_show(btn);
 
-   sc = elm_scroller_add(win);
-   elm_scroller_content_min_limit(sc, 0, 1);
-   elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-   elm_scroller_bounce_set(sc, 1, 0);
-   evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, 0.0);
-   evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, 0.5);
-   elm_box_pack_end(bx, sc);
-
-   en = elm_entry_add(win);
-   elm_entry_single_line_set(en, 1);
-   elm_entry_entry_set(en, "This is the middle entry here");
+   en = elm_scrolled_entry_add(win);
+   elm_scrolled_entry_single_line_set(en, 1);
+   elm_scrolled_entry_bounce_set(en, 1, 0);
+   elm_scrolled_entry_entry_set(en, "This is the middle entry here");
    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
-   elm_scroller_content_set(sc, en);
    evas_object_show(en);
+   elm_box_pack_end(bx, en);
   
-   evas_object_show(sc);
-   
    btn = elm_button_add(win);
    elm_button_label_set(btn, "Test Conformant");
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -75,16 +57,9 @@ test_conformant(void *data, Evas_Object *obj, void *event)
    elm_box_pack_end(bx, btn);
    evas_object_show(btn);
 
-   sc = elm_scroller_add(win);
-   elm_scroller_content_min_limit(sc, 0, 0);
-   elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-   elm_scroller_bounce_set(sc, 0, 1);
-   evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_box_pack_end(bx, sc);
-
-   en = elm_entry_add(win);
-   elm_entry_entry_set(en, 
+   en = elm_scrolled_entry_add(win);
+   elm_scrolled_entry_bounce_set(en, 0, 1);
+   elm_scrolled_entry_entry_set(en, 
                        "This is a multi-line entry at the bottom<br>"
                        "This can contain more than 1 line of text and be "
                        "scrolled around to allow for entering of lots of "
@@ -96,11 +71,9 @@ test_conformant(void *data, Evas_Object *obj, void *event)
                        "it is enabled.");
    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_scroller_content_set(sc, en);
    evas_object_show(en);
+   elm_box_pack_end(bx, en);
   
-   evas_object_show(sc);
-   
    elm_conformant_content_set(conform, bx);
    evas_object_show(bx);
    
index 1005ac2b71f43e620ed4b4a6df75bb02a1ad2676..6d74ca8f46000ceb0c8b9d7ad771ae4677a58fda 100644 (file)
@@ -1254,6 +1254,7 @@ extern "C" {
    EAPI void         elm_scrolled_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled);
    EAPI Eina_Bool    elm_scrolled_entry_context_menu_disabled_get(Evas_Object *obj);
    EAPI void         elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v);
+   EAPI void         elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
 
    EAPI Evas_Object *elm_conformant_add(Evas_Object *parent);
    EAPI void         elm_conformant_content_set(Evas_Object *obj, Evas_Object *content);
index 9f021f5bc9755626d29f6e85dde9b71cf66744b1..1ad4b697c05c74d9f10552ef570b340c07369585 100644 (file)
@@ -21,8 +21,11 @@ static void
 _sizing_eval(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
+   Evas_Coord minw, minh;
 
-   evas_object_size_hint_min_set(obj, -1, -1);
+   if (!wd) return;
+   evas_object_size_hint_min_get(wd->scroller, &minw, &minh);
+   evas_object_size_hint_min_set(obj, minw, minh);
    evas_object_size_hint_max_set(obj, -1, -1);
 }
 
@@ -118,9 +121,15 @@ elm_scrolled_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
    if (!wd) return;
    elm_entry_single_line_set(wd->entry, single_line);
    if (single_line)
-     elm_scroller_policy_set(wd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+     {
+       elm_scroller_policy_set(wd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+       elm_scroller_content_min_limit(wd->scroller, 0, 1);
+     }
    else
-     elm_scroller_policy_set(wd->scroller, wd->policy_h, wd->policy_v);
+     {
+       elm_scroller_policy_set(wd->scroller, wd->policy_h, wd->policy_v);
+       elm_scroller_content_min_limit(wd->scroller, 0, 0);
+     }
 }
 
 EAPI void
@@ -372,3 +381,11 @@ elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h,
    wd->policy_v = v;
    elm_scroller_policy_set(wd->scroller, h, v);
 }
+
+EAPI void
+elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
+}