1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include "config.h"
#include "baselineoverlay.h"
#include "gtkwidgetprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssboxesprivate.h"
struct _GtkBaselineOverlay
{
GtkInspectorOverlay parent_instance;
};
struct _GtkBaselineOverlayClass
{
GtkInspectorOverlayClass parent_class;
};
G_DEFINE_TYPE (GtkBaselineOverlay, gtk_baseline_overlay, GTK_TYPE_INSPECTOR_OVERLAY)
static void
recurse_child_widgets (GtkWidget *widget,
GtkSnapshot *snapshot)
{
int baseline;
GtkWidget *child;
GtkCssBoxes boxes;
if (!gtk_widget_get_mapped (widget))
return;
if (gtk_widget_get_overflow (widget) == GTK_OVERFLOW_HIDDEN)
{
gtk_css_boxes_init (&boxes, widget);
gtk_snapshot_push_rounded_clip (snapshot, gtk_css_boxes_get_padding_box (&boxes));
}
baseline = gtk_widget_get_baseline (widget);
if (baseline != -1)
{
GdkRGBA red = {1, 0, 0, 1};
graphene_rect_t bounds;
int width;
width = gtk_widget_get_width (widget);
/* Now do all the stuff */
gtk_snapshot_push_debug (snapshot, "Widget baseline debugging");
graphene_rect_init (&bounds,
0, baseline,
width, 1);
gtk_snapshot_append_color (snapshot, &red, &bounds);
gtk_snapshot_pop (snapshot);
}
/* Recurse into child widgets */
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
graphene_matrix_t matrix;
if (gtk_widget_compute_transform (child, widget, &matrix))
{
gtk_snapshot_save (snapshot);
gtk_snapshot_transform_matrix (snapshot, &matrix);
recurse_child_widgets (child, snapshot);
gtk_snapshot_restore (snapshot);
}
}
if (gtk_widget_get_overflow (widget) == GTK_OVERFLOW_HIDDEN)
gtk_snapshot_pop (snapshot);
}
static void
gtk_baseline_overlay_snapshot (GtkInspectorOverlay *overlay,
GtkSnapshot *snapshot,
GskRenderNode *node,
GtkWidget *widget)
{
recurse_child_widgets (widget, snapshot);
}
static void
gtk_baseline_overlay_init (GtkBaselineOverlay *self)
{
}
static void
gtk_baseline_overlay_class_init (GtkBaselineOverlayClass *klass)
{
GtkInspectorOverlayClass *overlay_class = (GtkInspectorOverlayClass *)klass;
overlay_class->snapshot = gtk_baseline_overlay_snapshot;
}
GtkInspectorOverlay *
gtk_baseline_overlay_new (void)
{
return g_object_new (GTK_TYPE_BASELINE_OVERLAY, NULL);
}
|