Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_box.c ewl_box.h ewl_scrollbar.c ewl_scrollbar.h 


Log Message:
Scrollbars now continuously scroll while holding down the arrow buttons. Might
need some tweaking for the speed.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_box.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -3 -r1.54 -r1.55
--- ewl_box.c   29 Sep 2003 21:46:50 -0000      1.54
+++ ewl_box.c   10 Oct 2003 21:42:28 -0000      1.55
@@ -179,6 +179,19 @@
 }
 
 /**
+ * @param b: the box to retrieve orientation
+ * @return Returns the orientation value of the box @a b.
+ * @brief Retrieves the orientation of the box
+ */
+Ewl_Orientation ewl_box_get_orientation(Ewl_Box *b)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("b", b, 0);
+
+       DRETURN_INT(b->orientation, DLEVEL_STABLE);
+}
+
+/**
  * @param b: the box to change homogeneous layout
  * @param h: the boolean value to change the layout mode to
  * @return Returns no value.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_box.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- ewl_box.h   6 Oct 2003 17:39:53 -0000       1.25
+++ ewl_box.h   10 Oct 2003 21:42:28 -0000      1.26
@@ -59,6 +59,7 @@
 Ewl_Widget     *ewl_box_new(Ewl_Orientation orientation);
 int             ewl_box_init(Ewl_Box * box, Ewl_Orientation orientation);
 void            ewl_box_set_orientation(Ewl_Box * b, Ewl_Orientation o);
+Ewl_Orientation ewl_box_get_orientation(Ewl_Box * b);
 void            ewl_box_set_spacing(Ewl_Box * b, int spacing);
 void            ewl_box_set_homogeneous(Ewl_Box *b, int h);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- ewl_scrollbar.c     29 Sep 2003 21:46:51 -0000      1.24
+++ ewl_scrollbar.c     10 Oct 2003 21:42:28 -0000      1.25
@@ -2,11 +2,13 @@
 #include <Ewl.h>
 
 
-void            __ewl_scrollbar_decrement(Ewl_Widget * w, void *ev_data,
+void            __ewl_scrollbar_scroll_start(Ewl_Widget * w, void *ev_data,
                                          void *user_data);
-void            __ewl_scrollbar_increment(Ewl_Widget * w, void *ev_data,
+void            __ewl_scrollbar_scroll_stop(Ewl_Widget * w, void *ev_data,
                                          void *user_data);
 
+int             __ewl_scrollbar_timer(void *data);
+
 
 /**
  * @param orientation: the desired orientation of the scrollbar
@@ -84,18 +86,30 @@
        if (orientation == EWL_ORIENTATION_HORIZONTAL) {
                ewl_callback_append(s->button_increment,
                                EWL_CALLBACK_MOUSE_DOWN,
-                               __ewl_scrollbar_increment, s);
+                               __ewl_scrollbar_scroll_start, s);
+               ewl_callback_append(s->button_increment,
+                               EWL_CALLBACK_MOUSE_UP,
+                               __ewl_scrollbar_scroll_stop, s);
                ewl_callback_append(s->button_decrement,
                                EWL_CALLBACK_MOUSE_DOWN,
-                               __ewl_scrollbar_decrement, s);
+                               __ewl_scrollbar_scroll_start, s);
+               ewl_callback_append(s->button_decrement,
+                               EWL_CALLBACK_MOUSE_UP,
+                               __ewl_scrollbar_scroll_stop, s);
        }
        else {
                ewl_callback_append(s->button_increment,
                                EWL_CALLBACK_MOUSE_DOWN,
-                               __ewl_scrollbar_decrement, s);
+                               __ewl_scrollbar_scroll_start, s);
+               ewl_callback_append(s->button_increment,
+                               EWL_CALLBACK_MOUSE_UP,
+                               __ewl_scrollbar_scroll_stop, s);
                ewl_callback_append(s->button_decrement,
                                EWL_CALLBACK_MOUSE_DOWN,
-                               __ewl_scrollbar_increment, s);
+                               __ewl_scrollbar_scroll_start, s);
+               ewl_callback_append(s->button_decrement,
+                               EWL_CALLBACK_MOUSE_UP,
+                               __ewl_scrollbar_scroll_stop, s);
        }
 
        /*
@@ -348,55 +362,85 @@
 /*
  * Decrement the value of the scrollbar's seeker portion
  */
