Commit 5b53eb28 authored by Alexander Larsson's avatar Alexander Larsson

textview: Add draw_layer vfunc

This allows subclasses to render things below and above the text
in the text view. This allows e.g. GtkSourceView to highlight the
cursor row and to render overlays for colum 80. This used to be done
by rendering before/after chaining up to the parent, but that doesn't
work anymore since the view now renders a background, and due to the
use of the pixel cache.
parent 4fe051bb
......@@ -5311,6 +5311,7 @@ draw_text (cairo_t *cr,
gpointer user_data)
{
GtkWidget *widget = user_data;
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
GtkStyleContext *context;
GdkRectangle bg_rect;
......@@ -5324,7 +5325,13 @@ draw_text (cairo_t *cr,
bg_rect.width, bg_rect.height);
gtk_style_context_restore (context);
if (GTK_TEXT_VIEW_GET_CLASS (text_view)->draw_layer != NULL)
GTK_TEXT_VIEW_GET_CLASS (text_view)->draw_layer (widget, GTK_TEXT_VIEW_LAYER_BELOW, cr);
gtk_text_view_paint (widget, cr);
if (GTK_TEXT_VIEW_GET_CLASS (text_view)->draw_layer != NULL)
GTK_TEXT_VIEW_GET_CLASS (text_view)->draw_layer (widget, GTK_TEXT_VIEW_LAYER_ABOVE, cr);
}
static void
......
......@@ -67,6 +67,19 @@ typedef enum
GTK_TEXT_WINDOW_BOTTOM
} GtkTextWindowType;
/**
* GtkTextViewLayer:
* @GTK_TEXT_VIEW_LAYER_BELOW: The layer rendered below the text (but above the background).
* @GTK_TEXT_VIEW_LAYER_ABOVE: The layer rendered above the text.
*
* Used to reference the parts of #GtkTextView.
*/
typedef enum
{
GTK_TEXT_VIEW_LAYER_BELOW,
GTK_TEXT_VIEW_LAYER_ABOVE
} GtkTextViewLayer;
/**
* GTK_TEXT_VIEW_PRIORITY_VALIDATE:
*
......@@ -86,6 +99,11 @@ struct _GtkTextView
GtkTextViewPrivate *priv;
};
/**
* GtkTextViewClass:
* @parent_class: The object class structure needs to be the first
* @draw_layer: Draw layers below and above the text in the text window.
*/
struct _GtkTextViewClass
{
GtkContainerClass parent_class;
......@@ -121,6 +139,10 @@ struct _GtkTextViewClass
GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);
void (* draw_layer) (GtkWidget *widget,
GtkTextViewLayer layer,
cairo_t *cr);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
......@@ -128,7 +150,6 @@ struct _GtkTextViewClass
void (*_gtk_reserved4) (void);
void (*_gtk_reserved5) (void);
void (*_gtk_reserved6) (void);
void (*_gtk_reserved7) (void);
};
GDK_AVAILABLE_IN_ALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment