forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
4fe051bb4a
commit
5b53eb287c
@ -5311,6 +5311,7 @@ draw_text (cairo_t *cr,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *widget = user_data;
|
GtkWidget *widget = user_data;
|
||||||
|
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GdkRectangle bg_rect;
|
GdkRectangle bg_rect;
|
||||||
|
|
||||||
@ -5324,7 +5325,13 @@ draw_text (cairo_t *cr,
|
|||||||
bg_rect.width, bg_rect.height);
|
bg_rect.width, bg_rect.height);
|
||||||
gtk_style_context_restore (context);
|
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);
|
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
|
static void
|
||||||
|
@ -67,6 +67,19 @@ typedef enum
|
|||||||
GTK_TEXT_WINDOW_BOTTOM
|
GTK_TEXT_WINDOW_BOTTOM
|
||||||
} GtkTextWindowType;
|
} 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:
|
* GTK_TEXT_VIEW_PRIORITY_VALIDATE:
|
||||||
*
|
*
|
||||||
@ -86,6 +99,11 @@ struct _GtkTextView
|
|||||||
GtkTextViewPrivate *priv;
|
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
|
struct _GtkTextViewClass
|
||||||
{
|
{
|
||||||
GtkContainerClass parent_class;
|
GtkContainerClass parent_class;
|
||||||
@ -121,6 +139,10 @@ struct _GtkTextViewClass
|
|||||||
|
|
||||||
GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);
|
GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);
|
||||||
|
|
||||||
|
void (* draw_layer) (GtkWidget *widget,
|
||||||
|
GtkTextViewLayer layer,
|
||||||
|
cairo_t *cr);
|
||||||
|
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_gtk_reserved1) (void);
|
void (*_gtk_reserved1) (void);
|
||||||
void (*_gtk_reserved2) (void);
|
void (*_gtk_reserved2) (void);
|
||||||
@ -128,7 +150,6 @@ struct _GtkTextViewClass
|
|||||||
void (*_gtk_reserved4) (void);
|
void (*_gtk_reserved4) (void);
|
||||||
void (*_gtk_reserved5) (void);
|
void (*_gtk_reserved5) (void);
|
||||||
void (*_gtk_reserved6) (void);
|
void (*_gtk_reserved6) (void);
|
||||||
void (*_gtk_reserved7) (void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user