-void __ewl_scrollbar_decrement(Ewl_Widget * w, void *ev_data, void *user_data)
+void
+__ewl_scrollbar_scroll_start(Ewl_Widget * w, void *ev_data, void *user_data)
 {
-       double          v;
        Ewl_Scrollbar  *s;
+       Ewl_Orientation o;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
        s = EWL_SCROLLBAR(user_data);
+       if (w == s->button_increment)
+               s->direction = 1;
+       else
+               s->direction = -1;
 
        /*
-        * ewl_seeker_decrease(EWL_SEEKER(s->seeker));
+        * Need to scroll in the opposite direction for the vertical
+        * scrollbar.
         */
+       o = ewl_box_get_orientation(EWL_BOX(s));
+       if (o == EWL_ORIENTATION_VERTICAL)
+               s->direction = -s->direction;
 
-       v = ewl_seeker_get_value(EWL_SEEKER(s->seeker));
-       v -= 0.05;
+       s->start_time = ecore_time_get();
+       s->timer = ecore_timer_add(0.02, __ewl_scrollbar_timer, s);
 
-       if (v < 0.0)
-               v = 0.0;
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
 
-       ewl_seeker_set_value(EWL_SEEKER(s->seeker), v);
+void
+__ewl_scrollbar_scroll_stop(Ewl_Widget * w, void *ev_data, void *user_data)
+{
+       Ewl_Scrollbar *s;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       s = EWL_SCROLLBAR(user_data);
+
+       ecore_timer_del(s->timer);
+
+       s->timer = NULL;
+       s->direction = 0;
+       s->start_time = 0;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-/*
- * Decrement the value of the scrollbar's seeker portion
- */
-void __ewl_scrollbar_increment(Ewl_Widget * w, void *ev_data, void *user_data)
+int __ewl_scrollbar_timer(void *data)
 {
-       double          v;
        Ewl_Scrollbar  *s;
+       double          dt;
+       double          value;
+       int             velocity;
+       char            tmp[PATH_MAX];
 
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
+       s = EWL_SCROLLBAR(data);
 
-       s = EWL_SCROLLBAR(user_data);
+       dt = ecore_time_get() - s->start_time;
+       value = ewl_seeker_get_value(EWL_SEEKER(s->seeker));
 
        /*
-        * ewl_seeker_increase(EWL_SEEKER(s->seeker));
+        * Check the theme for a velocity setting and bring it within normal
+        * useable bounds.
         */
+       snprintf(tmp, PATH_MAX, "%s/velocity", EWL_WIDGET(s)->appearance);
+       velocity = ewl_theme_data_get_int(EWL_WIDGET(s), tmp);
+       if (velocity < 1)
+               velocity = 1;
+       else if (velocity > 10)
+               velocity = 10;
 
-       v = ewl_seeker_get_value(EWL_SEEKER(s->seeker));
-       v += 0.05;
-
-       if (v > 1.0)
-               v = 1.0;
+       /*
+        * Move the value of the seeker based on the direction of it's motion
+        * and the velocity setting.
+        */
+       value += (double)(s->direction) * 10 * (1 - exp(-dt)) *
+                ((double)(velocity) / 100.0);
 
-       ewl_seeker_set_value(EWL_SEEKER(s->seeker), v);
+       ewl_seeker_set_value(EWL_SEEKER(s->seeker), value);
 
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       return 1;
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_scrollbar.h     6 Oct 2003 17:39:55 -0000       1.10
+++ ewl_scrollbar.h     10 Oct 2003 21:42:28 -0000      1.11
@@ -52,7 +52,10 @@
        unsigned int    buttons_alignment; /**< The ordering of buttons */
 
        double          fill_percentage; /**< The ratio of size for draggable */
+       double          start_time; /**< Time scrolling began */
+       Ecore_Timer    *timer; /**< Repeating timer for scrolling */
        Ewl_ScrollBar_Flags flag; /**< Flags to indicate part visibility */
+       signed char     direction;
 };
 
 /**




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to