mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Changes to gtktreeview to better support thicker focus lines,
and enhancements to the visibility of the default expander when its size has been increased.
This commit is contained in:
parent
d8068f867c
commit
011cb31f18
24
ChangeLog
24
ChangeLog
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -1,3 +1,27 @@
|
||||
2002-01-28 Bill Haneman <bill.haneman@sun.com>
|
||||
|
||||
* gtk/gtkstyle.c:
|
||||
Make sure that the default expanders are drawn with
|
||||
an outline thickness appropriate to the size of the
|
||||
expanders (RINT expander_size/7).
|
||||
Added static gtk_style_draw_polygon_with_gc(), to
|
||||
reduce code duplication.
|
||||
|
||||
* gtk/gtktreeview.c: (gtk_tree_view_bin_expose):
|
||||
Use focus_line_thickness when drawing focus lines.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c:(gtk_tree_view_column_cell_get_size):
|
||||
Adjust requested width to include focus line thickness.
|
||||
(gtk_tree_view_column_cell_render_or_focus):
|
||||
Calculate a focus line rectangle which gets larger as the focus
|
||||
line thickness increases, to avoid overwriting cell content.
|
||||
Render left-aligned content at x+focus_line_width.
|
||||
(gtk_tree_view_column_cell_draw_focus):
|
||||
Don't draw a focus line around an editable text cell, since the
|
||||
text caret already indicates keyboard focus.
|
||||
Pass a GtkStateType appropriate to the focussed cell's state
|
||||
to gtk_paint_focus.
|
||||
|
||||
Mon Jan 28 14:44:40 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_real_select_cursor_row): Only
|
||||
|
@ -4345,6 +4345,18 @@ apply_affine_on_point (double affine[6], GdkPoint *point)
|
||||
point->y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_draw_polygon_with_gc (GdkWindow *window, GdkGC *gc, gint line_width,
|
||||
gboolean do_fill, GdkPoint *points, gint n_points)
|
||||
{
|
||||
gdk_gc_set_line_attributes (gc, line_width,
|
||||
GDK_LINE_SOLID,
|
||||
GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
|
||||
gdk_draw_polygon (window, gc, do_fill, points, n_points);
|
||||
gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_default_draw_expander (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
@ -4359,12 +4371,14 @@ gtk_default_draw_expander (GtkStyle *style,
|
||||
gint expander_size;
|
||||
GdkPoint points[3];
|
||||
gint i;
|
||||
gint line_width;
|
||||
gdouble affine[6];
|
||||
gint degrees = 0;
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"expander_size", &expander_size,
|
||||
NULL);
|
||||
line_width = MAX (1, expander_size/7);
|
||||
|
||||
if (area)
|
||||
{
|
||||
@ -4372,12 +4386,13 @@ gtk_default_draw_expander (GtkStyle *style,
|
||||
gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
|
||||
}
|
||||
|
||||
points[0].x = 0;
|
||||
points[0].y = 0;
|
||||
points[1].x = expander_size / 2;
|
||||
points[1].y = expander_size / 2;
|
||||
points[2].x = 0;
|
||||
points[2].y = expander_size;
|
||||
expander_size -= (line_width * 2 - 2);
|
||||
points[0].x = line_width / 2;
|
||||
points[0].y = line_width / 2;
|
||||
points[1].x = expander_size / 2 + line_width / 2;
|
||||
points[1].y = expander_size / 2 + line_width / 2;
|
||||
points[2].x = line_width / 2;
|
||||
points[2].y = expander_size + line_width / 2;
|
||||
|
||||
switch (expander_style)
|
||||
{
|
||||
@ -4404,22 +4419,22 @@ gtk_default_draw_expander (GtkStyle *style,
|
||||
|
||||
if (state_type == GTK_STATE_PRELIGHT)
|
||||
{
|
||||
gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
TRUE, points, 3);
|
||||
gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
1, TRUE, points, 3);
|
||||
}
|
||||
else if (state_type == GTK_STATE_ACTIVE)
|
||||
{
|
||||
gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
|
||||
TRUE, points, 3);
|
||||
gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
FALSE, points, 3);
|
||||
gtk_style_draw_polygon_with_gc (window, style->light_gc[GTK_STATE_ACTIVE],
|
||||
1, TRUE, points, 3);
|
||||
gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
line_width, FALSE, points, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
|
||||
TRUE, points, 3);
|
||||
gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
FALSE, points, 3);
|
||||
gtk_style_draw_polygon_with_gc (window, style->base_gc[GTK_STATE_NORMAL],
|
||||
1, TRUE, points, 3);
|
||||
gtk_style_draw_polygon_with_gc (window, style->fg_gc[GTK_STATE_NORMAL],
|
||||
line_width, FALSE, points, 3);
|
||||
}
|
||||
if (area)
|
||||
{
|
||||
|
@ -2854,6 +2854,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
GtkRBTree *tree = NULL;
|
||||
GtkRBNode *node = NULL;
|
||||
gint width;
|
||||
gint focus_line_width;
|
||||
|
||||
switch (tree_view->priv->drag_dest_pos)
|
||||
{
|
||||
@ -2873,15 +2874,18 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
|
||||
break;
|
||||
gdk_drawable_get_size (tree_view->priv->bin_window,
|
||||
&width, NULL);
|
||||
gtk_widget_style_get (widget, "focus-line-width", &focus_line_width, NULL);
|
||||
gtk_paint_focus (widget->style,
|
||||
tree_view->priv->bin_window,
|
||||
GTK_WIDGET_STATE (widget),
|
||||
NULL,
|
||||
widget,
|
||||
"treeview-drop-indicator",
|
||||
0, BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
|
||||
width, MAX (BACKGROUND_HEIGHT (node), tree_view->priv->expander_size));
|
||||
|
||||
0, BACKGROUND_FIRST_PIXEL (tree_view, tree, node)
|
||||
- focus_line_width / 2,
|
||||
width, MAX(BACKGROUND_HEIGHT (node),
|
||||
tree_view->priv->expander_size)
|
||||
- focus_line_width + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2131,6 +2131,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
||||
{
|
||||
GList *list;
|
||||
gboolean first_cell = TRUE;
|
||||
gint focus_line_width;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
|
||||
@ -2139,6 +2140,8 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
||||
if (width)
|
||||
* width = 0;
|
||||
|
||||
gtk_widget_style_get (tree_column->tree_view, "focus-line-width", &focus_line_width, NULL);
|
||||
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
|
||||
@ -2162,8 +2165,8 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
|
||||
&new_height);
|
||||
|
||||
if (height)
|
||||
* height = MAX (*height, new_height);
|
||||
info->requested_width = MAX (info->requested_width, new_width);
|
||||
* height = MAX (*height, new_height + focus_line_width * 2);
|
||||
info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
|
||||
if (width)
|
||||
* width += info->requested_width;
|
||||
first_cell = TRUE;
|
||||
@ -2190,6 +2193,7 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
|
||||
gint full_requested_width = 0;
|
||||
gint extra_space;
|
||||
gint min_x, min_y, max_x, max_y;
|
||||
gint focus_line_width;
|
||||
|
||||
min_x = G_MAXINT;
|
||||
min_y = G_MAXINT;
|
||||
@ -2198,6 +2202,8 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
|
||||
|
||||
real_cell_area = *cell_area;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
|
||||
"focus-line-width", &focus_line_width, NULL);
|
||||
/* Find out how my extra space we have to allocate */
|
||||
for (list = tree_column->cell_list; list; list = list->next)
|
||||
{
|
||||
@ -2227,6 +2233,7 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
|
||||
|
||||
real_cell_area.width = info->requested_width +
|
||||
(info->expand?extra_space:0);
|
||||
real_cell_area.x += focus_line_width;
|
||||
if (render)
|
||||
{
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
@ -2284,17 +2291,17 @@ gtk_tree_view_column_cell_render_or_focus (GtkTreeViewColumn *tree_column,
|
||||
if (min_x >= max_x || min_y >= max_y)
|
||||
{
|
||||
*focus_rectangle = *cell_area;
|
||||
focus_rectangle->x -= 1;
|
||||
focus_rectangle->y -= 1;
|
||||
focus_rectangle->width += 2;
|
||||
focus_rectangle->height += 2;
|
||||
focus_rectangle->x -= focus_line_width;
|
||||
focus_rectangle->y -= focus_line_width;
|
||||
focus_rectangle->width += 2 * focus_line_width;
|
||||
focus_rectangle->height += 2 * focus_line_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
focus_rectangle->x = min_x - 1;
|
||||
focus_rectangle->y = min_y - 1;
|
||||
focus_rectangle->width = (max_x - min_x) + 2;
|
||||
focus_rectangle->height = (max_y - min_y) + 2;
|
||||
focus_rectangle->x = min_x - focus_line_width;
|
||||
focus_rectangle->y = min_y - focus_line_width;
|
||||
focus_rectangle->width = (max_x - min_x) + 2 * focus_line_width;
|
||||
focus_rectangle->height = (max_y - min_y) + 2 * focus_line_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2400,23 +2407,28 @@ gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
{
|
||||
gint focus_line_width;
|
||||
GtkStateType cell_state;
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
|
||||
gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
|
||||
"focus-line-width", &focus_line_width, NULL);
|
||||
if (tree_column->editable_widget)
|
||||
{
|
||||
/* This function is only called on the editable row when editing.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
gtk_paint_focus (tree_column->tree_view->style,
|
||||
window,
|
||||
GTK_WIDGET_STATE (tree_column->tree_view),
|
||||
NULL,
|
||||
tree_column->tree_view,
|
||||
"treeview",
|
||||
cell_area->x - 1,
|
||||
cell_area->y - 1,
|
||||
cell_area->width + 2,
|
||||
cell_area->height + 2);
|
||||
|
||||
cell_area->x - focus_line_width,
|
||||
cell_area->y - focus_line_width,
|
||||
cell_area->width + 2 * focus_line_width,
|
||||
cell_area->height + 2 * focus_line_width);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2429,10 +2441,13 @@ gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
|
||||
flags,
|
||||
FALSE,
|
||||
&focus_rectangle);
|
||||
|
||||
|
||||
cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
|
||||
(flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
|
||||
(flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
|
||||
gtk_paint_focus (tree_column->tree_view->style,
|
||||
window,
|
||||
GTK_WIDGET_STATE (tree_column->tree_view),
|
||||
cell_state,
|
||||
NULL,
|
||||
tree_column->tree_view,
|
||||
"treeview",
|
||||
|
Loading…
Reference in New Issue
Block a user