diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-16 10:56:44 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-16 10:56:44 +0800 |
commit | 8a6f65830092a2dec14005dc5712ee1ef54598a7 (patch) | |
tree | b2917dcacc28dffec73be9ad50025023391280e2 /calendar/gui | |
parent | 96eeb8b74e8994d1b08e50dc0c3df9cd895a2f9e (diff) | |
download | gsoc2013-evolution-8a6f65830092a2dec14005dc5712ee1ef54598a7.tar.gz gsoc2013-evolution-8a6f65830092a2dec14005dc5712ee1ef54598a7.tar.zst gsoc2013-evolution-8a6f65830092a2dec14005dc5712ee1ef54598a7.zip |
Now children have a vertical handle as well. This can be used to move the
1998-04-15 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (child_draw): Now children have a vertical
handle as well. This can be used to move the child anytime, not
only when it is focused.
(recompute_motion): Modified for new drag behavior.
svn path=/trunk/; revision=142
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/gncal-full-day.c | 107 |
1 files changed, 72 insertions, 35 deletions
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 7e3d2e0d41..6d95a79d41 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -41,14 +41,16 @@ struct layout_row { struct drag_info { enum { DRAG_NONE, - DRAG_SELECT, /* selecting a range in the main window */ - DRAG_MOVE, /* moving a child */ - DRAG_SIZE /* resizing a child */ + DRAG_SELECT, /* selecting a range in the main window */ + DRAG_MOVE, /* moving a child */ + DRAG_SIZE_TOP, /* resizing a child */ + DRAG_SIZE_BOTTOM } drag_mode; Child *child; - int start_row; - int rows_used; + int child_click_y; + int child_start_row; + int child_rows_used; int sel_click_row; int sel_start_row; @@ -179,11 +181,14 @@ static void child_set_text_pos (Child *child) { GtkAllocation allocation; + int has_focus; - allocation.x = 0; - allocation.y = (GTK_WIDGET_HAS_FOCUS (child->widget) ? HANDLE_SIZE : 0); - allocation.width = child->width; - allocation.height = child->height - (GTK_WIDGET_HAS_FOCUS (child->widget) ? (2 * HANDLE_SIZE) : 0); + has_focus = GTK_WIDGET_HAS_FOCUS (child->widget); + + allocation.x = HANDLE_SIZE; + allocation.y = has_focus ? HANDLE_SIZE : 0; + allocation.width = child->width - HANDLE_SIZE; + allocation.height = child->height - (has_focus ? (2 * HANDLE_SIZE) : 0); gtk_widget_size_request (child->widget, &child->widget->requisition); /* FIXME: is this needed? */ gtk_widget_size_allocate (child->widget, &allocation); @@ -238,6 +243,7 @@ static void child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_child) { GdkRectangle arect, rect, dest; + int has_focus; if (!area) { arect.x = 0; @@ -249,25 +255,40 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch area = &arect; } - /* Top handle */ + has_focus = GTK_WIDGET_HAS_FOCUS (child->widget); + + /* Left handle */ rect.x = 0; rect.y = 0; - rect.width = child->width; - rect.height = HANDLE_SIZE; + rect.width = HANDLE_SIZE; + rect.height = has_focus ? (child->height - HANDLE_SIZE) : child->height; if (gdk_rectangle_intersect (&rect, area, &dest)) view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); - /* Bottom handle */ + if (has_focus) { + /* Top handle */ - rect.y = child->height - HANDLE_SIZE; + rect.x = HANDLE_SIZE; + rect.y = 0; + rect.width = child->width - HANDLE_SIZE; + rect.height = HANDLE_SIZE; - if (gdk_rectangle_intersect (&rect, area, &dest)) - view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); + if (gdk_rectangle_intersect (&rect, area, &dest)) + view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); + + /* Bottom handle */ + + rect.y = child->height - HANDLE_SIZE; + + if (gdk_rectangle_intersect (&rect, area, &dest)) + view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); + } if (draw_child) { - area->y -= HANDLE_SIZE; + area->x -= HANDLE_SIZE; + area->y -= has_focus ? HANDLE_SIZE : 0; gtk_widget_draw (child->widget, area); } } @@ -1309,9 +1330,9 @@ draw_xor_rect (GncalFullDay *fullday) widget->style->white_gc, FALSE, di->child->x + i, - di->start_row * row_height + ythickness + i, + di->child_start_row * row_height + ythickness + i, di->child->width - 2 * i - 1, - di->rows_used * row_height - 2 * i - 2); + di->child_rows_used * row_height - 2 * i - 2); gdk_gc_set_function (widget->style->white_gc, GDK_COPY); gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN); @@ -1419,17 +1440,20 @@ button_1 (GncalFullDay *fullday, GdkEventButton *event) gtk_widget_get_pointer (widget, NULL, &y); - if (event->y < HANDLE_SIZE) + if (event->x < HANDLE_SIZE) di->drag_mode = DRAG_MOVE; + else if (event->y < HANDLE_SIZE) + di->drag_mode = DRAG_SIZE_TOP; else - di->drag_mode = DRAG_SIZE; + di->drag_mode = DRAG_SIZE_BOTTOM; row_height = calc_row_height (fullday); di->child = child; - di->start_row = get_row_from_y (fullday, child->y, FALSE); - di->rows_used = child->height / row_height; + di->child_click_y = event->y; + di->child_start_row = get_row_from_y (fullday, child->y, FALSE); + di->child_rows_used = child->height / row_height; gdk_pointer_grab (child->window, FALSE, (GDK_BUTTON_MOTION_MASK @@ -1534,24 +1558,35 @@ recompute_motion (GncalFullDay *fullday, int y) break; case DRAG_MOVE: - row = get_row_from_y (fullday, y, FALSE); + row = get_row_from_y (fullday, y - di->child_click_y, TRUE); + + if (row > (f_rows - di->child_rows_used)) + row = f_rows - di->child_rows_used; + + di->child_start_row = row; + + break; + + case DRAG_SIZE_TOP: + row = get_row_from_y (fullday, y, TRUE); - if (row > (f_rows - di->rows_used)) - row = f_rows - di->rows_used; + if (row > (di->child_start_row + di->child_rows_used - 1)) + row = di->child_start_row + di->child_rows_used - 1; - di->start_row = row; + di->child_rows_used = (di->child_start_row + di->child_rows_used) - row; + di->child_start_row = row; break; - case DRAG_SIZE: + case DRAG_SIZE_BOTTOM: row = get_row_from_y (fullday, y, TRUE); - if (row <= di->start_row) - row = di->start_row + 1; + if (row <= di->child_start_row) + row = di->child_start_row + 1; else if (row > f_rows) row = f_rows; - di->rows_used = row - di->start_row; + di->child_rows_used = row - di->child_start_row; break; @@ -1587,7 +1622,7 @@ update_from_drag_info (GncalFullDay *fullday) widget = GTK_WIDGET (fullday); - get_time_from_rows (fullday, di->start_row, di->rows_used, + get_time_from_rows (fullday, di->child_start_row, di->child_rows_used, &di->child->ico->dtstart, &di->child->ico->dtend); @@ -1632,14 +1667,15 @@ gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) break; case DRAG_MOVE: - case DRAG_SIZE: + case DRAG_SIZE_TOP: + case DRAG_SIZE_BOTTOM: draw_xor_rect (fullday); recompute_motion (fullday, y); gdk_pointer_ungrab (event->time); update_from_drag_info (fullday); - di->rows_used = 0; + di->child_rows_used = 0; break; @@ -1693,7 +1729,8 @@ gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event) break; case DRAG_MOVE: - case DRAG_SIZE: + case DRAG_SIZE_TOP: + case DRAG_SIZE_BOTTOM: draw_xor_rect (fullday); recompute_motion (fullday, y); draw_xor_rect (fullday); |