From: Enlightenment C. <no...@cv...> - 2008-01-23 01:51:33
|
Enlightenment CVS committal Author : jethomas Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_scrollpane.c ewl_scrollpane.h ewl_tree.c ewl_tree.h Log Message: Add a bunch of _get calls for kinetic scrollpane and tree. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollpane.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- ewl_scrollpane.c 20 Jan 2008 16:15:31 -0000 1.31 +++ ewl_scrollpane.c 23 Jan 2008 01:51:31 -0000 1.32 @@ -15,6 +15,7 @@ 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); +void ewl_scrollpane_cb_destroy(Ewl_Widget *w, void *ev, void *data); /** * @return Returns a new scrollpane on success, NULL on failure. @@ -128,8 +129,9 @@ /* * Setup kinetic scrolling info here */ - s->kinfo = NULL; - s->type = EWL_KINETIC_SCROLL_NONE; + ewl_scrollpane_kinetic_scrolling_set(s, EWL_KINETIC_SCROLL_NONE); + ewl_callback_append(w, EWL_CALLBACK_DESTROY, + ewl_scrollpane_cb_destroy, NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -147,21 +149,12 @@ DCHECK_PARAM_PTR(s); DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); + /* If set to current value we have nothing to do */ 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, @@ -171,8 +164,7 @@ } /* Only delete the callbacks if they were there originally */ - else if ((s->type != EWL_KINETIC_SCROLL_NONE) && - (type == EWL_KINETIC_SCROLL_NONE)) + else if ((s->type != EWL_KINETIC_SCROLL_NONE) && (s->kinfo)) { ewl_callback_del(s->overlay, EWL_CALLBACK_MOUSE_DOWN, ewl_scrollpane_cb_mouse_down); @@ -182,6 +174,16 @@ ewl_scrollpane_cb_mouse_move); } + /* Set up the scrollpane information */ + 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; + } + s->type = type; DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -935,7 +937,7 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } -/* +/** * @param s: The scrollpane to work with * @param w: The maximum velocity * @return Returns no value @@ -946,13 +948,29 @@ { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); - if (v) s->kinfo->vmax = v; + s->kinfo->vmax = v; DLEAVE_FUNCTION(DLEVEL_STABLE); } -/* +/** + * @param s: The scrollpane to work with + * @return Returns the maximum velocity + * @brief Gets the maximum velocity for kinetic scrolling + */ +double +ewl_scrollpane_kinetic_max_velocity_get(Ewl_Scrollpane *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(s, -1); + DCHECK_TYPE_RET(s, EWL_SCROLLPANE_TYPE, -1); + + DRETURN_INT(s->kinfo->vmax, DLEVEL_STABLE); +} + +/** * @param s: The scrollpane to work with * @param w: The minimum velocity * @return Returns no value @@ -963,13 +981,29 @@ { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); - if (v) s->kinfo->vmin = v; + s->kinfo->vmin = v; DLEAVE_FUNCTION(DLEVEL_STABLE); } -/* +/** + * @param s: The scrollpane to work with + * @return Returns the minimum velocity + * @brief Gets the minimum velocity for kinetic scrolling + */ +double +ewl_scrollpane_kinetic_min_velocity_get(Ewl_Scrollpane *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(s, -1); + DCHECK_TYPE_RET(s, EWL_SCROLLPANE_TYPE, -1); + + DRETURN_INT(s->kinfo->vmin, DLEVEL_STABLE); +} + +/** * @param s: The scrollpane to work with * @param w: The multiplier to reduce velocity * @return Returns no value @@ -980,13 +1014,29 @@ { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); - if (d) s->kinfo->dampen = d; + s->kinfo->dampen = d; DLEAVE_FUNCTION(DLEVEL_STABLE); } -/* +/** + * @param s: The scrollpane to work with + * @return Returns the minimum velocity + * @brief Gets the minimum velocity for kinetic scrolling + */ +double +ewl_scrollpane_kinetic_dampen_get(Ewl_Scrollpane *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(s, -1); + DCHECK_TYPE_RET(s, EWL_SCROLLPANE_TYPE, -1); + + DRETURN_INT(s->kinfo->vmin, DLEVEL_STABLE); +} + +/** * @param s: The scrollpane to work with * @param w: The desired frames per second * @return Returns no value @@ -997,8 +1047,44 @@ { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR(s); + DCHECK_TYPE(s, EWL_SCROLLPANE_TYPE); + + s->kinfo->fps = fps; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param s: The scrollpane to work with + * @return Returns the current frames per second + * brief Gets the times per second the timer used for scrolling will be called + */ +int +ewl_scrollpane_kinetic_fps_get(Ewl_Scrollpane *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(s, -1); + DCHECK_TYPE_RET(s, EWL_SCROLLPANE_TYPE, -1); + + DRETURN_INT(s->kinfo->fps, DLEVEL_STABLE); +} + +/** + * @internal + * @param w: The widget to use + * @parma ev: The event data + * @param data: User data + * @return Returns no value + * @brief Frees data from the scrollpane + */ +void +ewl_scrollpane_cb_destroy(Ewl_Widget *w, void *ev, void *data) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR(w); + DCHECK_TYPE(w, EWL_SCROLLPANE_TYPE); - if (fps) s->kinfo->fps = fps; + FREE(EWL_SCROLLPANE(w)->kinfo); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollpane.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- ewl_scrollpane.h 20 Jan 2008 05:06:12 -0000 1.20 +++ ewl_scrollpane.h 23 Jan 2008 01:51:31 -0000 1.21 @@ -89,7 +89,7 @@ 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_Kinetic_Scroll type; /**< If the scrollpane is to use kinetic scrolling */ }; Ewl_Widget *ewl_scrollpane_new(void); @@ -98,9 +98,13 @@ 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); +double ewl_scrollpane_kinetic_max_velocity_get(Ewl_Scrollpane *s); void ewl_scrollpane_kinetic_min_velocity_set(Ewl_Scrollpane *s, double v); +double ewl_scrollpane_kinetic_min_velocity_get(Ewl_Scrollpane *s); void ewl_scrollpane_kinetic_dampen_set(Ewl_Scrollpane *s, double d); +double ewl_scrollpane_kinetic_dampen_get(Ewl_Scrollpane *s); void ewl_scrollpane_kinetic_fps_set(Ewl_Scrollpane *s, int fps); +int ewl_scrollpane_kinetic_fps_get(Ewl_Scrollpane *s); 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.56 retrieving revision 1.57 diff -u -3 -r1.56 -r1.57 --- ewl_tree.c 20 Jan 2008 05:06:12 -0000 1.56 +++ ewl_tree.c 23 Jan 2008 01:51:31 -0000 1.57 @@ -1582,6 +1582,28 @@ /** * @param tree: The tree to work with + * @return Returns the maximum velocity of kinetic scrolling + * @brief Gets the maximum velocity for kinetic scrolling + */ +double +ewl_tree_kinetic_max_velocity_get(Ewl_Tree *tree) +{ + Ewl_Scrollpane *scroll; + double ret = -1.0; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, -1); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, -1); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ret = ewl_scrollpane_kinetic_max_velocity_get(scroll); + + DRETURN_INT(ret, 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 @@ -1604,6 +1626,28 @@ /** * @param tree: The tree to work with + * @return Returns the minimum velocity of kinetic scrolling + * @brief Gets the minimum velocity for kinetic scrolling + */ +double +ewl_tree_kinetic_min_velocity_get(Ewl_Tree *tree) +{ + Ewl_Scrollpane *scroll; + double ret = -1.0; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, -1); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, -1); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ret = ewl_scrollpane_kinetic_min_velocity_get(scroll); + + DRETURN_INT(ret, 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 @@ -1624,12 +1668,33 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } +/** + * @param tree: The tree to work with + * @return Returns the multiplier used to dampen in kinetic scrolling + * @brief Gets the multiplier used to reduce the velocity of kinetic scrolling + */ +double +ewl_tree_kinetic_dampen_get(Ewl_Tree *tree) +{ + Ewl_Scrollpane *scroll; + double ret = -1.0; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, -1); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, -1); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ret = ewl_scrollpane_kinetic_dampen_get(scroll); + + DRETURN_INT(ret, DLEVEL_STABLE); +} /** * @param tree: The tree to work with - * @param d: The multiplier to reduce velocity + * @param fps: The number of frames per second * @return Returns no value - * @brief Sets the multiplier to reduce the velocity of kinetic scrolling + * @brief Sets the number of times per second the tree scrolling is updated */ void ewl_tree_kinetic_fps_set(Ewl_Tree *tree, int fps) @@ -1645,6 +1710,28 @@ ewl_scrollpane_kinetic_fps_set(scroll, fps); DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param tree: The tree to work with + * @return Returns the number of frames per second + * @brief Gets the number of times per second the tree scrolling is updated + */ +int +ewl_tree_kinetic_fps_get(Ewl_Tree *tree) +{ + Ewl_Scrollpane *scroll; + int ret = -1; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET(tree, -1); + DCHECK_TYPE_RET(tree, EWL_TREE_TYPE, -1); + + scroll = ewl_tree_kinetic_scrollpane_get(tree); + if (scroll) + ret = ewl_scrollpane_kinetic_fps_get(scroll); + + DRETURN_INT(ret, DLEVEL_STABLE); } /** =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- ewl_tree.h 20 Jan 2008 05:06:12 -0000 1.31 +++ ewl_tree.h 23 Jan 2008 01:51:31 -0000 1.32 @@ -165,9 +165,13 @@ 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); +double ewl_tree_kinetic_max_velocity_get(Ewl_Tree *tree); void ewl_tree_kinetic_min_velocity_set(Ewl_Tree *tree, double v); +double ewl_tree_kinetic_min_velocity_get(Ewl_Tree *tree); void ewl_tree_kinetic_dampen_set(Ewl_Tree *tree, double d); +double ewl_tree_kinetic_dampen_get(Ewl_Tree *tree); void ewl_tree_kinetic_fps_set(Ewl_Tree *tree, int fps); +int ewl_tree_kinetic_fps_get(Ewl_Tree *tree); /* * Internal stuff. |