[gtk+] textview: Add draw_layer vfunc
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] textview: Add draw_layer vfunc
- Date: Mon, 28 Jul 2014 14:53:19 +0000 (UTC)
commit 5b53eb287c170d21de149b088be5a3608349139b
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jul 28 15:20:52 2014 +0200
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.
gtk/gtktextview.c | 7 +++++++
gtk/gtktextview.h | 23 ++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 40b2596..1a01582 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -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
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 46f57fd..aaa0356 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -68,6 +68,19 @@ typedef enum
} 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:
*
* The priority at which the text view validates onscreen lines
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]