Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src Modified Files: ewl_entry.c ewl_object.c ewl_scrollpane.c Log Message: Handle size changes caused by a change in the object fill policy. Started refactoring the scrollpane to make use of the cell widget. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -3 -r1.59 -r1.60 --- ewl_entry.c 8 Jun 2003 07:17:31 -0000 1.59 +++ ewl_entry.c 9 Jun 2003 05:55:13 -0000 1.60 @@ -221,7 +221,7 @@ base = ewl_cursor_get_base_position(EWL_CURSOR(e->cursor)); l = ewl_text_get_length(EWL_TEXT(e->text)); - if (l && c_spos > l) { + if (c_spos > l) { ex = sx = ewl_object_get_current_x(EWL_OBJECT(e->text)) + ewl_object_get_current_w(EWL_OBJECT(e->text)); ew = 5; =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- ewl_object.c 3 Jun 2003 04:00:47 -0000 1.36 +++ ewl_object.c 9 Jun 2003 05:55:13 -0000 1.37 @@ -176,12 +176,6 @@ DCHECK_PARAM_PTR("o", o); /* - * We may need to simulate resizes for changes in fill policy - if (w == PREFERRED_W(o)) - DRETURN(DLEVEL_STABLE); - */ - - /* * Store the previous size. */ old_size = PREFERRED_W(o); @@ -197,8 +191,9 @@ /* * Now update the widgets parent of the change in size. */ - ewl_container_resize_child(EWL_WIDGET(o), new_size - old_size, - EWL_ORIENTATION_HORIZONTAL); + if (!(o->flags & EWL_FILL_POLICY_HSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), new_size - old_size, + EWL_ORIENTATION_HORIZONTAL); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -220,12 +215,6 @@ DCHECK_PARAM_PTR("o", o); /* - * We may need to simulate resizes for changes in fill policy - if (h == PREFERRED_W(o)) - DRETURN(DLEVEL_STABLE); - */ - - /* * Store the previous size */ old_size = PREFERRED_H(o); @@ -241,9 +230,9 @@ /* * Notify the parent widgets of the change in size. */ - ewl_container_resize_child(EWL_WIDGET(o), - new_size - old_size, - EWL_ORIENTATION_VERTICAL); + if (!(o->flags & EWL_FILL_POLICY_VSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), new_size - old_size, + EWL_ORIENTATION_VERTICAL); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -536,10 +525,14 @@ */ inline void ewl_object_set_minimum_w(Ewl_Object * o, unsigned int w) { + unsigned int old_size, new_size; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("o", o); - MINIMUM_W(o) = w; + old_size = MINIMUM_W(o); + + new_size = MINIMUM_W(o) = w; if (MAXIMUM_W(o) < w) MAXIMUM_W(o) = w; @@ -550,6 +543,13 @@ if (CURRENT_W(o) < w) ewl_object_request_w(o, w); + /* + * Notify the parent widgets of the change in size. + */ + if (o->flags & EWL_FILL_POLICY_HSHRINK) + ewl_container_resize_child(EWL_WIDGET(o), new_size - old_size, + EWL_ORIENTATION_HORIZONTAL); + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -565,10 +565,14 @@ */ inline void ewl_object_set_minimum_h(Ewl_Object * o, unsigned int h) { + unsigned int old_size, new_size; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("o", o); - MINIMUM_H(o) = h; + old_size = MINIMUM_H(o); + + new_size = MINIMUM_H(o) = h; if (MAXIMUM_H(o) < h) MAXIMUM_H(o) = h; @@ -579,6 +583,13 @@ if (CURRENT_H(o) < h) ewl_object_request_h(o, h); + /* + * Notify the parent widgets of the change in size. + */ + if (o->flags & EWL_FILL_POLICY_VSHRINK) + ewl_container_resize_child(EWL_WIDGET(o), new_size - old_size, + EWL_ORIENTATION_VERTICAL); + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -1114,15 +1125,47 @@ */ inline void ewl_object_set_fill_policy(Ewl_Object * o, Ewl_Fill_Policy fill) { + unsigned int old_mask; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("o", o); + if ((o->flags & EWL_FILL_POLICY_MASK) == fill) + DRETURN(DLEVEL_STABLE); + + old_mask = o->flags; + /* * Keep the alignment portion and fill in the fill policy. */ o->flags &= EWL_ALIGNMENT_MASK; o->flags |= fill; + + /* + * Notify the parent of a resize if the fill policy causes the returned + * minimum size to change. Check horizontal change first. + */ + if ((old_mask & EWL_FILL_POLICY_HSHRINK) && + !(fill & EWL_FILL_POLICY_HSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), PREFERRED_W(o) - + MINIMUM_W(o), EWL_ORIENTATION_HORIZONTAL); + else if (!(old_mask & EWL_FILL_POLICY_HSHRINK) && + (fill & EWL_FILL_POLICY_HSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), MINIMUM_W(o) - + PREFERRED_W(o), EWL_ORIENTATION_HORIZONTAL); + + /* + * Now the vertical change + */ + if ((old_mask & EWL_FILL_POLICY_VSHRINK) && + !(fill & EWL_FILL_POLICY_VSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), PREFERRED_H(o) - + MINIMUM_H(o), EWL_ORIENTATION_VERTICAL); + else if (!(old_mask & EWL_FILL_POLICY_VSHRINK) && + (fill & EWL_FILL_POLICY_VSHRINK)) + ewl_container_resize_child(EWL_WIDGET(o), MINIMUM_H(o) - + PREFERRED_H(o), EWL_ORIENTATION_VERTICAL); if (EWL_WIDGET(o)->parent) ewl_widget_configure(EWL_WIDGET(o)->parent); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- ewl_scrollpane.c 3 Jun 2003 04:00:48 -0000 1.12 +++ ewl_scrollpane.c 9 Jun 2003 05:55:13 -0000 1.13 @@ -17,10 +17,6 @@ void __ewl_scrollpane_body_configure(Ewl_Widget * w, void *ev_data, void *user_data); -void __ewl_scrollpane_box_add(Ewl_Container * p, Ewl_Widget * child); -void __ewl_scrollpane_box_resize(Ewl_Container * p, Ewl_Widget * w, - int size, Ewl_Orientation o); - /** * ewl_scrollpane_new - create a new scrollpane * @@ -58,23 +54,15 @@ w = EWL_WIDGET(s); - ewl_container_init(EWL_CONTAINER(s), "scrollpane", - __ewl_scrollpane_add, __ewl_scrollpane_child_resize, - NULL); + ewl_container_init(EWL_CONTAINER(s), "scrollpane", __ewl_scrollpane_add, + __ewl_scrollpane_child_resize, NULL); /* * Create the container to hold the contents and it's configure * callback to position it's child. */ - s->box = NEW(Ewl_Container, 1); - ZERO(s->box, Ewl_Container, 1); - ewl_container_init(EWL_CONTAINER(s->box), - "scrollbox", - __ewl_scrollpane_box_add, - __ewl_scrollpane_box_resize, NULL); - - ewl_callback_append(s->box, EWL_CALLBACK_CONFIGURE, - __ewl_scrollpane_body_configure, s); + s->box = ewl_cell_new(); + ewl_widget_set_appearance(EWL_WIDGET(s->box), "scrollbox"); /* * Create the scrollbars for the scrollpane. @@ -257,76 +245,6 @@ } /* - * Configure the inner container of the scrollpane. - */ -void -__ewl_scrollpane_body_configure(Ewl_Widget * w, void *ev_data, void *user_data) -{ - double hfill, vfill; - int woffset, hoffset; - Ewl_Container *c; - Ewl_ScrollPane *s; - Ewl_Object *child; - - DENTER_FUNCTION(DLEVEL_STABLE); - - DCHECK_PARAM_PTR("user_data", user_data); - - c = EWL_CONTAINER(w); - s = EWL_SCROLLPANE(user_data); - - /* - * Get the value of the scrollbars. - */ - hfill = ewl_scrollbar_get_value(EWL_SCROLLBAR(s->hscrollbar)); - vfill = ewl_scrollbar_get_value(EWL_SCROLLBAR(s->vscrollbar)); - - /* - * Get the child to configure and return if none present - */ - child = ewd_list_goto_first(c->children); - if (!child) - DRETURN(DLEVEL_STABLE); - - /* - * Give the child it's preferred size. - */ - ewl_object_request_size(EWL_OBJECT(child), - ewl_object_get_minimum_w(child), - ewl_object_get_minimum_h(child)); - - /* - * Get the usable space of the container. - */ - woffset = CURRENT_W(w); - hoffset = CURRENT_H(w); - - /* - * Determine the distance to offset the position of the child. - */ - woffset = hfill * (CURRENT_W(child) - woffset); - hoffset = vfill * (CURRENT_H(child) - hoffset); - - /* - * Protect against scrolling small items. - */ - if (woffset < 0) - woffset = 0; - - if (hoffset < 0) - hoffset = 0; - - /* - * Now position the child correctly. - */ - ewl_object_request_position(EWL_OBJECT(child), - CURRENT_X(w) - woffset, - CURRENT_Y(w) - hoffset); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/* * When a horizontal scrollbar is clicked we need to move the contents of the * scrollpane horizontally. */ @@ -394,12 +312,6 @@ s = EWL_SCROLLPANE(parent); /* - * We don't really care when the scrollbars are resized. - */ -/* if (child != s->box) - DRETURN(DLEVEL_STABLE); */ - - /* * Update the preferred size of the scrollpane to that of the box. */ if (o == EWL_ORIENTATION_HORIZONTAL) @@ -412,39 +324,4 @@ ewl_object_get_minimum_h(EWL_OBJECT(s->hscrollbar))); DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/* - * When adding a child to the container, remove any other children. - */ -void __ewl_scrollpane_box_add(Ewl_Container * p, Ewl_Widget * child) -{ - /* - * Remove all the children before the newly added one. - */ - while (ewd_list_goto_first(p->children) != child) - ewd_list_remove_first(p->children); - - /* - * Remove all the children after the newly added one. - */ - while (ewd_list_goto_last(p->children) != child) - ewd_list_remove_last(p->children); - - ewl_object_set_preferred_size(EWL_OBJECT(p), - ewl_object_get_minimum_w(EWL_OBJECT(child)), - ewl_object_get_minimum_h(EWL_OBJECT(child))); -} - -void -__ewl_scrollpane_box_resize(Ewl_Container * p, Ewl_Widget * w, int size, - Ewl_Orientation o) -{ - /* - * Set the new preferred dimensions of the box. - */ - ewl_object_set_preferred_w(EWL_OBJECT(p), - ewl_object_get_minimum_w(EWL_OBJECT(w))); - ewl_object_set_preferred_h(EWL_OBJECT(p), - ewl_object_get_minimum_h(EWL_OBJECT(w))); } ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs