Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_seeker.c ewl_seeker.h 


Log Message:
Allow inverting the axis on the seeker.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_seeker.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -3 -r1.54 -r1.55
--- ewl_seeker.c        29 Mar 2004 05:54:59 -0000      1.54
+++ ewl_seeker.c        30 Mar 2004 21:55:17 -0000      1.55
@@ -275,6 +275,38 @@
 }
 
 /**
+ * @param s: the seeker to set invert property
+ * @param invert: the new value for the seekers invert property
+ * @return Returns no value.
+ * @brief Changes the invert property on the seeker for inverting it's scale.
+ */
+void ewl_seeker_set_invert(Ewl_Seeker *s, int invert)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("s", s);
+
+       if (s->invert != invert) {
+               s->invert = invert;
+               ewl_widget_configure(EWL_WIDGET(s));
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param s: the seeker to retrieve invert property value
+ * @return Returns the current value of the invert property in the seeker.
+ * @brief Retrieve the current invert value from a seeker.
+ */
+int ewl_seeker_get_invert(Ewl_Seeker *s)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("s", s, FALSE);
+
+       DRETURN_INT(s->invert, DLEVEL_STABLE);
+}
+
+/**
  * @param s: the seeker to increase
  * @return Returns no value.
  * @brief Increase the value of a seeker by it's step size
@@ -361,7 +393,7 @@
                ewl_widget_hide(w);
                s->autohide = -abs(s->autohide);
        }
-       s2 = s->value / s->range;
+       s2 = (s->range - s->value) / s->range;
 
        if (s->orientation == EWL_ORIENTATION_VERTICAL) {
                dh *= s1;
@@ -424,9 +456,9 @@
 {
        Ewl_Event_Mouse_Move *ev;
        Ewl_Seeker *s;
-       int mx, my;
-       int dx, dy;
-       int dw, dh;
+       int m;
+       int dc, dg;
+       int adjust;
        double scale;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -451,50 +483,41 @@
 
        ev = ev_data;
 
-       mx = ev->x;
-       my = ev->y;
+       if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
 
-       dx = CURRENT_X(s);
-       dy = CURRENT_Y(s);
-       dw = CURRENT_W(s);
-       dh = CURRENT_H(s);
+               m = ev->x;
 
-       if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
-               int adjust;
+               dc = CURRENT_X(s);
+               dg = CURRENT_W(s);
 
                adjust = ewl_object_get_current_w(EWL_OBJECT(s->button));
-               dw -= adjust;
-               adjust /= 2;
-               dx += adjust;
-
-               /*
-                * Wheeha make sure this bizatch doesn't run off the sides of
-                * the seeker.
-                */
-               if (mx < dx)
-                       mx = dx;
-               else if (mx > dx + dw)
-                       mx = dx + dw;
-
-               scale = (double)(mx - dx) / (double)dw;
        }
        else {
-               int adjust;
+               m = ev->y;
+               dc = CURRENT_Y(s);
+               dg = CURRENT_H(s);
 
                adjust = ewl_object_get_current_h(EWL_OBJECT(s->button));
-               dh -= adjust;
-               adjust /= 2;
-               dy += adjust;
-
-               if (my < dy)
-                       my = dy;
-               else if (my > (dy + dh))
-                       my = dy + dh;
-
-               scale = (double)(my - dy) / (double)dh;
        }
 
-       ewl_seeker_set_value(s, scale * s->range);
+       dg -= adjust;
+       adjust /= 2;
+       dc += adjust;
+
+       /*
+        * Wheeha make sure this bizatch doesn't run off the sides of
+        * the seeker.
+        */
+       if (m < dc)
+               m = dc;
+       else if (m > dc + dg)
+               m = dc + dg;
+
+       scale = s->range * (double)(m - dc) / (double)dg;
+       if (s->invert)
+               scale = s->range - scale;
+
+       ewl_seeker_set_value(s, scale);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -503,7 +526,7 @@
 {
        Ewl_Seeker     *s;
        Ewl_Event_Mouse_Down *ev;
-       double          value;
+       double          value, step = 0;
        int             xx, yy, ww, hh;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -524,18 +547,24 @@
         * relative to the button and the orientation of the seeker.
         */
        if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
-               if (ev->x < xx)
-                       value -= s->step;
-               else if (ev->x > xx + ww)
-                       value += s->step;
+               if (ev->x < xx) {
+                       step = -s->step;
+               }
+               else if (ev->x > xx + ww) {
+                       value = s->step;
+               }
        }
        else {
                if (ev->y < yy)
-                       value -= s->step;
+                       step = -s->step;
                else if (ev->y > yy + hh)
-                       value += s->step;
+                       step = s->step;
        }
 
+       if (s->invert)
+               step = -step;
+       value += step;
+
        ewl_seeker_set_value(s, value);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_seeker.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- ewl_seeker.h        29 Mar 2004 05:54:59 -0000      1.22
+++ ewl_seeker.h        30 Mar 2004 21:55:18 -0000      1.23
@@ -42,6 +42,7 @@
        double          value; /**< Currently chosen value */
        double          range; /**< Total selectable range */
        double          step; /**< Size of increments in the range */
+       int             invert; /**< Invert the axis */
        int             dragstart; /**< The coordinate where the drag starts */
        int             autohide; /**< Indicator to hide when not scrollable */
 };
@@ -73,6 +74,9 @@
 void            ewl_seeker_set_autohide(Ewl_Seeker *s, int v);
 int             ewl_seeker_get_autohide(Ewl_Seeker *s);
 
+void            ewl_seeker_set_invert(Ewl_Seeker *s, int invert);
+int             ewl_seeker_get_invert(Ewl_Seeker *s);
+
 void            ewl_seeker_decrease(Ewl_Seeker * s);
 void            ewl_seeker_increase(Ewl_Seeker * s);
 




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to