Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_paned.c ewl_tree2.c
Log Message:
- fix selection in tree2
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_paned.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_paned.c 9 Jan 2007 06:11:40 -0000 1.40
+++ ewl_paned.c 14 Jan 2007 23:11:03 -0000 1.41
@@ -708,15 +708,28 @@
}
static void
-ewl_paned_grabber_cb_mouse_down(Ewl_Widget *w, void *ev __UNUSED__,
+ewl_paned_grabber_cb_mouse_down(Ewl_Widget *w, void *ev,
void *data __UNUSED__)
{
+ Ewl_Paned *p;
+ Ewl_Event_Mouse_Down *event;
+ int ds;
+
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
+ event = ev;
+ p = EWL_PANED(w->parent);
+
+ if (ewl_paned_orientation_get(p) == EWL_ORIENTATION_HORIZONTAL)
+ ds = CURRENT_X(w) - event->x;
+ else
+ ds = CURRENT_Y(w) - event->y;
+
ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE,
- ewl_paned_grabber_cb_mouse_move, NULL);
+ ewl_paned_grabber_cb_mouse_move,
+ (void *) ds);
ewl_widget_state_set(w, "selected", EWL_STATE_PERSISTENT);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -738,19 +751,20 @@
}
static void
-ewl_paned_grabber_cb_mouse_move(Ewl_Widget *w, void *ev,
- void *data __UNUSED__)
+ewl_paned_grabber_cb_mouse_move(Ewl_Widget *w, void *ev, void *data)
{
Ewl_Event_Mouse_Move *e;
Ewl_Paned_Grabber *stop_grabber = NULL;
- Ewl_Widget *shrink = NULL, *grow = NULL, *child;
+ Ewl_Widget *child;
Ewl_Container *c;
Ewl_Paned *p;
- int cur_pos, amt, block_pos, grab_size, pos, cur_size = 0;
- int new_size, left, min, shrink_size, move_pos;
- int pane_pos, pane_size, pane_position;
- void *(*give_to)(Ecore_DList *list);
- void *(*take_from)(Ecore_DList *list);
+ Ewl_Widget *left_pane = NULL, *right_pane = NULL;
+
+ int paned_pos, paned_size;
+ int left_grabber_pos, right_grabber_pos;
+ int grabber_pos, grabber_size;
+ int mouse_pos, mouse_vec, mouse_offset;
+ int grabber_pos_new;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
@@ -760,49 +774,41 @@
e = ev;
p = EWL_PANED(w->parent);
c = EWL_CONTAINER(p);
+ mouse_offset = (int) data;
if (ewl_paned_orientation_get(p) == EWL_ORIENTATION_HORIZONTAL)
{
layout = horizontal_layout;
- move_pos = e->x;
- pane_position = CURRENT_X(p);
- pane_size = CURRENT_W(p);
+ mouse_pos = e->x;
+ paned_pos = CURRENT_X(p);
+ paned_size = CURRENT_W(p);
}
else
{
layout = vertical_layout;
- move_pos = e->y;
- pane_position = CURRENT_Y(p);
- pane_size = CURRENT_H(p);
+ mouse_pos = e->y;
+ paned_pos = CURRENT_Y(p);
+ paned_size = CURRENT_H(p);
}
- cur_pos = layout->current_position(EWL_OBJECT(w));
-
- /* shifting left */
- if ((cur_pos - move_pos) > 0)
- {
- give_to = ecore_dlist_next;
- take_from = ecore_dlist_previous;
- amt = cur_pos - move_pos;
- left = 1;
- }
- else if ((cur_pos - move_pos) < 0)
- {
- give_to = ecore_dlist_previous;
- take_from = ecore_dlist_next;
- amt = move_pos - cur_pos;
- left = 0;
- }
- else
+ grabber_pos = layout->current_position(EWL_OBJECT(w));
+ grabber_size = layout->current_size(EWL_OBJECT(w));
+
+ /*
+ * this is the vector pointing from the left edge of the grabber
+ * to the mouse position, so is it neagtive the grabber will
+ * be moved to the left side and is it positiv to the right
+ */
+ mouse_vec = mouse_pos - grabber_pos + mouse_offset;
+ if (mouse_vec == 0)
DRETURN(DLEVEL_STABLE);
- /* find the pane we are shifting into and the grabber
- * blockign us */
+ /* find the left grabber that is blocking us */
ecore_dlist_goto(c->children, w);
/* move past the selected grabber */
- take_from(c->children);
- while ((child = take_from(c->children)))
+ ecore_dlist_previous(c->children);
+ while ((child = ecore_dlist_previous(c->children)))
{
if (!VISIBLE(child)) continue;
@@ -812,94 +818,104 @@
break;
}
else
- shrink = child;
+ left_pane = child;
}
- /* find the pane we are giving space too */
+ /* if we didn't find a left grabber set the paned position instead */
+ if (stop_grabber)
+ left_grabber_pos =
+ layout->current_position(EWL_OBJECT(stop_grabber))
+ + grabber_size;
+ else
+ left_grabber_pos = paned_pos;
+
+ /* and now find the right pane */
ecore_dlist_goto(c->children, w);
+ stop_grabber = NULL;
/* move past the selected grabber */
- give_to(c->children);
- while ((child = give_to(c->children)))
+ ecore_dlist_next(c->children);
+ while ((child = ecore_list_next(c->children)))
{
if (!VISIBLE(child)) continue;
- if (ewl_widget_type_is(child, EWL_PANED_GRABBER_TYPE))
- printf("ERROR found grabber instead of child?\n");
- else
- {
- grow = child;
+ if (ewl_widget_type_is(child, EWL_PANED_GRABBER_TYPE)) {
+ stop_grabber = EWL_PANED_GRABBER(child);
break;
}
- }
-
- /* make sure the grabber dosen't move past the grabber before it or
- * the edges of the paned */
- grab_size = layout->current_size(EWL_OBJECT(w));
- if (stop_grabber)
- block_pos = layout->current_position(EWL_OBJECT(stop_grabber));
- else if (left)
- block_pos = pane_position;
- else
- block_pos = pane_position + pane_size;
-
- min = layout->minimum_size(EWL_OBJECT(shrink));
- cur_size = layout->current_size(EWL_OBJECT(shrink));
- if (left)
- {
- if ((cur_pos - amt) < (block_pos + grab_size + min))
- pos = block_pos + grab_size + min;
else
- pos = cur_pos - amt;
-
- amt = cur_pos - pos;
-
- /* don't have to shrink free space */
- if ((cur_pos - amt) < (block_pos + grab_size + cur_size))
- shrink_size = amt - (cur_pos - cur_size - block_pos -
grab_size);
- else
- shrink_size = 0;
-
- /* move the right pane */
- pane_pos = layout->current_position(EWL_OBJECT(grow));
- layout->position_request(EWL_OBJECT(grow), pane_pos - amt);
+ right_pane = child;
}
+
+ /* if we didn't find a left grabber set the paned position instead */
+ if (stop_grabber)
+ right_grabber_pos =
+ layout->current_position(EWL_OBJECT(stop_grabber));
else
- {
- if ((cur_pos + amt + grab_size + min) > block_pos)
- pos = block_pos - min - grab_size;
- else
- pos = cur_pos + amt;
-
- amt = pos - cur_pos;
+ right_grabber_pos = paned_pos + paned_size;
- /* don't have to shrink free space */
- if ((cur_pos + amt + grab_size + cur_size) > block_pos)
- shrink_size = amt - (block_pos - cur_pos - cur_size);
- else
- shrink_size = 0;
-
- /* move the right pane */
- pane_pos = layout->current_position(EWL_OBJECT(shrink));
- layout->position_request(EWL_OBJECT(shrink), pane_pos + amt);
+ /*
+ * now we have collected enought data to place the grabber
+ * and the panes on their new places
+ */
+ /* we don't want to shrink the panes more that it is allowed */
+ if (mouse_vec < 0) {
+ /* the left side get shrinked */
+ int pane_min = layout->minimum_size(EWL_OBJECT(left_pane));
+ if (grabber_pos + mouse_vec - left_grabber_pos < pane_min)
+ grabber_pos_new = left_grabber_pos + pane_min;
+ else
+ /* note that mouse_vec is here negative! */
+ grabber_pos_new = grabber_pos + mouse_vec;
+ }
+ else {
+ /* the right side get shrinked */
+ int pane_min = layout->minimum_size(EWL_OBJECT(right_pane));
+ if (right_grabber_pos - (grabber_pos + mouse_vec + grabber_size)
+ < pane_min)
+ grabber_pos_new =
+ right_grabber_pos - pane_min - grabber_size;
+ else
+ grabber_pos_new = grabber_pos + mouse_vec;
+ }
+
+ /*
+ * finally we can place the stuff
+ */
+ if (ewl_paned_orientation_get(p) == EWL_ORIENTATION_HORIZONTAL) {
+ ewl_object_place(EWL_OBJECT(left_pane), left_grabber_pos,
+ CURRENT_Y(p),
+ grabber_pos_new - left_grabber_pos,
+ CURRENT_H(p));
+ ewl_object_place(EWL_OBJECT(w), grabber_pos_new,
+ CURRENT_Y(p),
+ grabber_size,
+ CURRENT_H(p));
+ ewl_object_place(EWL_OBJECT(right_pane),
+ grabber_pos_new + grabber_size,
+ CURRENT_Y(p),
+ right_grabber_pos - grabber_pos_new
+ - grabber_size,
+ CURRENT_H(p));
+ }
+ else {
+ ewl_object_place(EWL_OBJECT(left_pane),
+ CURRENT_X(p),
+ left_grabber_pos,
+ CURRENT_W(p),
+ grabber_pos_new - left_grabber_pos);
+ ewl_object_place(EWL_OBJECT(w),
+ CURRENT_X(p),
+ grabber_pos_new,
+ CURRENT_W(p),
+ grabber_size);
+ ewl_object_place(EWL_OBJECT(right_pane),
+ CURRENT_X(p),
+ grabber_pos_new + grabber_size,
+ CURRENT_W(p),
+ right_grabber_pos - grabber_pos_new
+ - grabber_size);
}
-
- cur_size = layout->current_size(EWL_OBJECT(shrink));
- layout->variable_request(EWL_OBJECT(shrink), cur_size - shrink_size);
- new_size = layout->current_size(EWL_OBJECT(shrink));
-
- /* XXX didn't shirnk the entire amount do something ... */
- if ((cur_size - new_size) != shrink_size)
- {
- printf("ERROR, didn't shrink the entire amount ...?.\n");
- }
-
- cur_size = layout->current_size(EWL_OBJECT(grow));
- layout->variable_request(EWL_OBJECT(grow), cur_size + amt);
- new_size = layout->current_size(EWL_OBJECT(grow));
-
- /* place the grabber */
- layout->position_request(EWL_OBJECT(w), pos);
/* send a value_changed callback to signal something moved */
ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_tree2.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -3 -r1.48 -r1.49
--- ewl_tree2.c 12 Jan 2007 10:31:22 -0000 1.48
+++ ewl_tree2.c 14 Jan 2007 23:11:03 -0000 1.49
@@ -691,7 +691,8 @@
}
static void
-ewl_tree2_column_build(Ewl_Row *row, Ewl_Tree2_Column *col, void *mvc_data,
int r, int c)
+ewl_tree2_column_build(Ewl_Row *row, Ewl_Tree2_Column *col, void *mvc_data,
+ int r, int c, Ewl_Widget *node)
{
Ewl_Widget *cell;
Ewl_Widget *child;
@@ -707,7 +708,7 @@
ewl_container_child_append(EWL_CONTAINER(row), cell);
ewl_attach_widget_association_set(cell, row);
ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
- ewl_tree2_cb_cell_clicked, NULL);
+ ewl_tree2_cb_cell_clicked, node);
ewl_widget_show(cell);
val = col->model->fetch(mvc_data, r, c);
@@ -795,7 +796,7 @@
ewl_container_child_append(EWL_CONTAINER(node), row);
ewl_attach_widget_association_set(row, tree);
ewl_callback_append(row, EWL_CALLBACK_CLICKED,
- ewl_tree2_cb_row_clicked, NULL);
+ ewl_tree2_cb_row_clicked, node);
EWL_TREE2_NODE(node)->row = row;
ewl_widget_show(row);
@@ -810,7 +811,8 @@
ecore_list_goto_first(tree->columns);
while((col = ecore_list_next(tree->columns)))
{
- ewl_tree2_column_build(EWL_ROW(row), col,
curbranch->data, i, column);
+ ewl_tree2_column_build(EWL_ROW(row), col,
+ curbranch->data, i, column, node);
column ++;
}
@@ -890,8 +892,7 @@
}
static void
-ewl_tree2_cb_row_clicked(Ewl_Widget *w, void *ev __UNUSED__,
- void *data __UNUSED__)
+ewl_tree2_cb_row_clicked(Ewl_Widget *w, void *ev __UNUSED__, void *data)
{
Ewl_Tree2 *tree;
int row;
@@ -904,15 +905,15 @@
if (tree->type != EWL_TREE_SELECTION_TYPE_ROW)
DRETURN(DLEVEL_STABLE);
- row = ewl_container_child_index_get(EWL_CONTAINER(tree->rows), w);
+ row = ewl_container_child_index_get(EWL_CONTAINER(tree->rows),
+ EWL_WIDGET(data));
ewl_mvc_handle_click(EWL_MVC(tree), row, -1);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
static void
-ewl_tree2_cb_cell_clicked(Ewl_Widget *w, void *ev __UNUSED__,
- void *data __UNUSED__)
+ewl_tree2_cb_cell_clicked(Ewl_Widget *w, void *ev __UNUSED__, void *data)
{
Ewl_Row *row;
Ewl_Tree2 *tree;
@@ -928,7 +929,7 @@
DRETURN(DLEVEL_STABLE);
r = ewl_container_child_index_get(EWL_CONTAINER(tree->rows),
- EWL_WIDGET(row));
+ EWL_WIDGET(data));
column = ewl_container_child_index_get(EWL_CONTAINER(row), w);
ewl_mvc_handle_click(EWL_MVC(tree), r, column);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs