[libhandy] css: Add hdy_css_draw()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] css: Add hdy_css_draw()
- Date: Thu, 3 Dec 2020 12:49:25 +0000 (UTC)
commit 1573a5d5d131b99d1313cf32be29853f2cb1fed7
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Sep 13 02:18:59 2020 +0500
css: Add hdy_css_draw()
src/hdy-css-private.h | 3 +++
src/hdy-css.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/src/hdy-css-private.h b/src/hdy-css-private.h
index 34ed4512..09a5197c 100644
--- a/src/hdy-css-private.h
+++ b/src/hdy-css-private.h
@@ -28,4 +28,7 @@ void hdy_css_size_allocate_self (GtkWidget *widget,
void hdy_css_size_allocate_children (GtkWidget *widget,
GtkAllocation *allocation);
+void hdy_css_draw (GtkWidget *widget,
+ cairo_t *cr);
+
G_END_DECLS
diff --git a/src/hdy-css.c b/src/hdy-css.c
index 1bafcbf8..6e11a619 100644
--- a/src/hdy-css.c
+++ b/src/hdy-css.c
@@ -112,3 +112,37 @@ hdy_css_size_allocate_children (GtkWidget *widget,
allocation->x += border.left + padding.left;
allocation->y += border.top + padding.top;
}
+
+void
+hdy_css_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ gint width = gtk_widget_get_allocated_width (widget);
+ gint height = gtk_widget_get_allocated_height (widget);
+ GtkStyleContext *style_context;
+
+ if (width <= 0 || height <= 0)
+ return;
+
+ /* Manually apply the border, the padding and the margin as we can't use the
+ * private GtkGagdet.
+ */
+ style_context = gtk_widget_get_style_context (widget);
+
+ gtk_render_background (style_context, cr, 0, 0, width, height);
+ gtk_render_frame (style_context, cr, 0, 0, width, height);
+
+ if (gtk_widget_has_visible_focus (widget)) {
+ GtkStateFlags state_flags;
+ GtkBorder border;
+
+ state_flags = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_border (style_context, state_flags, &border);
+
+ gtk_render_focus (style_context, cr,
+ border.left, border.top,
+ width - border.left - border.right,
+ height - border.top - border.bottom);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]