From 8d0474f7dafd41bcbb66496ca9dbf5d84e5fcfeb Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 4 Sep 2009 09:50:25 +0000 Subject: [PATCH] index not in scroller. better. a start. SVN revision: 42241 --- src/bin/Makefile.am | 40 +++++-- src/bin/test.c | 4 +- src/bin/test_index.c | 56 ++++++++++ src/lib/Makefile.am | 1 + src/lib/elm_index.c | 282 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_scroller.c | 76 ------------- src/lib/els_box.c | 2 +- src/lib/els_scroller.c | 2 +- 8 files changed, 377 insertions(+), 86 deletions(-) create mode 100644 src/bin/test_index.c create mode 100644 src/lib/elm_index.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 019b006..dfb3c54 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -24,13 +24,39 @@ if BUILD_QUICKLAUNCH bin_PROGRAMS += elementary_quicklaunch elementary_run elementary_testql endif -elementary_test_SOURCES = test.c test_bg.c test_icon.c test_box.c \ -test_button.c test_toggle.c test_table.c test_clock.c test_layout.c \ -test_hover.c test_entry.c test_notepad.c test_anchorview.c test_anchorblock.c \ -test_toolbar.c test_hoversel.c test_list.c test_carousel.c test_inwin.c \ -test_scaling.c test_slider.c test_genlist.c test_check.c test_pager.c \ -test_radio.c test_win_state.c test_progressbar.c test_fileselector.c \ -test_separator.c test_scroller.c test_spinner.c +elementary_test_SOURCES = \ +test.c \ +test_bg.c \ +test_icon.c \ +test_box.c \ +test_button.c \ +test_toggle.c \ +test_table.c \ +test_clock.c \ +test_layout.c \ +test_hover.c \ +test_entry.c \ +test_notepad.c \ +test_anchorview.c \ +test_anchorblock.c \ +test_toolbar.c \ +test_hoversel.c \ +test_list.c \ +test_carousel.c \ +test_inwin.c \ +test_scaling.c \ +test_slider.c \ +test_genlist.c \ +test_check.c \ +test_pager.c \ +test_radio.c \ +test_win_state.c \ +test_progressbar.c \ +test_fileselector.c \ +test_separator.c \ +test_scroller.c \ +test_spinner.c \ +test_index.c elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la elementary_test_LDFLAGS = diff --git a/src/bin/test.c b/src/bin/test.c index a2b074c..3490cc1 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -44,8 +44,9 @@ void test_win_state(void *data, Evas_Object *obj, void *event_info); void test_progressbar(void *data, Evas_Object *obj, void *event_info); void test_fileselector(void *data, Evas_Object *obj, void *event_info); void test_separator(void *data, Evas_Object *obj, void *event_info); -void test_spinner(void *data, Evas_Object *obj, void *event_info); void test_scroller(void *data, Evas_Object *obj, void *event_info); +void test_spinner(void *data, Evas_Object *obj, void *event_info); +void test_index(void *data, Evas_Object *obj, void *event_info); static void my_win_del(void *data, Evas_Object *obj, void *event_info) @@ -173,6 +174,7 @@ my_win_main(void) elm_list_item_append(li, "Separator", NULL, NULL, test_separator, NULL); elm_list_item_append(li, "Scroller", NULL, NULL, test_scroller, NULL); elm_list_item_append(li, "Spinner", NULL, NULL, test_spinner, NULL); + elm_list_item_append(li, "Index", NULL, NULL, test_index, NULL); elm_list_go(li); diff --git a/src/bin/test_index.c b/src/bin/test_index.c new file mode 100644 index 0000000..2c723c8 --- /dev/null +++ b/src/bin/test_index.c @@ -0,0 +1,56 @@ +#include + +static Elm_Genlist_Item_Class itci; +char *gli_label_get(const void *data, Evas_Object *obj, const char *part) +{ + char buf[256]; + snprintf(buf, sizeof(buf), "Item # %i", (int)data); + return strdup(buf); +} +void gli_del(const void *data, Evas_Object *obj) +{ +} + +void +test_index(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *win, *bg, *gl, *id; + Elm_Genlist_Item *it; + int i; + + win = elm_win_add(NULL, "index", ELM_WIN_BASIC); + elm_win_title_set(win, "Index"); + elm_win_autodel_set(win, 1); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, 1.0, 1.0); + evas_object_show(bg); + + gl = elm_genlist_add(win); + evas_object_size_hint_weight_set(gl, 1.0, 1.0); + elm_win_resize_object_add(win, gl); + evas_object_show(gl); + + id = elm_index_add(win); + evas_object_size_hint_weight_set(id, 1.0, 1.0); + elm_win_resize_object_add(win, id); + evas_object_show(id); + + itci.item_style = "default"; + itci.func.label_get = gli_label_get; + itci.func.icon_get = NULL; + itci.func.state_get = NULL; + itci.func.del = gli_del; + + for (i = 0; i < 100; i++) + { + // FIXME: add to index too + it = elm_genlist_item_append(gl, &itci, + i/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_NONE, NULL/* func */, + NULL/* func data */); + } + + evas_object_resize(win, 320, 480); + evas_object_show(win); +} diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index c98d212..3dcdeb3 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -57,6 +57,7 @@ elm_pager.c \ elm_progressbar.c \ elm_separator.c \ elm_spinner.c \ +elm_index.c \ \ elc_notepad.c \ elc_anchorview.c \ diff --git a/src/lib/elm_index.c b/src/lib/elm_index.c new file mode 100644 index 0000000..9c5ccfe --- /dev/null +++ b/src/lib/elm_index.c @@ -0,0 +1,282 @@ +#include +#include "elm_priv.h" + +/** + * @defgroup Index Index + * + * XXX + * + * Signals that you can add callbacks for are: + * + * xxx - XXX. + * + * xxx - XXX. + */ + +typedef struct _Widget_Data Widget_Data; + +struct _Widget_Data +{ + Evas_Object *base; + Evas_Object *event; + Evas_Object *bx[2]; + const char *label; + Eina_Bool horizontal : 1; +}; + +static void _del_hook(Evas_Object *obj); +static void _theme_hook(Evas_Object *obj); +static void _sizing_eval(Evas_Object *obj); + +static void +_del_hook(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (wd->label) eina_stringshare_del(wd->label); + free(wd); +} + +static void +_theme_hook(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (wd->horizontal) + _elm_theme_set(wd->base, "index", "horizontal", elm_widget_style_get(obj)); + else + _elm_theme_set(wd->base, "index", "vertical", elm_widget_style_get(obj)); + edje_object_part_swallow(wd->base, "elm.swallow.event", wd->event); + edje_object_part_swallow(wd->base, "elm.swallow.content", wd->bx[0]); + if (edje_object_part_exists(wd->base, "elm.swallow.content.sub")) + { + if (!wd->bx[1]) + { + wd->bx[1] = _els_smart_box_add(evas_object_evas_get(wd->base)); + _els_smart_box_orientation_set(wd->bx[1], 0); + _els_smart_box_homogenous_set(wd->bx[1], 1); + elm_widget_sub_object_add(obj, wd->bx[1]); + } + edje_object_part_swallow(wd->base, "elm.swallow.content.sub", wd->bx[1]); + evas_object_show(wd->bx[1]); + } + else if (wd->bx[1]) + { + evas_object_del(wd->bx[1]); + wd->bx[1] = NULL; + } + edje_object_message_signal_process(wd->base); + edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale); + // FIXME: content and sub lists - eval + _sizing_eval(obj); +} + +static void +_sizing_eval(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; + + elm_coords_finger_size_adjust(1, &minw, 1, &minh); + edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh); + elm_coords_finger_size_adjust(1, &minw, 1, &minh); + evas_object_size_hint_min_set(obj, minw, minh); + evas_object_size_hint_max_set(obj, maxw, maxh); +} + +static void +_wheel(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Mouse_Wheel *ev = event_info; + Evas_Object *obj = o; +} + +static void +_mouse_down(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Mouse_Down *ev = event_info; + Evas_Object *obj = o; +} + +static void +_mouse_up(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Mouse_Up *ev = event_info; + Evas_Object *obj = o; +} + +static void +_mouse_move(void *data, Evas *e, Evas_Object *o, void *event_info) +{ + Evas_Event_Mouse_Move *ev = event_info; + Evas_Object *obj = o; +} + +/** + * Add a new index to the parent + * + * @param parent The parent object + * @return The new object or NULL if it cannot be created + * + * @ingroup Index + */ +EAPI Evas_Object * +elm_index_add(Evas_Object *parent) +{ + Evas_Object *obj; + Evas_Object *o; + Evas *e; + Widget_Data *wd; + + wd = ELM_NEW(Widget_Data); + e = evas_object_evas_get(parent); + obj = elm_widget_add(e); + elm_widget_type_set(obj, "index"); + elm_widget_sub_object_add(parent, obj); + elm_widget_data_set(obj, wd); + elm_widget_del_hook_set(obj, _del_hook); + elm_widget_theme_hook_set(obj, _theme_hook); + + wd->horizontal = EINA_FALSE; + + wd->base = edje_object_add(e); + _elm_theme_set(wd->base, "index", "vertical", "default"); + elm_widget_resize_object_set(obj, wd->base); + + o = evas_object_rectangle_add(e); + wd->event = o; + evas_object_color_set(o, 0, 0, 0, 0); + edje_object_part_swallow(wd->base, "elm.swallow.event", o); + elm_widget_sub_object_add(obj, o); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _wheel, obj); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, obj); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _mouse_up, obj); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, obj); + evas_object_show(o); + + wd->bx[0] = _els_smart_box_add(e); + _els_smart_box_orientation_set(wd->bx[0], 0); + _els_smart_box_homogenous_set(wd->bx[0], 1); + elm_widget_sub_object_add(obj, wd->bx[0]); + edje_object_part_swallow(wd->base, "elm.swallow.content", wd->bx[0]); + evas_object_show(wd->bx[0]); + + if (edje_object_part_exists(wd->base, "elm.swallow.content.sub")) + { + wd->bx[1] = _els_smart_box_add(e); + _els_smart_box_orientation_set(wd->bx[1], 0); + _els_smart_box_homogenous_set(wd->bx[1], 1); + elm_widget_sub_object_add(obj, wd->bx[1]); + edje_object_part_swallow(wd->base, "elm.swallow.content.sub", wd->bx[1]); + evas_object_show(wd->bx[1]); + } + + _sizing_eval(obj); + return obj; +} + +#if 0 +/** + * Set the label of the index + * + * @param obj The index object + * @param label The text label string in UTF-8 + * + * @ingroup Index + */ +EAPI void +elm_index_label_set(Evas_Object *obj, const char *label) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->label) eina_stringshare_del(wd->label); + if (label) + { + wd->label = eina_stringshare_add(label); + edje_object_signal_emit(wd->base, "elm,state,text,visible", "elm"); + edje_object_message_signal_process(wd->base); + } + else + { + wd->label = NULL; + edje_object_signal_emit(wd->base, "elm,state,text,hidden", "elm"); + edje_object_message_signal_process(wd->base); + } + edje_object_part_text_set(wd->base, "elm.text", label); + _sizing_eval(obj); +} + +/** + * Get the label of the index + * + * @param obj The index object + * @return The text label string in UTF-8 + * + * @ingroup Index + */ +EAPI const char * +elm_index_label_get(Evas_Object *obj) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + return wd->label; +} +#endif + +/** + * XXX + * + * @param obj The index object + * + * @ingroup Index + */ +EAPI void +elm_index_item_append(Evas_Object *obj, const char *letter, const void *item) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; +} + +/** + * XXX + * + * @param obj The index object + * + * @ingroup Index + */ +EAPI void +elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *item) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; +} + +/** + * XXX + * + * @param obj The index object + * + * @ingroup Index + */ +EAPI void +elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *item, const void *relative) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (!relative) elm_index_item_append(obj, letter, item); +} + +/** + * XXX + * + * @param obj The index object + * + * @ingroup Index + */ +EAPI void +elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const void *relative) +{ + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (!relative) elm_index_item_prepend(obj, letter, item); +} + diff --git a/src/lib/elm_scroller.c b/src/lib/elm_scroller.c index cd1e982..5ac9a59 100644 --- a/src/lib/elm_scroller.c +++ b/src/lib/elm_scroller.c @@ -38,8 +38,6 @@ struct _Widget_Data Evas_Object *content; Eina_Bool min_w : 1; Eina_Bool min_h : 1; - Eina_Bool index_h : 1; - Eina_Bool index_v : 1; double pagerel_h, pagerel_v; Evas_Coord pagesize_h, pagesize_v; }; @@ -457,80 +455,6 @@ elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce } /** - * Enable quick-index jump on each axis - * - * This enabled a quick jump list along a specific axis. This is, for example - * "A, B, C, D ... X, Y, Z" along an axis that will jump to the item beginning - * with that letter as a quick way to jump to the position desired. - * - * @param obj The scroller object - * @param h_index Will the index be available horizontally - * @param v_index Will the index be available vertically - * - * @ingroup Scroller - */ -EAPI void -elm_scroller_index_set(Evas_Object *obj, Eina_Bool h_index, Eina_Bool v_index) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - wd->index_h = h_index; - wd->index_v = v_index; - // XXX eval index and show/hide -} - -/** - * Clear specific indexes for the scroller - * - * This clears the horizontal and/or vertical indexes for the scroller. After - * this the indicated index(es) will be empty. - * - * @param obj The scroller object - * @param h_index Clear the horizontal index (or not) - * @param v_index Clear the vertical index (or not) - * - * @ingroup Scroller - */ -EAPI void -elm_scroller_index_clear(Evas_Object *obj, Eina_Bool h_index, Eina_Bool v_index) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - // XXX eval index and show/hide -} - -/** - * Add a scroller index member - * - * This adds an item in the scroller index, giving it a position in the - * virtual content region along a specific axis and a size (the area that - * index item consumes). This is used to determine how to display the - * index item, if at all, and where it will "jump to". If an icon is used, - * the icon object becomes owned by the scroller and will be deleted if the - * scroller is deleted or the index cleared. The index level can indicate - * to use the main index (0) or sub-indexes for more accurate positioning. - * These are optional and may not function if not supported. Icons used for - * non-functioning index levels will be deleted. - * - * @param obj The scroller object - * @param axis The axis this item is to be asigned to - * @param label A string label for this index item - * @param icon An icon to display on the index item - * @param position The virtual position of the item - * @param size The virtual size of the item - * @param level Index level. 0 is the main. Others (1, 2, etc.) are optional. - * - * @ingroup Scroller - */ -EAPI void -elm_scroller_index_add(Evas_Object *obj, Elm_Scroller_Axis axis, const char *label, Evas_Object *icon, Evas_Coord position, Evas_Coord size, int level) -{ - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - // XXX eval index and show/hide -} - -/** * Set scroll page size relative to viewport size * * The scroller is sapale of limiting scrolling by the user to "pages". That diff --git a/src/lib/els_box.c b/src/lib/els_box.c index 74dfe37..f2c1791 100644 --- a/src/lib/els_box.c +++ b/src/lib/els_box.c @@ -444,7 +444,7 @@ _smart_init(void) { static const Evas_Smart_Class sc = { - "e_box", + "els_box", EVAS_SMART_CLASS_VERSION, _smart_add, _smart_del, diff --git a/src/lib/els_scroller.c b/src/lib/els_scroller.c index 2cade71..be00f33 100644 --- a/src/lib/els_scroller.c +++ b/src/lib/els_scroller.c @@ -1,7 +1,7 @@ #include #include "elm_priv.h" -#define SMART_NAME "elm_scroller" +#define SMART_NAME "els_scroller" #define API_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME))) #define INTERNAL_ENTRY Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return; typedef struct _Smart_Data Smart_Data; -- 2.7.4