Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_menu_base.c ewl_scrollbar.c ewl_scrollbar.h 
        ewl_scrollpane.c ewl_seeker.c 


Log Message:
Refactoring scrollbars, and some slight progress on fixing the menu code.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_menu_base.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ewl_menu_base.c     3 Jun 2003 04:00:46 -0000       1.8
+++ ewl_menu_base.c     21 Jun 2003 22:50:13 -0000      1.9
@@ -25,7 +25,6 @@
         * Initialize the defaults of the inherited fields.
         */
        ewl_menu_item_init(EWL_MENU_ITEM(menu), image, title);
-       ewl_object_set_fill_policy(EWL_OBJECT(menu), EWL_FILL_POLICY_NONE);
 
        ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_SELECT,
                            __ewl_menu_base_expand, NULL);
@@ -103,6 +102,7 @@
         */
        ewl_box_init(EWL_BOX(item), EWL_ORIENTATION_HORIZONTAL);
        ewl_widget_set_appearance(EWL_WIDGET(item), "menuitem");
+       ewl_object_set_fill_policy(EWL_OBJECT(item), EWL_FILL_POLICY_NONE);
 
        ewl_container_notify_callback(EWL_CONTAINER(item),
                        EWL_CALLBACK_CLICKED);
@@ -120,14 +120,15 @@
        /*
         * Create the icon if one is requested.
         */
-       if (image) {
+       if (image)
                item->icon = ewl_image_new(image);
-               ewl_object_set_maximum_size(EWL_OBJECT(item->icon), 20, 20);
-               ewl_object_set_alignment(EWL_OBJECT(item->icon),
-                               EWL_ALIGNMENT_CENTER);
-               ewl_container_append_child(EWL_CONTAINER(item), item->icon);
-               ewl_widget_show(item->icon);
-       }
+       else
+               item->icon = ewl_spacer_new();
+
+       ewl_object_set_alignment(EWL_OBJECT(item->icon), EWL_ALIGNMENT_CENTER);
+       ewl_object_set_maximum_size(EWL_OBJECT(item->icon), 20, 20);
+       ewl_container_append_child(EWL_CONTAINER(item), item->icon);
+       ewl_widget_show(item->icon);
 
        /*
         * Create the text object for the menu item.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- ewl_scrollbar.c     10 Jun 2003 07:02:19 -0000      1.17
+++ ewl_scrollbar.c     21 Jun 2003 22:50:13 -0000      1.18
@@ -2,17 +2,10 @@
 #include <Ewl.h>
 
 
-void            __ewl_scrollbar_realize(Ewl_Widget * s, void *ev_data,
-                                       void *user_data);
 void            __ewl_scrollbar_decrement(Ewl_Widget * w, void *ev_data,
                                          void *user_data);
 void            __ewl_scrollbar_increment(Ewl_Widget * w, void *ev_data,
                                          void *user_data);
-void            __ewl_scrollbar_seeker_configure(Ewl_Widget * w, void *ev_data,
-                                                void *user_data);
-void            __ewl_scrollbar_seeker_value_changed(Ewl_Widget * w,
-                                                    void *ev_data,
-                                                    void *user_data);
 
 
 /**
@@ -68,19 +61,25 @@
        s->button_decrement = ewl_button_new(NULL);
        ewl_object_set_alignment(EWL_OBJECT(s->button_decrement),
                        EWL_ALIGNMENT_CENTER);
+       ewl_object_set_fill_policy(EWL_OBJECT(s->button_decrement),
+                                  EWL_FILL_POLICY_NONE);
+       ewl_widget_show(s->button_decrement);
+
+       /*
+        * Create the increment button.
+        */
        s->button_increment = ewl_button_new(NULL);
        ewl_object_set_alignment(EWL_OBJECT(s->button_increment),
                        EWL_ALIGNMENT_CENTER);
-       s->seeker = ewl_seeker_new(orientation);
+       ewl_object_set_fill_policy(EWL_OBJECT(s->button_increment),
+                                  EWL_FILL_POLICY_NONE);
+       ewl_widget_show(s->button_increment);
 
        /*
-        * Append callbacks for the scrollbars basic functions.
+        * Setup the seeker portion
         */
