Elm pager: die pager, die! Use naviframe instead.

SVN revision: 68015
This commit is contained in:
Tom Hacohen 2012-02-16 09:26:30 +00:00
parent dce2da14a8
commit 4787995f4b
10 changed files with 148 additions and 490 deletions

View File

@ -86,7 +86,6 @@ test_multi.c \
test_multibuttonentry.c \
test_naviframe.c \
test_notify.c \
test_pager.c \
test_panel.c \
test_panes.c \
test_photo.c \

View File

@ -90,8 +90,6 @@ void test_table7(void *data, Evas_Object *obj, void *event_info);
void test_gengrid(void *data, Evas_Object *obj, void *event_info);
void test_gengrid2(void *data, Evas_Object *obj, void *event_info);
void test_gengrid3(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);
@ -511,8 +509,6 @@ add_tests:
//------------------------------//
ADD_TEST(NULL, "Storyboard", "Naviframe", test_naviframe);
ADD_TEST(NULL, "Storyboard", "Pager", test_pager);
ADD_TEST(NULL, "Storyboard", "Pager Slide", test_pager_slide);
//------------------------------//
ADD_TEST(NULL, "Geographic", "Map", test_map);

View File

@ -1,337 +0,0 @@
#include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#ifndef ELM_LIB_QUICKLAUNCH
typedef struct _Pginfo Pginfo;
struct _Pginfo
{
Evas_Object *win, *pager, *pg1, *pg2, *pg3, *pg4;
};
static void
my_pager_1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Pginfo *info = data;
elm_pager_content_promote(info->pager, info->pg2);
}
static void
my_pager_2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Pginfo *info = data;
elm_pager_content_promote(info->pager, info->pg3);
}
static void
my_pager_3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Pginfo *info = data;
elm_pager_content_promote(info->pager, info->pg4);
}
static void
my_pager_4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Pginfo *info = data;
elm_pager_content_promote(info->pager, info->pg1);
}
static void
my_pager_pop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Pginfo *info = data;
elm_pager_content_pop(info->pager);
}
struct style_tuple {
const char *label;
const char *name;
};
static const struct style_tuple styles[] = {
{ "Default", "default"},
{ "Slide", "slide"},
{ "Slide Invisible", "slide_invisible"},
{ "Fade", "fade"},
{ "Fade Translucide", "fade_translucide"},
{ "Fade Invisible", "fade_invisible"},
{ "Flip", "flip"},
};
static void
_style(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *pg = data;
elm_object_style_set(pg, styles[elm_radio_value_get(obj)].name);
}
void
test_pager(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
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");
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_autodel_set(win, EINA_TRUE);
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);
evas_object_size_hint_weight_set(pg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, pg);
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_object_text_set(lb,
"This is page 1 in a pager stack.<br/>"
"<br/>"
"So what is a pager stack? It is a stack<br/>"
"of pages that hold widgets in it. The<br/>"
"pages can be pushed and popped on and<br/>"
"off the stack, activated and otherwise<br/>"
"activated if already in the stack<br/>"
"(activated means promoted to the top of<br/>"
"the stack).<br/>"
"<br/>"
"The theme may define the animation how<br/>"
"show and hide of pages. Select one theme style:");
elm_box_pack_end(bx, lb);
evas_object_show(lb);
unsigned int i = 0;
Evas_Object *rdg = NULL, *rd;
for (i = 0; i < (sizeof(styles) / sizeof(struct style_tuple)); i++)
{
rd = elm_radio_add(win);
elm_object_text_set(rd, styles[i].label);
elm_radio_state_value_set(rd, i);
if (rdg)
elm_radio_group_add(rd, rdg);
else
rdg = rd;
evas_object_smart_callback_add(rd, "changed", _style, pg);
elm_box_pack_end(bx, rd);
evas_object_show(rd);
}
elm_radio_value_set(rd, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "Flip to 2");
evas_object_smart_callback_add(bt, "clicked", my_pager_1, &info);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Popme");
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);
info.pg1 = bx;
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_object_text_set(lb,
"This is page 2 in a pager stack.<br/>"
"<br/>"
"This is just like the previous page in<br/>"
"the pager stack."
);
elm_box_pack_end(bx, lb);
evas_object_show(lb);
bt = elm_button_add(win);
elm_object_text_set(bt, "Flip to 3");
evas_object_smart_callback_add(bt, "clicked", my_pager_2, &info);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Popme");
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);
info.pg2 = bx;
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_object_text_set(lb,
"This is page 3 in a pager stack.<br/>"
"<br/>"
"This is just like the previous page in<br/>"
"the pager stack.");
elm_box_pack_end(bx, lb);
evas_object_show(lb);
bt = elm_button_add(win);
elm_object_text_set(bt, "Flip to 1");
evas_object_smart_callback_add(bt, "clicked", my_pager_3, &info);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Popme");
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);
info.pg3 = bx;
Evas_Object *ly, *ly2;
char buf[4096];
ly = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
elm_layout_file_set(ly, buf, "test/layout");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(ly);
ly2 = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
elm_layout_file_set(ly2, buf, "layout2");
evas_object_size_hint_weight_set(ly2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
//elm_win_resize_object_add(win, ly2);
evas_object_show(ly2);
bt = elm_button_add(win);
elm_object_text_set(bt, "Flip to 1");
evas_object_smart_callback_add(bt, "clicked", my_pager_4, &info);
elm_object_part_content_set(ly2, "element1", bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Popme");
evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
evas_object_show(bt);
elm_object_part_content_set(ly2, "element2", bt);
elm_object_part_content_set(ly, "swallow", ly2);
evas_object_show(ly);
elm_pager_content_push(pg, ly);
info.pg4 = ly2;
evas_object_show(win);
}
static void
my_pager_push(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
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_object_text_set(lb, buf);
elm_box_pack_end(bx, lb);
evas_object_show(lb);
bt = elm_button_add(info->win);
elm_object_text_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_object_text_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
_hide_finished(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
//To prevent the window size become zero.
Pginfo *info = data;
if (elm_pager_content_top_get(info->pager)) return;
elm_win_resize_object_del(info->win, info->pager);
}
void
test_pager_slide(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
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_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_autodel_set(win, EINA_TRUE);
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);
evas_object_smart_callback_add(pg, "hide,finished",
_hide_finished, &info);
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_object_text_set(lb,
"This is page 1 in a slide pager.<br/>"
"<br/>"
"The slide pager style is useful 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_object_text_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_object_text_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

View File

@ -223,7 +223,6 @@ EAPI extern Elm_Version *elm_version;
#include <elm_object.h>
// SanjeevBA
#include <elm_pager.h>
#include <elm_panel.h>
#include <elm_panes.h>
#include <elm_password.h>

View File

@ -108,7 +108,6 @@ elm_need.h \
elm_notify.h \
elm_object.h \
elm_object_item.h \
elm_pager.h \
elm_panel.h \
elm_panes.h \
elm_password.h \

View File

@ -1279,6 +1279,24 @@ elm_naviframe_item_promote(Elm_Object_Item *it)
edje_object_message_signal_process(elm_layout_edje_get(VIEW(navi_it)));
}
EAPI void
elm_naviframe_item_simple_promote(Evas_Object *obj, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
Elm_Naviframe_Item *itr;
EINA_INLIST_FOREACH(wd->stack, itr)
{
if (elm_object_item_content_get((Elm_Object_Item *) itr) == content)
{
elm_naviframe_item_promote((Elm_Object_Item *) itr);
break;
}
}
}
EAPI void
elm_naviframe_item_del(Elm_Object_Item *it)
{

View File

@ -384,6 +384,28 @@ EAPI void elm_naviframe_item_style_default_set(Evas_Object *obj, con
*/
EAPI const char *elm_naviframe_item_style_default_get(const Evas_Object *obj);
/**
* @def elm_naviframe_item_simple_push
* @brief Simple version of item_push.
*
* @see elm_naviframe_item_push
*/
#define elm_naviframe_item_simple_push(obj, content) \
{ \
Elm_Object_Item *__my_it; \
__my_it = elm_naviframe_item_push(obj, NULL, NULL, NULL, content, NULL); \
elm_naviframe_item_title_visible_set(__my_it, EINA_FALSE); \
(__my_it); \
}
/**
* @brief Simple version of item_promote.
*
* @see elm_naviframe_item_promote
*/
EAPI void elm_naviframe_item_simple_promote(Evas_Object *obj, Evas_Object *content);
/**
* @}
*/

View File

@ -4642,4 +4642,104 @@ EINA_DEPRECATED EAPI Evas_Object *elm_flip_content_back_unset(Evas_Objec
*/
EINA_DEPRECATED EAPI Eina_Bool elm_flip_front_get(const Evas_Object *obj);
/*
* Add a new pager to the parent
*
* @param parent The parent object
* @return The new object or NULL if it cannot be created
*
* @ingroup Pager
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI Evas_Object *elm_pager_add(Evas_Object *parent);
/**
* @brief Push an object to the top of the pager stack (and show it).
*
* @param obj The pager object
* @param content The object to push
*
* The object pushed becomes a child of the pager, it will be controlled and
* deleted when the pager is deleted.
*
* @note If the content is already in the stack use
* elm_pager_content_promote().
* @warning Using this function on @p content already in the stack results in
* undefined behavior.
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI void elm_pager_content_push(Evas_Object *obj, Evas_Object *content);
/**
* @brief Pop the object that is on top of the stack
*
* @param obj The pager object
*
* This pops the object that is on the top(visible) of the pager, makes it
* disappear, then deletes the object. The object that was underneath it on
* the stack will become visible.
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI void elm_pager_content_pop(Evas_Object *obj);
/**
* @brief Moves an object already in the pager stack to the top of the stack.
*
* @param obj The pager object
* @param content The object to promote
*
* This will take the @p content and move it to the top of the stack as
* if it had been pushed there.
*
* @note If the content isn't already in the stack use
* elm_pager_content_push().
* @warning Using this function on @p content not already in the stack
* results in undefined behavior.
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI void elm_pager_content_promote(Evas_Object *obj, Evas_Object *content);
/**
* @brief Return the object at the bottom of the pager stack
*
* @param obj The pager object
* @return The bottom object or NULL if none
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI Evas_Object *elm_pager_content_bottom_get(const Evas_Object *obj);
/**
* @brief Return the object at the top of the pager stack
*
* @param obj The pager object
* @return The top object or NULL if none
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI Evas_Object *elm_pager_content_top_get(const Evas_Object *obj);
/**
* @brief Set the default item style.
*
* Default item style will be used with items who's style is NULL
*
* @param obj The pager object
* @param style The style
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI void elm_pager_item_style_default_set(Evas_Object *obj, const char *style);
/**
* @brief Get the default item style
*
* @param obj The pager object
* @return the default item style
*
* @see elm_pager_item_style_default_set()
* @deprecated Use naviframe instead
*/
EINA_DEPRECATED EAPI const char *elm_pager_item_style_default_get(const Evas_Object *obj);
/**
* @}
*/

View File

@ -17,7 +17,7 @@ _pop_finished(void *data __UNUSED__, Evas_Object *obj, void *event_info)
evas_object_smart_callback_call(obj, "hide,finished", event_info);
}
EAPI Evas_Object *
EINA_DEPRECATED EAPI Evas_Object *
elm_pager_add(Evas_Object *parent)
{
Evas_Object *nf = elm_naviframe_add(parent);
@ -26,7 +26,7 @@ elm_pager_add(Evas_Object *parent)
return nf;
}
EAPI void
EINA_DEPRECATED EAPI void
elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
{
Elm_Object_Item *it;
@ -34,13 +34,13 @@ elm_pager_content_push(Evas_Object *obj, Evas_Object *content)
elm_naviframe_item_title_visible_set(it, EINA_FALSE);
}
EAPI void
EINA_DEPRECATED EAPI void
elm_pager_content_pop(Evas_Object *obj)
{
elm_naviframe_item_pop(obj);
}
EAPI void
EINA_DEPRECATED EAPI void
elm_pager_content_promote(Evas_Object *obj, Evas_Object *content)
{
Eina_List *items = elm_naviframe_items_get(obj);
@ -57,7 +57,7 @@ elm_pager_content_promote(Evas_Object *obj, Evas_Object *content)
eina_list_free(items);
}
EAPI Evas_Object *
EINA_DEPRECATED EAPI Evas_Object *
elm_pager_content_bottom_get(const Evas_Object *obj)
{
Elm_Object_Item *it;
@ -65,7 +65,7 @@ elm_pager_content_bottom_get(const Evas_Object *obj)
return elm_object_item_content_get(it);
}
EAPI Evas_Object *
EINA_DEPRECATED EAPI Evas_Object *
elm_pager_content_top_get(const Evas_Object *obj)
{
Elm_Object_Item *it;
@ -73,13 +73,13 @@ elm_pager_content_top_get(const Evas_Object *obj)
return elm_object_item_content_get(it);
}
EAPI void
EINA_DEPRECATED EAPI void
elm_pager_item_style_default_set(Evas_Object *obj, const char *style)
{
elm_naviframe_item_style_default_set(obj, style);
}
EAPI const char *
EINA_DEPRECATED EAPI const char *
elm_pager_item_style_default_get(const Evas_Object *obj)
{
return elm_naviframe_item_style_default_get(obj);

View File

@ -1,138 +0,0 @@
/**
* @defgroup Pager Pager
*
* @image html img/widget/pager/preview-00.png
* @image latex img/widget/pager/preview-00.eps
*
* @brief Widget that allows flipping between one or more pages
* of objects.
*
* The flipping between pages of objects is animated. All content
* in the pager is kept in a stack, the top being the last content added
* (visible one) on the top of that stack.
*
* Objects can be pushed or popped from the stack or deleted as
* well. Pushes and pops will animate the widget according to its
* style (a pop will also delete the child object once the
* animation is finished). Any object already in the pager can be
* promoted to the top (from its current stacking position) through
* the use of elm_pager_content_promote(). New objects are pushed
* to the top with elm_pager_content_push(). When the top item is
* no longer wanted, simply pop it with elm_pager_content_pop() and
* it will also be deleted. If an object is no longer needed and is
* not the top item, just delete it as normal. You can get the objects
* at the top and bottom with
* elm_pager_content_top_get() and elm_pager_content_bottom_get()
* respectively.
*
* Signals that you can add callbacks for are:
* - @c "show,finished" - when a new page is actually shown on the top
* - @c "hide,finished" - when a previous page is hidden
*
* Only after the first of that signals the child object is
* guaranteed to be visible, as in @c evas_object_visible_get().
*
* This widget has the following styles available:
* - @c "default"
*
* @note These styles affect only the flipping animations on the
* default theme; the appearance when not animating is unaffected
* by them.
*
* @ref tutorial_pager gives a good overview of the usage of the API.
* @{
*/
/**
* Add a new pager to the parent
*
* @param parent The parent object
* @return The new object or NULL if it cannot be created
*
* @ingroup Pager
*/
EAPI Evas_Object *elm_pager_add(Evas_Object *parent);
/**
* @brief Push an object to the top of the pager stack (and show it).
*
* @param obj The pager object
* @param content The object to push
*
* The object pushed becomes a child of the pager, it will be controlled and
* deleted when the pager is deleted.
*
* @note If the content is already in the stack use
* elm_pager_content_promote().
* @warning Using this function on @p content already in the stack results in
* undefined behavior.
*/
EAPI void elm_pager_content_push(Evas_Object *obj, Evas_Object *content);
/**
* @brief Pop the object that is on top of the stack
*
* @param obj The pager object
*
* This pops the object that is on the top(visible) of the pager, makes it
* disappear, then deletes the object. The object that was underneath it on
* the stack will become visible.
*/
EAPI void elm_pager_content_pop(Evas_Object *obj);
/**
* @brief Moves an object already in the pager stack to the top of the stack.
*
* @param obj The pager object
* @param content The object to promote
*
* This will take the @p content and move it to the top of the stack as
* if it had been pushed there.
*
* @note If the content isn't already in the stack use
* elm_pager_content_push().
* @warning Using this function on @p content not already in the stack
* results in undefined behavior.
*/
EAPI void elm_pager_content_promote(Evas_Object *obj, Evas_Object *content);
/**
* @brief Return the object at the bottom of the pager stack
*
* @param obj The pager object
* @return The bottom object or NULL if none
*/
EAPI Evas_Object *elm_pager_content_bottom_get(const Evas_Object *obj);
/**
* @brief Return the object at the top of the pager stack
*
* @param obj The pager object
* @return The top object or NULL if none
*/
EAPI Evas_Object *elm_pager_content_top_get(const Evas_Object *obj);
/**
* @brief Set the default item style.
*
* Default item style will be used with items who's style is NULL
*
* @param obj The pager object
* @param style The style
*/
EAPI void elm_pager_item_style_default_set(Evas_Object *obj, const char *style);
/**
* @brief Get the default item style
*
* @param obj The pager object
* @return the default item style
*
* @see elm_pager_item_style_default_set()
*/
EAPI const char *elm_pager_item_style_default_get(const Evas_Object *obj);
/**
* @}
*/