Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_entry.c ewl_entry.h ewl_misc.c ewl_widget.c 


Log Message:
Outlined some timer work for entry scrolling, simplified some checks for
realizing widgets to reduce setup overhead.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -3 -r1.81 -r1.82
--- ewl_entry.c 4 Mar 2004 06:31:18 -0000       1.81
+++ ewl_entry.c 8 Mar 2004 06:10:29 -0000       1.82
@@ -1,6 +1,7 @@
-
 #include <Ewl.h>
 
+static int ewl_entry_timer();
+
 /**
  * @param text: the initial text to display in the widget
  * @return Returns a new entry widget on success, NULL on failure.
@@ -137,6 +138,8 @@
                                ewl_entry_key_down_cb, NULL);
                ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
                                ewl_entry_mouse_down_cb, NULL);
+               ewl_callback_del(w, EWL_CALLBACK_MOUSE_UP,
+                               ewl_entry_mouse_up_cb);
                ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE,
                                ewl_entry_mouse_move_cb, NULL);
        }
@@ -145,6 +148,8 @@
                                ewl_entry_key_down_cb);
                ewl_callback_del(w, EWL_CALLBACK_MOUSE_DOWN,
                                ewl_entry_mouse_down_cb);
+               ewl_callback_del(w, EWL_CALLBACK_MOUSE_UP,
+                               ewl_entry_mouse_up_cb);
                ewl_callback_del(w, EWL_CALLBACK_MOUSE_MOVE,
                                ewl_entry_mouse_move_cb);
        }
@@ -338,6 +343,24 @@
 }
 
 /*
+ * Stop the scrolling timer.
+ */
+void ewl_entry_mouse_up_cb(Ewl_Widget * w, void *ev_data, void *user_data)
+{
+       Ewl_Entry *e = EWL_ENTRY(w);
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       if (e->timer) {
+               ecore_timer_del(e->timer);
+               e->timer = NULL;
+               e->start_time = 0.0;
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/*
  * Hilight text when the mouse moves when the button is pressed
  */
 void ewl_entry_mouse_move_cb(Ewl_Widget * w, void *ev_data, void *user_data)
@@ -360,14 +383,25 @@
 
        if (ev->x < CURRENT_X(e->text))
                index = 0;
-       else if (ev->x > CURRENT_X(e->text) + CURRENT_W(e->text))
+       else if (ev->x > CURRENT_X(e->text) + CURRENT_W(e->text)) {
                index = ewl_text_get_length(EWL_TEXT(e->text));
+       }
        else {
                index = ewl_text_get_index_at(EWL_TEXT(e->text), ev->x,
                                      (CURRENT_Y(e->text) +
                                       (CURRENT_H(e->text) / 2)));
        }
 
+       /*
+        * Should begin scrolling in either direction?
+        */
+       if (ev->x > CURRENT_X(e) || ev->x < CURRENT_X(e)) {
+               /*
+               e->start_time = ecore_time_get();
+               e->timer = ecore_timer_add(0.02, ewl_entry_timer, e);
+               */
+       }
+
        index++;
 
        ewl_cursor_select_to(EWL_CURSOR(e->cursor), index);
@@ -629,3 +663,59 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
+
+static int ewl_entry_timer(void *data)
+{
+       Ewl_Entry      *e;
+       double          dt;
+       double          value;
+       int             velocity, direction;
+
+       e = EWL_ENTRY(data);
+
+       dt = ecore_time_get() - e->start_time;
+       direction = ewl_cursor_get_base_position(EWL_CURSOR(e->cursor)) -
+                       ewl_cursor_get_end_position(EWL_CURSOR(e->cursor));
+
+       if (!direction)
+               direction = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor))
+                       - ewl_cursor_get_base_position(EWL_CURSOR(e->cursor));
+
+       if (!direction) {
+               int tmp;
+               direction = CURRENT_X(e->cursor) - CURRENT_X(e);
+               tmp = (CURRENT_X(e) + CURRENT_W(e)) - (CURRENT_X(e->cursor) +
+                               CURRENT_W(e->cursor));
+               if (direction < tmp)
+                       direction = -1;
+               else
+                       direction = 1;
+       }
+       else {
+               if (direction < 0)
+                       direction = 1;
+               else
+                       direction = -1;
+       }
+
+       /*
+        * Check the theme for a velocity setting and bring it within normal
+        * useable bounds.
+        */
+       velocity = ewl_theme_data_get_int(EWL_WIDGET(e), "velocity");
+       if (velocity < 1)
+               velocity = 1;
+       else if (velocity > 10)
+               velocity = 10;
+
+       /*
+        * Move the value of the seeker based on the direction of it's motion
+        * and the velocity setting.
+        */
+       value = (double)(direction) * 10.0 * (1 - exp(-dt)) *
+                ((double)(velocity) / 100.0);
+
+       e->offset = value * ewl_object_get_current_w(EWL_OBJECT(e->text));
+
+       return 1;
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -3 -r1.30 -r1.31
--- ewl_entry.h 24 Feb 2004 16:52:28 -0000      1.30
+++ ewl_entry.h 8 Mar 2004 06:10:29 -0000       1.31
@@ -38,6 +38,8 @@
 
        int             offset; /**< Starting position of cursor in text */
        int             editable; /**< Flag to indicate if user can edit text */
+       Ecore_Timer    *timer; /**< Time until scrolling text on select */
+       double          start_time; /**< Time timer started */
 };
 
 Ewl_Widget     *ewl_entry_new(char *text);
