Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_button.c ewl_container.c ewl_tree.c ewl_tree.h 
        ewl_widget.c 


Log Message:
Fix a few longstanding silly bugs with the mouse handling. More work towards a
usable tree widget, still not there but things are progressing.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_button.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -3 -r1.38 -r1.39
--- ewl_button.c        14 Jan 2003 21:44:58 -0000      1.38
+++ ewl_button.c        1 Apr 2003 06:25:23 -0000       1.39
@@ -1,17 +1,6 @@
 
 #include <Ewl.h>
 
-void            __ewl_button_focus_in(Ewl_Widget * w, void *ev_data,
-                                     void *user_data);
-void            __ewl_button_focus_out(Ewl_Widget * w, void *ev_data,
-                                      void *user_data);
-void            __ewl_button_mouse_down(Ewl_Widget * w, void *ev_data,
-                                       void *user_data);
-void            __ewl_button_mouse_up(Ewl_Widget * w, void *ev_data,
-                                     void *user_data);
-void            __ewl_button_show(Ewl_Widget * w, void *ev_data,
-                                 void *user_data);
-
 /**
  * ewl_button_new - allocate and initialize a new button
  * @label: the string to use as a label for the button
@@ -60,19 +49,6 @@
        w->recursive = FALSE;
 
        /*
-        * Attach necessary callback mechanisms
-        */
-       ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
-                           __ewl_button_mouse_down, NULL);
-       ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP, __ewl_button_mouse_up,
-                           NULL);
-       ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN, __ewl_button_focus_in,
-                           NULL);
-       ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT, __ewl_button_focus_out,
-                           NULL);
-       ewl_callback_append(w, EWL_CALLBACK_SHOW, __ewl_button_show, NULL);
-
-       /*
         * Create and setup the label for the button if it's desired.
         */
        if (label) {
@@ -80,6 +56,7 @@
                ewl_object_set_alignment(EWL_OBJECT(b->label_object),
                                         EWL_ALIGNMENT_CENTER);
                ewl_container_append_child(EWL_CONTAINER(b), b->label_object);
+               ewl_widget_show(b->label_object);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -108,65 +85,6 @@
                ewl_text_set_text(EWL_TEXT(b->label_object), l);
 
        ewl_widget_configure(w);
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-
-void __ewl_button_focus_in(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       if (w->state & EWL_STATE_PRESSED)
-               ewl_widget_update_appearance(w, "clicked");
-       else
-               ewl_widget_update_appearance(w, "hilited");
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void __ewl_button_focus_out(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       ewl_widget_update_appearance(w, "normal");
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void __ewl_button_mouse_down(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       ewl_widget_update_appearance(w, "clicked");
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void __ewl_button_mouse_up(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-
-       if (w->state & EWL_STATE_HILITED) {
-               ewl_widget_update_appearance(w, "hilited");
-               ewl_callback_call(w, EWL_CALLBACK_CLICKED);
-       } else
-               ewl_widget_update_appearance(w, "normal");
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-void __ewl_button_show(Ewl_Widget * w, void *ev_data, void *user_data)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-
-       if (EWL_BUTTON(w)->label_object)
-               ewl_widget_show(EWL_BUTTON(w)->label_object);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ewl_container.c     25 Mar 2003 18:36:07 -0000      1.31
+++ ewl_container.c     1 Apr 2003 06:25:23 -0000       1.32
@@ -401,17 +401,13 @@
         */
        while ((child2 = ewl_container_get_child_at(EWL_CONTAINER(child),
                                                    x, y))) {
-               if (child2->recursive) {
-                       child = ewl_container_get_child_at(EWL_CONTAINER(child),
-                                                          x, y);
-
-                       if (!child)
-                               DRETURN_PTR(child2, DLEVEL_STABLE);
-               } else
+               if (child2->recursive)
+                       child = child2;
+               else
                        DRETURN_PTR(child2, DLEVEL_STABLE);
        }
 
-       DRETURN_PTR((child ? child : NULL), DLEVEL_STABLE);
+       DRETURN_PTR((child2 ? child2 : child), DLEVEL_STABLE);
 }
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tree.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_tree.c  29 Mar 2003 23:20:19 -0000      1.6
+++ ewl_tree.c  1 Apr 2003 06:25:23 -0000       1.7
@@ -1,18 +1,16 @@
 #include "Ewl.h"
 
-/*
- * FIXME: See fixme below.
- */
-#define DEFAULT_INDENT 30
-
 static void __ewl_tree_add(Ewl_Container *c, Ewl_Widget *w);
 static void __ewl_tree_child_resize(Ewl_Container *c, Ewl_Widget *w, int size,
                Ewl_Orientation o);
 static void __ewl_tree_configure(Ewl_Widget *w, void *ev_data, void *user_data);
 static void __ewl_tree_node_configure(Ewl_Widget * w, void *ev_data,
                void *user_data);
+static void __ewl_tree_node_clicked(Ewl_Widget * w, void *ev_data,
+               void *user_data);
 
 static void __ewl_tree_node_add(Ewl_Container *c, Ewl_Widget *w);
+static void __ewl_tree_node_remove(Ewl_Container *c, Ewl_Widget *w);
 static void __ewl_tree_node_resize(Ewl_Container *c, Ewl_Widget *w, int size,
                Ewl_Orientation o);
 
@@ -72,12 +70,6 @@
        tree->ncols = columns;
        tree->colw = NEW(int, columns);
 
-       /*
-        * FIXME: This should be configurable in the theme, possibly character
-        * width based.
-        */
-       tree->indent = DEFAULT_INDENT;
-
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
@@ -267,10 +259,12 @@
        DCHECK_PARAM_PTR_RET("node", node, FALSE);
 
        ewl_container_init(EWL_CONTAINER(node), "node", __ewl_tree_node_add,
-                       __ewl_tree_node_resize, NULL);
+                       __ewl_tree_node_resize, __ewl_tree_node_remove);
 
        ewl_callback_append(EWL_WIDGET(node), EWL_CALLBACK_CONFIGURE,
                        __ewl_tree_node_configure, NULL);
+       ewl_callback_append(EWL_WIDGET(node), EWL_CALLBACK_CLICKED,
+                       __ewl_tree_node_clicked, NULL);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
@@ -291,18 +285,17 @@
        if (!node->expanded)
                DRETURN(DLEVEL_STABLE);
 
-       node->expanded = FALSE;
-
        ewd_list_goto_first(EWL_CONTAINER(node)->children);
        ewd_list_next(EWL_CONTAINER(node)->children);
 
        while ((w = ewd_list_next(EWL_CONTAINER(node)->children))) {
                ewl_widget_hide(w);
-               ewl_object_set_preferred_h(EWL_OBJECT(node),
-                               PREFERRED_H(node) -
-                               ewl_object_get_preferred_h(EWL_OBJECT(w)));
        }
 
+       node->expanded = FALSE;
+
+       ewl_widget_update_appearance(EWL_WIDGET(node), "collapsed");
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -329,11 +322,10 @@
 
        while ((w = ewd_list_next(EWL_CONTAINER(node)->children))) {
                ewl_widget_show(w);
-               ewl_object_set_preferred_h(EWL_OBJECT(node),
-                               PREFERRED_H(node) +
-                               ewl_object_get_preferred_h(EWL_OBJECT(w)));
        }
 
+       ewl_widget_update_appearance(EWL_WIDGET(node), "expanded");
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -402,7 +394,7 @@
        Ewl_Tree_Node *node;
        Ewl_Container *c;
        Ewl_Object *child;
-       int x, y, width;
+       int y, width;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
@@ -421,15 +413,15 @@
         */
        ewl_object_request_geometry(child, CURRENT_X(w), CURRENT_Y(w),
                        CURRENT_W(w), ewl_object_get_preferred_h(child));
-       x = CURRENT_X(w);/* + node->tree->indent; */
+       
        y = CURRENT_Y(w) + ewl_object_get_current_h(child);
-       width = CURRENT_W(w) - x + CURRENT_X(w);
+       width = CURRENT_W(w) - CURRENT_X(w) + CURRENT_X(w);
 
        /*
         * All subsequent children are lower nodes and rows.
         */
        while ((child = ewd_list_next(c->children))) {
-               ewl_object_request_geometry(child, x, y, width,
+               ewl_object_request_geometry(child, CURRENT_X(w), y, width,
                                ewl_object_get_preferred_h(child));
                y += ewl_object_get_current_h(child);
        }
@@ -438,6 +430,22 @@
 }
 
 static void
+__ewl_tree_node_clicked(Ewl_Widget * w, void *ev_data, void *user_data)
+{
+       Ewl_Tree_Node *node;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       node = EWL_TREE_NODE(w);
+       if (node->expanded)
+               ewl_tree_node_collapse(node);
+       else
+               ewl_tree_node_expand(node);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
 __ewl_tree_node_add(Ewl_Container *c, Ewl_Widget *w)
 {
        int width;
@@ -447,7 +455,10 @@
 
        node = EWL_TREE_NODE(c);
 
-       if (node->expanded || !ewd_list_nodes(c->children)) {
+       if (!ewd_list_nodes(c->children))
+               node->row = w;
+
+       if (node->expanded || w == node->row) {
                ewl_object_set_preferred_h(EWL_OBJECT(c),
                                PREFERRED_H(c) +
                                ewl_object_get_preferred_h(EWL_OBJECT(w)));
@@ -456,6 +467,29 @@
        width = ewl_object_get_preferred_w(EWL_OBJECT(w));
        if (PREFERRED_W(c) < width)
                ewl_object_set_preferred_w(EWL_OBJECT(c), width);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+__ewl_tree_node_remove(Ewl_Container *c, Ewl_Widget *w)
+{
+       int width;
+       Ewl_Tree_Node *node;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       node = EWL_TREE_NODE(c);
+
+       if (node->expanded || w == node->row) {
+               ewl_object_set_preferred_h(EWL_OBJECT(c),
+                               PREFERRED_H(c) -
+                               ewl_object_get_preferred_h(EWL_OBJECT(w)));
+       }
+
+       width = ewl_object_get_preferred_w(EWL_OBJECT(w));
+       if (PREFERRED_W(c) >= width)
+               ewl_container_prefer_largest(c, EWL_ORIENTATION_HORIZONTAL);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tree.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_tree.h  25 Mar 2003 18:36:21 -0000      1.4
+++ ewl_tree.h  1 Apr 2003 06:25:23 -0000       1.5
@@ -21,8 +21,6 @@
 
        unsigned int **colbases;
        unsigned int **colbounds;
-
-       int indent;
 };
 
 typedef struct _ewl_tree_node Ewl_Tree_Node;
@@ -36,6 +34,7 @@
 {
        Ewl_Container container;
        Ewl_Tree *tree;
+       Ewl_Widget *row;
        int expanded;
 };
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- ewl_widget.c        25 Mar 2003 18:36:21 -0000      1.48
+++ ewl_widget.c        1 Apr 2003 06:25:23 -0000       1.49
@@ -7,25 +7,33 @@
 extern Ewl_Widget *last_focused;
 extern Ewl_Widget *dnd_widget;
 
-void            __ewl_widget_show(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_show(Ewl_Widget * w, void *ev_data,
                                  void *user_data);
-void            __ewl_widget_hide(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_hide(Ewl_Widget * w, void *ev_data,
                                  void *user_data);
-void            __ewl_widget_realize(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_realize(Ewl_Widget * w, void *ev_data,
                                     void *user_data);
-void            __ewl_widget_unrealize(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_unrealize(Ewl_Widget * w, void *ev_data,
                                     void *user_data);
-void            __ewl_widget_configure(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_configure(Ewl_Widget * w, void *ev_data,
                                       void *user_data);
-void            __ewl_widget_theme_update(Ewl_Widget * w, void *event_data,
+static void     __ewl_widget_theme_update(Ewl_Widget * w, void *event_data,
                                          void *user_data);
-void            __ewl_widget_destroy(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_destroy(Ewl_Widget * w, void *ev_data,
                                     void *user_data);
-void            __ewl_widget_reparent(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_reparent(Ewl_Widget * w, void *ev_data,
                                      void *user_data);
-void            __ewl_widget_enable(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_enable(Ewl_Widget * w, void *ev_data,
                                    void *user_data);
-void            __ewl_widget_disable(Ewl_Widget * w, void *ev_data,
+static void     __ewl_widget_disable(Ewl_Widget * w, void *ev_data,
+                                    void *user_data);
+static void     __ewl_widget_focus_in(Ewl_Widget * w, void *ev_data,
+                                    void *user_data);
+static void     __ewl_widget_focus_out(Ewl_Widget * w, void *ev_data,
+                                    void *user_data);
+static void     __ewl_widget_mouse_down(Ewl_Widget * w, void *ev_data,
+                                    void *user_data);
+static void     __ewl_widget_mouse_up(Ewl_Widget * w, void *ev_data,
                                     void *user_data);
 
 static inline void __ewl_widget_ebits_destroy(Ewl_Widget *w);
@@ -83,7 +91,15 @@
        ewl_callback_append(w, EWL_CALLBACK_WIDGET_ENABLE, __ewl_widget_enable,
                            NULL);
        ewl_callback_append(w, EWL_CALLBACK_WIDGET_DISABLE,
-                           __ewl_widget_disable, NULL);
+                       __ewl_widget_disable, NULL);
+       ewl_callback_append(w, EWL_CALLBACK_FOCUS_IN, __ewl_widget_focus_in,
+                           NULL);
+       ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT, __ewl_widget_focus_out,
+                           NULL);
+       ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, __ewl_widget_mouse_down,
+                           NULL);
+       ewl_callback_append(w, EWL_CALLBACK_MOUSE_UP, __ewl_widget_mouse_up,
+                           NULL);
 
        ewl_widget_set_appearance(w, appearance);
 
@@ -845,6 +861,37 @@
        ewl_widget_update_appearance(w, "disabled");
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+__ewl_widget_focus_in(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+       if (w->state & EWL_STATE_PRESSED)
+               ewl_widget_update_appearance(w, "clicked");
+       else
+               ewl_widget_update_appearance(w, "hilited");
+}
+
+static void
+__ewl_widget_focus_out(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+       ewl_widget_update_appearance(w, "normal");
+}
+
+static void
+__ewl_widget_mouse_down(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+       ewl_widget_update_appearance(w, "clicked");
+}
+
+static void
+__ewl_widget_mouse_up(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+       if (w->state & EWL_STATE_HILITED) {
+               ewl_widget_update_appearance(w, "hilited");
+               ewl_callback_call(w, EWL_CALLBACK_CLICKED);
+       } else
+               ewl_widget_update_appearance(w, "normal");
 }
 
 static inline void __ewl_widget_ebits_destroy(Ewl_Widget *w)




-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to