-       ewl_callback_append(w, EWL_CALLBACK_REALIZE,
-                           __ewl_scrollbar_realize, NULL);
-
-       ewl_callback_append(s->button_decrement, EWL_CALLBACK_MOUSE_DOWN,
-                           __ewl_scrollbar_decrement, s);
+       s->seeker = ewl_seeker_new(orientation);
+       ewl_widget_show(s->seeker);
 
        /*
         * Attach callbacks to the buttons and seeker to handle the various
@@ -88,16 +87,8 @@
         */
        ewl_callback_append(s->button_increment, EWL_CALLBACK_MOUSE_DOWN,
                            __ewl_scrollbar_increment, s);
-       ewl_callback_append(s->seeker, EWL_CALLBACK_CONFIGURE,
-                           __ewl_scrollbar_seeker_configure, s);
-
-       /*
-        * Set the default fill policies for the buttons and the seeker
-        */
-       ewl_object_set_fill_policy(EWL_OBJECT(s->button_decrement),
-                                  EWL_FILL_POLICY_NONE);
-       ewl_object_set_fill_policy(EWL_OBJECT(s->button_increment),
-                                  EWL_FILL_POLICY_NONE);
+       ewl_callback_append(s->button_decrement, EWL_CALLBACK_MOUSE_DOWN,
+                           __ewl_scrollbar_decrement, s);
 
        /*
         * Set the default alignment for the buttons.
@@ -116,8 +107,8 @@
         * Append a value change callback to the seeker to catch when it
         * moves.
         */
-       ewl_callback_append(s->seeker, EWL_CALLBACK_VALUE_CHANGED,
-                           __ewl_scrollbar_seeker_value_changed, s);
+       ewl_container_notify_callback(EWL_CONTAINER(s),
+                       EWL_CALLBACK_VALUE_CHANGED);
 
        /*
         * Define the maximum value that the seeker can reach, and the
@@ -154,7 +145,8 @@
                        ewl_container_append_child(EWL_CONTAINER(s),
                                                   s->button_increment);
                        ewl_container_append_child(EWL_CONTAINER(s), s->seeker);
-               } else if (s->buttons_alignment & EWL_ALIGNMENT_RIGHT) {
+               }
+               else if (s->buttons_alignment & EWL_ALIGNMENT_RIGHT) {
 
                        /*
                         * Place in seeker, decrement, increment order.
@@ -164,7 +156,8 @@
                                                   s->button_decrement);
                        ewl_container_append_child(EWL_CONTAINER(s),
                                                   s->button_increment);
-               } else {
+               }
+               else {
 
                        /*
                         * Place in decrement, seeker, increment order.
@@ -183,7 +176,8 @@
                ewl_widget_set_appearance(w, "hscrollbar");
                ewl_object_set_fill_policy(EWL_OBJECT(s),
                                EWL_FILL_POLICY_HFILL);
-       } else {
+       }
+       else {
 
                if (s->buttons_alignment & EWL_ALIGNMENT_TOP) {
 
@@ -195,7 +189,8 @@
                        ewl_container_append_child(EWL_CONTAINER(s),
                                                   s->button_decrement);
                        ewl_container_append_child(EWL_CONTAINER(s), s->seeker);
-               } else if (s->buttons_alignment & EWL_ALIGNMENT_BOTTOM) {
+               }
+               else if (s->buttons_alignment & EWL_ALIGNMENT_BOTTOM) {
 
                        /*
                         * Place in seeker, increment, decrement order.
@@ -205,7 +200,8 @@
                                                   s->button_increment);
                        ewl_container_append_child(EWL_CONTAINER(s),
                                                   s->button_decrement);
-               } else {
+               }
+               else {
 
                        /*
                         * Place in increment, seeker, decrement order.
@@ -230,81 +226,43 @@
 }
 
 /**
- * ewl_scrollbar_set_fill_percentage - set the percentage filled by drag button
- * @s: the scrollbar to change fill percentage
- * @fp: the percentage of the scrollbar filled by the drag button
+ * ewl_scrollbar_get_value - get the current value of the dragbar
+ * @s: the scrollbar to get the current value
  *
- * Returns no value. Changes the area of the scrollbar that is filled by the
- * drag button.
+ * Returns the current value of the scrollbar @s.
  */