@@ -62,6 +64,7 @@
                                 void *user_data);
 void ewl_entry_key_down_cb(Ewl_Widget * w, void *ev_data, void *user_data);
 void ewl_entry_mouse_down_cb(Ewl_Widget * w, void *ev_data, void *user_data);
+void ewl_entry_mouse_up_cb(Ewl_Widget * w, void *ev_data, void *user_data);
 void ewl_entry_mouse_move_cb(Ewl_Widget * w, void *ev_data, void *user_data);
 void ewl_entry_select_cb(Ewl_Widget * w, void *ev_data, void *user_data);
 void ewl_entry_deselect_cb(Ewl_Widget * w, void *ev_data, void *user_data);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -3 -r1.66 -r1.67
--- ewl_misc.c  27 Feb 2004 00:30:58 -0000      1.66
+++ ewl_misc.c  8 Mar 2004 06:10:30 -0000       1.67
@@ -510,6 +510,8 @@
         * Now clean off any children of this widget, they will get added
         * later.
         */
+       /* FIXME: This is a big source of slow down on long lists of widgets,
+        * might not be worth it
        ewd_list_goto_first(configure_list);
        while ((search = ewd_list_current(configure_list))) {
                Ewl_Widget *parent;
@@ -526,6 +528,7 @@
 
                ewd_list_next(configure_list);
        }
+       */
 
        /*
         * FIXME: Remove this once we get things stabilize a bit more.
@@ -597,40 +600,16 @@
                DRETURN(DLEVEL_STABLE);
 
        if (!ewl_object_get_flags(EWL_OBJECT(w), EWL_FLAG_PROPERTY_TOPLEVEL)) {
-               if (w->parent && !REALIZED(w->parent))
+               if (!w->parent || !REALIZED(w->parent))
                        DRETURN(DLEVEL_STABLE);
        }
 
        ewl_object_add_queued(EWL_OBJECT(w), EWL_FLAG_QUEUED_RSCHEDULED);
-
        ewd_list_append(realize_list, w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_child_add_place(Ewl_Widget *w)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       if (ewl_object_get_flags(EWL_OBJECT(w), EWL_FLAG_PROPERTY_TOPLEVEL))
-               ewd_list_append(child_add_list, w);
-       else {
-               Ewl_Widget *p;
-
-               ewd_list_goto_first(child_add_list);
-               while ((p = ewd_list_current(child_add_list))) {
-                       if (ewl_container_parent_of(p, w)) {
-                               ewd_list_insert(child_add_list, w);
-                               DRETURN(DLEVEL_STABLE);
-                       }
-                       else
-                               ewd_list_next(child_add_list);
-               }
-       }
-       ewd_list_prepend(child_add_list, w);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
 void ewl_realize_queue()
 {
        Ewl_Widget *w;
@@ -641,7 +620,9 @@
 
        /*
         * First realize any widgets that require it, this looping should
-        * avoid deep recursion, and works from top to bottom.
+        * avoid deep recursion, and works from top to bottom since widgets
+        * can't be placed on this list unless their parent has been realized
+        * or they are a toplevel widget.
         */
        ewd_list_goto_first(realize_list);
        while ((w = ewd_list_remove_first(realize_list))) {
@@ -649,10 +630,8 @@
                        ewl_object_remove_queued(EWL_OBJECT(w),
                                        EWL_FLAG_QUEUED_RSCHEDULED);
                        ewl_widget_realize(EWL_WIDGET(w));
-
+                       ewd_list_prepend(child_add_list, w);
                }
-
-               ewl_child_add_place(w);
        }
 
        /*
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -3 -r1.107 -r1.108
--- ewl_widget.c        4 Mar 2004 00:29:21 -0000       1.107
+++ ewl_widget.c        8 Mar 2004 06:10:30 -0000       1.108
@@ -262,7 +262,7 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
-       if (/* FIXME: !REALIZED(w) | */ !VISIBLE(w))
+       if (!VISIBLE(w))
                DRETURN(DLEVEL_STABLE);
 
        ewl_configure_request(w);




-------------------------------------------------------
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