From: Dave Andreoli <dave@gurumeditation.it>
authorDave Andreoli <dave@gurumeditation.it>
Tue, 27 Jul 2010 23:43:12 +0000 (23:43 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Tue, 27 Jul 2010 23:43:12 +0000 (23:43 +0000)
Subject: [E-devel] New elm pager "slide" and "slide_invisible" styles

Hi everyone,
I have done 2 new style for the pager widget:

"slide" and "slide_invisible"

They work different from the other styles: new (pushed) pages
comes from right and the old go out left, while popped pages
goes out from right. It works like the enna browser, or like all the
"browser lists" on iphone.

The patch include the 2 new styles, a new elementary_test
page called "Pager Slide", a little code for elm_pager.c  that was
needed
for the new style to work and simple update for the other existing
styles.

The patch is located at:
http://pastebin.com/jSbg0wb9

I can commit this myself, just give me the go ;)

SVN revision: 50559

data/themes/default.edc
src/bin/test.c
src/bin/test_pager.c
src/lib/elm_pager.c

index 5a80182..8bdd5ba 100644 (file)
@@ -18691,6 +18691,14 @@ collections {
         }
       }
       programs {
+        program { name: "push_start";
+           signal: "elm,action,push";
+           source: "elm";
+           action:  STATE_SET "hidden" 0.0;
+           target: "base";
+           target: "clip";
+            after: "show_start2";
+        }
          program { name: "show_start";
            signal: "elm,action,show";
            source: "elm";
@@ -18709,6 +18717,14 @@ collections {
          program { name: "show_end";
             action: SIGNAL_EMIT "elm,action,show,finished" "";
         }
+         program { name: "pop_start";
+           signal: "elm,action,pop";
+           source: "elm";
+           action:  STATE_SET "visible" 0.0;
+           target: "base";
+           target: "clip";
+            after: "hide_start2";
+        }
          program { name: "hide_start";
            signal: "elm,action,hide";
            source: "elm";
@@ -18737,6 +18753,320 @@ collections {
       }
    }
 
+   group { name: "elm/pager/base/slide";
+      images {
+        image: "frame_1.png" COMP;
+        image: "frame_2.png" COMP;
+        image: "dia_grad.png" COMP;
+      }
+      parts {
+        part { name: "clip";
+           type: RECT;
+           mouse_events: 0;
+           description { state: "default" 0.0;
+              rel1 {
+                 to: "base";
+                 offset: -9999 -9999;
+              }
+              rel2 {
+                 to: "base";
+                 offset: 9999 9999;
+              }
+              color: 255 255 255 255;
+           }
+           description { state: "visible" 0.0;
+              inherit: "default" 0.0;
+           }
+           description { state: "hidden" 0.0;
+              inherit: "default" 0.0;
+              color: 255 255 255 0;
+              visible: 0;
+           }
+           description { state: "hidden2" 0.0;
+              inherit: "default" 0.0;
+              color: 255 255 255 0;
+              visible: 0;
+           }
+        }
+        part { name: "base0";
+           mouse_events:  0;
+           clip_to: "clip";
+           description { state: "default" 0.0;
+              image.normal: "dia_grad.png";
+              rel1.to: "over";
+              rel2.to: "over";
+              fill {
+                 smooth: 0;
+                 size {
+                    relative: 0.0 1.0;
+                    offset: 64 0;
+                 }
+              }
+           }
+        }
+        part { name: "base";
+           mouse_events:  0;
+           clip_to: "clip";
+           description { state: "default" 0.0;
+              image {
+                 normal: "frame_2.png";
+                 border: 5 5 32 26;
+                 middle: 0;
+              }
+              fill.smooth : 0;
+           }
+           description { state: "hidden" 0.0;
+              inherit: "default" 0.0;
+              rel1.relative: -1.0 0.0;
+              rel2.relative: 0.0 1.0;
+           }
+           description { state: "hidden2" 0.0;
+              inherit: "default" 0.0;
+              rel1.relative: 1.0 0.0;
+              rel2.relative: 2.0 1.0;
+           }
+           description { state: "visible" 0.0;
+              inherit: "default" 0.0;
+              rel1.relative: 0.0 0.0;
+              rel2.relative: 1.0 1.0;
+           }
+        }
+        part { name: "over";
+           mouse_events:  0;
+           clip_to: "clip";
+           description { state:    "default" 0.0;
+              rel1 {
+                 to: "base";
+                 offset: 4 4;
+              }
+              rel2 {
+                 to: "base";
+                 offset: -5 -5;
+              }
+              image {
+                 normal: "frame_1.png";
+                 border: 2 2 28 22;
+                 middle: 0;
+              }
+              fill.smooth : 0;
+           }
+        }
+        part { name: "elm.swallow.content";
+           type: SWALLOW;
+           clip_to: "clip";
+           description { state: "default" 0.0;
+              rel1 {
+                 to: "base";
+                 offset: 8 8;
+              }
+              rel2 {
+                 to: "base";
+                 offset: -9 -9;
+              }
+           }
+        }
+      }
+      programs {
+        program { name: "push_start";
+           signal: "elm,action,push";
+           source: "elm";
+           action:  STATE_SET "hidden2" 0.0;
+           target: "base";
+           target: "clip";
+           after: "show_start2";
+        }
+        program { name: "show_start";
+           signal: "elm,action,show";
+           source: "elm";
+           action:  STATE_SET "hidden" 0.0;
+           target: "base";
+           target: "clip";
+           after: "show_start2";
+        }
+        program { name: "show_start2";
+           action:  STATE_SET "visible" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "show_end";
+        }
+        program { name: "show_end";
+           action: SIGNAL_EMIT "elm,action,show,finished" "";
+        }
+        program { name: "pop_start";
+           signal: "elm,action,pop";
+           source: "elm";
+           action:  STATE_SET "visible" 0.0;
+           target: "base";
+           target: "clip";
+           after: "pop_start2";
+        }
+        program { name: "pop_start2";
+           action:  STATE_SET "hidden2" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "hide_end";
+        }
+        program { name: "hide_start";
+           signal: "elm,action,hide";
+           source: "elm";
+           action:  STATE_SET "visible" 0.0;
+           target: "base";
+           target: "clip";
+           after: "hide_start2";
+        }
+        program { name: "hide_start2";
+           action:  STATE_SET "hidden" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "hide_end";
+        }
+        program { name: "hide_end";
+           action: SIGNAL_EMIT "elm,action,hide,finished" "";
+        }
+        program { name: "reset";
+           signal: "elm,action,reset";
+           source: "elm";
+           action:  STATE_SET "default" 0.0;
+           target: "base";
+           target: "clip";
+        }
+      }
+   }
+   group { name: "elm/pager/base/slide_invisible";
+      parts {
+        part { name: "clip";
+           type: RECT;
+           mouse_events: 0;
+           description { state: "default" 0.0;
+              rel1 {
+                 to: "base";
+                 offset: -9999 -9999;
+           }
+              rel2 {
+                 to: "base";
+                 offset: 9999 9999;
+              }
+              color: 255 255 255 255;
+           }
+           description { state: "visible" 0.0;
+              inherit: "default" 0.0;
+           }
+           description { state: "hidden" 0.0;
+              inherit: "default" 0.0;
+              color: 255 255 255 0;
+              visible: 0;
+           }
+           description { state: "hidden2" 0.0;
+              inherit: "default" 0.0;
+              color: 255 255 255 0;
+              visible: 0;
+           }
+        }
+        part { name: "base";
+           type: RECT;
+           mouse_events:  0;
+           clip_to: "clip";
+           description { state: "default" 0.0;
+              color: 0 0 0 0;
+           }
+           description { state: "hidden" 0.0;
+              color: 0 0 0 0;
+              rel1.relative: -1.0 0.0;
+              rel2.relative: 0.0 1.0;
+           }
+           description { state: "hidden2" 0.0;
+              color: 0 0 0 0;
+              rel1.relative: 1.0 0.0;
+              rel2.relative: 2.0 1.0;
+           }
+           description { state: "visible" 0.0;
+              color: 0 0 0 0;
+              rel1.relative: 0.0 0.0;
+              rel2.relative: 1.0 1.0;
+           }
+        }
+        part { name: "elm.swallow.content";
+           type: SWALLOW;
+           clip_to: "clip";
+           description { state: "default" 0.0;
+              rel1.to: "base";
+              rel2.to: "base";
+           }
+        }
+      }
+      programs {
+        program { name: "push_start";
+           signal: "elm,action,push";
+           source: "elm";
+           action:  STATE_SET "hidden2" 0.0;
+           target: "base";
+           target: "clip";
+           after: "show_start2";
+        }
+        program { name: "show_start";
+           signal: "elm,action,show";
+           source: "elm";
+           action:  STATE_SET "hidden" 0.0;
+           target: "base";
+           target: "clip";
+           after: "show_start2";
+        }
+        program { name: "show_start2";
+           action:  STATE_SET "visible" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "show_end";
+        }
+        program { name: "show_end";
+           action: SIGNAL_EMIT "elm,action,show,finished" "";
+        }
+        program { name: "pop_start";
+           signal: "elm,action,pop";
+           source: "elm";
+           action:  STATE_SET "visible" 0.0;
+           target: "base";
+           target: "clip";
+           after: "pop_start2";
+        }
+        program { name: "pop_start2";
+           action:  STATE_SET "hidden2" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "hide_end";
+        }
+        program { name: "hide_start";
+           signal: "elm,action,hide";
+           source: "elm";
+           action:  STATE_SET "visible" 0.0;
+           target: "base";
+           target: "clip";
+           after: "hide_start2";
+        }
+        program { name: "hide_start2";
+           action:  STATE_SET "hidden" 0.0;
+           transition: DECELERATE 0.5;
+           target: "base";
+           target: "clip";
+           after: "hide_end";
+        }
+        program { name: "hide_end";
+           action: SIGNAL_EMIT "elm,action,hide,finished" "";
+        }
+        program { name: "reset";
+           signal: "elm,action,reset";
+           source: "elm";
+           action:  STATE_SET "default" 0.0;
+           target: "base";
+           target: "clip";
+        }
+      }
+   }
+
    group { name: "elm/pager/base/fade";
        data.item: "onshow" "raise";
        // other options
@@ -18858,6 +19188,14 @@ collections {
            }
        }
        programs {
+           program { name: "push_start";
+               signal: "elm,action,push";
+               source: "elm";
+               action:  STATE_SET "hidden" 0.0;
+               target: "clip";
+               target: "clip_base";
+               after: "show_start2";
+           }
            program { name: "show_start";
                signal: "elm,action,show";
                source: "elm";
@@ -18876,6 +19214,14 @@ collections {
            program { name: "show_end";
                action: SIGNAL_EMIT "elm,action,show,finished" "";
            }
+           program { name: "pop_start";
+               signal: "elm,action,pop";
+               source: "elm";
+               action:  STATE_SET "visible" 0.0;
+               target: "clip";
+               target: "clip_base";
+               after: "hide_start2";
+           }
            program { name: "hide_start";
                signal: "elm,action,hide";
                source: "elm";
@@ -19024,6 +19370,14 @@ collections {
            }
        }
        programs {
+           program { name: "push_start";
+               signal: "elm,action,push";
+               source: "elm";
+               action:  STATE_SET "hidden" 0.0;
+               target: "clip";
+               target: "clip_base";
+               after: "show_start2";
+           }
            program { name: "show_start";
                signal: "elm,action,show";
                source: "elm";
@@ -19042,6 +19396,14 @@ collections {
            program { name: "show_end";
                action: SIGNAL_EMIT "elm,action,show,finished" "";
            }
+           program { name: "pop_start";
+               signal: "elm,action,pop";
+               source: "elm";
+               action:  STATE_SET "visible" 0.0;
+               target: "clip";
+               target: "clip_base";
+               after: "hide_start2";
+           }
            program { name: "hide_start";
                signal: "elm,action,hide";
                source: "elm";
@@ -19110,6 +19472,13 @@ collections {
            }
        }
        programs {
+           program { name: "push_start";
+               signal: "elm,action,push";
+               source: "elm";
+               action:  STATE_SET "hidden" 0.0;
+               target: "clip";
+               after: "show_start2";
+           }
            program { name: "show_start";
                signal: "elm,action,show";
                source: "elm";
@@ -19126,6 +19495,13 @@ collections {
            program { name: "show_end";
                action: SIGNAL_EMIT "elm,action,show,finished" "";
            }
+           program { name: "pop_start";
+               signal: "elm,action,pop";
+               source: "elm";
+               action:  STATE_SET "visible" 0.0;
+               target: "clip";
+               after: "hide_start2";
+           }
            program { name: "hide_start";
                signal: "elm,action,hide";
                source: "elm";
index 5211f76..e49c7e5 100644 (file)
@@ -45,6 +45,7 @@ void test_genlist6(void *data, Evas_Object *obj, void *event_info);
 void test_table(void *data, Evas_Object *obj, void *event_info);
 void test_gengrid(void *data, Evas_Object *obj, void *event_info);
 void test_pager(void *data, Evas_Object *obj, void *event_info);
+void test_pager_slide(void *data, Evas_Object *obj, void *event_info);
 void test_win_state(void *data, Evas_Object *obj, void *event_info);
 void test_win_state2(void *data, Evas_Object *obj, void *event_info);
 void test_progressbar(void *data, Evas_Object *obj, void *event_info);
@@ -242,6 +243,7 @@ my_win_main(void)
    ADD_TEST("Checks", test_check);
    ADD_TEST("Radios", test_radio);
    ADD_TEST("Pager", test_pager);
+   ADD_TEST("Pager Slide", test_pager_slide);
    ADD_TEST("Window States", test_win_state);
    ADD_TEST("Window States 2", test_win_state2);
    ADD_TEST("Progressbar", test_progressbar);
index 477fc9a..335dde5 100644 (file)
@@ -4,7 +4,7 @@ typedef struct _Pginfo Pginfo;
 
 struct _Pginfo
 {
-   Evas_Object *pager, *pg1, *pg2, *pg3;
+   Evas_Object *win, *pager, *pg1, *pg2, *pg3;
 };
 
 static void
@@ -44,6 +44,7 @@ test_pager(void *data, Evas_Object *obj, void *event_info)
    win = elm_win_add(NULL, "pager", ELM_WIN_BASIC);
    elm_win_title_set(win, "Pager");
    elm_win_autodel_set(win, 1);
+   info.win = win;
 
    bg = elm_bg_add(win);
    elm_win_resize_object_add(win, bg);
@@ -148,4 +149,91 @@ test_pager(void *data, Evas_Object *obj, void *event_info)
 
    evas_object_show(win);
 }
+
+static void
+my_pager_push(void *data, Evas_Object *obj, void *event_info)
+{
+   Pginfo *info = data;
+   Evas_Object *bx, *bt, *lb;
+   static int count = 2;
+   char *buf[32];
+
+   bx = elm_box_add(info->win);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_show(bx);
+
+   lb = elm_label_add(info->win);
+   snprintf(buf, sizeof(buf), "This is page %d in the slide pager<br><br>", count++);
+   elm_label_label_set(lb, buf);
+   elm_box_pack_end(bx, lb);
+   evas_object_show(lb);
+
+   bt = elm_button_add(info->win);
+   elm_button_label_set(bt, "Push a new page");
+   evas_object_smart_callback_add(bt, "clicked", my_pager_push, info);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+
+   bt = elm_button_add(info->win);
+   elm_button_label_set(bt, "Go back (pop)");
+   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, info);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+   elm_pager_content_push(info->pager, bx);
+}
+
+void
+test_pager_slide(void *data, Evas_Object *obj, void *event_info)
+{
+   Evas_Object *win, *bg, *pg, *bx, *lb, *bt;
+   static Pginfo info;
+
+   win = elm_win_add(NULL, "pager", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Pager Slide");
+   elm_win_autodel_set(win, 1);
+   info.win = win;
+
+   bg = elm_bg_add(win);
+   elm_win_resize_object_add(win, bg);
+   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_show(bg);
+
+   pg = elm_pager_add(win);
+   elm_win_resize_object_add(win, pg);
+   elm_object_style_set(pg, "slide");
+   evas_object_show(pg);
+   info.pager = pg;
+
+   bx = elm_box_add(win);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_show(bx);
+
+   lb = elm_label_add(win);
+   elm_label_label_set(lb,
+                      "This is page 1 in a slide pager.<br>"
+                      "<br>"
+                      "The slide pager style is usefull for browsing<br>"
+                      "a hierarchy of objects, as it makes clear<br>"
+                      "the direction of the browse.<br>"
+                      "This is the 'slide' style, also available<br>"
+                      "a fully transparent style named 'slide_invisble'.<br>"
+                      "<br>");
+   elm_box_pack_end(bx, lb);
+   evas_object_show(lb);
+
+   bt = elm_button_add(win);
+   elm_button_label_set(bt, "Push a new page");
+   evas_object_smart_callback_add(bt, "clicked", my_pager_push, &info);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+
+   bt = elm_button_add(win);
+   elm_button_label_set(bt, "Go back (pop)");
+   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+   elm_pager_content_push(pg, bx);
+
+   evas_object_show(win);
+}
 #endif
index b1c0299..b04e533 100644 (file)
@@ -111,7 +111,10 @@ _eval_top(Evas_Object *obj)
        if (wd->top)
          {
             o = wd->top->base;
-            edje_object_signal_emit(o, "elm,action,hide", "elm");
+            if (wd->top->popme)
+               edje_object_signal_emit(o, "elm,action,pop", "elm");
+            else
+               edje_object_signal_emit(o, "elm,action,hide", "elm");
             onhide = edje_object_data_get(o, "onhide");
             if (onhide)
               {
@@ -119,10 +122,14 @@ _eval_top(Evas_Object *obj)
                  else if (!strcmp(onhide, "lower")) evas_object_lower(o);
               }
          }
+       wd->oldtop = wd->top;
        wd->top = ittop;
        o = wd->top->base;
        evas_object_show(o);
-       edje_object_signal_emit(o, "elm,action,show", "elm");
+       if (wd->oldtop && wd->oldtop->popme)
+           edje_object_signal_emit(o, "elm,action,show", "elm");
+       else
+           edje_object_signal_emit(o, "elm,action,push", "elm");
        onshow = edje_object_data_get(o, "onshow");
        if (onshow)
          {
@@ -271,7 +278,7 @@ elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
                                    _signal_hide_finished, it);
    evas_object_event_callback_add(it->content,
                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                 _changed_size_hints, it);
+                                  _changed_size_hints, it);
    edje_object_part_swallow(it->base, "elm.swallow.content", it->content);
    edje_object_size_min_calc(it->base, &it->minw, &it->minh);
    evas_object_show(it->content);
@@ -313,7 +320,7 @@ elm_pager_content_pop(Evas_Object *obj)
 
             wd->top = it;
             o = wd->top->base;
-            edje_object_signal_emit(o, "elm,action,hide", "elm");
+            edje_object_signal_emit(o, "elm,action,pop", "elm");
             onhide = edje_object_data_get(o, "onhide");
             if (onhide)
               {