-void ewl_scrollbar_set_fill_percentage(Ewl_Scrollbar * s, double fp)
+double ewl_scrollbar_get_value(Ewl_Scrollbar * s)
 {
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("s", s);
-
-       /*
-        * Perform a bounds check on the fill percentage.
-        */
-       if (fp < 0)
-               fp = 0;
-       else if (fp > 1)
-               fp = 1;
-
-       /*
-        * Set the fill percentage on the seeker.
-        */
-       s->fill_percentage = fp;
-
-       /*
-        * Adjust the step based on the fill percentage.
-        */
-       if (fp == 1 || fp == 0)
-               ewl_seeker_set_step(EWL_SEEKER(s->seeker), 0.05);
-       else
-               ewl_seeker_set_step(EWL_SEEKER(s->seeker), 1.0 - fp);
-
-       ewl_widget_configure(EWL_WIDGET(s));
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
+       double          v;
 
-/**
- * ewl_scrollbar_get_fill_percentage - get the percentage filled by drag button
- * @s: the scrollbar to retrieve fill percentage
- *
- * Returns the percentage of the scrollbar that the drag button fills on
- * success, -1 on failure.
- */
-double ewl_scrollbar_get_fill_percentage(Ewl_Scrollbar * s)
-{
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("s", s, -1);
 
-       DRETURN_FLOAT(s->fill_percentage, DLEVEL_STABLE);
+       v = ewl_seeker_get_value(EWL_SEEKER(s->seeker));
+
+       if (EWL_BOX(s)->orientation == EWL_ORIENTATION_VERTICAL)
+               v = 1.0 - v;
+
+       DRETURN_FLOAT(v, DLEVEL_UNSTABLE);
 }
 
 /**
- * ewl_scrollbar_get_value - get the current value of the dragbar
- * @s: the scrollbar to get the current value
+ * ewl_scrollbar_set_value - set the current value of the dragbar
+ * @s: the scrollbar to set the current value
  *
- * Returns the current value of the scrollbar @s.
+ * Returns no value. Sets the current value of the scrollbar @s.
  */
-double ewl_scrollbar_get_value(Ewl_Scrollbar * s)
+void ewl_scrollbar_set_value(Ewl_Scrollbar * s, double v)
 {
-       double          v;
-
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("s", s, -1);
-
-       v = ewl_seeker_get_value(EWL_SEEKER(s->seeker));
+       DCHECK_PARAM_PTR("s", s);
 
        if (EWL_BOX(s)->orientation == EWL_ORIENTATION_VERTICAL)
                v = 1.0 - v;
 
-       if (s->fill_percentage == 1.0)
-               v = 0.0;
+       ewl_seeker_set_value(EWL_SEEKER(s->seeker), v);
 
-       DRETURN_FLOAT(v, DLEVEL_UNSTABLE);
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 /**
@@ -320,6 +278,7 @@
        DCHECK_PARAM_PTR("s", s);
 
        s->flag = f;
+       ewl_widget_configure(EWL_WIDGET(s));
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -340,35 +299,6 @@
 
 
 /*
- * Make sure that we show all the parts of the scrollbar
- */
-void __ewl_scrollbar_realize(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       Ewl_Scrollbar  *s;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       s = EWL_SCROLLBAR(w);
-
-       ewl_widget_realize(s->button_decrement);
-       ewl_widget_realize(s->seeker);
-       ewl_widget_realize(s->button_increment);
-
-       if (EWL_BOX(s)->orientation == EWL_ORIENTATION_HORIZONTAL) {
-               ewl_object_set_preferred_h(EWL_OBJECT(s), MINIMUM_H(s->seeker));
-               MINIMUM_H(s) = MINIMUM_H(s->seeker);
-               MAXIMUM_H(s) = MAXIMUM_H(s->seeker);
-       } else {
-               ewl_object_set_preferred_w(EWL_OBJECT(s), MINIMUM_W(s->seeker));
-               MINIMUM_W(s) = MINIMUM_W(s->seeker);
-               MAXIMUM_W(s) = MAXIMUM_W(s->seeker);
-       }
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/*
  * Decrement the value of the scrollbar's seeker portion
  */
 void __ewl_scrollbar_decrement(Ewl_Widget * w, void *ev_data, void *user_data)
@@ -420,54 +350,6 @@
                v = 1.0;
 
        ewl_seeker_set_value(EWL_SEEKER(s->seeker), v);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-__ewl_scrollbar_seeker_configure(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       Ewl_Scrollbar  *sc;
-       Ewl_Seeker     *se;
-       int             req_w = 0, req_h = 0;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       DCHECK_PARAM_PTR("user_data", user_data);
-
-       sc = user_data;
-       se = EWL_SEEKER(w);
-
-       req_w = CURRENT_W(w) - (INSET_LEFT(w) + INSET_RIGHT(w));
-       req_h = CURRENT_H(w) - (INSET_TOP(w) + INSET_BOTTOM(w));
-
-       /*
-        * Adjust the size of the scrollbar based on the fill percentage and
-        * orientation.
-        */
-       if (EWL_BOX(sc)->orientation == EWL_ORIENTATION_HORIZONTAL) {
-               req_w *= sc->fill_percentage;
-       } else {
-               req_h *= sc->fill_percentage;
-       }
-
-       /*
-        * Request the new size for the dragbar.
-        */
-       ewl_object_request_size(EWL_OBJECT(se->dragbar), req_w, req_h);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void
-__ewl_scrollbar_seeker_value_changed(Ewl_Widget * w, void *ev_data,
-                                    void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-       DCHECK_PARAM_PTR("user_data", user_data);
-
-       ewl_callback_call(user_data, EWL_CALLBACK_VALUE_CHANGED);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_scrollbar.h     25 May 2002 05:46:42 -0000      1.5
+++ ewl_scrollbar.h     21 Jun 2003 22:50:13 -0000      1.6
@@ -25,10 +25,8 @@
 void            ewl_scrollbar_init(Ewl_Scrollbar * s,
                                   Ewl_Orientation orientation);
 
-void            ewl_scrollbar_set_fill_percentage(Ewl_Scrollbar * s, double fp);
-double          ewl_scrollbar_get_fill_percentage(Ewl_Scrollbar * s);
-
 double          ewl_scrollbar_get_value(Ewl_Scrollbar * s);
+void            ewl_scrollbar_set_value(Ewl_Scrollbar * s, double v);
 
 void            ewl_scrollbar_set_flag(Ewl_Scrollbar * s,
                                       Ewl_ScrollBar_Flags f);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- ewl_scrollpane.c    11 Jun 2003 07:02:23 -0000      1.15
+++ ewl_scrollpane.c    21 Jun 2003 22:50:13 -0000      1.16
@@ -56,7 +56,7 @@
 
        ewl_container_init(EWL_CONTAINER(s), "scrollpane", __ewl_scrollpane_add,
                        __ewl_scrollpane_child_resize, NULL);
-       ewl_object_set_fill_policy(EWL_OBJECT(s), EWL_FILL_POLICY_ALL);
+       ewl_object_set_fill_policy(EWL_OBJECT(s), EWL_FILL_POLICY_FILL);
 
        /*
         * Create the container to hold the contents and it's configure
@@ -180,7 +180,7 @@
  */
 void __ewl_scrollpane_configure(Ewl_Widget * w, void *ev_data, void *user_data)
 {
-       int b_width, b_height;
+       int             b_width, b_height;
        Ewl_ScrollPane *s;
        int             vs_width = 0;
        int             hs_height = 0;
@@ -220,26 +220,25 @@
                                    vs_width, content_h);
 
        /*
-        * Update the fill percentage on the scrollbars based on available space
-        * for the content.
+        * A rare case where we need to know the preferred size over the
+        * minimum size.
         */
        b_width = ewl_object_get_preferred_w(EWL_OBJECT(s->box));
        b_height = ewl_object_get_preferred_h(EWL_OBJECT(s->box));
-       ewl_scrollbar_set_fill_percentage(EWL_SCROLLBAR(s->hscrollbar),
-                                         (double) content_w /
-                                         (double) b_width);
-       ewl_scrollbar_set_fill_percentage(EWL_SCROLLBAR(s->vscrollbar),
-                                         (double) content_h /
-                                         (double) b_width);
+
+       b_width = (int)(ewl_scrollbar_get_value(EWL_SCROLLBAR(s->hscrollbar)) *
+                                             (double)(b_width));
+       b_height= (int)(ewl_scrollbar_get_value(EWL_SCROLLBAR(s->vscrollbar)) *
+                                             (double)(b_height));
 
        /*
         * Now move the box into position. For the scrollpane to work we move
         * the box relative to the scroll value.
         */
        ewl_object_request_geometry(EWL_OBJECT(s->box),
-                                   CURRENT_X(w),
-                                   CURRENT_Y(w),
-                                   content_w, content_h);
+                                   CURRENT_X(w) - b_width,
+                                   CURRENT_Y(w) - b_height,
+                                   content_w + b_width, content_h + b_height);
 
        /*
         * Configure the parts of the scrollpane.
@@ -320,10 +319,11 @@
        /*
         * Update the preferred size of the scrollpane to that of the box.
         */
-       if (o == EWL_ORIENTATION_HORIZONTAL)
+       if (o == EWL_ORIENTATION_HORIZONTAL) {
                ewl_object_set_preferred_w(EWL_OBJECT(parent),
                                ewl_object_get_minimum_w(EWL_OBJECT(s->box)) +
                                ewl_object_get_minimum_w(EWL_OBJECT(s->vscrollbar)));
+       }
        else
                ewl_object_set_preferred_h(EWL_OBJECT(parent),
                                ewl_object_get_minimum_h(EWL_OBJECT(s->box)) +
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_seeker.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- ewl_seeker.c        3 Jun 2003 04:00:48 -0000       1.36
+++ ewl_seeker.c        21 Jun 2003 22:50:13 -0000      1.37
@@ -18,11 +18,6 @@
                                      void *user_data);
 void            __ewl_seeker_focus_out(Ewl_Widget * w, void *ev_data,
                                       void *user_data);
-void            __ewl_seeker_mouse_move(Ewl_Widget * w, void *ev_data,
-                                       void *user_data);
-void            __ewl_seeker_position_to_value(Ewl_Seeker * s, int in_x,
-                                              int in_y);
-void            __ewl_seeker_value_to_position(Ewl_Seeker * s);
 void            __ewl_seeker_appearance_changed(Ewl_Widget * w, void *ev_data,
                                                void *user_data);
 
@@ -95,6 +90,7 @@
         */
        s->dragbar = ewl_button_new(NULL);
        ewl_container_append_child(EWL_CONTAINER(s), s->dragbar);
+       ewl_widget_set_appearance(EWL_WIDGET(s->dragbar), "dragbar");
 
        /*
         * Set the starting orientation, range and values
@@ -102,7 +98,7 @@
        s->orientation = orientation;
        s->range = 100.0;
        s->value = 0.0;
-       s->step = 5.0;
+       s->step = 10.0;
 
        /*
         * Add necessary configuration callbacks
@@ -111,12 +107,10 @@
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, __ewl_seeker_configure,
                            NULL);
-       ewl_callback_append(w, EWL_CALLBACK_THEME_UPDATE,
-                           __ewl_seeker_theme_update, NULL);
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, __ewl_seeker_mouse_down,
                            NULL);
-       ewl_callback_append(w, EWL_CALLBACK_THEME_UPDATE,
-                           __ewl_seeker_appearance_changed, NULL);
+       ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE,
+                           __ewl_seeker_dragbar_mouse_move, NULL);
 
        /*
         * Append a callback for catching mouse movements on the dragbar and
@@ -126,8 +120,12 @@
                            __ewl_seeker_dragbar_mouse_down, NULL);
        ewl_callback_append(s->dragbar, EWL_CALLBACK_MOUSE_UP,
                            __ewl_seeker_dragbar_mouse_up, NULL);
-       ewl_callback_append(s->dragbar, EWL_CALLBACK_MOUSE_MOVE,
-                           __ewl_seeker_dragbar_mouse_move, NULL);
+
+       /*
+        * We want to catch mouse movement events from the dragbar.
+        */
+       ewl_container_notify_callback(EWL_CONTAINER(s),
+                       EWL_CALLBACK_MOUSE_MOVE);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -309,6 +307,7 @@
 }
 
 
+
 /*
  * Draw the representation of the seeker
  */
@@ -331,6 +330,9 @@
 void __ewl_seeker_configure(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Seeker     *s;
+       double          s1, s2;
+       int             dx, dy;
+       unsigned int    dw, dh;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
@@ -339,8 +341,28 @@
        if (!s->dragbar)
                DRETURN(DLEVEL_STABLE);
 
-       __ewl_seeker_value_to_position(s);
-       ewl_widget_configure(EWL_WIDGET(s->dragbar));
+       dx = CURRENT_X(s);
+       dy = CURRENT_Y(s);
+       dw = CURRENT_W(s);
+       dh = CURRENT_H(s);
+
+       /*
+        * First determine the size based on the number of steps to span from
+        * min to max values. Then reduce the total scale to keep the dragbar on
+        * the seeker, then position the dragbar.
+        */
+       s1 = s->step / s->range;
+       s2 = s->value / s->range;
+       if (s->orientation == EWL_ORIENTATION_VERTICAL) {
+               dh *= s1;
+               dy += (CURRENT_H(s) - dh) * s2;
+       }
+       else {
+               dw *= s1;
+               dx += (CURRENT_W(s) - dw) * s2;
+       }
+
+       ewl_object_request_geometry(EWL_OBJECT(s->dragbar), dx, dy, dw, dh);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -391,166 +413,78 @@
 __ewl_seeker_dragbar_mouse_move(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ecore_Event_Mouse_Move *ev;
+       Ewl_Seeker *s;
+       int mx, my;
+       int dx, dy;
+       unsigned int dw, dh;
+       double scale;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        DCHECK_PARAM_PTR("w", w);
        DCHECK_PARAM_PTR("ev_data", ev_data);
 
+       s = EWL_SEEKER(w);
+
        /*
-        * If the pointer is not pressed we don't care about mouse movements.
+        * If the dragbar is not pressed we don't care about mouse movements.
         */
-       if (!(w->state & EWL_STATE_PRESSED))
+       if (!(s->dragbar->state & EWL_STATE_PRESSED))
                DRETURN(DLEVEL_STABLE);
 
-       if (EWL_SEEKER(w->parent)->dragstart < 1)
+       if (s->dragstart < 1)
                DRETURN(DLEVEL_STABLE);
 
        ev = ev_data;
 
-       __ewl_seeker_position_to_value(EWL_SEEKER(w->parent), ev->x, ev->y);
-       ewl_widget_configure(w);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-void __ewl_seeker_position_to_value(Ewl_Seeker * s, int in_x, int in_y)
-{
-       Ewl_Widget     *w;
-       double          val = 0.0, old_val;
-       int             xx, yy, ww, hh;
-       int             req_x, req_y;
+       mx = ev->x;
+       my = ev->y;
 
-       w = s->dragbar;
+       dx = CURRENT_X(s);
+       dy = CURRENT_Y(s);
+       dw = CURRENT_W(s);
+       dh = CURRENT_H(s);
 
-       ewl_object_get_current_geometry(EWL_OBJECT(s), &xx, &yy, &ww, &hh);
-
-       /*
-        * Adjust the width and height to fit within the insets of the bit
-        */
-       xx += INSET_LEFT(w);
-       yy += INSET_TOP(w);
-       ww -= INSET_LEFT(w) + INSET_RIGHT(w);
-       hh -= INSET_TOP(w) + INSET_BOTTOM(w);
-
-       /*
-        * The direction of the dragbar move depends on the orientation of the
-        * parent seeker.
-        */
        if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
-               if (CURRENT_W(w) >= ww)
-                       goto end;
-               /*
-                * Use the current x value along with the starting drag
-                * position to determine the new position
-                */
-               req_x = in_x - s->dragstart;
-               /*
-                * Check the boundaries to make sure we're not off the end of
-                * the bar
-                */
-               if (req_x < xx)
-                       req_x = xx;
-
-               if (req_x + CURRENT_W(w) > xx + ww)
-                       req_x = xx + ww - CURRENT_W(w);
-
-               /*
-                * Calculate the new value for the seeker
-                */
-               val = 1.0 -
-                   (((double) (req_x - xx) / (double) (ww - CURRENT_W(w))));
+               unsigned int adjust;
 
-       } else {
-               if (CURRENT_H(w) >= hh)
-                       goto end;
-               /*
-                * Use the current y value along with the starting drag
-                * position to determine the new position
-                */
-               req_y = in_y - s->dragstart;
+               adjust = ewl_object_get_current_w(EWL_OBJECT(s->dragbar));
+               dw -= adjust;
+               adjust /= 2;
+               dx += adjust;
 
                /*
-                * Check the boundaries to make sure we're not off the end of
-                * the bar
+                * Wheeha make sure this bizatch doesn't run off the sides of
+                * the seeker.
                 */
-               if (req_y < yy)
-                       req_y = yy;
+               if (mx < dx)
+                       mx = dx;
+               else if (mx > dx + dw)
+                       mx = dx + dw;
 
-               if (req_y + CURRENT_H(w) > yy + hh)
-                       req_y = yy + hh - CURRENT_H(w);
-
-               /*
-                * Calculate the new value for the seeker
-                */
-               val = (double) (req_y - yy) / (double) (hh - CURRENT_H(w));
+               scale = (double)(mx - dx) / (double)dw;
        }
+       else {
+               unsigned int adjust;
 
-      end:
-       /*
-        * Calculate the new value and determine if the VALUE_CHANGED callback
-        * needs to be triggered
-        */
-       old_val = s->value;
-       s->value = s->range - val * s->range;
-
-       if (s->value > s->range)
-               s->value = s->range;
-
-       __ewl_seeker_value_to_position(s);
-
-       if (old_val != s->value)
-               ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED);
-}
-
-
-/*
- * Map the seeker's value to a position.
- */
-void __ewl_seeker_value_to_position(Ewl_Seeker * s)
-{
-       Ewl_Widget     *w;
-       int             xx, yy, ww, hh;
-       int             req_x, req_y;
-
-       w = s->dragbar;
-
-       ewl_object_get_current_geometry(EWL_OBJECT(s), &xx, &yy, &ww, &hh);
-
-       /*
-        * The direction of the dragbar move depends on the orientation of the
-        * parent seeker.
-        */
-       if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
-
-               /*
-                * Use the current value along with the range to determine the
-                * new position
-                */
-               req_x = xx + ww - (int) (floor((double) (ww - CURRENT_W(w)) *
-                                              ((s->range -
-                                                s->value) / s->range))) -
-                   CURRENT_W(w);
-
-               req_y = yy;
-       } else {
-
-               /*
-                * Use the current value along with the range to determine the
-                * new position
-                */
-               req_y = yy + hh - (int) (floor((double)
-                                              (hh - CURRENT_H(w)) *
-                                              (s->value / s->range))) -
-                   CURRENT_H(w);
+               adjust = ewl_object_get_current_h(EWL_OBJECT(s->dragbar));
+               dh -= adjust;
+               adjust /= 2;
+               dy += adjust;
+
+               if (my < dy)
+                       my = dy;
+               else if (my > (dy + dh))
+                       my = dy + dh;
 
-               req_x = xx;
+               scale = (double)(my - dy) / (double)dh;
        }
 
-       ewl_object_request_position(EWL_OBJECT(w), req_x, req_y);
-}
+       s->value = scale * s->range;
+       ewl_widget_configure(w);
 
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
 
 void __ewl_seeker_mouse_down(Ewl_Widget * w, void *ev_data, void *user_data)
 {
@@ -569,21 +503,21 @@
        ewl_object_get_current_geometry(EWL_OBJECT(s->dragbar),
                                        &xx, &yy, &ww, &hh);
 
-       switch (s->orientation) {
-       case EWL_ORIENTATION_HORIZONTAL:
+       /*
+        * Increment or decrement the value based on the position of the click
+        * relative to the dragbar and the orientation of the seeker.
+        */
+       if (s->orientation == EWL_ORIENTATION_HORIZONTAL) {
                if (ev->x < xx)
                        s->value -= s->step;
                else if (ev->x > xx + ww)
                        s->value += s->step;
-               break;
-       case EWL_ORIENTATION_VERTICAL:
+       }
+       else {
                if (ev->y < yy)
                        s->value += s->step;
                else if (ev->y > yy + hh)
                        s->value -= s->step;
-               break;
-       default:
-               break;
        }
 
        if (s->value < 0.0)
@@ -594,50 +528,12 @@
        /*
         * Determine the new position of the dragbar and configure it.
         */
-       __ewl_seeker_value_to_position(s);
-       ewl_widget_configure(s->dragbar);
+       ewl_widget_configure(EWL_WIDGET(s));
 
        /*
         * Now signal that the value of the seeker has changed.
         */
        ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-/*
- * Update the theme for the dragbar.
- */
-void __ewl_seeker_theme_update(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       Ewl_Seeker     *s;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       s = EWL_SEEKER(w);
-
-       ewl_widget_theme_update(s->dragbar);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-void
-__ewl_seeker_appearance_changed(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       Ewl_Seeker     *s;
-       char            appearance[PATH_MAX];
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       s = EWL_SEEKER(w);
-
-       snprintf(appearance, PATH_MAX, "%s/dragbar", w->appearance);
-
-       ewl_widget_set_appearance(s->dragbar, appearance);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }




-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to