Enlightenment CVS committal Author : jethomas Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_enums.h ewl_scrollpane.c ewl_scrollpane.h ewl_tree.c ewl_tree.h Log Message: Add kinetic scrolling ability to tree and scrollpane. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_enums.h,v retrieving revision 1.84 retrieving revision 1.85 diff -u -3 -r1.84 -r1.85 --- ewl_enums.h 14 Nov 2007 20:07:58 -0000 1.84 +++ ewl_enums.h 20 Jan 2008 05:06:12 -0000 1.85 @@ -878,6 +878,21 @@ typedef enum Ewl_Filelist_View Ewl_Filelist_View; /** + * @enum Ewl_Kinetic_Scroll + * The type of kinetic scrolling + */ +enum Ewl_Kinetic_Scroll +{ + EWL_KINETIC_SCROLL_NONE, + EWL_KINETIC_SCROLL_NORMAL, +}; + +/* + * The Ewl_Kinetic_Scroll + */ +typedef enum Ewl_Kinetic_Scroll Ewl_Kinetic_Scroll; + +/** * @} */ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollpane.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- ewl_scrollpane.c 5 Dec 2007 16:44:53 -0000 1.29 +++ ewl_scrollpane.c 20 Jan 2008 05:06:12 -0000 1.30 @@ -8,6 +8,13 @@ #include "ewl_private.h" #include "ewl_debug.h" +void ewl_scrollpane_cb_mouse_down(Ewl_Widget *w, void *ev, void *data); +void ewl_scrollpane_cb_mouse_up(Ewl_Widget *w, void *ev, void *data); +void ewl_scrollpane_cb_mouse_move(Ewl_Widget *w, void *ev, void *data); +static int ewl_scrollpane_cb_scroll_timer(void *data); +void ewl_scrollpane_cb_scroll(Ewl_Scrollpane *s, double x, double y, + int *tx, int *ty); + /** * @return Returns a new scrollpane on success, NULL on failure. * @brief Create a new scrollpane @@ -117,10 +124,83 @@ ewl_callback_append(w, EWL_CALLBACK_MOUSE_WHEEL, ewl_scrollpane_cb_wheel_scroll, NULL); + /* + * Setup kinetic scrolling info here + */ + s->kinfo = NULL; + s->type = EWL_KINETIC_SCROLL_NONE; + DRETURN_INT(TRUE, DLEVEL_STABLE); } /** + * @param s: The scrollpane to setup + * @param use: To use kinetic scrolling or not + * @return Returns no value + * @brief Sets up default values and callbacks for kinetic scrolling + */ +void +ewl_scrollpane_kinetic_scrolling_set(Ewl_Scrollpane *s, Ewl_Kinetic_Scroll type) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); + + if ((s->type) && (type == s->type)) + DRETURN(DLEVEL_STABLE); + + if (type == EWL_KINETIC_SCROLL_NORMAL) + { + /* If true, then set up */ + if (!s->kinfo) + { + s->kinfo = NEW(Ewl_Scrollpane_Scroll_Info, 1); + s->kinfo->fps = 15; + s->kinfo->vmax = 50.0; + s->kinfo->vmin = 0.0; + s->kinfo->dampen = 0.95; + } + + ewl_callback_append(s->overlay, EWL_CALLBACK_MOUSE_DOWN, + ewl_scrollpane_cb_mouse_down, s); + ewl_callback_append(s->overlay, EWL_CALLBACK_MOUSE_UP, + ewl_scrollpane_cb_mouse_up, s); + ewl_callback_append(s->overlay, EWL_CALLBACK_MOUSE_MOVE, + ewl_scrollpane_cb_mouse_move, s); + } + + /* Only delete the callbacks if they were there originally */ + else if ((s->type != EWL_KINETIC_SCROLL_NONE) && + (type == EWL_KINETIC_SCROLL_NONE)) + { + ewl_callback_del(s->overlay, EWL_CALLBACK_MOUSE_DOWN, + ewl_scrollpane_cb_mouse_down); + ewl_callback_del(s->overlay, EWL_CALLBACK_MOUSE_UP, + ewl_scrollpane_cb_mouse_up); + ewl_callback_del(s->overlay, EWL_CALLBACK_MOUSE_MOVE, + ewl_scrollpane_cb_mouse_move); + } + + s->type = type; + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param s: The scrollpane to use + * @return Returns the type of scrolling used + * @brief Gets the type of kinetic scrolling used + */ +Ewl_Kinetic_Scroll +ewl_scrollpane_kinetic_scrolling_get(Ewl_Scrollpane *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(s, EWL_KINETIC_SCROLL_NONE); + DCHECK_TYPE_RET(s, EWL_SCROLLPANE_TYPE, EWL_KINETIC_SCROLL_NONE); + + DRETURN_INT(s->type, DLEVEL_STABLE); +} + +/** * @param s: the scrollpane that contains the scrollbar to change * @param f: the flags to set on the horizontal scrollbar in @a s * @return Returns no value. @@ -624,6 +704,300 @@ ewl_scrollpane_vscrollbar_value_set(s, ewl_scrollpane_vscrollbar_value_get(s) + ev->z * ewl_scrollpane_vscrollbar_step_get(s)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @ev_data: The Ewl_Event_Mouse_Down data + * @param data: UNUSED + * @return Returns no value + * @brief The mouse down setting up kinetic scrolling + */ +void +ewl_scrollpane_cb_mouse_down(Ewl_Widget *w, void *ev, void *data) +{ + Ewl_Scrollpane *s; + Ewl_Event_Mouse *md; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(ev); + DCHECK_PARAM_PTR(data); + DCHECK_TYPE(w, EWL_WIDGET_TYPE); + + s = EWL_SCROLLPANE(data); + md = EWL_EVENT_MOUSE(ev); + s->kinfo->vel_x = 0.0; + s->kinfo->vel_y = 0.0; + s->kinfo->x = md->x; + s->kinfo->y = md->y; + s->kinfo->clicked = !!TRUE; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @ev_data: The Ewl_Event_Mouse_Move data + * @param data: UNUSED + * @return Returns no value + * @brief The mouse move callback for kinetic scrolling + */ +void +ewl_scrollpane_cb_mouse_move(Ewl_Widget *w, void *ev, void *data) +{ + Ewl_Scrollpane *s; + Ewl_Event_Mouse *mm; + int cx, cy; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(ev); + DCHECK_PARAM_PTR(data); + + s = EWL_SCROLLPANE(data); + mm = EWL_EVENT_MOUSE(ev); + + if (!s->kinfo->clicked) + DRETURN(DLEVEL_STABLE); + + if (!s->kinfo->active) + { + ecore_timer_add(1.0/s->kinfo->fps, + ewl_scrollpane_cb_scroll_timer, s); + s->kinfo->active = !!TRUE; + } + + s->kinfo->xc = mm->x; + s->kinfo->yc = mm->y; + cx = (s->kinfo->xc - s->kinfo->x); + cy = (s->kinfo->yc - s->kinfo->y); + + /* v = (change in position / (width or height of scroll * + * (range of velocities) + min)) + */ + s->kinfo->vel_x = ((cx / + (double)ewl_object_current_w_get(EWL_OBJECT(w))) * + (s->kinfo->vmax - s->kinfo->vmin)) + s->kinfo->vmin; + + s->kinfo->vel_y = ((cy / + (double)ewl_object_current_h_get(EWL_OBJECT(w))) * + (s->kinfo->vmax - s->kinfo->vmin)) + s->kinfo->vmin; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to work with + * @ev_data: The Ewl_Event_Mouse_Up data + * @param data: UNUSED + * @return Returns no value + * @brief The mouse up callback for kinetic scrolling + */ +void +ewl_scrollpane_cb_mouse_up(Ewl_Widget *w, void *ev, void *data) +{ + Ewl_Scrollpane *s; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(data); + + s = EWL_SCROLLPANE(data); + s->kinfo->clicked = !!FALSE; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + +/** + * @internal + * @param data: The scrollpane to work with + * @return Returns 1 if the timer is to continue, 0 otherwise + * @brief Performs some calculations then calls the scroll function + */ +static int ewl_scrollpane_cb_scroll_timer(void *data) +{ + Ewl_Scrollpane *s; + double h, w; + int tx = 0, ty = 0; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(data, FALSE); + + s = EWL_SCROLLPANE(data); + + /* If the mouse is down, accelerate and check velocity */ + if (!s->kinfo->clicked) + { + s->kinfo->vel_x *= s->kinfo->dampen; + s->kinfo->vel_y *= s->kinfo->dampen; + + h = s->kinfo->vel_y * ((s->kinfo->vel_y < 0) ? -1 : 1); + w = s->kinfo->vel_x * ((s->kinfo->vel_x < 0) ? -1 : 1); + + if ((w < 0.5) && (h < 0.5)) + { + s->kinfo->active = !!FALSE; + DRETURN_INT(0, DLEVEL_STABLE); + } + } + + /* Actually scroll the pane */ + ewl_scrollpane_cb_scroll(s, s->kinfo->vel_x, s->kinfo->vel_y, &tx, &ty); + + /* If at the end of a scrollbar, set x/y to current */ + if (!tx) + s->kinfo->x = s->kinfo->xc; + if (!ty) + s->kinfo->y = s->kinfo->yc; + + DRETURN_INT(1, DLEVEL_STABLE); +} + +/** + * @internal + * @param s: The scrollpane to work with + * @param x: The horizontal velocity + * @param y: The vertical velocity + * @param tx: Pointer to integer tested + * @param ty: Pointer to integer tested + * @return Returns no value + * @brief Scrolls the scrollpane based on the given parameters + */ +void +ewl_scrollpane_cb_scroll(Ewl_Scrollpane *s, double x, double y, + int *tx, int *ty) +{ + double w, h; + Ewl_Scrollbar *ry, *rx; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); + + ry = EWL_SCROLLBAR(s->vscrollbar); + rx = EWL_SCROLLBAR(s->hscrollbar); + + if (!((ewl_scrollpane_vscrollbar_value_get(s) == 1.0) && + (y > 0)) && + !((ewl_scrollpane_vscrollbar_value_get(s) == 0.0) && + (y < 0))) + { + h = ewl_scrollpane_vscrollbar_value_get(s) + (y * + ewl_scrollpane_vscrollbar_step_get(s) / 100); + + /* If h is greater than possible setting, set to remainder */ + if (h > ewl_range_maximum_value_get(EWL_RANGE(ry->seeker))) + { + h = ewl_range_maximum_value_get(EWL_RANGE(ry->seeker)); + if (ty) *ty = FALSE; + } + else if (h < ewl_range_minimum_value_get(EWL_RANGE(ry->seeker))) + { + h = ewl_range_minimum_value_get(EWL_RANGE(ry->seeker)); + if (ty) *ty = FALSE; + } + else + if (ty) *ty = TRUE; + + ewl_scrollpane_vscrollbar_value_set(s, h); + } + + if (!((ewl_scrollpane_hscrollbar_value_get(s) == 1.0) && + (x > 0)) && + !((ewl_scrollpane_hscrollbar_value_get(s) == 0.0) && + (x < 0))) + { + w = ewl_scrollpane_hscrollbar_value_get(s) + (x * + ewl_scrollpane_hscrollbar_step_get(s) / 100); + + /* And again for the w */ + if (w > ewl_range_maximum_value_get(EWL_RANGE(rx->seeker))) + { + w = ewl_range_maximum_value_get(EWL_RANGE(rx->seeker)); + if (tx) *tx = FALSE; + } + else if (w < ewl_range_minimum_value_get(EWL_RANGE(rx->seeker))) + { + w = ewl_range_minimum_value_get(EWL_RANGE(rx->seeker)); + if (tx) *tx = FALSE; + } + else + if (tx) *tx = TRUE; + + ewl_scrollpane_hscrollbar_value_set(s, w); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/* + * @param s: The scrollpane to work with + * @param w: The maximum velocity + * @return Returns no value + * @brief Sets the maximum velocity for kinetic scrolling + */ +void +ewl_scrollpane_kinetic_max_velocity_set(Ewl_Scrollpane *s, double v) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + + if (v) s->kinfo->vmax = v; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/* + * @param s: The scrollpane to work with + * @param w: The minimum velocity + * @return Returns no value + * @brief Sets the minimum velocity for kinetic scrolling + */ +void +ewl_scrollpane_kinetic_min_velocity_set(Ewl_Scrollpane *s, double v) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + + if (v) s->kinfo->vmin = v; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/* + * @param s: The scrollpane to work with + * @param w: The multiplier to reduce velocity + * @return Returns no value + * @brief Sets the multiplier to reduce the velocity of kinetic scrolling + */ +void +ewl_scrollpane_kinetic_dampen_set(Ewl_Scrollpane *s, double d) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + + if (d) s->kinfo->dampen = d; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/* + * @param s: The scrollpane to work with + * @param w: The desired frames per second + * @return Returns no value + * @brief Sets the number of times per second to recalculate velocity and update the tree + */ +void +ewl_scrollpane_kinetic_fps_set(Ewl_Scrollpane *s, int fps) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(s); + + if (fps) s->kinfo->fps = fps; DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollpane.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_scrollpane.h 13 Nov 2007 06:03:16 -0000 1.19 +++ ewl_scrollpane.h 20 Jan 2008 05:06:12 -0000 1.20 @@ -33,6 +33,36 @@ #define EWL_SCROLLPANE_IS(w) (ewl_widget_type_is(EWL_WIDGET(w), EWL_SCROLLPANE_TYPE)) /** + * The scrollpane can be scolled with a drag of the mouse + */ +typedef struct Ewl_Scrollpane_Scroll_Info Ewl_Scrollpane_Scroll_Info; + +/** + * @def EWL_SCROLLPANE_SCROLL_INFO(scroll_info) + * Typecasts a pointer to an Ewl_Scrollpane_Scroll_Info pointer. + */ +#define EWL_SCROLLPANE_SCROLL_INFO(scroll_info) ((Ewl_Scrollpane_Scroll_Info *) scroll_info) + +/** + * @brief Enables a scrollpane to be scrolled with kinetic behaviour + */ +struct Ewl_Scrollpane_Scroll_Info +{ + unsigned char clicked:1; /**< If the mouse is currently clicked or not */ + unsigned char active:1; /**< If the pane is currently moving */ + int fps; /**< Number of recalculations per second */ + int x; /**< Mouse down location (x) */ + int y; /**< Mouse down location (y) */ + int xc; /**< Mouse up location (x) */ + int yc; /**< Mouse up location (y) */ + double vel_x; /**< Current horizontal velocity */ + double vel_y; /**< Current vertical */ + double vmax; /**< Maximum speed in pixels */ + double vmin; /**< Minimum speed in pixels */ + double dampen; /**< Frictional variable */ +}; + +/** * The scrollpane provides a way to pan around large collections of images. */ typedef struct Ewl_Scrollpane Ewl_Scrollpane; @@ -58,10 +88,19 @@ Ewl_Widget *vscrollbar; /**< Vertical scrollbar */ Ewl_Scrollpane_Flags hflag; /**< Flags for horizontal scrollbar */ Ewl_Scrollpane_Flags vflag; /**< Flags for vertical scrollbar */ + Ewl_Scrollpane_Scroll_Info *kinfo; /**< Kinetic scrolling info */ + Ewl_Kinetic_Scroll type; /**< If the scrollpane is to use kinetic scrolling */ }; Ewl_Widget *ewl_scrollpane_new(void); int ewl_scrollpane_init(Ewl_Scrollpane *s); +void ewl_scrollpane_kinetic_scrolling_set(Ewl_Scrollpane *s, + Ewl_Kinetic_Scroll type); +Ewl_Kinetic_Scroll ewl_scrollpane_kinetic_scrolling_get(Ewl_Scrollpane *s); +void ewl_scrollpane_kinetic_max_velocity_set(Ewl_Scrollpane *s, double v); +void ewl_scrollpane_kinetic_min_velocity_set(Ewl_Scrollpane *s, double v); +void ewl_scrollpane_kinetic_dampen_set(Ewl_Scrollpane *s, double d); +void ewl_scrollpane_kinetic_fps_set(Ewl_Scrollpane *s, int fps); void ewl_scrollpane_hscrollbar_flag_set(Ewl_Scrollpane *s, Ewl_Scrollpane_Flags f); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -3 -r1.55 -r1.56 --- ewl_tree.c 11 Dec 2007 05:51:22 -0000 1.55 +++ ewl_tree.c 20 Jan 2008 05:06:12 -0000 1.56 @@ -8,6 +8,7 @@ #include "ewl_label.h" #include "ewl_paned.h" #include "ewl_tree_view_scrolled.h" +#include "ewl_scrollpane.h" #include "ewl_private.h" #include "ewl_macros.h" #include "ewl_debug.h" @@ -41,6 +42,7 @@ static Ewl_Tree_Expansions_List *ewl_tree_expansions_list_new(void); static void ewl_tree_expansions_list_destroy(Ewl_Tree_Expansions_List *el); +Ewl_Scrollpane *ewl_tree_kinetic_scrollpane_get(Ewl_Tree *tree); /** * @return Returns NULL on failure, a new tree widget on success. @@ -107,6 +109,7 @@ ewl_tree_headers_visible_set(tree, TRUE); ewl_tree_fixed_rows_set(tree, FALSE); ewl_tree_alternate_row_colors_set(tree, TRUE); + tree->scroll_type = EWL_KINETIC_SCROLL_NONE; ewl_callback_append(EWL_WIDGET(tree), EWL_CALLBACK_CONFIGURE, ewl_tree_cb_configure, NULL); @@ -1513,3 +1516,169 @@ ewl_tree_cb_node_child_add(c, w); } + +/** + * @param tree: The tree to set kinetic scrolling for + * @param type: The type of kinetic scrolling to use + * @return Returns no value + * @brief Sets up the tree to use kinetic scrolling + */ +void +ewl_tree_kinetic_scrolling_set(Ewl_Tree *tree, Ewl_Kinetic_Scroll type) +{ + Ewl_Scrollpane *scroll; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(tree); + DCHECK_TYPE(tree, EWL_TREE_TYPE); + + if (!type) + DRETURN(DLEVEL_STABLE); + + tree->scroll_type = type; + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ewl_scrollpane_kinetic_scrolling_set(EWL_SCROLLPANE(scroll), type); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param tree: The tree to use + * @return Returns the type of kinetic scrolling used + * @brief Gets the type of kinetic scrolling used + */ +Ewl_Kinetic_Scroll +ewl_tree_kinetic_scrolling_get(Ewl_Tree *tree) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, EWL_KINETIC_SCROLL_NONE); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, EWL_KINETIC_SCROLL_NONE); + + DRETURN_INT(tree->scroll_type, DLEVEL_STABLE); +} + +/** + * @param tree: The tree to work with + * @param v: The maximum velocity + * @return Returns no value + * @brief Sets the maximum velocity for kinetic scrolling + */ +void +ewl_tree_kinetic_max_velocity_set(Ewl_Tree *tree, double v) +{ + Ewl_Scrollpane *scroll; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(tree); + DCHECK_TYPE(tree, EWL_TREE_TYPE); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ewl_scrollpane_kinetic_max_velocity_set(scroll, v); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param tree: The tree to work with + * @param v: The minimum velocity + * @return Returns no value + * @brief Sets the minimum velocity for kinetic scrolling + */ +void +ewl_tree_kinetic_min_velocity_set(Ewl_Tree *tree, double v) +{ + Ewl_Scrollpane *scroll; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(tree); + DCHECK_TYPE(tree, EWL_TREE_TYPE); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ewl_scrollpane_kinetic_min_velocity_set(scroll, v); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param tree: The tree to work with + * @param d: The multiplier to reduce velocity + * @return Returns no value + * @brief Sets the multiplier to reduce the velocity of kinetic scrolling + */ +void +ewl_tree_kinetic_dampen_set(Ewl_Tree *tree, double d) +{ + Ewl_Scrollpane *scroll; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(tree); + DCHECK_TYPE(tree, EWL_TREE_TYPE); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ewl_scrollpane_kinetic_dampen_set(scroll, d); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + +/** + * @param tree: The tree to work with + * @param d: The multiplier to reduce velocity + * @return Returns no value + * @brief Sets the multiplier to reduce the velocity of kinetic scrolling + */ +void +ewl_tree_kinetic_fps_set(Ewl_Tree *tree, int fps) +{ + Ewl_Scrollpane *scroll; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(tree); + DCHECK_TYPE(tree, EWL_TREE_TYPE); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ewl_scrollpane_kinetic_fps_set(scroll, fps); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param tree: The tree to work with + * @return Returns the scrollpane used in the view + * @brief A helper function for setting kinetic scrolling variables + */ +Ewl_Scrollpane * +ewl_tree_kinetic_scrollpane_get(Ewl_Tree *tree) +{ + Ewl_Widget *s; + Ewl_Container *scroll, *temp; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, NULL); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, NULL); + + s = ewl_tree_content_widget_get(tree); + scroll = ewl_container_redirect_get(EWL_CONTAINER(s)); + + while (!ewl_widget_type_is(EWL_WIDGET(scroll), EWL_SCROLLPANE_TYPE)) + { + temp = scroll; + scroll = ewl_container_redirect_get(temp); + + if (!scroll) + { + DWARNING("No scrollpane to use for kinetic scrolling"); + DRETURN_PTR(NULL, DLEVEL_STABLE); + } + } + + DRETURN_PTR(EWL_SCROLLPANE(scroll), DLEVEL_STABLE); +} + + =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree.h,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ewl_tree.h 11 Dec 2007 05:51:22 -0000 1.30 +++ ewl_tree.h 20 Jan 2008 05:06:12 -0000 1.31 @@ -119,6 +119,8 @@ unsigned char fixed:1; /**< Rows are fixed height */ unsigned char headers_visible:1; /**< Are the headers visible? */ unsigned char row_color_alternate:1; /**< Are the rows alternating? */ + + Ewl_Kinetic_Scroll scroll_type; /**< Type of kinetic scrolling */ }; /* @@ -158,6 +160,14 @@ unsigned int ewl_tree_row_expanded_is(Ewl_Tree *tree, void *data, unsigned int row); + +void ewl_tree_kinetic_scrolling_set(Ewl_Tree *tree, + Ewl_Kinetic_Scroll type); +Ewl_Kinetic_Scroll ewl_tree_kinetic_scrolling_get(Ewl_Tree *tree); +void ewl_tree_kinetic_max_velocity_set(Ewl_Tree *tree, double v); +void ewl_tree_kinetic_min_velocity_set(Ewl_Tree *tree, double v); +void ewl_tree_kinetic_dampen_set(Ewl_Tree *tree, double d); +void ewl_tree_kinetic_fps_set(Ewl_Tree *tree, int fps); /* * Internal stuff. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs