From: Enlightenment C. <no...@cv...> - 2007-01-13 17:01:09
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/engines/ecore_fb Modified Files: ecore_fb.c Log Message: * [FB engine] The windows can now be resized by dragging their bottom-right corner * [Entry] etk_entry_add_clear_button() --> etk_entry_clear_button_add() =================================================================== RCS file: /cvs/e/e17/libs/etk/src/engines/ecore_fb/ecore_fb.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ecore_fb.c 13 Jan 2007 19:29:19 -0000 1.14 +++ ecore_fb.c 13 Jan 2007 23:00:38 -0000 1.15 @@ -53,6 +53,10 @@ static void _window_unrealized_cb(Etk_Object *object, void *data); static void _window_titlebar_mouse_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source); static void _window_titlebar_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _window_resize_mouse_in_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _window_resize_mouse_out_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _window_resize_mouse_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _window_resize_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source); static void _window_maximize_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source); static void _window_close_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source); @@ -82,10 +86,15 @@ static void (*_event_callback)(Etk_Event_Type event, Etk_Event_Global event_info) = NULL; static int _mouse_x = 0; static int _mouse_y = 0; -static Etk_Window *_window_dragged = NULL; + +static Etk_Window *_window_to_drag = NULL; static int _window_drag_offset_x = 0; static int _window_drag_offset_y = 0; +static Etk_Window *_window_to_resize = NULL; +static int _window_resize_offset_x = 0; +static int _window_resize_offset_y = 0; + static Etk_Window *_focused_window = NULL; @@ -740,6 +749,16 @@ _window_titlebar_mouse_down_cb, window); edje_object_signal_callback_add(engine_data->border, "mouse,up,1*", "etk.event.titlebar", _window_titlebar_mouse_up_cb, window); + + edje_object_signal_callback_add(engine_data->border, "mouse,in", "etk.event.resize", + _window_resize_mouse_in_cb, window); + edje_object_signal_callback_add(engine_data->border, "mouse,out", "etk.event.resize", + _window_resize_mouse_out_cb, window); + edje_object_signal_callback_add(engine_data->border, "mouse,down,1*", "etk.event.resize", + _window_resize_mouse_down_cb, window); + edje_object_signal_callback_add(engine_data->border, "mouse,up,1*", "etk.event.resize", + _window_resize_mouse_up_cb, window); + edje_object_signal_callback_add(engine_data->border, "mouse,clicked,1*", "etk.event.maximize", _window_maximize_mouse_up_cb, window); edje_object_signal_callback_add(engine_data->border, "mouse,clicked,1*", "etk.event.close", @@ -778,7 +797,7 @@ if (!engine_data->maximized) { - _window_dragged = window; + _window_to_drag = window; _window_drag_offset_x = _mouse_x - engine_data->border_position.x; _window_drag_offset_y = _mouse_y - engine_data->border_position.y; } @@ -789,7 +808,51 @@ /* Called when the titlebar of the window is released */ static void _window_titlebar_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { - _window_dragged = NULL; + _window_to_drag = NULL; +} + +/* Called when the mouse pointer enters the resize-rect of the window's border */ +static void _window_resize_mouse_in_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Etk_Window *window; + + if (!(window = ETK_WINDOW(data))) + return; + etk_toplevel_pointer_push(ETK_TOPLEVEL(window), ETK_POINTER_RESIZE_BR); +} + +/* Called when the mouse pointer leaves the resize-rect of the window's border */ +static void _window_resize_mouse_out_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Etk_Window *window; + + if (!(window = ETK_WINDOW(data))) + return; + etk_toplevel_pointer_pop(ETK_TOPLEVEL(window), ETK_POINTER_RESIZE_BR); +} + +/* Called when the mouse presses the resize-rect of the window's border */ +static void _window_resize_mouse_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Etk_Window *window; + Etk_Engine_Window_Data *engine_data; + + if (!(window = ETK_WINDOW(data))) + return; + engine_data = window->engine_data; + + if (!engine_data->maximized) + { + _window_to_resize = window; + _window_resize_offset_x = _mouse_x - engine_data->size.w; + _window_resize_offset_y = _mouse_y - engine_data->size.h; + } +} + +/* Called when the mouse releases the resize-rect of the window's border */ +static void _window_resize_mouse_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _window_to_resize = NULL; } /* Called when the mouse releases the maximize button */ @@ -823,8 +886,11 @@ evas_object_move(_pointer_object, _mouse_x, _mouse_y); /* Move the window to drag */ - if (_window_dragged) - etk_window_move(_window_dragged, _mouse_x - _window_drag_offset_x, _mouse_y - _window_drag_offset_y); + if (_window_to_drag) + etk_window_move(_window_to_drag, _mouse_x - _window_drag_offset_x, _mouse_y - _window_drag_offset_y); + /* Or resize the window to resize */ + else if (_window_to_resize) + etk_window_resize(_window_to_resize, _mouse_x - _window_resize_offset_x, _mouse_y - _window_resize_offset_y); return 1; } @@ -840,8 +906,11 @@ evas_object_move(_pointer_object, _mouse_x, _mouse_y); /* Move the window to drag */ - if (_window_dragged) - etk_window_move(_window_dragged, _mouse_x - _window_drag_offset_x, _mouse_y - _window_drag_offset_y); + if (_window_to_drag) + etk_window_move(_window_to_drag, _mouse_x - _window_drag_offset_x, _mouse_y - _window_drag_offset_y); + /* Or resize the window to resize */ + else if (_window_to_resize) + etk_window_resize(_window_to_resize, _mouse_x - _window_resize_offset_x, _mouse_y - _window_resize_offset_y); return 1; } |
From: Enlightenment C. <no...@cv...> - 2007-01-13 17:01:09
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/data/wm/default Modified Files: borders.edc pointers.edc Log Message: * [FB engine] The windows can now be resized by dragging their bottom-right corner * [Entry] etk_entry_add_clear_button() --> etk_entry_clear_button_add() =================================================================== RCS file: /cvs/e/e17/libs/etk/data/wm/default/borders.edc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- borders.edc 12 Jan 2007 02:53:55 -0000 1.1 +++ borders.edc 13 Jan 2007 23:00:37 -0000 1.2 @@ -31,6 +31,22 @@ } } part { + name: "etk.event.resize"; + type: RECT; + description { + state: "default" 0.0; + color: 255 255 255 0; + rel1 { + relative: 1.0 1.0; + offset: -16 -16; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } + } + part { name: "title_shadow2"; mouse_events: 0; description { =================================================================== RCS file: /cvs/e/e17/libs/etk/data/wm/default/pointers.edc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- pointers.edc 12 Jan 2007 02:53:55 -0000 1.1 +++ pointers.edc 13 Jan 2007 23:00:37 -0000 1.2 @@ -97,3 +97,28 @@ } } } + +group { + name: "etk/wm_pointer_resize_br"; + min: 18 18; + parts { + part { + name: "pointer"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: -17 -17; + } + rel2 { + relative: 0.0 0.0; + offset: 0 0; + } + image { + normal: "pointer_resize_br.png"; + } + } + } + } +} |
From: Enlightenment C. <no...@cv...> - 2007-01-13 17:01:10
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/data/wm/default/images Modified Files: Makefile.am images.edc Added Files: pointer_resize_br.png Log Message: * [FB engine] The windows can now be resized by dragging their bottom-right corner * [Entry] etk_entry_add_clear_button() --> etk_entry_clear_button_add() =================================================================== RCS file: /cvs/e/e17/libs/etk/data/wm/default/images/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- Makefile.am 12 Jan 2007 02:53:55 -0000 1.1 +++ Makefile.am 13 Jan 2007 23:00:37 -0000 1.2 @@ -18,4 +18,5 @@ pointer_default.png \ pointer_text_edit.png \ pointer_h_double_arrow.png \ - pointer_v_double_arrow.png + pointer_v_double_arrow.png \ + pointer_resize_br.png =================================================================== RCS file: /cvs/e/e17/libs/etk/data/wm/default/images/images.edc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- images.edc 12 Jan 2007 02:53:55 -0000 1.1 +++ images.edc 13 Jan 2007 23:00:37 -0000 1.2 @@ -18,4 +18,5 @@ image: "pointer_text_edit.png" COMP; image: "pointer_h_double_arrow.png" COMP; image: "pointer_v_double_arrow.png" COMP; + image: "pointer_resize_br.png" COMP; } |
From: Enlightenment C. <no...@cv...> - 2007-01-16 17:49:32
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/tools/etk_prefs Modified Files: etk_prefs.c Log Message: * Replace Etk_Tree by Etk_Tree2. The old tree is now removed.. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/tools/etk_prefs/etk_prefs.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- etk_prefs.c 19 Dec 2006 22:01:57 -0000 1.5 +++ etk_prefs.c 16 Jan 2007 23:49:27 -0000 1.6 @@ -53,16 +53,18 @@ etk_widget_size_request_set(tree, 180, 240); etk_tree_mode_set(ETK_TREE(tree), ETK_TREE_MODE_LIST); etk_tree_multiple_select_set(ETK_TREE(tree), ETK_FALSE); - etk_tree_row_height_set(ETK_TREE(tree), 52); - col = etk_tree_col_new(ETK_TREE(tree), _("Category"), etk_tree_model_icon_text_new(ETK_TREE(tree), ETK_TREE_FROM_EDJE), 90); + etk_tree_rows_height_set(ETK_TREE(tree), 52); + + col = etk_tree_col_new(ETK_TREE(tree), _("Category"), 90, 0.0); + etk_tree_col_model_add(col, etk_tree_model_image_new()); + etk_tree_col_model_add(col, etk_tree_model_text_new()); etk_tree_build(ETK_TREE(tree)); - etk_tree_freeze(ETK_TREE(tree)); + etk_prefs_standard_item_add(tree, "apps/preferences-desktop-theme_48", _("Theme"), NULL); etk_prefs_standard_item_add(tree, "apps/preferences-desktop-font_48", _("Fonts"), NULL); etk_prefs_standard_item_add(tree, "apps/preferences-desktop-locale_48", _("Language"), NULL); etk_prefs_standard_item_add(tree, "apps/system-users_48", _("User Preferences"), NULL); - etk_prefs_standard_item_add(tree, "categories/preferences-system_48", _("General"), NULL); - etk_tree_thaw(ETK_TREE(tree)); + etk_prefs_standard_item_add(tree, "categories/preferences-system_48", _("General"), NULL); /* paned to hold the tree on one side and the pref's contents on the other */ paned = etk_hpaned_new(); @@ -95,23 +97,22 @@ Etk_Tree_Row *row; file = etk_theme_icon_get(); - row = etk_tree_append(ETK_TREE(tree), etk_tree_nth_col_get(ETK_TREE(tree), - 0), - file, icon, label, NULL); + row = etk_tree_row_append(ETK_TREE(tree), NULL, + etk_tree_nth_col_get(ETK_TREE(tree), 0), file, icon, label, + NULL); i++; + j = malloc(sizeof(int)); *j = i; - etk_tree_row_data_set(row, j); + etk_tree_row_data_set_full(row, j, free); } static void _etk_prefs_row_clicked(Etk_Object *object, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data) { - int *num = NULL; + int *num; - num = etk_tree_row_data_get(row); - - if (num) - etk_notebook_current_page_set(ETK_NOTEBOOK(data), *num); + if ((num = etk_tree_row_data_get(row))) + etk_notebook_current_page_set(ETK_NOTEBOOK(data), *num); } static Etk_Widget *_etk_prefs_theme_tab_create() @@ -146,10 +147,12 @@ etk_widget_size_request_set(theme_list, 180, 240); etk_tree_mode_set(ETK_TREE(theme_list), ETK_TREE_MODE_LIST); etk_tree_multiple_select_set(ETK_TREE(theme_list), ETK_FALSE); - col1 = etk_tree_col_new(ETK_TREE(theme_list), "Themes", etk_tree_model_text_new(ETK_TREE(theme_list)), 150); - etk_tree_row_height_set(ETK_TREE(theme_list), 60); + etk_tree_rows_height_set(ETK_TREE(theme_list), 60); etk_tree_headers_visible_set(ETK_TREE(theme_list), ETK_FALSE); etk_signal_connect("row_selected", ETK_OBJECT(theme_list), ETK_CALLBACK(_etk_prefs_theme_row_selected_cb), preview); + + col1 = etk_tree_col_new(ETK_TREE(theme_list), "Themes", 150, 0.0); + etk_tree_col_model_add(col1, etk_tree_model_text_new()); etk_tree_build(ETK_TREE(theme_list)); /* scan for themes and add them to the list */ @@ -159,7 +162,7 @@ const char *widget_theme = etk_config_widget_theme_get(); theme = l->data; - row = etk_tree_append(ETK_TREE(theme_list), col1, theme, NULL); + row = etk_tree_row_append(ETK_TREE(theme_list), NULL, col1, theme, NULL); if (widget_theme) if (!strcmp(theme, widget_theme)) etk_tree_row_select(row); |
From: Enlightenment C. <no...@cv...> - 2007-01-16 17:49:33
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: Etk.h Makefile.am etk_filechooser_widget.c etk_tree.c etk_tree.h etk_tree_model.c etk_tree_model.h etk_types.h Removed Files: etk_tree2.c etk_tree2.h etk_tree2_model.c etk_tree2_model.h Log Message: * Replace Etk_Tree by Etk_Tree2. The old tree is now removed.. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/Etk.h,v retrieving revision 1.46 retrieving revision 1.47 diff -u -3 -r1.46 -r1.47 --- Etk.h 9 Dec 2006 09:56:32 -0000 1.46 +++ Etk.h 16 Jan 2007 23:49:26 -0000 1.47 @@ -76,8 +76,6 @@ #include "etk_toplevel.h" #include "etk_tree.h" #include "etk_tree_model.h" -#include "etk_tree2.h" -#include "etk_tree2_model.h" #include "etk_viewport.h" #include "etk_widget.h" #include "etk_window.h" =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/Makefile.am,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- Makefile.am 9 Dec 2006 09:56:32 -0000 1.50 +++ Makefile.am 16 Jan 2007 23:49:26 -0000 1.51 @@ -81,8 +81,6 @@ etk_toplevel.h \ etk_tree.h \ etk_tree_model.h \ -etk_tree2.h \ -etk_tree2_model.h \ etk_type.h \ etk_types.h \ etk_utils.h \ @@ -155,8 +153,6 @@ etk_toplevel.c \ etk_tree.c \ etk_tree_model.c \ -etk_tree2.c \ -etk_tree2_model.c \ etk_type.c \ etk_utils.c \ etk_viewport.c \ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_filechooser_widget.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- etk_filechooser_widget.c 19 Dec 2006 22:01:57 -0000 1.16 +++ etk_filechooser_widget.c 16 Jan 2007 23:49:26 -0000 1.17 @@ -175,7 +175,7 @@ /* TODO: compiler warning? */ strftime(mod_time_string, 128, "%x", mod_time2); - etk_tree_append(ETK_TREE(filechooser_widget->files_tree), + etk_tree_row_append(ETK_TREE(filechooser_widget->files_tree), NULL, filechooser_widget->files_name_col, etk_theme_icon_get(), "places/folder_16", filename, filechooser_widget->files_date_col, mod_time_string, NULL); } @@ -213,7 +213,7 @@ /* TODO: compiler warning? */ strftime(mod_time_string, 128, "%x", mod_time2); - etk_tree_append(ETK_TREE(filechooser_widget->files_tree), + etk_tree_row_append(ETK_TREE(filechooser_widget->files_tree), NULL, filechooser_widget->files_name_col, etk_theme_icon_get(), icon ? icon : "mimetypes/text-x-generic_16", filename, filechooser_widget->files_date_col, mod_time_string, NULL); } @@ -256,19 +256,17 @@ */ Evas_List *etk_filechooser_widget_selected_files_get(Etk_Filechooser_Widget *filechooser_widget) { - char *filename; - Evas_List *files = NULL; - Evas_List *selected_rows; - Evas_List *l; - - selected_rows = etk_tree_selected_rows_get(ETK_TREE(filechooser_widget->files_tree)); - for(l = selected_rows; l; l = l->next) - { - etk_tree_row_fields_get(l->data, filechooser_widget->files_name_col, NULL, NULL, &filename, NULL); - files = evas_list_append(files, filename); - } + char *filename; + Etk_Tree_Row *row; + Evas_List *files = NULL; + + for (row = etk_tree_first_row_get(ETK_TREE(filechooser_widget->files_tree)); row; row = etk_tree_row_next_get(row)) + { + etk_tree_row_fields_get(row, filechooser_widget->files_name_col, NULL, NULL, &filename, NULL); + files = evas_list_append(files, filename); + } - return files; + return files; } /** @@ -355,7 +353,9 @@ fcw->places_tree = etk_tree_new(); etk_widget_size_request_set(fcw->places_tree, 180, 180); etk_paned_child1_set(ETK_PANED(vpaned), fcw->places_tree, ETK_TRUE); - fcw->places_col = etk_tree_col_new(ETK_TREE(fcw->places_tree), _("Places"), etk_tree_model_icon_text_new(ETK_TREE(fcw->places_tree), ETK_TREE_FROM_EDJE), 120); + fcw->places_col = etk_tree_col_new(ETK_TREE(fcw->places_tree), _("Places"), 120, 0.0); + etk_tree_col_model_add(fcw->places_col, etk_tree_model_image_new()); + etk_tree_col_model_add(fcw->places_col, etk_tree_model_text_new()); etk_tree_build(ETK_TREE(fcw->places_tree)); etk_widget_show(fcw->places_tree); etk_widget_internal_set(fcw->places_tree, ETK_TRUE); @@ -364,7 +364,9 @@ fcw->fav_tree = etk_tree_new(); etk_widget_size_request_set(fcw->fav_tree, 180, 180); etk_paned_child2_set(ETK_PANED(vpaned), fcw->fav_tree, ETK_TRUE); - fcw->fav_col = etk_tree_col_new(ETK_TREE(fcw->fav_tree), _("Favorites"), etk_tree_model_icon_text_new(ETK_TREE(fcw->fav_tree), ETK_TREE_FROM_EDJE), 120); + fcw->fav_col = etk_tree_col_new(ETK_TREE(fcw->fav_tree), _("Favorites"), 120, 0.0); + etk_tree_col_model_add(fcw->fav_col, etk_tree_model_image_new()); + etk_tree_col_model_add(fcw->fav_col, etk_tree_model_text_new()); etk_tree_build(ETK_TREE(fcw->fav_tree)); etk_widget_show(fcw->fav_tree); etk_widget_internal_set(fcw->fav_tree, ETK_TRUE); @@ -373,9 +375,12 @@ fcw->files_tree = etk_tree_new(); etk_widget_size_request_set(fcw->files_tree, 400, 120); etk_paned_child2_set(ETK_PANED(fcw->hpaned), fcw->files_tree, ETK_TRUE); - fcw->files_name_col = etk_tree_col_new(ETK_TREE(fcw->files_tree), _("Filename"), etk_tree_model_icon_text_new(ETK_TREE(fcw->files_tree), ETK_TREE_FROM_EDJE), 100); + fcw->files_name_col = etk_tree_col_new(ETK_TREE(fcw->files_tree), _("Filename"), 100, 0.0); + etk_tree_col_model_add(fcw->files_name_col, etk_tree_model_image_new()); + etk_tree_col_model_add(fcw->files_name_col, etk_tree_model_text_new()); etk_tree_col_expand_set(fcw->files_name_col, ETK_TRUE); - fcw->files_date_col = etk_tree_col_new(ETK_TREE(fcw->files_tree), _("Date"), etk_tree_model_text_new(ETK_TREE(fcw->files_tree)), 60); + fcw->files_date_col = etk_tree_col_new(ETK_TREE(fcw->files_tree), _("Date"), 60, 0.0); + etk_tree_col_model_add(fcw->files_date_col, etk_tree_model_text_new()); etk_tree_build(ETK_TREE(fcw->files_tree)); etk_widget_show(fcw->files_tree); etk_widget_internal_set(fcw->files_tree, ETK_TRUE); @@ -535,16 +540,19 @@ etk_tree_freeze(ETK_TREE(fcw->places_tree)); - row = etk_tree_append(ETK_TREE(fcw->places_tree), fcw->places_col, etk_theme_icon_get(), "actions/go-up_16", "..", NULL); + row = etk_tree_row_append(ETK_TREE(fcw->places_tree), NULL, + fcw->places_col, etk_theme_icon_get(), "actions/go-up_16", "..", NULL); etk_tree_row_data_set_full(row, strdup(".."), free); if ((home = getenv("HOME"))) { - row = etk_tree_append(ETK_TREE(fcw->places_tree), fcw->places_col, etk_theme_icon_get(), "places/user-home_16", _("Home"), NULL); + row = etk_tree_row_append(ETK_TREE(fcw->places_tree), NULL, + fcw->places_col, etk_theme_icon_get(), "places/user-home_16", _("Home"), NULL); etk_tree_row_data_set_full(row, strdup(home), free); } - row = etk_tree_append(ETK_TREE(fcw->places_tree), fcw->places_col, etk_theme_icon_get(), "devices/computer_16", _("Root"), NULL); + row = etk_tree_row_append(ETK_TREE(fcw->places_tree), NULL, + fcw->places_col, etk_theme_icon_get(), "devices/computer_16", _("Root"), NULL); etk_tree_row_data_set_full(row, strdup("/"), free); /* Adds the mount points */ @@ -574,7 +582,8 @@ if (!fs_supported) continue; - row = etk_tree_append(ETK_TREE(fcw->places_tree), fcw->places_col, etk_theme_icon_get(), "devices/drive-harddisk_16", ecore_file_get_file(mount_point->mnt_dir), NULL); + row = etk_tree_row_append(ETK_TREE(fcw->places_tree), NULL, + fcw->places_col, etk_theme_icon_get(), "devices/drive-harddisk_16", ecore_file_get_file(mount_point->mnt_dir), NULL); etk_tree_row_data_set_full(row, strdup(mount_point->mnt_dir), free); } endmntent(mtab); @@ -607,7 +616,8 @@ if (!fs_supported) continue; - row = etk_tree_append(ETK_TREE(fcw->places_tree), fcw->places_col, etk_theme_icon_get(), "devices/drive-harddisk_16", ecore_file_get_file(mount_points[i].f_mntonname), NULL); + row = etk_tree_row_append(ETK_TREE(fcw->places_tree), NULL, + fcw->places_col, etk_theme_icon_get(), "devices/drive-harddisk_16", ecore_file_get_file(mount_points[i].f_mntonname), NULL); etk_tree_row_data_set_full(row, strdup(mount_points[i].f_mntonname), free); } } @@ -641,7 +651,8 @@ if (sscanf(line, "file://%s", fav) == 1) { - row = etk_tree_append(ETK_TREE(fcw->fav_tree), fcw->fav_col, etk_theme_icon_get(), "places/folder_16", ecore_file_get_file(fav), NULL); + row = etk_tree_row_append(ETK_TREE(fcw->fav_tree), NULL, + fcw->fav_col, etk_theme_icon_get(), "places/folder_16", ecore_file_get_file(fav), NULL); etk_tree_row_data_set_full(row, strdup(fav), free); } } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v retrieving revision 1.80 retrieving revision 1.81 diff -u -3 -r1.80 -r1.81 --- etk_tree.c 9 Dec 2006 09:56:33 -0000 1.80 +++ etk_tree.c 16 Jan 2007 23:49:26 -0000 1.81 @@ -1,19 +1,14 @@ /** @file etk_tree.c */ #include "etk_tree.h" #include <stdlib.h> -#include <stdio.h> #include <string.h> -#include <math.h> -#include <Ecore_Data.h> #include <Edje.h> -#include "etk_theme.h" #include "etk_tree_model.h" #include "etk_scrolled_view.h" #include "etk_button.h" #include "etk_toplevel.h" -#include "etk_window.h" -#include "etk_drag.h" #include "etk_event.h" +#include "etk_theme.h" #include "etk_signal.h" #include "etk_signal_callback.h" #include "etk_utils.h" @@ -23,51 +18,43 @@ * @{ */ -#define ETK_TREE_MIN_HEADER_WIDTH 10 -#define ETK_TREE_MIN_ROW_HEIGHT 8 -#define ETK_TREE_NUM_OBJECTS_PER_CELL 3 +#define TREE_GET(widget) \ + ETK_TREE(etk_object_data_get(ETK_OBJECT(widget), "_Etk_Tree::Tree")) -#define ETK_TREE_GRID_TYPE (_etk_tree_grid_type_get()) -#define ETK_TREE_GRID(obj) (ETK_OBJECT_CAST((obj), ETK_TREE_GRID_TYPE, Etk_Tree_Grid)) -#define ETK_IS_TREE_GRID(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_TREE_GRID_TYPE)) - -typedef struct Etk_Tree_Grid -{ - /* Inherit form Etk_Widget */ - Etk_Widget widget; +#define COL_MIN_WIDTH 24 +#define COL_RESIZE_THRESHOLD 3 +#define MIN_ROW_HEIGHT 12 +#define DEFAULT_ROW_HEIGHT 24 +#define CELL_HMARGINS 4 +#define CELL_VMARGINS 2 +#define MODEL_INTERSPACE 8 - Etk_Tree *tree; - Evas_Object *clip; -} Etk_Tree_Grid; typedef struct Etk_Tree_Cell_Objects { - Evas_Object *objects[ETK_TREE_NUM_OBJECTS_PER_CELL]; + Evas_Object *objects[MAX_MODELS_PER_COL][MAX_OBJECTS_PER_MODEL]; } Etk_Tree_Cell_Objects; -typedef struct Etk_Tree_Row_Objects +typedef struct Etk_Tree_Row_Object { Evas_Object *expander; Evas_Object *background; - Etk_Tree_Cell_Objects *cells_objects; + Etk_Tree_Cell_Objects *cells; Etk_Tree_Row *row; -} Etk_Tree_Row_Objects; +} Etk_Tree_Row_Object; enum Etk_Tree_Signal_Id { + ETK_TREE_ALL_SELECTED_SIGNAL, + ETK_TREE_ALL_UNSELECTED_SIGNAL, ETK_TREE_ROW_SELECTED_SIGNAL, ETK_TREE_ROW_UNSELECTED_SIGNAL, ETK_TREE_ROW_CLICKED_SIGNAL, ETK_TREE_ROW_ACTIVATED_SIGNAL, - ETK_TREE_ROW_EXPANDED_SIGNAL, - ETK_TREE_ROW_COLLAPSED_SIGNAL, - ETK_TREE_ROW_MOUSE_IN_SIGNAL, - ETK_TREE_ROW_MOUSE_OUT_SIGNAL, - ETK_TREE_ROW_MOUSE_MOVE_SIGNAL, + ETK_TREE_ROW_UNFOLDED_SIGNAL, + ETK_TREE_ROW_FOLDED_SIGNAL, ETK_TREE_ROW_SHOWN_SIGNAL, - ETK_TREE_ROW_HIDDEN_SIGNAL, - ETK_TREE_SELECT_ALL_SIGNAL, - ETK_TREE_UNSELECT_ALL_SIGNAL, + ETK_TREE_ROW_HIDDEN_SIGNAL, ETK_TREE_NUM_SIGNALS }; @@ -76,7 +63,7 @@ ETK_TREE_MODE_PROPERTY, ETK_TREE_MULTIPLE_SELECT_PROPERTY, ETK_TREE_HEADERS_VISIBLE_PROPERTY, - ETK_TREE_ROW_HEIGHT_PROPERTY + ETK_TREE_ROWS_HEIGHT_PROPERTY }; enum Etk_Tree_Col_Signal_Id @@ -88,74 +75,72 @@ enum Etk_Tree_Col_Property_Id { ETK_TREE_COL_TITLE_PROPERTY, - ETK_TREE_COL_WIDTH_PROPERTY, - ETK_TREE_COL_MIN_WIDTH_PROPERTY, - ETK_TREE_COL_VISIBLE_WIDTH_PROPERTY, ETK_TREE_COL_VISIBLE_PROPERTY, ETK_TREE_COL_RESIZABLE_PROPERTY, - ETK_TREE_COL_PLACE_PROPERTY, - ETK_TREE_COL_EXPAND_PROPERTY + ETK_TREE_COL_POSITION_PROPERTY, + ETK_TREE_COL_EXPAND_PROPERTY, + ETK_TREE_COL_WIDTH_PROPERTY, + ETK_TREE_COL_MIN_WIDTH_PROPERTY, + ETK_TREE_COL_ALIGN_PROPERTY }; -static Etk_Type *_etk_tree_grid_type_get(); -static void _etk_tree_grid_constructor(Etk_Tree_Grid *grid); -static void _etk_tree_grid_size_allocate(Etk_Widget *widget, Etk_Geometry geometry); -static void _etk_tree_grid_scroll(Etk_Widget *widget, int x, int y); -static void _etk_tree_grid_scroll_size_get(Etk_Widget *widget, Etk_Size scrollview_size, Etk_Size scrollbar_size, Etk_Size *scroll_size); -static void _etk_tree_grid_realize_cb(Etk_Object *object, void *data); static void _etk_tree_constructor(Etk_Tree *tree); static void _etk_tree_destructor(Etk_Tree *tree); static void _etk_tree_property_set(Etk_Object *object, int property_id, Etk_Property_Value *value); static void _etk_tree_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value); +static void _etk_tree_size_request(Etk_Widget *widget, Etk_Size *size); static void _etk_tree_size_allocate(Etk_Widget *widget, Etk_Geometry geometry); static void _etk_tree_realize_cb(Etk_Object *object, void *data); -static void _etk_tree_unrealize_cb(Etk_Object *object, void *data); static void _etk_tree_col_constructor(Etk_Tree_Col *tree_col); static void _etk_tree_col_destructor(Etk_Tree_Col *tree_col); static void _etk_tree_col_property_set(Etk_Object *object, int property_id, Etk_Property_Value *value); static void _etk_tree_col_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value); -static void _etk_tree_expander_clicked_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _etk_tree_row_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _etk_tree_row_clicked_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _etk_tree_row_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _etk_tree_row_mouse_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _etk_tree_row_mouse_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_headers_size_allocate(Etk_Tree *tree, Etk_Geometry geometry); +static void _etk_tree_scroll_content_size_allocate(Etk_Widget *widget, Etk_Geometry geometry); +static void _etk_tree_scroll_content_scroll(Etk_Widget *widget, int x, int y); +static void _etk_tree_scroll_content_scroll_size_get(Etk_Widget *widget, Etk_Size scrollview_size, Etk_Size scrollbar_size, Etk_Size *scroll_size); +static void _etk_tree_grid_size_allocate(Etk_Widget *widget, Etk_Geometry geometry); + +static void _etk_tree_realize_cb(Etk_Object *object, void *data); static void _etk_tree_focus_cb(Etk_Object *object, void *event, void *data); static void _etk_tree_unfocus_cb(Etk_Object *object, void *event, void *data); static void _etk_tree_key_down_cb(Etk_Object *object, Etk_Event_Key_Down *event, void *data); -static void _etk_tree_header_mouse_down_cb(Etk_Object *object, Etk_Event_Mouse_Down *event, void *data); -static void _etk_tree_header_mouse_up_cb(Etk_Object *object, Etk_Event_Mouse_Up *event, void *data); -static void _etk_tree_header_mouse_move_cb(Etk_Object *object, Etk_Event_Mouse_Move *event, void *data); -static void _etk_tree_header_mouse_in_cb(Etk_Object *object, Etk_Event_Mouse_In *event, void *data); -static void _etk_tree_header_mouse_out_cb(Etk_Object *object, Etk_Event_Mouse_Out *event, void *data); -static void _etk_tree_drag_drop_cb(Etk_Object *object, void *event, void *data); -static void _etk_tree_drag_end_cb(Etk_Object *object, void *data); - -static void _etk_tree_update(Etk_Tree *tree); -static int _etk_tree_rows_draw(Etk_Tree *tree, Etk_Tree_Row *first_row, Evas_List **items_objects, - int x, int w, int h, int xoffset, int yoffset, int first_row_id, int first_row_color); -static Etk_Tree_Row *_etk_tree_row_new_valist(Etk_Tree *tree, Etk_Tree_Row *row, va_list args); -static void _etk_tree_row_free(Etk_Tree_Row *row); -static void _etk_tree_row_fields_set_valist_full(Etk_Tree_Row *row, va_list args, Etk_Bool emit_value_changed_signal); -static Etk_Tree_Row_Objects *_etk_tree_row_objects_new(Etk_Tree *tree); -static void _etk_tree_row_objects_free(Etk_Tree_Row_Objects *row_objects, Etk_Tree *tree); +static void _etk_tree_scroll_content_realize_cb(Etk_Object *object, void *data); +static void _etk_tree_grid_realize_cb(Etk_Object *object, void *data); +static void _etk_tree_grid_unrealize_cb(Etk_Object *object, void *data); + +static void _etk_tree_headers_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_headers_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_headers_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_headers_mouse_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_headers_mouse_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + +static void _etk_tree_row_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_row_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _etk_tree_row_expander_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + +static void _etk_tree_purge_job(void *data); +static void _etk_tree_purge(Etk_Tree *tree); +static void _etk_tree_row_move_to_purge_pool(Etk_Tree_Row *row); + static void _etk_tree_col_realize(Etk_Tree *tree, int col_nth); -static Etk_Tree_Col *etk_tree_col_to_resize_get(Etk_Tree_Col *col, int x); +static Etk_Tree_Col *etk_tree_col_to_resize_get(Etk_Tree *tree, int x); +static void _etk_tree_headers_rect_create(Etk_Tree *tree, Etk_Widget *parent); + +static Etk_Tree_Row *_etk_tree_row_next_to_render_get(Etk_Tree_Row *row, int *depth); +static Etk_Tree_Row_Object *_etk_tree_row_object_create(Etk_Tree *tree); +static void _etk_tree_row_object_destroy(Etk_Tree *tree, Etk_Tree_Row_Object *row_object); +static void _etk_tree_expanders_clip(Etk_Tree *tree); -static void _etk_tree_row_selected_rows_get(Etk_Tree_Row *row, Evas_List **selected_rows); -static void _etk_tree_row_unselected_rows_get(Etk_Tree_Row *row, Evas_List **unselected_rows); -static void _etk_tree_row_select_all(Etk_Tree_Row *row); -static void _etk_tree_row_unselect_all(Etk_Tree_Row *row); static void _etk_tree_row_select(Etk_Tree *tree, Etk_Tree_Row *row, Etk_Modifiers modifiers); -static void _etk_tree_heapify(Etk_Tree *tree, Etk_Tree_Row **heap, int root, int size, int (*compare_cb)(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), int asc, Etk_Tree_Col *col, void *data); + static Etk_Signal *_etk_tree_signals[ETK_TREE_NUM_SIGNALS]; static Etk_Signal *_etk_tree_col_signals[ETK_TREE_COL_NUM_SIGNALS]; -static Etk_Bool _etk_tree_drag_started = ETK_FALSE; -static Etk_Mouse_Flags _etk_tree_mouse_flags = ETK_MOUSE_NONE; + /************************** * @@ -164,8 +149,9 @@ **************************/ /** + * @internal * @brief Gets the type of an Etk_Tree - * @return Returns the type on an Etk_Tree + * @return Returns the type of an Etk_Tree */ Etk_Type *etk_tree_type_get() { @@ -173,26 +159,38 @@ if (!tree_type) { - tree_type = etk_type_new("Etk_Tree", ETK_WIDGET_TYPE, sizeof(Etk_Tree), ETK_CONSTRUCTOR(_etk_tree_constructor), ETK_DESTRUCTOR(_etk_tree_destructor)); - - _etk_tree_signals[ETK_TREE_ROW_SELECTED_SIGNAL] = etk_signal_new("row_selected", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_UNSELECTED_SIGNAL] = etk_signal_new("row_unselected", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_CLICKED_SIGNAL] = etk_signal_new("row_clicked", tree_type, -1, etk_marshaller_VOID__POINTER_POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_ACTIVATED_SIGNAL] = etk_signal_new("row_activated", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_EXPANDED_SIGNAL] = etk_signal_new("row_expaned", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_COLLAPSED_SIGNAL] = etk_signal_new("row_collapsed", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_MOUSE_IN_SIGNAL] = etk_signal_new("row_mouse_in", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_MOUSE_OUT_SIGNAL] = etk_signal_new("row_mouse_out", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_MOUSE_MOVE_SIGNAL] = etk_signal_new("row_mouse_move", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_SHOWN_SIGNAL] = etk_signal_new("row_shown", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_ROW_HIDDEN_SIGNAL] = etk_signal_new("row_hidden", tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - _etk_tree_signals[ETK_TREE_SELECT_ALL_SIGNAL] = etk_signal_new("select_all", tree_type, -1, etk_marshaller_VOID__VOID, NULL, NULL); - _etk_tree_signals[ETK_TREE_UNSELECT_ALL_SIGNAL] = etk_signal_new("unselect_all", tree_type, -1, etk_marshaller_VOID__VOID, NULL, NULL); - - etk_type_property_add(tree_type, "mode", ETK_TREE_MODE_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(ETK_TREE_MODE_LIST)); - etk_type_property_add(tree_type, "multiple_select", ETK_TREE_MULTIPLE_SELECT_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); - etk_type_property_add(tree_type, "headers_visible", ETK_TREE_HEADERS_VISIBLE_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); - etk_type_property_add(tree_type, "row_height", ETK_TREE_ROW_HEIGHT_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(24)); + tree_type = etk_type_new("Etk_Tree", ETK_WIDGET_TYPE, sizeof(Etk_Tree), + ETK_CONSTRUCTOR(_etk_tree_constructor), ETK_DESTRUCTOR(_etk_tree_destructor)); + + _etk_tree_signals[ETK_TREE_ALL_SELECTED_SIGNAL] = etk_signal_new("all_selected", + tree_type, -1, etk_marshaller_VOID__VOID, NULL, NULL); + _etk_tree_signals[ETK_TREE_ALL_UNSELECTED_SIGNAL] = etk_signal_new("all_unselected", + tree_type, -1, etk_marshaller_VOID__VOID, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_SELECTED_SIGNAL] = etk_signal_new("row_selected", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_UNSELECTED_SIGNAL] = etk_signal_new("row_unselected", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_CLICKED_SIGNAL] = etk_signal_new("row_clicked", + tree_type, -1, etk_marshaller_VOID__POINTER_POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_ACTIVATED_SIGNAL] = etk_signal_new("row_activated", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_UNFOLDED_SIGNAL] = etk_signal_new("row_unfolded", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_FOLDED_SIGNAL] = etk_signal_new("row_folded", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_SHOWN_SIGNAL] = etk_signal_new("row_shown", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_signals[ETK_TREE_ROW_HIDDEN_SIGNAL] = etk_signal_new("row_hidden", + tree_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + + etk_type_property_add(tree_type, "mode", ETK_TREE_MODE_PROPERTY, + ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(ETK_TREE_MODE_LIST)); + etk_type_property_add(tree_type, "multiple_select", ETK_TREE_MULTIPLE_SELECT_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); + etk_type_property_add(tree_type, "headers_visible", ETK_TREE_HEADERS_VISIBLE_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); + etk_type_property_add(tree_type, "rows_height", ETK_TREE_ROWS_HEIGHT_PROPERTY, + ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(DEFAULT_ROW_HEIGHT)); tree_type->property_set = _etk_tree_property_set; tree_type->property_get = _etk_tree_property_get; @@ -202,17 +200,9 @@ } /** - * @brief Creates a new tree - * @return Returns the new tree widget - */ -Etk_Widget *etk_tree_new() -{ - return etk_widget_new(ETK_TREE_TYPE, "theme_group", "tree", "focusable", ETK_TRUE, "focus_on_click", ETK_TRUE, NULL); -} - -/** + * @internal * @brief Gets the type of an Etk_Tree_Col - * @return Returns the type on an Etk_Tree_Col + * @return Returns the type of an Etk_Tree_Col */ Etk_Type *etk_tree_col_type_get() { @@ -220,18 +210,28 @@ if (!tree_col_type) { - tree_col_type = etk_type_new("Etk_Tree_Col", ETK_OBJECT_TYPE, sizeof(Etk_Tree_Col), ETK_CONSTRUCTOR(_etk_tree_col_constructor), ETK_DESTRUCTOR(_etk_tree_col_destructor)); + tree_col_type = etk_type_new("Etk_Tree_Col", ETK_OBJECT_TYPE, sizeof(Etk_Tree_Col), + ETK_CONSTRUCTOR(_etk_tree_col_constructor), ETK_DESTRUCTOR(_etk_tree_col_destructor)); - _etk_tree_col_signals[ETK_TREE_COL_CELL_VALUE_CHANGED] = etk_signal_new("cell_value_changed", tree_col_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); + _etk_tree_col_signals[ETK_TREE_COL_CELL_VALUE_CHANGED] = etk_signal_new("cell_value_changed", + tree_col_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); - etk_type_property_add(tree_col_type, "title", ETK_TREE_COL_TITLE_PROPERTY, ETK_PROPERTY_STRING, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_string(NULL)); - etk_type_property_add(tree_col_type, "width", ETK_TREE_COL_WIDTH_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(ETK_TREE_MIN_HEADER_WIDTH)); - etk_type_property_add(tree_col_type, "min_width", ETK_TREE_COL_MIN_WIDTH_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(-1)); - etk_type_property_add(tree_col_type, "visible_width", ETK_TREE_COL_VISIBLE_WIDTH_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE, NULL); - etk_type_property_add(tree_col_type, "visible", ETK_TREE_COL_VISIBLE_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); - etk_type_property_add(tree_col_type, "resizable", ETK_TREE_COL_RESIZABLE_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); - etk_type_property_add(tree_col_type, "place", ETK_TREE_COL_PLACE_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(0)); - etk_type_property_add(tree_col_type, "expand", ETK_TREE_COL_EXPAND_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_FALSE)); + etk_type_property_add(tree_col_type, "title", ETK_TREE_COL_TITLE_PROPERTY, + ETK_PROPERTY_STRING, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_string(NULL)); + etk_type_property_add(tree_col_type, "visible", ETK_TREE_COL_VISIBLE_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); + etk_type_property_add(tree_col_type, "resizable", ETK_TREE_COL_RESIZABLE_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); + etk_type_property_add(tree_col_type, "position", ETK_TREE_COL_POSITION_PROPERTY, + ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(0)); + etk_type_property_add(tree_col_type, "expand", ETK_TREE_COL_EXPAND_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_FALSE)); + etk_type_property_add(tree_col_type, "width", ETK_TREE_COL_WIDTH_PROPERTY, + ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(COL_MIN_WIDTH)); + etk_type_property_add(tree_col_type, "min_width", ETK_TREE_COL_MIN_WIDTH_PROPERTY, + ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(COL_MIN_WIDTH)); + etk_type_property_add(tree_col_type, "align", ETK_TREE_COL_ALIGN_PROPERTY, + ETK_PROPERTY_FLOAT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_float(0.0)); tree_col_type->property_set = _etk_tree_col_property_set; tree_col_type->property_get = _etk_tree_col_property_get; @@ -241,49 +241,218 @@ } /** - * @brief Creates a new column for a tree + * @brief Creates a new tree + * @return Returns the new tree + */ +Etk_Widget *etk_tree_new() +{ + return etk_widget_new(ETK_TREE_TYPE, "theme_group", "tree", + "focusable", ETK_TRUE, "focus_on_click", ETK_TRUE, NULL); +} + +/** + * @brief Sets the mode of the tree. The tree must not be built + * @param tree a tree + * @param mode the mode the tree should use (ETK_TREE_MODE_LIST or ETK_TREE_MODE_TREE) + */ +void etk_tree_mode_set(Etk_Tree *tree, Etk_Tree_Mode mode) +{ + if (!tree) + return; + if (tree->built) + { + ETK_WARNING("Unable to change the mode of the tree because the tree is already built"); + return; + } + + tree->mode = mode; + etk_object_notify(ETK_OBJECT(tree), "mode"); +} + +/** + * @brief Gets the mode of tree + * @param tree a tree + * @return Returns the mode of tree (ETK_TREE_MODE_LIST or ETK_TREE_MODE_TREE) + */ +Etk_Tree_Mode etk_tree_mode_get(Etk_Tree *tree) +{ + if (!tree) + return ETK_TREE_MODE_LIST; + return tree->mode; +} + +/** + * @brief Sets whether the user can select several rows of the tree + * @param tree a tree + * @param multiple_select ETK_TRUE to allow the user to select several rows, ETK_FALSE otherwise + */ +void etk_tree_multiple_select_set(Etk_Tree *tree, Etk_Bool multiple_select) +{ + if (!tree || tree->multiple_select == multiple_select) + return; + + if (!multiple_select) + etk_tree_unselect_all(tree); + tree->multiple_select = multiple_select; + etk_object_notify(ETK_OBJECT(tree), "multiple_select"); +} + +/** + * @brief Gets whether or not several rows can be selected in the tree + * @param tree a tree + * @return ETK_TRUE if several rows can be selected, ETK_FALSE otherwise + */ +Etk_Bool etk_tree_multiple_select_get(Etk_Tree *tree) +{ + if (!tree) + return ETK_FALSE; + return tree->multiple_select; +} + +/** + * @brief Sets whether the column-headers should be visible or not + * @param tree a tree + * @param headers_visible ETK_TRUE to show the column-headers, ETK_FALSE to hide them + */ +void etk_tree_headers_visible_set(Etk_Tree *tree, Etk_Bool headers_visible) +{ + if (!tree || (tree->headers_visible == headers_visible)) + return; + + tree->headers_visible = headers_visible; + etk_object_notify(ETK_OBJECT(tree), "headers_visible"); + etk_widget_redraw_queue(ETK_WIDGET(tree)); +} + +/** + * @brief Gets whether or not the column-headers are visible + * @param tree a tree + * @return Returns ETK_TRUE if the column-headers are visible, ETK_FALSE otherwise + */ +Etk_Bool etk_tree_headers_visible_get(Etk_Tree *tree) +{ + if (!tree) + return ETK_FALSE; + return tree->headers_visible; +} + +/** + * @brief Sets the height of the rows of the tree + * @param tree a tree + * @param rows_height the rows height to set. The minimum value is 12 + */ +void etk_tree_rows_height_set(Etk_Tree *tree, int rows_height) +{ + if (!tree) + return; + + rows_height = ETK_MAX(rows_height, MIN_ROW_HEIGHT); + if (tree->rows_height != rows_height) + { + Etk_Range *vscrollbar; + + tree->rows_height = rows_height; + vscrollbar = etk_scrolled_view_vscrollbar_get(ETK_SCROLLED_VIEW(tree->scrolled_view)); + etk_range_increments_set(vscrollbar, rows_height, 5 * rows_height); + + etk_object_notify(ETK_OBJECT(tree), "rows_height"); + etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(tree->scroll_content), NULL); + etk_widget_redraw_queue(ETK_WIDGET(tree)); + } +} + +/** + * @brief Gets the height of the rows of the tree + * @param tree a tree + * @return Returns the height of the rows of the tree + */ +int etk_tree_rows_height_get(Etk_Tree *tree) +{ + if (!tree) + return DEFAULT_ROW_HEIGHT; + return tree->rows_height; +} + +/** + * @brief Builds the tree. You have to call this function after you have added all the columns + * and before you add the rows to the tree. Once the tree is built, it can not be unbuilt, + * and you could not add new columns anymore + * @param tree a tree + */ +void etk_tree_build(Etk_Tree *tree) +{ + if (!tree || tree->built) + return; + tree->built = ETK_TRUE; +} + +/** + * @brief Freezes the tree: the won't be updated until it is thawed. It is useful to add + * a lot (> 1000) of rows efficiently. To add a few rows, freeze/thaw() is not necessary + * @param tree a tree + * @see etk_tree_thaw() + */ +void etk_tree_freeze(Etk_Tree *tree) +{ + if (!tree || tree->frozen) + return; + tree->frozen = ETK_TRUE; +} + +/** + * @brief Thaws the tree: the tree will be updated the tree if it was frozen + * @param tree a tree + * @see etk_tree_freeze() + */ +void etk_tree_thaw(Etk_Tree *tree) +{ + if (!tree || !tree->frozen) + return; + + tree->frozen = ETK_FALSE; + etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(tree->scroll_content), NULL); + etk_widget_redraw_queue(ETK_WIDGET(tree)); +} + +/** + * @brief Inserts a new column into a tree * @param tree a tree * @param title the tile of the column - * @param model the model to use for the column - * @param width the requested width of the column. It won't be necessary the visible width of the column since it can be expanded to fit the available space + * @param width the requested width of the column. It won't be necessary the visible width + * of the column since it can be expanded to fit the available space + * @param alignment the horizontal alignment of the objects inside the column, from 0.0 (left alignment) + * to 1.0 (right alignment) * @return Returns the new column */ -Etk_Tree_Col *etk_tree_col_new(Etk_Tree *tree, const char *title, Etk_Tree_Model *model, int width) +Etk_Tree_Col *etk_tree_col_new(Etk_Tree *tree, const char *title, int width, float alignment) { Etk_Tree_Col *new_col; Etk_Widget *new_header; - if (!tree || !model) + if (!tree) return NULL; - if (model->col) + if (tree->built) { - ETK_WARNING("The tree model to use for that column is already used for another column"); + ETK_WARNING("The tree is built, you can not add a new column"); return NULL; } tree->columns = realloc(tree->columns, sizeof(Etk_Tree_Col *) * (tree->num_cols + 1)); - new_col = ETK_TREE_COL(etk_object_new(ETK_TREE_COL_TYPE, "title", title, "width", width, "visible", ETK_TRUE, "resizable", ETK_TRUE, NULL)); + new_col = ETK_TREE_COL(etk_object_new(ETK_TREE_COL_TYPE, "title", title, + "width", width, "visible", ETK_TRUE, "resizable", ETK_TRUE, "align", alignment, NULL)); tree->columns[tree->num_cols] = new_col; new_col->id = tree->num_cols; - new_col->place = new_col->id; - etk_object_notify(ETK_OBJECT(new_col), "place"); new_col->tree = tree; - new_col->model = model; - new_col->model->col = new_col; + new_col->position = tree->num_cols; /* Creates the header widget */ - new_header = etk_widget_new(ETK_BUTTON_TYPE, "theme_group", "header", "theme_parent", tree, "label", - title, "xalign", 0.0, "repeat_mouse_events", ETK_TRUE, "internal", ETK_TRUE, NULL); - etk_widget_parent_set(new_header, ETK_WIDGET(tree)); - etk_widget_show(new_header); - if (tree->headers_clip) - etk_widget_clip_set(new_header, tree->headers_clip); - etk_signal_connect("mouse_down", ETK_OBJECT(new_header), ETK_CALLBACK(_etk_tree_header_mouse_down_cb), new_col); - etk_signal_connect("mouse_up", ETK_OBJECT(new_header), ETK_CALLBACK(_etk_tree_header_mouse_up_cb), new_col); - etk_signal_connect("mouse_move", ETK_OBJECT(new_header), ETK_CALLBACK(_etk_tree_header_mouse_move_cb), new_col); - etk_signal_connect("mouse_in", ETK_OBJECT(new_header), ETK_CALLBACK(_etk_tree_header_mouse_in_cb), new_col); - etk_signal_connect("mouse_out", ETK_OBJECT(new_header), ETK_CALLBACK(_etk_tree_header_mouse_out_cb), new_col); + new_header = etk_widget_new(ETK_BUTTON_TYPE, "theme_group", "header","theme_parent", tree, + "label", title, "xalign", 0.0, "internal", ETK_TRUE, NULL); + if (tree->tree_contains_headers) + etk_widget_parent_set(new_header, ETK_WIDGET(tree)); + else + etk_widget_parent_set(new_header, tree->scroll_content); new_col->header = new_header; tree->num_cols++; @@ -304,11 +473,11 @@ return tree->num_cols; } - /** * @brief Gets the "nth" column of the tree * @param tree a tree - * @param nth the rank of the column you want to get + * @param nth the index of the column to get. Since the columns can be reordered or hidden, + * @a nth corresponds to the "nth" created column, which is not necessarily the "nth" visible column * @return Returns the "nth" column of the tree */ Etk_Tree_Col *etk_tree_nth_col_get(Etk_Tree *tree, int nth) @@ -319,48 +488,81 @@ } /** - * @brief Sets whether the column headers should be displayed - * @param tree a tree - * @param headers_visible ETK_TRUE if the column headers should be displayed + * @brief Gets the tree which contains the given column + * @param col a column + * @return Returns the tree which contains the given column, or NULL on failure */ -void etk_tree_headers_visible_set(Etk_Tree *tree, Etk_Bool headers_visible) +Etk_Tree *etk_tree_col_tree_get(Etk_Tree_Col *col) { - if (!tree || (tree->headers_visible == headers_visible)) - return; + if (!col) + return NULL; + return col->tree; +} - tree->headers_visible = headers_visible; - etk_object_notify(ETK_OBJECT(tree), "headers_visible"); - etk_widget_redraw_queue(ETK_WIDGET(tree)); +/** + * @brief Adds a model to a column of the tree. You can add several models to the same column in order to combine them. + * For example, if you want the column's content to be an icon followed by a text, add the "image" model and then the + * "text" model + * @param col a column + * @param model the model to add to the column @a col + * @warning the number of models per column is limited to 5 + */ +void etk_tree_col_model_add(Etk_Tree_Col *col, Etk_Tree_Model *model) +{ + if (!col || !model || !col->tree) + return; + if (col->tree->built) + { + ETK_WARNING("You cannot add a model to a column once the tree is built"); + return; + } + if (col->num_models >= MAX_MODELS_PER_COL) + { + ETK_WARNING("The number of models per column is limited to %d. Unable to add the model", MAX_MODELS_PER_COL); + return; + } + if (model->col) + { + ETK_WARNING("The tree-model to add to that column is already used by another column"); + return; + } + + col->models[col->num_models] = model; + model->tree = col->tree; + model->col = col; + col->num_models++; } /** - * @brief Gets the visibility of the column headers - * @param tree a tree - * @return Returns ETK_TRUE whether the column headers are visible + * @brief Gets the column's header widget. This can be used if you want to detect clicks on it for example. + * The header widget is an Etk_Button + * @param col a column + * @return Returns the column's header widget */ -Etk_Bool etk_tree_headers_visible_get(Etk_Tree *tree) +Etk_Widget *etk_tree_col_header_get(Etk_Tree_Col *col) { - if (!tree) - return ETK_FALSE; - return tree->headers_visible; + if (!col) + return NULL; + return col->header; } /** * @brief Sets the title of the column - * @param col a tree column + * @param col a column of a tree * @param title the title to set */ void etk_tree_col_title_set(Etk_Tree_Col *col, const char *title) { if (!col || !col->header) return; + etk_button_label_set(ETK_BUTTON(col->header), title); etk_object_notify(ETK_OBJECT(col), "title"); } /** * @brief Gets the title of the column - * @param col a tree column + * @param col a column of a tree * @return Returns the title of the column */ const char *etk_tree_col_title_get(Etk_Tree_Col *col) @@ -371,56 +573,58 @@ } /** - * @brief Sets the requested width of the column. It won't be necessary the visible width of the column since it can be expanded to fit the available space - * @param col a tree column - * @param width the requested width to set + * @brief Sets the width of the column. It won't be necessarily the visible width of the column since + * the column can expand + * @param col a column of a tree + * @param width the width to set */ void etk_tree_col_width_set(Etk_Tree_Col *col, int width) { - if (!col) + if (!col || col->width == width) return; - col->requested_width = ETK_MAX(width, ETK_TREE_MIN_HEADER_WIDTH); + + col->width = ETK_MAX(width, col->min_width); etk_object_notify(ETK_OBJECT(col), "width"); + if (col->tree) { - etk_widget_redraw_queue(ETK_WIDGET(col->tree->grid)); - etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(col->tree->grid), NULL); + etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(col->tree->scroll_content), NULL); + etk_widget_redraw_queue(ETK_WIDGET(col->tree)); } } /** - * @brief Gets the requested width of the column - * @param col a tree column - * @return Returns the requested width of the column + * @brief Gets the width of the column. TODO: (what if the col expands??) + * @param col a column of a tree + * @return Returns the width of the column */ int etk_tree_col_width_get(Etk_Tree_Col *col) { if (!col) return 0; - return col->requested_width; + return col->width; } /** - * @brief Sets the minimum width of the column. The column couldn't be smaller than this width - * @param col a tree column - * @param min_width the minimum width to set. -1 to make etk calculate the min_width + * @brief Sets the minimum width of the column. The column can not be smaller than this width + * @param col a column of a tree + * @param min_width the minimum width to set. -1 to use the default value */ void etk_tree_col_min_width_set(Etk_Tree_Col *col, int min_width) { if (!col || (col->min_width == min_width)) return; - col->min_width = min_width; + + col->min_width = ETK_MAX(min_width, COL_MIN_WIDTH); + if (col->width < col->min_width) + etk_tree_col_width_set(col, col->min_width); + etk_object_notify(ETK_OBJECT(col), "min_width"); - if (col->tree) - { - etk_widget_redraw_queue(ETK_WIDGET(col->tree->grid)); - etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(col->tree->grid), NULL); - } } /** * @brief Gets the minimum width of the column - * @param col a tree column + * @param col a column of a tree * @return Returns the minimum width of the column */ int etk_tree_col_min_width_get(Etk_Tree_Col *col) @@ -432,20 +636,21 @@ /** * @brief Sets whether the column can be resized by the user - * @param col a tree column - * @param resizable ETK_TRUE whether the column should be resizable + * @param col a column of a tree + * @param resizable ETK_TRUE to make the column resizable, ETK_FALSE otherwise */ void etk_tree_col_resizable_set(Etk_Tree_Col *col, Etk_Bool resizable) { if (!col || (col->resizable == resizable)) return; + col->resizable = resizable; etk_object_notify(ETK_OBJECT(col), "resizable"); } /** * @brief Gets whether the column can be resized by the user - * @param col a tree column + * @param col a column of a tree * @return Returns ETK_TRUE if the column is resizable */ Etk_Bool etk_tree_col_resizable_get(Etk_Tree_Col *col) @@ -457,23 +662,23 @@ /** * @brief Sets whether the column should expand if there is some free space in the tree - * @param col a tree column - * @param expand ETK_TRUE whether the column should be expandable + * @param col a column of a tree + * @param expand ETK_TRUE to make the column expand, ETK_FALSE otherwise */ void etk_tree_col_expand_set(Etk_Tree_Col *col, Etk_Bool expand) { if (!col || (col->expand == expand)) return; + col->expand = expand; etk_object_notify(ETK_OBJECT(col), "expand"); - if (col->tree) - etk_widget_redraw_queue(ETK_WIDGET(col->tree->grid)); + etk_widget_redraw_queue(ETK_WIDGET(col->tree)); } /** - * @brief Gets whether the column expands if there is some free space in the tree - * @param col a tree column - * @return Returns ETK_TRUE if the column is expandable + * @brief Gets whether the column expands + * @param col a column of a tree + * @return Returns ETK_TRUE if the column expands, ETK_FALSE otherwise */ Etk_Bool etk_tree_col_expand_get(Etk_Tree_Col *col) { @@ -483,26 +688,58 @@ } /** - * @brief Sets whether the column is visible - * @param col a tree column - * @param visible ETK_TRUE whether the column should be visible + * @brief Sets the horizontal alignment of the objects inside the column + * @param col a column of a tree + * @param alignment the horizontal alignment to use, from 0.0 (left alignment) to 1.0 (right alignment) + */ +void etk_tree_col_alignment_set(Etk_Tree_Col *col, float alignment) +{ + if (!col || col->align == alignment) + return; + + col->align = ETK_CLAMP(alignment, 0.0, 1.0); + etk_object_notify(ETK_OBJECT(col), "align"); + + if (col->tree) + etk_widget_redraw_queue(ETK_WIDGET(col->tree)); +} + +/** + * @brief Gets the horizontal alignment of the objects inside the column + * @param col a column of a tree + * @return Returns the horizontal alignment of the column, from 0.0 (left alignment) to 1.0 (right alignment) + */ +float etk_tree_col_alignment_get(Etk_Tree_Col *col) +{ + if (!col) + return 0.0; + return col->align; +} + +/** + * @brief Sets whether or not the column is visible + * @param col a column of a tree + * @param visible ETK_TRUE to show the column, ETK_FALSE to hide it */ void etk_tree_col_visible_set(Etk_Tree_Col *col, Etk_Bool visible) { if (!col || (col->visible == visible)) return; + col->visible = visible; etk_object_notify(ETK_OBJECT(col), "visible"); + if (col->tree) { - etk_widget_redraw_queue(ETK_WIDGET(col->tree->grid)); - etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(col->tree->grid), NULL); + _etk_tree_expanders_clip(col->tree); + etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(col->tree->scroll_content), NULL); + etk_widget_redraw_queue(ETK_WIDGET(col->tree)); } } /** - * @brief Gets whether the column is visible - * @param col a tree column + * @brief Gets whether or not the column is visible + * @param col a column of a tree * @return Returns ETK_TRUE if the column is visible */ Etk_Bool etk_tree_col_visible_get(Etk_Tree_Col *col) @@ -513,834 +750,751 @@ } /** - * @brief Reorders the the column - * @param col a tree column - * @param new_place the new place that the column should take (0 is the first column on the left of the tree, etk_tree_num_cols_get(tree) - 1 is the last one on the right) + * @brief Changes the position of the column + * @param col a column of a tree + * @param position the new position the column should take (0 is the first column on the left of the tree, + * "etk_tree_num_cols_get(tree) - 1" is the last one on the right) */ -void etk_tree_col_reorder(Etk_Tree_Col *col, int new_place) +void etk_tree_col_position_set(Etk_Tree_Col *col, int position) { int i; - if (!col || !col->tree || (col->place == new_place)) + if (!col || !col->tree || (col->position == position)) return; - new_place = ETK_CLAMP(new_place, 0, col->tree->num_cols - 1); - if (new_place < col->place) + position = ETK_CLAMP(position, 0, col->tree->num_cols - 1); + if (position < col->position) { for (i = 0; i < col->tree->num_cols; i++) { - if (col->tree->columns[i]->place >= new_place && col->tree->columns[i]->place < col->place) + if (col->tree->columns[i]->position >= position && col->tree->columns[i]->position < col->position) { - col->tree->columns[i]->place++; - etk_object_notify(ETK_OBJECT(col->tree->columns[i]), "place"); + col->tree->columns[i]->position++; + etk_object_notify(ETK_OBJECT(col->tree->columns[i]), "position"); } } } - else if (new_place > col->place) + else if (position > col->position) { for (i = 0; i < col->tree->num_cols; i++) { - if (col->tree->columns[i]->place > col->place && col->tree->columns[i]->place <= new_place) + if (col->tree->columns[i]->position > col->position && col->tree->columns[i]->position <= position) { - col->tree->columns[i]->place--; - etk_object_notify(ETK_OBJECT(col->tree->columns[i]), "place"); + col->tree->columns[i]->position--; + etk_object_notify(ETK_OBJECT(col->tree->columns[i]), "position"); } } } - col->place = new_place; + col->position = position; etk_object_notify(ETK_OBJECT(col), "place"); - etk_widget_redraw_queue(ETK_WIDGET(col->tree->grid)); + + _etk_tree_expanders_clip(col->tree); + etk_widget_redraw_queue(ETK_WIDGET(col->tree)); } /** - * @brief Gets the place of the column (0 is the first column on the left of the tree, etk_tree_num_cols_get(tree) - 1 is the last one on the right) - * @param col a tree column - * @return Returns the place of the column + * @brief Gets the position of the column (0 is the first column on the left of the tree, + * "etk_tree_num_cols_get(tree) - 1" is the last one on the right) + * @param col a column of a tree + * @return Returns the position of the column */ -int etk_tree_col_place_get(Etk_Tree_Col *col) +int etk_tree_col_position_get(Etk_Tree_Col *col) { if (!col) return 0; - return col->place; + return col->position; } /** - * @brief Sets the sorting function for a column - * @param col a tree column - * @param compare_cb the sorting comparator - * @param data a pointer to user data, it will be passed to compare_cb + * @brief Sets the sorting function of a column. This function will be called when + * the header of the column is clicked or when you call etk_tree_col_sort() + * @param col a column of a tree + * @param compare_cb the function to call to compare two rows. It should return a negative + * value if the cell of "row1" has a lower value than the cell of "row2", 0 if they have the + * same value, and a positive value if the cell of "row2" has a greater value than the cell of "row1" + * @param data a pointer that will be passed to @a compare_cb when it is called */ -void etk_tree_col_sort_func_set(Etk_Tree_Col *col, int (*compare_cb)(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), void *data) +void etk_tree_col_sort_set(Etk_Tree_Col *col, int (*compare_cb)(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data), void *data) { if (!col) return; + col->sort.compare_cb = compare_cb; col->sort.data = data; } /** - * @brief Sets the mode used by the tree. The tree has to be not built + * Inserts a new row at the beginning of the tree (if @a parent is NULL) or as the first child of an existing row + * (if @a parent is not NULL and if the tree is in the "tree" mode) * @param tree a tree - * @param mode the mode which will be used by the tree: ETK_TREE_MODE_LIST (rows can not have children) or ETK_TREE_MODE_TREE (rows can have children) + * @param parent the parent row of the row to insert. NULL means the row will be inserted at the tree's root + * @param ... an "Etk_Tree_Col *" followed by the value of the cell, then any number of "Etk_Tree_Col *"/Value pairs, + * and terminated by NULL. Note that, according to the model used by the column, a cell value can use several parameters + * @return Returns the new row, or NULL on failure */ -void etk_tree_mode_set(Etk_Tree *tree, Etk_Tree_Mode mode) +Etk_Tree_Row *etk_tree_row_prepend(Etk_Tree *tree, Etk_Tree_Row *parent, ...) { + Etk_Tree_Row *row; + va_list args; + if (!tree) - return; - if (tree->built) - { - ETK_WARNING("Unable to change the mode of the tree because the tree has been built."); - return; - } + return NULL; - tree->mode = mode; - etk_object_notify(ETK_OBJECT(tree), "mode"); + va_start(args, parent); + row = etk_tree_row_insert_valist(tree, parent, NULL, args); + va_end(args); + + return row; } /** - * @brief Gets the mode used by the tree + * Inserts a new row at the end of the tree (if @a parent is NULL) or as the last child of an existing row + * (if @a parent is not NULL and if the tree is in the "tree" mode) * @param tree a tree - * @return Returns the mode used by the tree: ETK_TREE_MODE_LIST (rows can not have children) or ETK_TREE_MODE_TREE (rows can have children) + * @param parent the parent row of the row to insert. NULL means the row will be inserted at the tree's root + * @param ... an "Etk_Tree_Col *" followed by the value of the cell, then any number of "Etk_Tree_Col *"/Value pairs, + * and terminated by NULL. Note that, according to the model used by the column, a cell value can use several parameters + * @return Returns the new row, or NULL on failure */ -Etk_Tree_Mode etk_tree_mode_get(Etk_Tree *tree) +Etk_Tree_Row *etk_tree_row_append(Etk_Tree *tree, Etk_Tree_Row *parent, ...) { + Etk_Tree_Row *row; + va_list args; + if (!tree) - return ETK_TREE_MODE_LIST; - return tree->mode; + return NULL; + + va_start(args, parent); + if (!parent) + parent = &tree->root; + row = etk_tree_row_insert_valist(tree, parent, parent->last_child, args); + va_end(args); + + return row; } /** - * @brief Builds the tree. This function to be called after having added all the columns and before being able to add rows to the tree + * @brief Inserts a new row after an existing row * @param tree a tree + * @param parent the parent row of the row to insert. If @a after is not NULL, @a parent is optionnal (the parent of the + * new row will be the parent of @a after) + * @param after the row after which the new row will be inserted. NULL means the new row will be inserted at the + * beginning of the tree (if @a parent is NULL) or as the first child of @a parent (if @a parent is not NULL and if the + * tree is in the "tree" mode) + * @param ... an "Etk_Tree_Col *" followed by the value of the cell, then any number of "Etk_Tree_Col *"/Value pairs, + * and terminated by NULL. Note that, according to the model used by the column, a cell value can use several parameters + * @return Returns the new row, or NULL on failure */ -void etk_tree_build(Etk_Tree *tree) +Etk_Tree_Row *etk_tree_row_insert(Etk_Tree *tree, Etk_Tree_Row *parent, Etk_Tree_Row *after, ...) { - if (!tree) - return; - tree->built = ETK_TRUE; -} - -/** - * @brief Freezes the tree: it will not be updated until it is thawed @n - * This function is useful when you want to add a lot of rows quickly. - * @param tree a tree - */ -void etk_tree_freeze(Etk_Tree *tree) -{ - if (!tree) - return; - tree->frozen = ETK_TRUE; -} - -/** - * @brief Thaws the tree: it will update the tree if it was frozen - * @param tree a tree - */ -void etk_tree_thaw(Etk_Tree *tree) -{ - if (!tree || !tree->frozen) - return; + Etk_Tree_Row *row; + va_list args; - tree->frozen = ETK_FALSE; - etk_widget_redraw_queue(ETK_WIDGET(tree->grid)); - etk_signal_emit_by_name("scroll_size_changed", ETK_OBJECT(tree->grid), NULL); -} - -/** - * @brief Gets the number of rows of the tree - * @param tree a tree - * @return Returns the number of rows of the tree - */ -int etk_tree_num_rows_get(Etk_Tree *tree) -{ if (!tree) - return 0; - return tree->num_rows; + return NULL; + + va_start(args, after); + row = etk_tree_row_insert_valist(tree, parent, after, args); + va_end(args); + + return row; } /** - * @brief Gets the rownumber of the row + * @brief Inserts a new row after an existing row * @param tree a tree - * @param row a row - * @return Returns the rownumber of the row + * @param parent the parent row of the row to insert. If @a after is not NULL, @a parent is optionnal (the parent of the + * new row will be the parent of @a after) + * @param after the row after which the new row will be inserted. NULL means the new row will be inserted at the + * beginning of the tree (if @a parent is NULL) or as the first child of @a parent (if @a parent is not NULL and if the + * tree is in the "tree" mode) + * @param args an "Etk_Tree_Col *" followed by the value of the cell, then any number of "Etk_Tree_Col *"/Value pairs, + * and terminated by NULL. Note that, according to the model used by the column, a cell value can use several parameters + * @return Returns the new row, or NULL on failure */ -int etk_tree_row_num_get(Etk_Tree *tree, Etk_Tree_Row *row) +Etk_Tree_Row *etk_tree_row_insert_valist(Etk_Tree *tree, Etk_Tree_Row *parent, Etk_Tree_Row *after, va_list args) { - Etk_Tree_Row *cur_row; - int n = 0; - - if (!tree || !row) - return 0; - - cur_row = etk_tree_first_row_get(ETK_TREE(tree)); - while (cur_row != NULL) - { - if (row == cur_row) return n; - n++; - cur_row = etk_tree_next_row_get(cur_row, ETK_FALSE, ETK_FALSE); - } - - return 0; -} - - - + Etk_Tree_Row *new_row; + Etk_Tree_Col *col; + va_list args2; + int i, j; -/** - * @brief Sets the height of the rows of the tree - * @param tree a tree - * @param row_height the new height of the rows. If @a row_height < 8, the tree will use the theme default value - */ -void etk_tree_row_height_set(Etk_Tree *tree, int row_height) -{ - if (!tree || (tree->row_height == row_height && !tree->use_default_row_height)) - return; + if (!tree) + return NULL; + if (!tree->built) + { + ETK_WARNING("The tree is not built yet, you can not add a row to the tree"); + return NULL; + } + + if (after) + parent = after->parent; + if (!parent) + parent = &tree->root; - if (row_height < ETK_TREE_MIN_ROW_HEIGHT) + new_row = malloc(sizeof(Etk_Tree_Row)); + new_row->data = NULL; + new_row->data_free_cb = NULL; + new_row->delete_me = ETK_FALSE; + new_row->selected = ETK_FALSE; + new_row->unfolded = ETK_FALSE; + + /* Insert the row in the tree hierarchy */ + new_row->tree = tree; + new_row->parent = parent; + new_row->first_child = NULL; + new_row->last_child = NULL; + new_row->num_children = 0; + new_row->num_visible_children = 0; + if (after) { - tree->use_default_row_height = ETK_TRUE; - if (etk_widget_theme_data_get(tree->grid, "row_height", "%d", &tree->row_height) != 1 || tree->row_height < ETK_TREE_MIN_ROW_HEIGHT) - tree->row_height = ETK_TREE_MIN_ROW_HEIGHT; - etk_range_increments_set(etk_scrolled_view_vscrollbar_get(ETK_SCROLLED_VIEW(tree->scrolled_view)), tree->row_height, 5 * tree->row_height); + new_row->prev = after; + new_row->next = after->next; + if (after->next) + after->next->prev = new_row; + after->next = new_row; + if (after == parent->last_child) + parent->last_child = new_row; } else { - tree->use_default_row_height = ETK_FALSE; - tree->r... [truncated message content] |
From: Enlightenment C. <no...@cv...> - 2007-01-16 17:49:58
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/data/themes/default/widgets Modified Files: entry.edc Log Message: * Replace Etk_Tree by Etk_Tree2. The old tree is now removed.. =================================================================== RCS file: /cvs/e/e17/libs/etk/data/themes/default/widgets/entry.edc,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- entry.edc 13 Jan 2007 18:39:22 -0000 1.8 +++ entry.edc 16 Jan 2007 23:49:26 -0000 1.9 @@ -1,9 +1,9 @@ group { name: "etk/entry"; - min: 120 20; + min: 120 22; data { item: "highlight_image_color" "242 222 181 255"; - item: "inner_part_margin" 2; /* Margin between images and the editable */ + item: "inner_part_margin" 5; /* Margin between images and the editable */ } parts { part { |
From: Enlightenment C. <no...@cv...> - 2007-01-16 17:49:58
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/engines/ecore_fb Modified Files: ecore_fb.c Log Message: * Replace Etk_Tree by Etk_Tree2. The old tree is now removed.. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/engines/ecore_fb/ecore_fb.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ecore_fb.c 13 Jan 2007 23:00:38 -0000 1.15 +++ ecore_fb.c 16 Jan 2007 23:49:26 -0000 1.16 @@ -11,7 +11,7 @@ /* TODO: Debug */ #include <Ecore_X.h> -#define USE_X11 1 +#define USE_X11 0 #define WM_THEME_FILE (PACKAGE_DATA_DIR "/wm/default.edj") |
From: Enlightenment C. <no...@cv...> - 2007-01-16 17:50:01
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/bin Modified Files: Makefile.am etk_test.c etk_test.h etk_tree_test.c Removed Files: etk_tree2_test.c Log Message: * Replace Etk_Tree by Etk_Tree2. The old tree is now removed.. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/Makefile.am,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- Makefile.am 28 Nov 2006 21:40:06 -0000 1.19 +++ Makefile.am 16 Jan 2007 23:49:26 -0000 1.20 @@ -28,7 +28,6 @@ etk_canvas_test.c \ etk_colorpicker_test.c \ etk_tree_test.c \ -etk_tree2_test.c \ etk_paned_test.c \ etk_scrolled_view_test.c \ etk_menu_test.c \ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_test.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 --- etk_test.c 28 Nov 2006 21:40:06 -0000 1.32 +++ etk_test.c 16 Jan 2007 23:49:26 -0000 1.33 @@ -68,11 +68,6 @@ ETK_TEST_ADVANCED_WIDGET }, { - "Tree2", - etk_test_tree2_window_create, - ETK_TEST_ADVANCED_WIDGET - }, - { "Paned", etk_test_paned_window_create, ETK_TEST_CONTAINER =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_test.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- etk_test.h 28 Nov 2006 21:40:07 -0000 1.19 +++ etk_test.h 16 Jan 2007 23:49:26 -0000 1.20 @@ -11,7 +11,6 @@ void etk_test_colorpicker_window_create(void *data); void etk_test_canvas_window_create(void *data); void etk_test_tree_window_create(void *data); -void etk_test_tree2_window_create(void *data); void etk_test_paned_window_create(void *data); void etk_test_scrolled_view_window_create(void *data); void etk_test_menu_window_create(void *data); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_tree_test.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- etk_tree_test.c 29 Dec 2006 22:10:12 -0000 1.36 +++ etk_tree_test.c 16 Jan 2007 23:49:26 -0000 1.37 @@ -1,38 +1,23 @@ #include "etk_test.h" -#include <string.h> #include <stdlib.h> +#include <string.h> #include "config.h" -static void _etk_test_tree_drag_drop_cb(Etk_Object *object, void *event, void *data); -static void _etk_test_tree_drag_begin_cb(Etk_Object *object, void *data); -static void _etk_test_tree_add_items(Etk_Tree *tree, int n); -static void _etk_test_tree_row_selected(Etk_Object *object, Etk_Tree_Row *row, void *data); -static void _etk_test_tree_row_unselected(Etk_Object *object, Etk_Tree_Row *row, void *data); -static void _etk_test_tree_row_clicked(Etk_Object *object, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data); -static void _etk_test_tree_row_activated(Etk_Object *object, Etk_Tree_Row *row, void *data); +static void _etk_test_tree_key_down_cb(Etk_Object *object, Etk_Event_Key_Down *event, void *data); +static void _etk_test_tree_row_clicked_cb(Etk_Object *object, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data); static void _etk_test_tree_checkbox_toggled_cb(Etk_Object *object, Etk_Tree_Row *row, void *data); -static void _etk_test_tree_clear_list_cb(Etk_Object *object, void *data); -static void _etk_test_tree_add_5_cb(Etk_Object *object, void *data); -static void _etk_test_tree_add_50_cb(Etk_Object *object, void *data); -static void _etk_test_tree_add_500_cb(Etk_Object *object, void *data); -static void _etk_test_tree_add_5000_cb(Etk_Object *object, void *data); -static void _etk_test_tree_sort_cb(Etk_Object *object, void *data); -static int _etk_test_tree_compare_cb(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data); - -static Etk_Bool ascendant = ETK_TRUE; /* Creates the window for the tree test */ void etk_test_tree_window_create(void *data) { static Etk_Widget *win = NULL; + Etk_Widget *vbox; Etk_Widget *tree; - Etk_Tree_Row *row; Etk_Tree_Col *col1, *col2, *col3, *col4; - Etk_Widget *table; - Etk_Widget *label; - Etk_Widget *frame; - Etk_Widget *button; - Etk_Widget *hbox; + Etk_Tree_Row *row; + Etk_Widget *statusbar; + char row_name[128]; + const char *stock_key; int i; if (win) @@ -41,296 +26,158 @@ return; } + /* Create the window and the vbox where the widgets will be packed into */ win = etk_window_new(); etk_window_title_set(ETK_WINDOW(win), "Etk Tree Test"); + etk_window_resize(ETK_WINDOW(win), 440, 500); etk_signal_connect("delete_event", ETK_OBJECT(win), ETK_CALLBACK(etk_window_hide_on_delete), NULL); - - table = etk_table_new(2, 3, ETK_FALSE); - etk_container_add(ETK_CONTAINER(win), table); - - /* The tree: */ - label = etk_label_new("<h1>Tree:</h1>"); - etk_table_attach(ETK_TABLE(table), label, 0, 0, 0, 0, 0, 0, ETK_TABLE_FILL); - + + vbox = etk_vbox_new(ETK_FALSE, 0); + etk_container_add(ETK_CONTAINER(win), vbox); + + /* Create the tree widget */ tree = etk_tree_new(); - etk_widget_size_request_set(tree, 320, 400); - etk_table_attach_default(ETK_TABLE(table), tree, 0, 0, 1, 1); - etk_tree_mode_set(ETK_TREE(tree), ETK_TREE_MODE_TREE); etk_tree_multiple_select_set(ETK_TREE(tree), ETK_TRUE); - col1 = etk_tree_col_new(ETK_TREE(tree), "Column 1", etk_tree_model_icon_text_new(ETK_TREE(tree), ETK_TREE_FROM_EDJE), 90); - col2 = etk_tree_col_new(ETK_TREE(tree), "Column 2", etk_tree_model_double_new(ETK_TREE(tree)), 60); - col3 = etk_tree_col_new(ETK_TREE(tree), "Column 3", etk_tree_model_image_new(ETK_TREE(tree), ETK_TREE_FROM_FILE), 60); - col4 = etk_tree_col_new(ETK_TREE(tree), "Column 4", etk_tree_model_checkbox_new(ETK_TREE(tree)), 40); - etk_tree_build(ETK_TREE(tree)); - etk_signal_connect("cell_value_changed", ETK_OBJECT(col4), ETK_CALLBACK(_etk_test_tree_checkbox_toggled_cb), NULL); + etk_widget_padding_set(tree, 5, 5, 5, 5); + etk_box_append(ETK_BOX(vbox), tree, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); + /* We first create the columns of the tree, and then we "build" the tree with etk_tree_build() */ + col1 = etk_tree_col_new(ETK_TREE(tree), "Column 1", 130, 0.0); + etk_tree_col_model_add(col1, etk_tree_model_image_new()); + etk_tree_col_model_add(col1, etk_tree_model_text_new()); + + col2 = etk_tree_col_new(ETK_TREE(tree), "Column 2", 60, 1.0); + etk_tree_col_model_add(col2, etk_tree_model_double_new()); + + col3 = etk_tree_col_new(ETK_TREE(tree), "Column 3", 60, 0.0); + etk_tree_col_model_add(col3, etk_tree_model_image_new()); + + col4 = etk_tree_col_new(ETK_TREE(tree), "Column 4", 60, 0.5); + etk_tree_col_model_add(col4, etk_tree_model_checkbox_new()); + + etk_tree_build(ETK_TREE(tree)); + + /* Then we add the rows to the tree. etk_tree_freeze/thaw() is used to improve + * the speed when you insert a lot of rows. It is not really important if you + * insert only some thousands of rows (here, we insert 3000 rows) */ etk_tree_freeze(ETK_TREE(tree)); for (i = 0; i < 1000; i++) { - row = etk_tree_append(ETK_TREE(tree), col1, etk_theme_icon_get(), "places/user-home_16", "Row1", - col2, 10.0, col3, PACKAGE_DATA_DIR "/images/1star.png", col4, ETK_FALSE, NULL); - row = etk_tree_append_to_row(row, col1, etk_theme_icon_get(), "places/folder_16", "Row2", - col2, 20.0, col3, PACKAGE_DATA_DIR "/images/2stars.png", col4, ETK_FALSE, NULL); - etk_tree_append_to_row(row, col1, etk_theme_icon_get(), "mimetypes/text-x-generic_16", "Row3", - col2, 30.0, col3, PACKAGE_DATA_DIR "/images/3stars.png", col4, ETK_FALSE, NULL); + sprintf(row_name, "Row %d", (i * 3) + 1); + stock_key = etk_stock_key_get(ETK_STOCK_PLACES_USER_HOME, ETK_STOCK_SMALL); + row = etk_tree_row_append(ETK_TREE(tree), NULL, + col1, etk_theme_icon_get(), stock_key, row_name, + col2, 10.0, + col3, PACKAGE_DATA_DIR "/images/1star.png", NULL, + col4, ETK_FALSE, + NULL); + + sprintf(row_name, "Row %d", (i * 3) + 2); + stock_key = etk_stock_key_get(ETK_STOCK_PLACES_FOLDER, ETK_STOCK_SMALL); + row = etk_tree_row_append(ETK_TREE(tree), row, + col1, etk_theme_icon_get(), stock_key, row_name, + col2, 20.0, + col3, PACKAGE_DATA_DIR "/images/2stars.png", NULL, + col4, ETK_TRUE, + NULL); + + sprintf(row_name, "Row %d", (i * 3) + 3); + stock_key = etk_stock_key_get(ETK_STOCK_TEXT_X_GENERIC, ETK_STOCK_SMALL); + etk_tree_row_append(ETK_TREE(tree), row, + col1, etk_theme_icon_get(), stock_key, row_name, + col2, 30.0, + col3, PACKAGE_DATA_DIR "/images/3stars.png", NULL, + col4, ETK_TRUE, + NULL); } etk_tree_thaw(ETK_TREE(tree)); - - /* The list: */ - label = etk_label_new("<h1>List:</h1>"); - etk_table_attach(ETK_TABLE(table), label, 1, 1, 0, 0, 0, 0, ETK_TABLE_FILL); - - tree = etk_tree_new(); - etk_widget_dnd_source_set(ETK_WIDGET(tree), ETK_TRUE); - etk_widget_dnd_dest_set(ETK_WIDGET(tree), ETK_TRUE); - etk_signal_connect("drag_drop", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_drag_drop_cb), NULL); - etk_signal_connect("drag_begin", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_drag_begin_cb), NULL); - etk_widget_size_request_set(tree, 320, 400); - etk_table_attach_default(ETK_TABLE(table), tree, 1, 1, 1, 1); - - etk_tree_mode_set(ETK_TREE(tree), ETK_TREE_MODE_LIST); - etk_tree_multiple_select_set(ETK_TREE(tree), ETK_TRUE); - col1 = etk_tree_col_new(ETK_TREE(tree), "Column 1", etk_tree_model_icon_text_new(ETK_TREE(tree), ETK_TREE_FROM_FILE), 90); - col2 = etk_tree_col_new(ETK_TREE(tree), "Column 2", etk_tree_model_int_new(ETK_TREE(tree)), 90); - etk_tree_col_sort_func_set(col2, _etk_test_tree_compare_cb, NULL); - col3 = etk_tree_col_new(ETK_TREE(tree), "Column 3", etk_tree_model_image_new(ETK_TREE(tree), ETK_TREE_FROM_FILE), 90); - etk_tree_build(ETK_TREE(tree)); - - _etk_test_tree_add_items(ETK_TREE(tree), 5000); - etk_signal_connect("row_selected", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_row_selected), NULL); - etk_signal_connect("row_unselected", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_row_unselected), NULL); - etk_signal_connect("row_clicked", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_row_clicked), NULL); - etk_signal_connect("row_activated", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_row_activated), NULL); - - /* Frame */ - frame = etk_frame_new("List Actions"); - etk_table_attach(ETK_TABLE(table), frame, 0, 1, 2, 2, 0, 0, ETK_TABLE_FILL); - hbox = etk_hbox_new(ETK_TRUE, 10); - etk_container_add(ETK_CONTAINER(frame), hbox); - - button = etk_button_new_with_label("Clear"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_clear_list_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - - button = etk_button_new_with_label("Add 5 rows"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_add_5_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - - button = etk_button_new_with_label("Add 50 rows"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_add_50_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - - button = etk_button_new_with_label("Add 500 rows"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_add_500_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - - button = etk_button_new_with_label("Add 5000 rows"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_add_5000_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - - button = etk_button_new_with_label("Sort"); - etk_signal_connect("clicked", ETK_OBJECT(button), ETK_CALLBACK(_etk_test_tree_sort_cb), tree); - etk_box_append(ETK_BOX(hbox), button, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); - + + /* Finally we create the statusbar used to display the events on the tree */ + statusbar = etk_statusbar_new(); + etk_box_append(ETK_BOX(vbox), statusbar, ETK_BOX_START, ETK_BOX_FILL, 0); + + etk_signal_connect("key_down", ETK_OBJECT(tree), + ETK_CALLBACK(_etk_test_tree_key_down_cb), NULL); + etk_signal_connect("row_clicked", ETK_OBJECT(tree), + ETK_CALLBACK(_etk_test_tree_row_clicked_cb), statusbar); + etk_signal_connect("cell_value_changed", ETK_OBJECT(col4), + ETK_CALLBACK(_etk_test_tree_checkbox_toggled_cb), statusbar); + etk_widget_show_all(win); } -/* TODO: doc */ -static void _etk_test_tree_drag_drop_cb(Etk_Object *object, void *event, void *data) -{ - Etk_Tree *tree; - Etk_Tree_Row *row; - char *col1_string, *col3_path; - int col2_value; - - tree = ETK_TREE(object); - row = etk_tree_selected_row_get(tree); - etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, &col1_string, etk_tree_nth_col_get(tree, 1), &col2_value, etk_tree_nth_col_get(tree, 2), &col3_path, NULL); - printf("Row dropped on %p: \"%s\" %d %s\n", row, col1_string, col2_value, col3_path); -} - -/* TODO: doc */ -static void _etk_test_tree_drag_begin_cb(Etk_Object *object, void *data) +/* Called when a key is pressed while the tree is focused: + * we use this to delete the selected rows if "DEL" is pressed */ +static void _etk_test_tree_key_down_cb(Etk_Object *object, Etk_Event_Key_Down *event, void *data) { Etk_Tree *tree; - Etk_Tree_Row *row; - char *col1_string, *col3_path; - int col2_value; - const char **types; - unsigned int num_types; - char *drag_data; - Etk_Drag *drag; - Etk_Widget *button; - - tree = ETK_TREE(object); - row = etk_tree_selected_row_get(tree); - - drag = ETK_DRAG((ETK_WIDGET(tree))->drag); - - etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, &col1_string, etk_tree_nth_col_get(tree, 1), &col2_value, etk_tree_nth_col_get(tree, 2), &col3_path, NULL); - - types = calloc(1, sizeof(char*)); - num_types = 1; - types[0] = strdup("text/plain"); - drag_data = strdup(col1_string); - - etk_drag_types_set(drag, types, num_types); - etk_drag_data_set(drag, drag_data, strlen(drag_data) + 1); - button = etk_button_new_with_label(col1_string); - etk_button_image_set(ETK_BUTTON(button), ETK_IMAGE(etk_image_new_from_file(col3_path, NULL))); - etk_container_add(ETK_CONTAINER(drag), button); -} - -/* Adds n items to the tree */ -static void _etk_test_tree_add_items(Etk_Tree *tree, int n) -{ - int i; - Etk_Tree_Col *col1, *col2, *col3; - char row_name[256]; - char star_path[256]; - int rand_value; - - if (!tree) + Etk_Tree_Row *r; + + if (!(tree = ETK_TREE(object))) return; - - col1 = etk_tree_nth_col_get(tree, 0); - col2 = etk_tree_nth_col_get(tree, 1); - col3 = etk_tree_nth_col_get(tree, 2); - - etk_tree_freeze(tree); - for (i = 0; i < n; i++) + + if (strcmp(event->keyname, "Delete") == 0) { - snprintf(row_name, 256, "Row%d", i); - if (i % 3 == 0) - strncpy(star_path, PACKAGE_DATA_DIR "/images/1star.png", 256); - else if (i % 3 == 1) - strncpy(star_path, PACKAGE_DATA_DIR "/images/2stars.png", 256); - else - strncpy(star_path, PACKAGE_DATA_DIR "/images/3stars.png", 256); - rand_value = rand() % 10000; - etk_tree_append(ETK_TREE(tree), col1, PACKAGE_DATA_DIR "/images/1star.png", row_name, col2, rand_value, col3, star_path, NULL); + /* We walk through all the rows of the tree, and we delete those which are selected. + * Note that we can safely manipulate "r" with etk_tree_row_walk_next(), even if it + * has been deleted with etk_tree_row_delete(), because etk_tree_row_delete() just + * marks the row as deleted, but the row is not effectively deleted immediately */ + for (r = etk_tree_first_row_get(tree); r; r = etk_tree_row_walk_next(r, ETK_TRUE)) + { + if (etk_tree_row_is_selected(r)) + etk_tree_row_delete(r); + } + + etk_signal_stop(); } - etk_tree_thaw(tree); -} - -/* Called when a row is selected */ -static void _etk_test_tree_row_selected(Etk_Object *object, Etk_Tree_Row *row, void *data) -{ - Etk_Tree *tree; - char *col1_string, *col3_path; - int col2_value; - - tree = ETK_TREE(object); - etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, &col1_string, etk_tree_nth_col_get(tree, 1), &col2_value, etk_tree_nth_col_get(tree, 2), &col3_path, NULL); - printf("Row selected %p: \"%s\" %d %s\n", row, col1_string, col2_value, col3_path); -} - -/* Called when a row is unselected */ -static void _etk_test_tree_row_unselected(Etk_Object *object, Etk_Tree_Row *row, void *data) -{ - printf("Row unselected %p\n", row); -} - -/* Called when a row is clicked */ -static void _etk_test_tree_row_clicked(Etk_Object *object, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data) -{ - printf("Row clicked %p. Button: %d. ", row, event->button); - if (event->flags & ETK_MOUSE_TRIPLE_CLICK) - printf("Triple Click\n"); - else if (event->flags & ETK_MOUSE_DOUBLE_CLICK) - printf("Double Click\n"); - else - printf("Single Click\n"); } -/* Called when a row is activated */ -static void _etk_test_tree_row_activated(Etk_Object *object, Etk_Tree_Row *row, void *data) +/* Called when a row of the tree is clicked: we display the clicked row in the statusbar */ +/* TODO: sometimes it's a Etk_Event_Mouse_Up, sometimes a Etk_Event_Mouse_Down... */ +static void _etk_test_tree_row_clicked_cb(Etk_Object *object, Etk_Tree_Row *row, Etk_Event_Mouse_Up *event, void *data) { Etk_Tree *tree; - char *col1_string, *col3_path; - int col2_value; - - tree = ETK_TREE(object); - etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, &col1_string, etk_tree_nth_col_get(tree, 1), &col2_value, etk_tree_nth_col_get(tree, 2), &col3_path, NULL); - printf("Row activated %p: \"%s\" %d %s\n", row, col1_string, col2_value, col3_path); -} - -/* Called when a checkbox of the tree is toggled */ -static void _etk_test_tree_checkbox_toggled_cb(Etk_Object *object, Etk_Tree_Row *row, void *data) -{ - Etk_Bool checked; - Etk_Tree_Col *col; + Etk_Statusbar *statusbar; + char *row_name; + char message[1024]; - if (!(col = ETK_TREE_COL(object)) || !row) + if (!(tree = ETK_TREE(object)) || !(statusbar = ETK_STATUSBAR(data)) || !row || !event) return; - etk_tree_row_fields_get(row, col, &checked, NULL); - if (checked) - printf("Checkbox activated\n"); - else - printf("Checkbox deactivated\n"); -} - -/* Called when the "Clear" button is clicked */ -static void _etk_test_tree_clear_list_cb(Etk_Object *object, void *data) -{ - Etk_Tree *tree; - - if (!(tree = ETK_TREE(data))) - return; - etk_tree_clear(tree); -} - -/* Called when the "Add 5 items" button is clicked */ -static void _etk_test_tree_add_5_cb(Etk_Object *object, void *data) -{ - _etk_test_tree_add_items(ETK_TREE(data), 5); -} - -/* Called when the "Add 50 items" button is clicked */ -static void _etk_test_tree_add_50_cb(Etk_Object *object, void *data) -{ - _etk_test_tree_add_items(ETK_TREE(data), 50); -} - -/* Called when the "Add 500 items" button is clicked */ -static void _etk_test_tree_add_500_cb(Etk_Object *object, void *data) -{ - _etk_test_tree_add_items(ETK_TREE(data), 500); -} - -/* Called when the "Add 5000 items" button is clicked */ -static void _etk_test_tree_add_5000_cb(Etk_Object *object, void *data) -{ - _etk_test_tree_add_items(ETK_TREE(data), 5000); + /* We retrieve the name of the row: this information is located in the first column, + * and it corresponds to the third param of the model (the two first params correspond + * to the icon used, we ignore them here (that's why there are two NULL params)). + * etk_tree_row_fields_get() has to be terminated by NULL */ + etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, NULL, &row_name, NULL); + + sprintf(message, "Row \"%s\" clicked (%s)", row_name, + (event->flags & ETK_MOUSE_TRIPLE_CLICK) ? "Triple" : + ((event->flags & ETK_MOUSE_DOUBLE_CLICK) ? "Double" : "Single")); + + etk_statusbar_message_push(statusbar, message, 0); } -/* Called when the "Sort" button is clicked */ -static void _etk_test_tree_sort_cb(Etk_Object *object, void *data) +/* Called when a checkbox of the tree is toggled: we display its new state in the statusbar */ +static void _etk_test_tree_checkbox_toggled_cb(Etk_Object *object, Etk_Tree_Row *row, void *data) { Etk_Tree *tree; + Etk_Tree_Col *col; + Etk_Statusbar *statusbar; + Etk_Bool checked; + char *row_name; + char message[1024]; - if (!(tree = ETK_TREE(data))) + if (!(col = ETK_TREE_COL(object)) || !(statusbar = ETK_STATUSBAR(data)) || !row) return; - etk_tree_sort(tree, _etk_test_tree_compare_cb, ascendant, etk_tree_nth_col_get(tree, 1), NULL); - ascendant = !ascendant; -} - -/* Compares two rows of the tree */ -static int _etk_test_tree_compare_cb(Etk_Tree *tree, Etk_Tree_Row *row1, Etk_Tree_Row *row2, Etk_Tree_Col *col, void *data) -{ - int row1_value, row2_value; - if (!tree || !row1 || !row2 || !col) - return 0; + tree = etk_tree_col_tree_get(col); + + /* We retrieve the name of the row: see _etk_test_tree_row_clicked_cb() for more info*/ + etk_tree_row_fields_get(row, etk_tree_nth_col_get(tree, 0), NULL, NULL, &row_name, NULL); + /* We then retrieve the new state of the checkbox */ + etk_tree_row_fields_get(row, col, &checked, NULL); - etk_tree_row_fields_get(row1, col, &row1_value, NULL); - etk_tree_row_fields_get(row2, col, &row2_value, NULL); - if (row1_value < row2_value) - return -1; - else if (row1_value > row2_value) - return 1; - else - return 0; + sprintf(message, "Row \"%s\" has been %s", row_name, checked ? "checked" : "unchecked"); + etk_statusbar_message_push(statusbar, message, 0); } |
From: Enlightenment C. <no...@cv...> - 2007-01-16 22:57:08
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_tree.c etk_tree.h etk_tree_model.h Log Message: * [Tree] Do not inter-model space if the first model is invisible =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -3 -r1.81 -r1.82 --- etk_tree.c 16 Jan 2007 23:49:26 -0000 1.81 +++ etk_tree.c 17 Jan 2007 04:57:05 -0000 1.82 @@ -2401,7 +2401,7 @@ else w = 0; - if ((j + 1) != col->num_models) + if ((j + 1) != col->num_models && w > 0) w += MODEL_INTERSPACE; model_geometry.x += w; =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- etk_tree.h 16 Jan 2007 23:49:26 -0000 1.27 +++ etk_tree.h 17 Jan 2007 04:57:05 -0000 1.28 @@ -200,6 +200,7 @@ /* TODO: Etk_Tree_Row *etk_tree_row_insert_sorted(Etk_Tree *tree, Etk_Tree_Row *parent, ...); */ void etk_tree_row_delete(Etk_Tree_Row *row); void etk_tree_clear(Etk_Tree *tree); +/* TODO: way to insert a separator... */ void etk_tree_row_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, ...); void etk_tree_row_fields_set_valist(Etk_Tree_Row *row, Etk_Bool emit_signal, va_list args); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree_model.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- etk_tree_model.h 16 Jan 2007 23:49:27 -0000 1.7 +++ etk_tree_model.h 17 Jan 2007 04:57:05 -0000 1.8 @@ -46,6 +46,8 @@ void etk_tree_model_image_width_set(Etk_Tree_Model *model, int width, float alignment); void etk_tree_model_image_width_get(Etk_Tree_Model *model, int *width, float *alignment); +/* TODO: checkbox-model: use a third value to actually hide the checkbox */ + /** @} */ #endif |
From: Enlightenment C. <no...@cv...> - 2007-01-17 15:33:55
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_cache.c Log Message: * [Cache] Automatically remove an object from the cache when it gets deleted =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_cache.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- etk_cache.c 12 Jan 2007 02:53:56 -0000 1.12 +++ etk_cache.c 17 Jan 2007 21:33:39 -0000 1.13 @@ -9,11 +9,7 @@ * @{ */ -/************************** - * - * Implementation - * - **************************/ +static void _etk_cache_object_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); typedef struct Etk_Cache_Item { @@ -22,6 +18,12 @@ Evas_Object *object; } Etk_Cache_Item; +/************************** + * + * Implementation + * + **************************/ + /** * @brief Creates a new cache system that you can use to cache image objects or Edje objects. You usually don't need * to use that, except if you are implementing your own widget or your own tree model which may need to load a lot @@ -70,21 +72,13 @@ while (cache->cached_objects) { item = cache->cached_objects->data; - - if (cache->free_cb) - cache->free_cb(item->object, cache->free_cb_data); evas_object_del(item->object); - free(item->filename); - free(item->key); - free(item); - - cache->cached_objects = evas_list_remove_list(cache->cached_objects, cache->cached_objects); } } /** - * @brief Sets the callback to call when a cached object is deleted (because it is too old, or because the cache is - * cleared) + * @brief Sets the callback to call when a cached object is deleted (if it is there is no more space in the cache, + * or if the cache is being cleared) * @param cache a cache system * @param free_cb the function to call when a cached object is deleted. @a object is the object that will be deleted, * and @a data is the user data you gave (see the next param) @@ -120,15 +114,7 @@ while (cache->cached_objects && num_objects > cache->size) { item = cache->cached_objects->data; - - if (cache->free_cb) - cache->free_cb(item->object, cache->free_cb_data); evas_object_del(item->object); - free(item->filename); - free(item->key); - free(item); - - cache->cached_objects = evas_list_remove_list(cache->cached_objects, cache->cached_objects); num_objects--; } } @@ -171,6 +157,7 @@ void etk_cache_add(Etk_Cache *cache, Evas_Object *object, const char *filename, const char *key) { Etk_Cache_Item *item; + Evas_List *l; if (!cache || !object || cache->size <= 0 || !filename) { @@ -183,15 +170,21 @@ return; } - evas_object_hide(object); + /* If the object is already cached, we move it at the end of the cache */ + if ((l = evas_object_data_get(object, "_Etk_Cache::Node"))) + { + item = l->data; + cache->cached_objects = evas_list_remove_list(cache->cached_objects, l); + cache->cached_objects = evas_list_append(cache->cached_objects, item); + evas_object_data_set(item->object, "_Etk_Cache::Node", evas_list_last(cache->cached_objects)); + return; + } /* If no more space is available, we remove the oldest object of the cache */ if (evas_list_count(cache->cached_objects) >= cache->size) { item = cache->cached_objects->data; - if (cache->free_cb) - cache->free_cb(item->object, cache->free_cb_data); evas_object_del(item->object); free(item->filename); free(item->key); @@ -206,7 +199,11 @@ item->key = key ? strdup(key) : NULL; item->object = object; + evas_object_hide(object); + evas_object_event_callback_add(object, EVAS_CALLBACK_FREE, _etk_cache_object_deleted_cb, cache); + cache->cached_objects = evas_list_append(cache->cached_objects, item); + evas_object_data_set(item->object, "_Etk_Cache::Node", evas_list_last(cache->cached_objects)); } /** @@ -222,19 +219,17 @@ if (!cache || !object) return; - for (l = cache->cached_objects; l; l = l->next) + if ((l = evas_object_data_get(object, "_Etk_Cache::Node"))) { item = l->data; - if (item->object == object) - { - /* We have found our object. We can now remove it */ - free(item->filename); - free(item->key); - free(item); - - cache->cached_objects = evas_list_remove_list(cache->cached_objects, l); - return; - } + + evas_object_data_del(object, "_Etk_Cache::Node"); + evas_object_event_callback_del(object, EVAS_CALLBACK_FREE, _etk_cache_object_deleted_cb); + free(item->filename); + free(item->key); + free(item); + + cache->cached_objects = evas_list_remove_list(cache->cached_objects, l); } } @@ -263,6 +258,9 @@ && ((!item->key && !key) || (item->key && key && strcmp(item->key, key) == 0))) { object = item->object; + + evas_object_data_del(object, "_Etk_Cache::Node"); + evas_object_event_callback_del(object, EVAS_CALLBACK_FREE, _etk_cache_object_deleted_cb); free(item->filename); free(item->key); free(item); @@ -273,6 +271,25 @@ } return NULL; +} + +/************************** + * + * Private functions + * + **************************/ + +/* Called when an object of the cache is deleted */ +static void _etk_cache_object_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + Etk_Cache *cache; + + if (!(cache = data)) + return; + + etk_cache_remove(cache, obj); + if (cache->free_cb) + cache->free_cb(obj, cache->free_cb_data); } /** @} */ |
From: Enlightenment C. <no...@cv...> - 2007-01-17 15:47:04
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_cache.c Log Message: * [Cache] Fix a segv when the cache is full.. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_cache.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_cache.c 17 Jan 2007 21:33:39 -0000 1.13 +++ etk_cache.c 17 Jan 2007 21:46:56 -0000 1.14 @@ -160,20 +160,22 @@ Evas_List *l; if (!cache || !object || cache->size <= 0 || !filename) - { - if (cache && object) - { - if (cache->free_cb) - cache->free_cb(object, cache->free_cb_data); - evas_object_del(object); - } return; - } /* If the object is already cached, we move it at the end of the cache */ if ((l = evas_object_data_get(object, "_Etk_Cache::Node"))) { item = l->data; + if (item->filename != filename) + { + free(item->filename); + item->filename = strdup(filename); + } + if (item->key != key) + { + free(item->key); + item->key = strdup(key); + } cache->cached_objects = evas_list_remove_list(cache->cached_objects, l); cache->cached_objects = evas_list_append(cache->cached_objects, item); evas_object_data_set(item->object, "_Etk_Cache::Node", evas_list_last(cache->cached_objects)); @@ -184,13 +186,7 @@ if (evas_list_count(cache->cached_objects) >= cache->size) { item = cache->cached_objects->data; - evas_object_del(item->object); - free(item->filename); - free(item->key); - free(item); - - cache->cached_objects = evas_list_remove_list(cache->cached_objects, cache->cached_objects); } /* We create a new cache-item for the object and we add it to the cache */ |
From: Enlightenment C. <no...@cv...> - 2007-01-26 17:09:56
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_tree.c Log Message: * [Tree] The hscrollbar no longer takes into account the invisible cols =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v retrieving revision 1.83 retrieving revision 1.84 diff -u -3 -r1.83 -r1.84 --- etk_tree.c 22 Jan 2007 22:51:35 -0000 1.83 +++ etk_tree.c 26 Jan 2007 23:09:45 -0000 1.84 @@ -2060,7 +2060,10 @@ scroll_size->w = 0; for (i = 0; i < tree->num_cols; i++) - scroll_size->w += tree->columns[i]->width; + { + if (tree->columns[i]->visible) + scroll_size->w += tree->columns[i]->width; + } scroll_size->h = tree->root.num_visible_children * tree->rows_height; } |
From: Enlightenment C. <no...@cv...> - 2007-01-28 11:31:37
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/doc Modified Files: etk.css Log Message: * [Doc] Fix css for recent doxygen =================================================================== RCS file: /cvs/e/e17/libs/etk/doc/etk.css,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- etk.css 25 May 2006 21:06:59 -0000 1.3 +++ etk.css 28 Jan 2007 17:31:34 -0000 1.4 @@ -44,8 +44,8 @@ CAPTION { font-weight: bold } DIV.qindex { width: 100%; - background-color: #eeeeee; - border: 1px solid #b0b0b0; + background-color: #e8eef2; + border: 1px solid #84b0c7; text-align: center; margin: 2px; padding: 2px; @@ -53,16 +53,16 @@ } DIV.nav { width: 100%; - background-color: #eeeeee; - border: 1px solid #b0b0b0; + background-color: #e8eef2; + border: 1px solid #84b0c7; text-align: center; margin: 2px; padding: 2px; line-height: 140%; } DIV.navtab { - background-color: #eeeeee; - border: 1px solid #b0b0b0; + background-color: #e8eef2; + border: 1px solid #84b0c7; text-align: center; margin: 2px; margin-right: 15px; @@ -74,40 +74,40 @@ A.qindex { text-decoration: none; font-weight: bold; - color: #444444; + color: #1A419D; } A.qindex:visited { text-decoration: none; font-weight: bold; - color: #333333 + color: #1A419D } A.qindex:hover { text-decoration: none; - background-color: #dddddd; + background-color: #ddddff; } A.qindexHL { text-decoration: none; font-weight: bold; - background-color: #666666; + background-color: #6666cc; color: #ffffff; border: 1px double #9295C2; } A.qindexHL:hover { text-decoration: none; - background-color: #666666; + background-color: #6666cc; color: #ffffff; } -A.qindexHL:visited { text-decoration: none; background-color: #666666; color: #ffffff } +A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff } A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } -A.code:link { text-decoration: underline; font-weight: normal; color: #000000 } -A.code:visited { text-decoration: underline; font-weight: normal; color: #000000 } -A.codeRef:link { text-decoration: underline; font-weight: normal; color: #000000 } -A.codeRef:visited { text-decoration: underline; font-weight: normal; color: #000000 } -A:hover { text-decoration: none; background-color: #f2f2f2 } +A.code:link { text-decoration: none; font-weight: normal; color: #0000FF} +A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF} +A.codeRef:link { font-weight: normal; color: #0000FF} +A.codeRef:visited { font-weight: normal; color: #0000FF} +A:hover { text-decoration: none; background-color: #f2f2ff } DL.el { margin-left: -1cm } .fragment { - font-family: Fixed, monospace; + font-family: monospace, fixed; font-size: 95%; } PRE.fragment { @@ -123,14 +123,7 @@ padding-bottom: 4px; } DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } -TD.md { background-color: #F4F4F4; font-weight: bold; } -TD.mdPrefix { - background-color: #F4F4F4; - color: #606060; - font-size: 80%; -} -TD.mdname1 { background-color: #F4F4F4; font-weight: bold; color: #602020; } -TD.mdname { background-color: #F4F4F4; font-weight: bold; color: #602020; } + DIV.groupHeader { margin-left: 16px; margin-top: 12px; @@ -139,7 +132,7 @@ } DIV.groupText { margin-left: 16px; font-style: italic; font-size: 90% } TD.indexkey { - background-color: #eeeeee; + background-color: #e8eef2; font-weight: bold; padding-right : 10px; padding-top : 2px; @@ -152,7 +145,7 @@ border: 1px solid #CCCCCC; } TD.indexvalue { - background-color: #eeeeee; + background-color: #e8eef2; font-style: italic; padding-right : 10px; padding-top : 2px; @@ -177,14 +170,6 @@ SPAN.preprocessor { color: #806020 } SPAN.stringliteral { color: #002080 } SPAN.charliteral { color: #008080 } -.mdTable { - border: 1px solid #868686; - background-color: #F4F4F4; - width: 100%; -} -.mdRow { - padding: 8px 10px; -} .mdescLeft { padding: 0px 8px 4px 8px; font-size: 80%; @@ -308,24 +293,87 @@ INPUT.search { font-size: 75%; color: #000080; font-weight: normal; - background-color: #eeeeee; + background-color: #e8eef2; } TD.tiny { font-size: 75%; } a { - color: #525252; + color: #1A41A8; } a:visited { - color: #525252; + color: #2A3798; } .dirtab { padding: 4px; border-collapse: collapse; - border: 1px solid #b0b0b0; + border: 1px solid #84b0c7; } -TH.dirtab { background: #eeeeee; +TH.dirtab { background: #e8eef2; font-weight: bold; } HR { height: 1px; border: none; border-top: 1px solid black; } + +/* Style for detailed member documentation */ +.memtemplate { + font-size: 80%; + color: #606060; + font-weight: normal; +} +.memnav { + background-color: #e8eef2; + border: 1px solid #84b0c7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} +.memitem { + padding: 4px; + background-color: #fafafa; + border-width: 1px; + border-style: solid; + border-color: #dedeee; + -moz-border-radius: 8px 8px 8px 8px; +} +.memname { + white-space: nowrap; + font-weight: bold; +} +.memdoc{ + padding-left: 10px; +} +.memproto { + background-color: #e0e0e0; + width: 100%; + border-width: 1px; + border-style: solid; + border-color: #b0b0b0; + font-weight: bold; + -moz-border-radius: 8px 8px 8px 8px; +} +.paramkey { + text-align: right; +} +.paramtype { + white-space: nowrap; +} +.paramname { + color: #602020; + font-style: italic; + white-space: nowrap; +} +/* End Styling for detailed member documentation */ + +/* for the tree view */ +.ftvtree { + font-family: sans-serif; + margin:0.5em; +} +.directory { font-size: 9pt; font-weight: bold; } +.directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } +.directory > h3 { margin-top: 0; } +.directory p { margin: 0px; white-space: nowrap; } +.directory div { display: none; margin: 0px; } +.directory img { vertical-align: -30%; } |
From: Enlightenment C. <no...@cv...> - 2007-01-28 11:35:06
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/doc Modified Files: etk.css Log Message: * [Doc] Looks a bit better =================================================================== RCS file: /cvs/e/e17/libs/etk/doc/etk.css,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- etk.css 28 Jan 2007 17:31:34 -0000 1.4 +++ etk.css 28 Jan 2007 17:35:05 -0000 1.5 @@ -345,7 +345,7 @@ padding-left: 10px; } .memproto { - background-color: #e0e0e0; + background-color: #eaeaea; width: 100%; border-width: 1px; border-style: solid; |
From: Enlightenment C. <no...@cv...> - 2007-01-28 11:46:08
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_colorpicker.c etk_colorpicker.h etk_range.c etk_range.h etk_spinner.c Log Message: * [Colorpicker] Apply Dave's patch to add a alpha slider to the colorpicker: you can use etk_colorpicker_use_alpha_set/get() to set whether or not it should be visible. * [Range] etk_range_value_set() now returns ETK_TRUE if the value has actually been changed, ETK_FALSE otherwise =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- etk_colorpicker.c 6 Oct 2006 17:04:14 -0000 1.22 +++ etk_colorpicker.c 28 Jan 2007 17:46:04 -0000 1.23 @@ -32,7 +32,8 @@ enum Etk_Colorpicker_Property_Id { - ETK_CP_MODE_PROPERTY + ETK_CP_MODE_PROPERTY, + ETK_CP_USE_ALPHA_PROPERTY }; static void _etk_colorpicker_constructor(Etk_Colorpicker *cp); @@ -49,6 +50,7 @@ static void _etk_colorpicker_current_color_realize_cb(Etk_Object *object, void *data); static void _etk_colorpicker_current_color_unrealize_cb(Etk_Object *object, void *data); static void _etk_colorpicker_slider_value_changed_cb(Etk_Object *object, double value, void *data); +static void _etk_colorpicker_alpha_slider_value_changed_cb(Etk_Object *object, double value, void *data); static void _etk_colorpicker_radio_toggled_cb(Etk_Object *object, void *data); static void _etk_colorpicker_sp_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); @@ -85,6 +87,7 @@ static void _etk_colorpicker_vp_color_get(Etk_Colorpicker *cp, int i, int *r, int *g, int *b); static void _etk_colorpicker_color_calc(Etk_Colorpicker_Mode mode, float sp_xpos, float sp_ypos, float vp_pos, int *r, int *g, int *b); +static float _etk_colorpicker_max_values[6] = { 360.0, 1.0, 1.0, 255.0, 255.0, 255.0 }; static Evas_Smart *_etk_colorpicker_picker_smart = NULL; static int _etk_colorpicker_picker_smart_use = 0; static Etk_Signal *_etk_colorpicker_signals[ETK_CP_NUM_SIGNALS]; @@ -101,7 +104,7 @@ * @brief Gets the type of an Etk_Colorpicker * @return Returns the type of an Etk_Colorpicker */ -Etk_Type *etk_colorpicker_type_get() +Etk_Type *etk_colorpicker_type_get(void) { static Etk_Type *cp_type = NULL; @@ -115,6 +118,8 @@ etk_type_property_add(cp_type, "color_mode", ETK_CP_MODE_PROPERTY, ETK_PROPERTY_INT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_int(ETK_COLORPICKER_H)); + etk_type_property_add(cp_type, "use_alpha", ETK_CP_USE_ALPHA_PROPERTY, + ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_FALSE)); cp_type->property_set = _etk_colorpicker_property_set; cp_type->property_get = _etk_colorpicker_property_get; @@ -127,7 +132,7 @@ * @brief Creates a new colorpicker * @return Returns the new colorpicker */ -Etk_Widget *etk_colorpicker_new() +Etk_Widget *etk_colorpicker_new(void) { return etk_widget_new(ETK_COLORPICKER_TYPE, "theme_group", "colorpicker", NULL); } @@ -180,11 +185,11 @@ { value = etk_range_value_get(ETK_RANGE(cp->sliders[i])); if (i == mode) - cp->vp_pos = value / cp->sliders_max_value[i]; + cp->vp_pos = value / _etk_colorpicker_max_values[i]; else if (i == cp->sp_xcomponent) - cp->sp_xpos = value / cp->sliders_max_value[i]; + cp->sp_xpos = value / _etk_colorpicker_max_values[i]; else if (i == cp->sp_ycomponent) - cp->sp_ypos = value / cp->sliders_max_value[i]; + cp->sp_ypos = value / _etk_colorpicker_max_values[i]; } _etk_colorpicker_update(cp, ETK_TRUE, ETK_TRUE, ETK_TRUE, ETK_TRUE); @@ -211,14 +216,20 @@ */ void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color) { - if (cp->current_color.r == color.r && cp->current_color.g == color.g && cp->current_color.b == color.b) + if (cp->current_color.r == color.r && cp->current_color.g == color.g + && cp->current_color.b == color.b && cp->current_color.a == color.a) + { return; + } + /* TODO: this may bug if the B component is not changed... */ + /* TODO: this may emit the signal twice... */ cp->ignore_value_changed = ETK_TRUE; etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_R]), color.r); etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_G]), color.g); cp->ignore_value_changed = ETK_FALSE; etk_range_value_set(ETK_RANGE(cp->sliders[ETK_COLORPICKER_B]), color.b); + etk_range_value_set(ETK_RANGE(cp->alpha_slider), color.a); } /** @@ -237,6 +248,47 @@ return cp->current_color; } +/** + * @brief Sets whether or not the colorpicker has a slider that allows the user to choose the alpha + * component of the color + * @param cp a colorpicher + * @param use_alpha ETK_TRUE to make the colorpicker have an alpha slider, ETK_FALSE otherwise + */ +void etk_colorpicker_use_alpha_set(Etk_Colorpicker *cp, Etk_Bool use_alpha) +{ + if (!cp || cp->use_alpha == use_alpha) + return; + + cp->use_alpha = use_alpha; + if (cp->use_alpha) + { + etk_widget_show(cp->alpha_slider); + etk_widget_show(cp->alpha_name_label); + etk_widget_show(cp->alpha_value_label); + etk_range_value_set(ETK_RANGE(cp->alpha_slider), cp->current_color.a); + } + else + { + etk_widget_hide(cp->alpha_slider); + etk_widget_hide(cp->alpha_name_label); + etk_widget_hide(cp->alpha_value_label); + cp->current_color.a = 255; + } + etk_object_notify(ETK_OBJECT(cp), "use_alpha"); +} + +/** + * @brief Gets whether the colorpicker has an alpha slider + * @param cp a colorpicher + * @return Returns ETK_TRUE if the colorpicker has an alpha slider, ETK_FALSE otherwise + */ +Etk_Bool etk_colorpicker_use_alpha_get(Etk_Colorpicker *cp) +{ + if (!cp) + return ETK_FALSE; + return cp->use_alpha; +} + /************************** * * Etk specific functions @@ -248,7 +300,6 @@ { Etk_Widget *cp_widget; char *labels[6] = { _("H"), _("S"), _("V"), _("R"), _("G"), _("B") }; - float values[6] = { 360.0, 1.0, 1.0, 255.0, 255.0, 255.0 }; float steps[6] = { 1.0, 0.01, 0.01, 1.0, 1.0, 1.0 }; int i; @@ -256,6 +307,7 @@ return; cp->mode = ETK_COLORPICKER_H; + cp->use_alpha = ETK_FALSE; cp->sp_xcomponent = ETK_COLORPICKER_V; cp->sp_ycomponent = ETK_COLORPICKER_S; @@ -303,7 +355,7 @@ etk_widget_internal_set(cp->picker_widget, ETK_TRUE); etk_widget_show(cp->picker_widget); - cp->component_table = etk_table_new(3, 6, ETK_FALSE); + cp->component_table = etk_table_new(3, 7, ETK_FALSE); etk_table_attach_default(ETK_TABLE(cp->main_table), cp->component_table, 1, 1, 0, 0); etk_widget_internal_set(cp->component_table, ETK_TRUE); etk_widget_show(cp->component_table); @@ -320,20 +372,20 @@ etk_widget_internal_set(cp->radios[i], ETK_TRUE); etk_widget_show(cp->radios[i]); - cp->sliders[i] = etk_hslider_new(0.0, values[i], 0.0, steps[i], steps[i] * 5); + cp->sliders[i] = etk_hslider_new(0.0, _etk_colorpicker_max_values[i], 0.0, steps[i], steps[i] * 5); etk_table_attach(ETK_TABLE(cp->component_table), cp->sliders[i], 1, 1, i, i, 0, 0, ETK_TABLE_HFILL | ETK_TABLE_EXPAND); etk_widget_theme_parent_set(cp->sliders[i], ETK_WIDGET(cp)); etk_widget_internal_set(cp->sliders[i], ETK_TRUE); etk_widget_show(cp->sliders[i]); - cp->sliders_max_value[i] = values[i]; cp->sliders_image[i] = NULL; cp->value_labels[i] = etk_label_new("0"); etk_table_attach(ETK_TABLE(cp->component_table), cp->value_labels[i], 2, 2, i, i, 0, 0, ETK_TABLE_HFILL | ETK_TABLE_VEXPAND); etk_widget_internal_set(cp->value_labels[i], ETK_TRUE); + /* TODO: this sucks.. the width shouldn't be hardcoded.. */ etk_widget_size_request_set(cp->value_labels[i], 28, -1); etk_widget_show(cp->value_labels[i]); @@ -347,8 +399,32 @@ ETK_CALLBACK(_etk_colorpicker_slider_value_changed_cb), cp); } + /* Alpha slider */ + { + cp->alpha_name_label = etk_label_new(_("Alpha")); + etk_table_attach(ETK_TABLE(cp->component_table), cp->alpha_name_label, 0, 0, 6, 6, + 0, 0, ETK_TABLE_HFILL | ETK_TABLE_VEXPAND); + etk_widget_internal_set(cp->alpha_name_label, ETK_TRUE); + + cp->alpha_slider = etk_hslider_new(0.0, 255.0, 255.0, 10, 5.0); + etk_table_attach(ETK_TABLE(cp->component_table), cp->alpha_slider, 1, 1, 6, 6, + 0, 0, ETK_TABLE_HFILL | ETK_TABLE_EXPAND); + etk_widget_internal_set(cp->alpha_slider, ETK_TRUE); + + cp->alpha_value_label = etk_label_new("255"); + etk_table_attach(ETK_TABLE(cp->component_table), cp->alpha_value_label, 2, 2, 6, 6, + 0, 0, ETK_TABLE_HFILL | ETK_TABLE_VEXPAND); + etk_widget_internal_set(cp->alpha_value_label, ETK_TRUE); + /* TODO: this sucks.. the width shouldn't be hardcoded.. */ + etk_widget_size_request_set(cp->alpha_value_label, 28, -1); + + etk_signal_connect("value_changed", ETK_OBJECT(cp->alpha_slider), + ETK_CALLBACK(_etk_colorpicker_alpha_slider_value_changed_cb), cp); + } + /* We create the widgets for the color preview */ cp->color_table = etk_table_new(2, 1, ETK_FALSE); + etk_widget_padding_set(cp->color_table, 3, 3, 3, 3); etk_table_attach(ETK_TABLE(cp->main_table), cp->color_table, 0, 0, 1, 1, 0, 0, ETK_TABLE_FILL | ETK_TABLE_HEXPAND); etk_widget_internal_set(cp->color_table, ETK_TRUE); @@ -616,6 +692,7 @@ static void _etk_colorpicker_current_color_realize_cb(Etk_Object *object, void *data) { Etk_Colorpicker *cp; + Etk_Color color; Evas *evas; if (!(cp = ETK_COLORPICKER(data)) || !(evas = etk_widget_toplevel_evas_get(ETK_WIDGET(cp)))) @@ -625,8 +702,9 @@ etk_widget_swallow_object(cp->current_color_widget, "preview_rect", cp->current_color_rect); evas_object_show(cp->current_color_rect); - evas_object_color_set(cp->current_color_rect, cp->current_color.r, - cp->current_color.g, cp->current_color.b, 255); + color = cp->current_color; + evas_color_argb_premul(color.a, &color.r, &color.g, &color.b); + evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, color.a); } /* Called when the current color widget of the colorpicker is unrealized */ @@ -662,11 +740,11 @@ { /* First, we update the position of the cursors */ if (i == cp->mode) - cp->vp_pos = value / cp->sliders_max_value[i]; + cp->vp_pos = value / _etk_colorpicker_max_values[i]; else if (i == cp->sp_xcomponent) - cp->sp_xpos = value / cp->sliders_max_value[i]; + cp->sp_xpos = value / _etk_colorpicker_max_values[i]; else if (i == cp->sp_ycomponent) - cp->sp_ypos = value / cp->sliders_max_value[i]; + cp->sp_ypos = value / _etk_colorpicker_max_values[i]; /* We update the corresponding label */ if (i == ETK_COLORPICKER_S || i == ETK_COLORPICKER_V) @@ -742,7 +820,8 @@ cp->current_color.r = color.r; cp->current_color.g = color.g; cp->current_color.b = color.b; - evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, 255); + evas_color_argb_premul(cp->current_color.a, &color.r, &color.g, &color.b); + evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, cp->current_color.a); if (cp->emit_signal) etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); } @@ -756,6 +835,36 @@ } } +/* Called when the alpha slider's value is changed */ +static void _etk_colorpicker_alpha_slider_value_changed_cb(Etk_Object *object, double value, void *data) +{ + Etk_Colorpicker *cp; + Etk_Widget *slider; + Etk_Color color; + char string[10]; + + if (!(slider = ETK_WIDGET(object)) || !(cp = ETK_COLORPICKER(data))) + return; + + snprintf(string, 10, "%d", (int)(value)); + etk_label_set(ETK_LABEL(cp->alpha_value_label), string); + + /* TODO: do we really need that?? */ + if (cp->ignore_value_changed) + return; + + color.r = cp->current_color.r; + color.g = cp->current_color.g; + color.b = cp->current_color.b; + + cp->current_color.a = value; + evas_color_argb_premul(cp->current_color.a, &color.r, &color.g, &color.b); + evas_object_color_set(cp->current_color_rect, color.r, color.g, color.b, cp->current_color.a); + + if (cp->emit_signal) + etk_signal_emit(_etk_colorpicker_signals[ETK_CP_COLOR_CHANGED_SIGNAL], ETK_OBJECT(cp), NULL); +} + /* Called when the color mode is changed with the radio buttons */ static void _etk_colorpicker_radio_toggled_cb(Etk_Object *object, void *data) { @@ -839,7 +948,7 @@ evas_object_geometry_get(cp->vp_image, NULL, &y, NULL, &h); percent = 1.0 - ETK_CLAMP((float)(event->canvas.y - y) / h, 0.0, 1.0); - etk_range_value_set(ETK_RANGE(cp->sliders[cp->mode]), percent * cp->sliders_max_value[cp->mode]); + etk_range_value_set(ETK_RANGE(cp->sliders[cp->mode]), percent * _etk_colorpicker_max_values[cp->mode]); cp->vp_dragging = ETK_TRUE; } @@ -867,7 +976,7 @@ evas_object_geometry_get(cp->vp_image, NULL, &y, NULL, &h); percent = 1.0 - ETK_CLAMP((float)(event->cur.canvas.y - y) / h, 0.0, 1.0); - etk_range_value_set(ETK_RANGE(cp->sliders[cp->mode]), percent * cp->sliders_max_value[cp->mode]); + etk_range_value_set(ETK_RANGE(cp->sliders[cp->mode]), percent * _etk_colorpicker_max_values[cp->mode]); } /* Called when the image of a slider of the colorpicker is resized */ @@ -1110,9 +1219,11 @@ return; cp->emit_signal = ETK_FALSE; - etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_xcomponent]), xpercent * cp->sliders_max_value[cp->sp_xcomponent]); + etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_xcomponent]), + xpercent * _etk_colorpicker_max_values[cp->sp_xcomponent]); cp->emit_signal = ETK_TRUE; - etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_ycomponent]), ypercent * cp->sliders_max_value[cp->sp_ycomponent]); + etk_range_value_set(ETK_RANGE(cp->sliders[cp->sp_ycomponent]), + ypercent * _etk_colorpicker_max_values[cp->sp_ycomponent]); } /* Updates of the colorpicker */ @@ -1364,3 +1475,5 @@ } /** @} */ + +/* TODOC: write documentation... */ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- etk_colorpicker.h 6 Oct 2006 17:04:14 -0000 1.11 +++ etk_colorpicker.h 28 Jan 2007 17:46:04 -0000 1.12 @@ -69,7 +69,6 @@ /* Sliders */ Etk_Widget *sliders[6]; Evas_Object *sliders_image[6]; - float sliders_max_value[6]; int sliders_res; Etk_Bool sliders_need_update; @@ -78,6 +77,11 @@ Etk_Widget *radios[6]; Etk_Widget *value_labels[6]; + /* Alpha slider */ + Etk_Widget *alpha_slider; + Etk_Widget *alpha_name_label; + Etk_Widget *alpha_value_label; + /* Current color objects */ Etk_Widget *color_table; Etk_Widget *current_color_label; @@ -87,18 +91,20 @@ Etk_Bool ignore_value_changed; Etk_Bool emit_signal; + Etk_Bool use_alpha; Etk_Colorpicker_Mode mode; Etk_Color current_color; }; -Etk_Type *etk_colorpicker_type_get(); -Etk_Widget *etk_colorpicker_new(); +Etk_Type *etk_colorpicker_type_get(void); +Etk_Widget *etk_colorpicker_new(void); void etk_colorpicker_mode_set(Etk_Colorpicker *cp, Etk_Colorpicker_Mode mode); Etk_Colorpicker_Mode etk_colorpicker_mode_get(Etk_Colorpicker *cp); - -void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color); -Etk_Color etk_colorpicker_current_color_get(Etk_Colorpicker *cp); +void etk_colorpicker_current_color_set(Etk_Colorpicker *cp, Etk_Color color); +Etk_Color etk_colorpicker_current_color_get(Etk_Colorpicker *cp); +void etk_colorpicker_use_alpha_set(Etk_Colorpicker *cp, Etk_Bool use_alpha); +Etk_Bool etk_colorpicker_use_alpha_get(Etk_Colorpicker *cp); /** @} */ =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_range.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- etk_range.c 6 Oct 2006 17:04:14 -0000 1.16 +++ etk_range.c 28 Jan 2007 17:46:04 -0000 1.17 @@ -44,7 +44,7 @@ * @brief Gets the type of an Etk_Range * @return Returns the type of an Etk_Range */ -Etk_Type *etk_range_type_get() +Etk_Type *etk_range_type_get(void) { static Etk_Type *range_type = NULL; @@ -80,13 +80,15 @@ * @brief Sets the value of the range * @param range a range * @param value the value to set to the range + * @return Returns ETK_TRUE if the value has actually been changed, ETK_FALSE otherwise (because + * the current value is equal to the new value) */ -void etk_range_value_set(Etk_Range *range, double value) +Etk_Bool etk_range_value_set(Etk_Range *range, double value) { double new_value; if (!range) - return; + return ETK_FALSE; new_value = ETK_CLAMP(value, range->lower, range->upper - range->page_size); if (new_value != range->value) @@ -94,7 +96,10 @@ range->value = new_value; etk_signal_emit(_etk_range_signals[ETK_RANGE_VALUE_CHANGED_SIGNAL], ETK_OBJECT(range), NULL, range->value); etk_object_notify(ETK_OBJECT(range), "value"); + return ETK_TRUE; } + + return ETK_FALSE; } /** =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_range.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- etk_range.h 2 Jun 2006 18:46:34 -0000 1.9 +++ etk_range.h 28 Jan 2007 17:46:04 -0000 1.10 @@ -39,10 +39,10 @@ void (*value_changed)(Etk_Range *range, double value); }; -Etk_Type *etk_range_type_get(); +Etk_Type *etk_range_type_get(void); -void etk_range_value_set(Etk_Range *range, double value); -double etk_range_value_get(Etk_Range *range); +Etk_Bool etk_range_value_set(Etk_Range *range, double value); +double etk_range_value_get(Etk_Range *range); void etk_range_range_set(Etk_Range *range, double lower, double upper); void etk_range_range_get(Etk_Range *range, double *lower, double *upper); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_spinner.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- etk_spinner.c 26 Dec 2006 14:51:23 -0000 1.4 +++ etk_spinner.c 28 Jan 2007 17:46:04 -0000 1.5 @@ -819,9 +819,7 @@ if (spinner->snap_to_ticks) value = _etk_spinner_value_snap(spinner, value); - if (etk_range_value_get(ETK_RANGE(spinner)) != value) - etk_range_value_set(ETK_RANGE(spinner), value); - else + if (!etk_range_value_set(ETK_RANGE(spinner), value)) _etk_spinner_update_text_from_value(spinner); } |
From: Enlightenment C. <no...@cv...> - 2007-01-28 11:46:35
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/bin Modified Files: etk_colorpicker_test.c Log Message: * [Colorpicker] Apply Dave's patch to add a alpha slider to the colorpicker: you can use etk_colorpicker_use_alpha_set/get() to set whether or not it should be visible. * [Range] etk_range_value_set() now returns ETK_TRUE if the value has actually been changed, ETK_FALSE otherwise =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_colorpicker_test.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- etk_colorpicker_test.c 24 Jun 2006 17:54:06 -0000 1.6 +++ etk_colorpicker_test.c 28 Jan 2007 17:46:04 -0000 1.7 @@ -16,6 +16,7 @@ etk_signal_connect("delete_event", ETK_OBJECT(win), ETK_CALLBACK(etk_window_hide_on_delete), NULL); cp = etk_colorpicker_new(); + etk_colorpicker_use_alpha_set(ETK_COLORPICKER(cp), ETK_TRUE); etk_container_add(ETK_CONTAINER(win), cp); etk_widget_show_all(win); |
From: Enlightenment C. <no...@cv...> - 2007-01-28 11:46:36
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/data/themes/default/widgets Modified Files: colorpicker.edc Log Message: * [Colorpicker] Apply Dave's patch to add a alpha slider to the colorpicker: you can use etk_colorpicker_use_alpha_set/get() to set whether or not it should be visible. * [Range] etk_range_value_set() now returns ETK_TRUE if the value has actually been changed, ETK_FALSE otherwise =================================================================== RCS file: /cvs/e/e17/libs/etk/data/themes/default/widgets/colorpicker.edc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- colorpicker.edc 20 Oct 2006 17:51:44 -0000 1.7 +++ colorpicker.edc 28 Jan 2007 17:46:04 -0000 1.8 @@ -175,9 +175,23 @@ group { name: "etk/colorpicker/color_preview"; - min: 40 18; + min: 40 22; parts { part { + name: "background"; + type: RECT; + description { + state: "default" 0.0; + color: 255 255 255 255; + rel1 { + to: "preview_rect"; + } + rel2 { + to: "preview_rect"; + } + } + } + part { name: "preview_rect"; type: SWALLOW; description { @@ -200,11 +214,11 @@ state: "default" 0.0; rel1 { relative: 0.0 0.0; - offset: 0 0; + offset: 8 0; } rel2 { relative: 1.0 1.0; - offset: -1 -1; + offset: -5 -1; } image { normal: "colorpicker_slider_trough.png"; |
From: Enlightenment C. <no...@cv...> - 2007-01-28 16:57:08
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_tree.c etk_tree.h etk_tree_model.c etk_tree_model.h Log Message: * [Tree] Chady's patch applied: it adds etk_tree_row_model_fields_set/get(). Thanks :) =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v retrieving revision 1.84 retrieving revision 1.85 diff -u -3 -r1.84 -r1.85 --- etk_tree.c 26 Jan 2007 23:09:45 -0000 1.84 +++ etk_tree.c 28 Jan 2007 22:57:06 -0000 1.85 @@ -530,6 +530,7 @@ col->models[col->num_models] = model; model->tree = col->tree; model->col = col; + model->index = col->num_models; col->num_models++; } @@ -1040,7 +1041,7 @@ * @brief Sets the values of the cells of the row * @param row a row of the tree * @param emit_signal whether or not the "cell_value_changed" signal should be emitted on the modified columns. - * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have + * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have a * callback connected on this signal * @param ... an "Etk_Tree_Col *" followed by the value of the cell, * then any number of "Etk_Tree_Col *"/Value pairs, and terminated by NULL. @@ -1062,7 +1063,7 @@ * @brief Sets the values of the cells of the row * @param row a row of the tree * @param emit_signal whether or not the "cell_value_changed" signal should be emitted on the modified columns. - * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have + * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have a * callback connected on this signal * @param args an "Etk_Tree_Col *" followed by the value of the cell, * then any number of "Etk_Tree_Col *"/Value pairs, and terminated by NULL. @@ -1137,6 +1138,104 @@ if (col->models[i]->cell_data_get) col->models[i]->cell_data_get(col->models[i], row->cells_data[col->id][i], &args); } + } + va_end(args2); +} + +/** + * @brief Sets the values of the models of the row + * @param row a row of the tree + * @param emit_signal whether or not the "cell_value_changed" signal should be emitted on the modified columns. + * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have a + * callback connected on this signal + * @param args an "Etk_Tree_Model *" followed by the value of the model, then any number of + * "Etk_Tree_Model *"/Value pairs, and terminated by NULL. + * Note that, according to the models, a cell value can use several parameters + */ +void etk_tree_row_model_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, ...) +{ + va_list args; + + if (!row) + return; + + va_start(args, emit_signal); + etk_tree_row_model_fields_set_valist(row, emit_signal, args); + va_end(args); +} + +/** + * @brief Sets the values of the models of the row + * @param row a row of the tree + * @param emit_signal whether or not the "cell_value_changed" signal should be emitted on the modified columns. + * Most of the time, the signal don't need to be emitted (so @a emit_signal should be ETK_FALSE), except if you have a + * callback connected on this signal + * @param args an "Etk_Tree_Model *" followed by the value of the model, then any number of + * "Etk_Tree_Model *"/Value pairs, and terminated by NULL. + * Note that, according to the models, a cell value can use several parameters + */ +void etk_tree_row_model_fields_set_valist(Etk_Tree_Row *row, Etk_Bool emit_signal, va_list args) +{ + Etk_Tree_Model *model; + va_list args2; + + if (!row) + return; + + va_copy(args2, args); + while ((model = va_arg(args2, Etk_Tree_Model *))) + { + if (model->cell_data_set) + model->cell_data_set(model, row->cells_data[model->col->id][model->index], &args2); + if (emit_signal) + etk_signal_emit(_etk_tree_col_signals[ETK_TREE_COL_CELL_VALUE_CHANGED], ETK_OBJECT(model->col), NULL, row); + } + va_end(args2); + + if (!row->tree->frozen) + etk_widget_redraw_queue(ETK_WIDGET(row->tree)); +} + +/** + * @brief Gets the values of the models of the row + * @param row a row of the tree + * @param ... an "Etk_Tree_Model *" followed by the location where to store the value of this model, + * then any number of "Etk_Tree_Model *"/Location pairs, and terminated by NULL. + * Note that some models may require several locations to store their value + */ +void etk_tree_row_model_fields_get(Etk_Tree_Row *row, ...) +{ + va_list args; + + if (!row) + return; + + va_start(args, row); + etk_tree_row_model_fields_get_valist(row, args); + va_end(args); +} + +/** + * @brief Gets the values of the models of the row + * @param row a row of the tree + * @param args an "Etk_Tree_Model *" followed by the location where to store the value of this model, + * then any number of "Etk_Tree_Model *"/Location pairs, and terminated by NULL. + * Note that some models may require several locations to store their value + */ +void etk_tree_row_model_fields_get_valist(Etk_Tree_Row *row, va_list args) +{ + Etk_Tree_Model *model; + va_list args2; + int i; + + if (!row) + return; + + va_copy(args2, args); + while ((model = va_arg(args, Etk_Tree_Model *))) + { + if (model->cell_data_get) + model->cell_data_get(model, row->cells_data[model->col->id][model->index], &args); } va_end(args2); } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- etk_tree.h 17 Jan 2007 04:57:05 -0000 1.28 +++ etk_tree.h 28 Jan 2007 22:57:07 -0000 1.29 @@ -207,6 +207,11 @@ void etk_tree_row_fields_get(Etk_Tree_Row *row, ...); void etk_tree_row_fields_get_valist(Etk_Tree_Row *row, va_list args); +void etk_tree_row_model_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, ...); +void etk_tree_row_model_fields_set_valist(Etk_Tree_Row *row, Etk_Bool emit_signal, va_list args); +void etk_tree_row_model_fields_get(Etk_Tree_Row *row, ...); +void etk_tree_row_model_fields_get_valist(Etk_Tree_Row *row, va_list args); + void etk_tree_row_data_set(Etk_Tree_Row *row, void *data); void etk_tree_row_data_set_full(Etk_Tree_Row *row, void *data, void (*free_cb)(void *data)); void *etk_tree_row_data_get(Etk_Tree_Row *row); =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree_model.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- etk_tree_model.c 28 Jan 2007 19:30:11 -0000 1.13 +++ etk_tree_model.c 28 Jan 2007 22:57:07 -0000 1.14 @@ -767,7 +767,6 @@ edje_object_message_signal_process(cell_objects[0]); evas_object_data_set(cell_objects[0], "_Etk_Tree_Model_Checkbox::Row", row); - evas_object_data_set(cell_objects[0], "_Etk_Tree_Model_Checkbox::Checked", checked); edje_object_size_min_get(cell_objects[0], &w, &h); evas_object_move(cell_objects[0], geometry.x, geometry.y + ((geometry.h - h) / 2)); evas_object_resize(cell_objects[0], w, h); @@ -793,13 +792,12 @@ { Etk_Tree_Model *model; Etk_Tree_Row *row; - Etk_Bool *checked; Evas_Event_Mouse_Up *event; int ox, oy, ow, oh; + Etk_Bool checked; if (!(model = data) || !model->col || !(event = event_info) - || !(row = evas_object_data_get(obj, "_Etk_Tree_Model_Checkbox::Row")) - || !(checked = evas_object_data_get(obj, "_Etk_Tree_Model_Checkbox::Checked"))) + || !(row = evas_object_data_get(obj, "_Etk_Tree_Model_Checkbox::Row"))) { return; } @@ -807,11 +805,8 @@ evas_object_geometry_get(obj, &ox, &oy, &ow, &oh); if (ETK_INSIDE(event->canvas.x, event->canvas.y, ox, oy, ow, oh)) { - *checked = !(*checked); - etk_signal_emit_by_name("cell_value_changed", ETK_OBJECT(model->col), NULL, row); - - /* Force the redraw the tree */ - etk_widget_redraw_queue(ETK_WIDGET(model->tree)); + etk_tree_row_model_fields_get(row, model, &checked, NULL); + etk_tree_row_model_fields_set(row, ETK_TRUE, model, !checked, NULL); } } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree_model.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- etk_tree_model.h 17 Jan 2007 04:57:05 -0000 1.8 +++ etk_tree_model.h 28 Jan 2007 22:57:07 -0000 1.9 @@ -22,6 +22,7 @@ Etk_Tree *tree; Etk_Tree_Col *col; int cell_data_size; + int index; void (*model_free)(Etk_Tree_Model *model); void (*cell_data_init)(Etk_Tree_Model *model, void *cell_data); |
From: Enlightenment C. <no...@cv...> - 2007-01-28 23:20:42
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/bin Modified Files: etk_tree_test.c Log Message: * Connect the "cell_value_changed" signal to the correct column =================================================================== RCS file: /cvs/e/e17/libs/etk/src/bin/etk_tree_test.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -3 -r1.38 -r1.39 --- etk_tree_test.c 29 Jan 2007 02:26:51 -0000 1.38 +++ etk_tree_test.c 29 Jan 2007 05:20:40 -0000 1.39 @@ -72,7 +72,7 @@ row = etk_tree_row_append(ETK_TREE(tree), NULL, col1, etk_theme_icon_get(), stock_key, row_name, col2, 0.57, - col3, 7, + col3, 7, col4, PACKAGE_DATA_DIR "/images/1star.png", NULL, col5, ETK_FALSE, NULL); @@ -82,7 +82,7 @@ row = etk_tree_row_append(ETK_TREE(tree), row, col1, etk_theme_icon_get(), stock_key, row_name, col2, 20.0, - col3, 19, + col3, 19, col4, PACKAGE_DATA_DIR "/images/2stars.png", NULL, col5, ETK_TRUE, NULL); @@ -107,7 +107,7 @@ ETK_CALLBACK(_etk_test_tree_key_down_cb), NULL); etk_signal_connect("row_clicked", ETK_OBJECT(tree), ETK_CALLBACK(_etk_test_tree_row_clicked_cb), statusbar); - etk_signal_connect("cell_value_changed", ETK_OBJECT(col4), + etk_signal_connect("cell_value_changed", ETK_OBJECT(col5), ETK_CALLBACK(_etk_test_tree_checkbox_toggled_cb), statusbar); etk_widget_show_all(win); |
From: Enlightenment C. <no...@cv...> - 2007-02-04 21:49:24
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_tree.c Log Message: * [Tree] Fix row prepending =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v retrieving revision 1.85 retrieving revision 1.86 diff -u -3 -r1.85 -r1.86 --- etk_tree.c 28 Jan 2007 22:57:06 -0000 1.85 +++ etk_tree.c 5 Feb 2007 03:49:22 -0000 1.86 @@ -961,10 +961,9 @@ { new_row->prev = NULL; new_row->next = parent->first_child; - if (!parent->first_child) - parent->first_child = new_row; - else + if (parent->first_child) parent->first_child->prev = new_row; + parent->first_child = new_row; if (!parent->last_child) parent->last_child = new_row; } @@ -1226,7 +1225,6 @@ { Etk_Tree_Model *model; va_list args2; - int i; if (!row) return; |
From: Enlightenment C. <no...@cv...> - 2007-02-06 15:45:46
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_window.c etk_window.h Log Message: * [Window] center-on-window should be fixed (patch from saturn_vk) =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_window.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -3 -r1.42 -r1.43 --- etk_window.c 13 Jan 2007 19:29:19 -0000 1.42 +++ etk_window.c 6 Feb 2007 21:45:36 -0000 1.43 @@ -212,16 +212,27 @@ if (!window_to_center) return; + if (window_to_center->center_on_window) + { + etk_object_weak_pointer_remove(ETK_OBJECT(window), (void **)(&window_to_center->center_on_window)); + window_to_center->center_on_window = NULL; + } + + /* If the window has not been been resized yet, we can't center it already, + * so we queue the center-action for later */ if (window_to_center->wait_size_request) { - window_to_center->center = ETK_TRUE; window_to_center->center_on_window = window; if (window) etk_object_weak_pointer_add(ETK_OBJECT(window), (void **)(&window_to_center->center_on_window)); } + /* Otherwise we center it right now */ else { - etk_engine_mouse_screen_geometry_get(&x, &y, &w, &h); + if (window) + etk_window_geometry_get(window, &x, &y, &w, &h); + else + etk_engine_mouse_screen_geometry_get(&x, &y, &w, &h); etk_window_geometry_get(window_to_center, NULL, NULL, &cw, &ch); etk_window_move(window_to_center, x + (w - cw) / 2, y + (h - ch) / 2); } @@ -535,7 +546,6 @@ return; window->wait_size_request = ETK_TRUE; - window->center = ETK_FALSE; window->center_on_window = NULL; window->delete_event = _etk_window_delete_event_handler; @@ -700,12 +710,8 @@ window->wait_size_request = ETK_FALSE; if (etk_widget_is_visible(ETK_WIDGET(window))) etk_engine_window_show(window); - if (window->center) - { + if (window->center_on_window) etk_window_center_on_window(window, window->center_on_window); - window->center = ETK_FALSE; - window->center_on_window = NULL; - } } } } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_window.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- etk_window.h 27 Jan 2007 05:14:32 -0000 1.21 +++ etk_window.h 6 Feb 2007 21:45:36 -0000 1.22 @@ -40,7 +40,6 @@ Etk_Bool (*delete_event)(Etk_Window *window); Etk_Bool wait_size_request; - Etk_Bool center; Etk_Window *center_on_window; }; |
From: Enlightenment C. <no...@cv...> - 2007-02-13 20:31:18
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_colorpicker.c Log Message: * Still nothing... =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_colorpicker.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- etk_colorpicker.c 28 Jan 2007 17:46:04 -0000 1.23 +++ etk_colorpicker.c 14 Feb 2007 02:31:02 -0000 1.24 @@ -24,7 +24,7 @@ void (*move_resize)(Etk_Colorpicker *cp, int x, int y, int w, int h); } Etk_Colorpicker_Picker_SD; -enum Etk_Combobox_Signal_Id +enum Etk_Colorpicker_Signal_Id { ETK_CP_COLOR_CHANGED_SIGNAL, ETK_CP_NUM_SIGNALS |
From: Enlightenment C. <no...@cv...> - 2007-02-17 12:28:22
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_dialog.c Log Message: * [Dialog] Fix a potential bug with etk_dialog_action_area_alignment_set() and document the new "action_area_align" property =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_dialog.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- etk_dialog.c 17 Feb 2007 17:27:08 -0000 1.14 +++ etk_dialog.c 17 Feb 2007 18:28:19 -0000 1.15 @@ -63,7 +63,8 @@ etk_type_property_add(dialog_type, "has_separator", ETK_DIALOG_HAS_SEPARATOR_PROPERTY, ETK_PROPERTY_BOOL, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_bool(ETK_TRUE)); - etk_type_property_add(dialog_type, "action_area_align", ETK_DIALOG_ACTION_AREA_ALIGN_PROPERTY, ETK_PROPERTY_FLOAT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_float(0.5)); + etk_type_property_add(dialog_type, "action_area_align", ETK_DIALOG_ACTION_AREA_ALIGN_PROPERTY, + ETK_PROPERTY_FLOAT, ETK_PROPERTY_READABLE_WRITABLE, etk_property_value_float(0.5)); dialog_type->property_set = _etk_dialog_property_set; dialog_type->property_get = _etk_dialog_property_get; @@ -188,14 +189,13 @@ */ void etk_dialog_action_area_alignment_set(Etk_Dialog *dialog, float align) { - float yalign, xscale, yscale; - - etk_alignment_get(ETK_ALIGNMENT(dialog->action_area_alignment), NULL, &yalign, &xscale, &yscale); - etk_alignment_set(ETK_ALIGNMENT(dialog->action_area_alignment), align, yalign, xscale, yscale); + if (!dialog) + return; if (dialog->align != align) { dialog->align = align; + etk_alignment_set(ETK_ALIGNMENT(dialog->action_area_alignment), align, 0.5, 0.0, 0.0); etk_object_notify(ETK_OBJECT(dialog), "action_area_align"); } } @@ -208,7 +208,7 @@ void etk_dialog_action_area_alignment_get(Etk_Dialog *dialog, float *align) { if (align) - *align = dialog ? dialog->align : 0; + *align = dialog ? dialog->align : 0.0; } /** @@ -301,6 +301,7 @@ etk_widget_internal_set(dialog->action_area_hbox, ETK_TRUE); etk_widget_show(dialog->action_area_hbox); + dialog->align = 0.5; dialog->has_separator = ETK_TRUE; } @@ -404,4 +405,10 @@ * @prop_type Boolean * @prop_rw * @prop_val ETK_TRUE + * \par: + * @prop_name "action_area_align": The horizontal alignment of the widgets in the action area, + * from 0.0 (left) to 1.0 (right) + * @prop_type Float + * @prop_rw + * @prop_val 0.5 */ |
From: Enlightenment C. <no...@cv...> - 2007-02-17 12:39:22
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/src/lib Modified Files: etk_label.c etk_widget.c Log Message: * [Widget] The theme-object can now be used as a normal member-object. It fixes some placement problems with labels. * [Label] Some cleanup =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_label.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- etk_label.c 28 Jan 2007 18:39:07 -0000 1.26 +++ etk_label.c 17 Feb 2007 18:39:18 -0000 1.27 @@ -2,6 +2,7 @@ #include "etk_label.h" #include <stdlib.h> #include <string.h> +#include <Edje.h> #include "etk_signal.h" #include "etk_signal_callback.h" #include "etk_utils.h" @@ -82,19 +83,14 @@ if (text != label->text) { - free(label->text); - label->text = (text && *text != '\0') ? strdup(text) : NULL; + free(label->text); + label->text = (text && *text != '\0') ? strdup(text) : NULL; } - if (ETK_WIDGET(label)->theme_object) - { - if (!label->text) - etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", ""); - else - etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", label->text); - } -/* if (label->text_object)*/ -/* evas_object_textblock_text_markup_set(label->text_object, label->text ? label->text : " ");*/ + if (!label->text) + etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", ""); + else + etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", label->text); etk_widget_size_recalc_queue(ETK_WIDGET(label)); } @@ -253,6 +249,7 @@ requested_size->w = 0; requested_size->h = 0; + /* TODO: We no longer need to implement size_request() actually */ if (ETK_WIDGET(label)->theme_object) edje_object_size_min_calc(ETK_WIDGET(label)->theme_object, &requested_size->w, &requested_size->h); } @@ -267,7 +264,8 @@ return; _etk_label_size_request(widget, &requested_size); - evas_object_move(ETK_WIDGET(label)->theme_object, geometry.x + (geometry.w - requested_size.w) * label->xalign, + evas_object_move(ETK_WIDGET(label)->theme_object, + geometry.x + (geometry.w - requested_size.w) * label->xalign, geometry.y + (geometry.h - requested_size.h) * label->yalign); evas_object_resize(ETK_WIDGET(label)->theme_object, requested_size.w, requested_size.h); } @@ -285,8 +283,11 @@ if (!(label = ETK_LABEL(object))) return; - - etk_label_set(label, label->text); + + if (!label->text) + etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", ""); + else + etk_widget_theme_part_text_set(ETK_WIDGET(label), "etk.text.textblock", label->text); etk_widget_size_recalc_queue(ETK_WIDGET(label)); } =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_widget.c,v retrieving revision 1.94 retrieving revision 1.95 diff -u -3 -r1.94 -r1.95 --- etk_widget.c 3 Feb 2007 19:27:58 -0000 1.94 +++ etk_widget.c 17 Feb 2007 18:39:18 -0000 1.95 @@ -3269,7 +3269,10 @@ } if (widget->theme_object) - evas_object_move(widget->theme_object, widget->geometry.x, widget->geometry.y); + { + evas_object_geometry_get(widget->theme_object, &child_x, &child_y, NULL, NULL); + evas_object_move(widget->theme_object, child_x + x_offset, child_y + y_offset); + } if (widget->event_object) evas_object_move(widget->event_object, widget->geometry.x, widget->geometry.y); /* Move the member-objects and the children to the right place */ |
From: Enlightenment C. <no...@cv...> - 2007-02-18 10:53:38
|
Enlightenment CVS committal Author : moom Project : e17 Module : libs/etk Dir : e17/libs/etk/data/themes/default/macros Added Files: style.edc Log Message: * [Theme] Rename label's part "etk.text.textblock" to "etk.text.label" and tree's part "etk.text.text" to "etk.text.label" * [Theme] Each widget now have its own label's theme-group. You can thus use different label styles for different widgets * [Widget] Theme-children can now emits automatically the same theme-signals as their theme-parents... this is used for the labels to make them reactive to signals like "etk,state,pressed", "etk,state,released", ... * All existing themes are broken * |