[gtk+] gtk-demo: Try to fix foreigndrawing scrollbars



commit fdd3c912a0b08573bd8efefe6d40fa00d805196b
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 8 08:13:56 2016 -0500

    gtk-demo: Try to fix foreigndrawing scrollbars
    
    The node hierarchy and sizing has changed with the gadgetization
    of range widgets.

 demos/gtk-demo/foreigndrawing.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/demos/gtk-demo/foreigndrawing.c b/demos/gtk-demo/foreigndrawing.c
index 5488fce..0b45ebd 100644
--- a/demos/gtk-demo/foreigndrawing.c
+++ b/demos/gtk-demo/foreigndrawing.c
@@ -313,24 +313,33 @@ draw_horizontal_scrollbar (GtkWidget     *widget,
                            GtkStateFlags  state)
 {
   GtkStyleContext *scrollbar_context;
+  GtkStyleContext *contents_context;
   GtkStyleContext *trough_context;
   GtkStyleContext *slider_context;
 
   /* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
   scrollbar_context = get_style (NULL, "scrollbar.horizontal");
-  trough_context = get_style (scrollbar_context, "trough");
+  contents_context = get_style (scrollbar_context, "contents");
+  trough_context = get_style (contents_context, "trough");
   slider_context = get_style (trough_context, "slider");
 
   gtk_style_context_set_state (scrollbar_context, state);
+  gtk_style_context_set_state (contents_context, state);
   gtk_style_context_set_state (trough_context, state);
   gtk_style_context_set_state (slider_context, state);
 
+  gtk_render_background (scrollbar_context, cr, x, y, width, height);
+  gtk_render_frame (scrollbar_context, cr, x, y, width, height);
+  gtk_render_background (contents_context, cr, x, y, width, height);
+  gtk_render_frame (contents_context, cr, x, y, width, height);
   gtk_render_background (trough_context, cr, x, y, width, height);
   gtk_render_frame (trough_context, cr, x, y, width, height);
-  gtk_render_slider (slider_context, cr, x + position, y + 1, 30, height - 2, GTK_ORIENTATION_HORIZONTAL);
+  gtk_render_background (slider_context, cr, x + position, y - 2, 30, height + 4);
+  gtk_render_frame (slider_context, cr, x + position, y, 30, height);
 
   g_object_unref (slider_context);
   g_object_unref (trough_context);
+  g_object_unref (contents_context);
   g_object_unref (scrollbar_context);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]