71
_cairo_round_rectangle (cairo_t *cr,
78
g_return_if_fail (cr != NULL);
82
cairo_rectangle (cr, x, y, w, h);
86
cairo_move_to (cr, x+radius, y);
87
cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
88
cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, G_PI * 0.5);
89
cairo_arc (cr, x+radius, y+h-radius, radius, G_PI * 0.5, G_PI);
90
cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5);
93
/* Set the appropriate matrix for
94
* patterns coming from the style context
97
style_pattern_set_matrix (cairo_pattern_t *pattern,
101
cairo_matrix_t matrix;
104
if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE)
106
cairo_surface_t *surface;
108
cairo_pattern_get_surface (pattern, &surface);
109
w = cairo_image_surface_get_width (surface);
110
h = cairo_image_surface_get_height (surface);
115
cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height);
116
cairo_pattern_set_matrix (pattern, &matrix);
120
72
adwaita_engine_render_arrow (GtkThemingEngine *engine,
133
line_width = size / 3.0 / sqrt (2);
134
cairo_set_line_width (cr, line_width);
135
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
136
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
138
cairo_translate (cr, x + size / 2.0, y + size / 2.0);
139
cairo_rotate (cr, angle - G_PI_2);
140
cairo_translate (cr, size / 4.0, 0);
85
line_width = size / 3.0 / sqrt (2);
86
cairo_set_line_width (cr, line_width);
87
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
88
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
90
cairo_translate (cr, x + size / 2.0, y + size / 2.0);
91
cairo_rotate (cr, angle - G_PI_2);
92
cairo_translate (cr, size / 4.0, 0);
143
(size / (size + line_width)),
144
(size / (size + line_width)));
146
cairo_move_to (cr, -size / 2.0, -size / 2.0);
147
cairo_rel_line_to (cr, size / 2.0, size / 2.0);
148
cairo_rel_line_to (cr, - size / 2.0, size / 2.0);
150
state = gtk_theming_engine_get_state (engine);
151
gtk_theming_engine_get_color (engine, state, &color);
153
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
154
!(state & GTK_STATE_FLAG_INSENSITIVE) && !(state & GTK_STATE_FLAG_PRELIGHT)) {
155
GdkRGBA *arrow_color;
157
gtk_theming_engine_get (engine, state,
158
"-adwaita-menuitem-arrow-color", &arrow_color,
161
if (arrow_color != NULL) {
162
color = *arrow_color;
165
gdk_rgba_free (arrow_color);
168
gdk_cairo_set_source_rgba (cr, &color);
95
(size / (size + line_width)),
96
(size / (size + line_width)));
98
cairo_move_to (cr, -size / 2.0, -size / 2.0);
99
cairo_rel_line_to (cr, size / 2.0, size / 2.0);
100
cairo_rel_line_to (cr, - size / 2.0, size / 2.0);
102
state = gtk_theming_engine_get_state (engine);
103
gtk_theming_engine_get_color (engine, state, &color);
105
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
106
!(state & GTK_STATE_FLAG_INSENSITIVE) && !(state & GTK_STATE_FLAG_PRELIGHT))
108
GdkRGBA *arrow_color;
110
gtk_theming_engine_get (engine, state,
111
"-adwaita-menuitem-arrow-color", &arrow_color,
114
if (arrow_color != NULL)
115
color = *arrow_color;
117
gdk_rgba_free (arrow_color);
120
gdk_cairo_set_source_rgba (cr, &color);
175
127
adwaita_engine_render_focus (GtkThemingEngine *engine,
182
GdkRGBA *fill_color, *border_color = NULL;
183
cairo_pattern_t *pattern = NULL;
185
gint line_width, focus_pad;
188
double dashes[2] = { 2.0, 0.2 };
190
state = gtk_theming_engine_get_state (engine);
191
gtk_theming_engine_get (engine, state,
192
"-adwaita-focus-border-color", &border_color,
193
"-adwaita-focus-fill-color", &fill_color,
194
"-adwaita-focus-border-radius", &border_radius,
195
"-adwaita-focus-border-gradient", &pattern,
196
"-adwaita-focus-border-dashes", &use_dashes,
199
gtk_theming_engine_get_style (engine,
200
"focus-line-width", &line_width,
201
"focus-padding", &focus_pad,
204
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
205
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL)) {
206
/* as we render the tab smaller than the whole allocation, we need
207
* to recenter and resize the focus on the tab.
214
cairo_set_line_width (cr, line_width);
216
if (line_width > 1) {
217
_cairo_round_rectangle (cr, x, y,
218
width, height, border_radius);
220
_cairo_round_rectangle (cr, x + 0.5, y + 0.5,
221
width - 1, height - 1, border_radius);
224
/* if we have a fill color, draw the fill */
225
if (fill_color != NULL) {
226
gdk_cairo_set_source_rgba (cr, fill_color);
227
cairo_fill_preserve (cr);
231
cairo_set_dash (cr, dashes, 1, 0.0);
234
/* if we have a gradient, draw the gradient, otherwise
235
* draw the line if we have a color for it.
237
if (pattern != NULL) {
238
style_pattern_set_matrix (pattern, width, height);
240
cairo_set_source (cr, pattern);
241
} else if (border_color != NULL) {
242
gdk_cairo_set_source_rgba (cr, border_color);
248
if (pattern != NULL) {
249
cairo_pattern_destroy (pattern);
252
if (border_color != NULL) {
253
gdk_rgba_free (border_color);
256
if (fill_color != NULL) {
257
gdk_rgba_free (fill_color);
262
render_from_assets_common (GtkThemingEngine *engine,
269
gboolean retval = FALSE;
271
GValue value = { 0, };
272
cairo_pattern_t *asset = NULL;
273
cairo_surface_t *surface = NULL;
275
state = gtk_theming_engine_get_state (engine);
276
gtk_theming_engine_get_property (engine,
281
asset = g_value_dup_boxed (&value);
282
g_value_unset (&value);
285
cairo_pattern_get_surface (asset, &surface);
288
if (surface != NULL) {
291
cairo_set_source_surface (cr, surface, x, y);
293
width / cairo_image_surface_get_width (surface),
294
height / cairo_image_surface_get_height (surface));
303
cairo_pattern_destroy (asset);
310
render_check_menuitem (GtkThemingEngine *engine,
320
state = gtk_theming_engine_get_state (engine);
321
gtk_theming_engine_get_color (engine, state, &color);
323
if (!(state & GTK_STATE_FLAG_ACTIVE))
328
cairo_translate (cr, x, y);
330
cairo_set_line_width (cr, 2.0);
331
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
332
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
334
cairo_move_to (cr, 0.5 + (width * 0.08), (height * 0.67));
335
cairo_line_to (cr, 0.5 + (width * 0.32), (height * 0.90));
336
cairo_line_to (cr, 0.5 + (width * 0.80), (height * 0.33));
338
gdk_cairo_set_source_rgba (cr, &color);
134
GdkRGBA *fill_color, *border_color = NULL;
135
cairo_pattern_t *pattern = NULL;
137
gint line_width, focus_pad;
140
double dashes[2] = { 2.0, 0.2 };
141
const GtkWidgetPath *path;
143
path = gtk_theming_engine_get_path (engine);
144
state = gtk_theming_engine_get_state (engine);
145
gtk_theming_engine_get (engine, state,
146
"-adwaita-focus-border-color", &border_color,
147
"-adwaita-focus-fill-color", &fill_color,
148
"-adwaita-focus-border-radius", &border_radius,
149
"-adwaita-focus-border-gradient", &pattern,
150
"-adwaita-focus-border-dashes", &use_dashes,
153
gtk_theming_engine_get_style (engine,
154
"focus-line-width", &line_width,
155
"focus-padding", &focus_pad,
158
/* as we render the tab smaller than the whole allocation, we need
159
* to recenter and resize the focus on the tab.
161
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
162
gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_TAB, NULL))
168
/* the treeview rows don't change allocation when modifying focus-padding,
169
* so we have to move the focus ring inside the allocated area manually.
171
if (gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW))
175
width -= 2 * focus_pad;
176
height -= 2 * focus_pad;
180
cairo_set_line_width (cr, line_width);
183
_cairo_round_rectangle_sides (cr, border_radius,
185
SIDE_ALL, GTK_JUNCTION_NONE);
187
_cairo_round_rectangle_sides (cr, border_radius,
189
width - 1, height - 1,
190
SIDE_ALL, GTK_JUNCTION_NONE);
192
/* if we have a fill color, draw the fill */
193
if (fill_color != NULL)
195
gdk_cairo_set_source_rgba (cr, fill_color);
196
cairo_fill_preserve (cr);
200
cairo_set_dash (cr, dashes, 1, 0.0);
202
/* if we have a gradient, draw the gradient, otherwise
203
* draw the line if we have a color for it.
207
style_pattern_set_matrix (pattern, width, height, FALSE);
208
cairo_set_source (cr, pattern);
210
else if (border_color != NULL)
212
gdk_cairo_set_source_rgba (cr, border_color);
219
cairo_pattern_destroy (pattern);
221
if (border_color != NULL)
222
gdk_rgba_free (border_color);
224
if (fill_color != NULL)
225
gdk_rgba_free (fill_color);
345
229
adwaita_engine_render_check (GtkThemingEngine *engine,
352
GdkRGBA *bg, *border, *fg;
353
gboolean inconsistent = FALSE;
354
gboolean draw_bullet;
358
if (gtk_theming_engine_has_class (engine,
359
GTK_STYLE_CLASS_MENUITEM))
361
render_check_menuitem (engine, cr,
362
x, y, width, height);
367
if (render_from_assets_common (engine, cr,
368
x, y + 2.0, width, height)) {
372
/* fallback to old code path */
373
state = gtk_theming_engine_get_state (engine);
374
inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
375
draw_bullet = (state & GTK_STATE_FLAG_ACTIVE);
376
draw_bullet |= inconsistent;
380
gtk_theming_engine_get (engine, state,
381
"border-radius", &radius,
382
"background-color", &bg,
383
"border-color", &border,
387
cairo_translate (cr, x, y);
388
cairo_set_line_width (cr, 1);
390
_cairo_round_rectangle (cr, 0.5, 0.5, width-1, height-1, 2);
392
if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
394
gdk_cairo_set_source_rgba (cr, bg);
395
cairo_fill_preserve (cr);
398
gdk_cairo_set_source_rgba (cr, border);
403
if (inconsistent) /* Inconsistent */
405
cairo_set_line_width (cr, 2.0);
406
cairo_move_to (cr, 3, height*0.5);
407
cairo_line_to (cr, width-3, height*0.5);
411
cairo_set_line_width (cr, 1.7);
412
cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
413
cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
415
cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
416
0.5 + (width*0.5), (height*0.4),
417
0.5 + (width*0.70), (height*0.25));
421
gdk_cairo_set_source_rgba (cr, fg);
429
gdk_rgba_free (border);
433
render_radio_menuitem (GtkThemingEngine *engine,
444
state = gtk_theming_engine_get_state (engine);
446
if (!(state & GTK_STATE_FLAG_ACTIVE))
449
gtk_theming_engine_get_color (engine, state, &color);
451
radius = MAX (height / 2.0, width / 2.0) * 0.58;
455
cairo_translate (cr, x + width / 2.0, y + height * 0.67);
461
gdk_cairo_set_source_rgba (cr, &color);
236
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
237
(engine, cr, x, y, width, height);
468
241
adwaita_engine_render_option (GtkThemingEngine *engine,
475
GdkRGBA *bg, *border, *fg, highlight;
476
GtkSymbolicColor *sym, *shade;
477
gboolean inconsistent;
478
gboolean draw_bullet;
479
gdouble cx, cy, radius;
482
if (gtk_theming_engine_has_class (engine,
483
GTK_STYLE_CLASS_MENUITEM))
485
render_radio_menuitem (engine, cr, x, y, width, height);
489
if (render_from_assets_common (engine, cr,
490
x, y + 2.0, width, height)) {
494
/* fallback to old code path */
497
radius = MIN (width, height) / 2.0;
501
state = gtk_theming_engine_get_state (engine);
503
gtk_theming_engine_get (engine, state,
504
"background-color", &bg,
505
"border-color", &border,
509
inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
510
draw_bullet = (state & GTK_STATE_FLAG_ACTIVE) != 0;
511
draw_bullet |= inconsistent;
513
sym = gtk_symbolic_color_new_literal (bg);
514
shade = gtk_symbolic_color_new_shade (sym, 1.1);
515
gtk_symbolic_color_resolve (shade, NULL, &highlight);
517
cairo_translate (cr, x, y);
518
cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
520
cairo_new_sub_path (cr);
521
cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
523
if ((state & GTK_STATE_FLAG_INSENSITIVE) == 0)
525
gdk_cairo_set_source_rgba (cr, bg);
526
cairo_fill_preserve (cr);
529
gdk_cairo_set_source_rgba (cr, border);
536
gdouble line_width = floor (radius * 2 / 3);
538
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
539
cairo_set_line_width (cr, line_width);
541
cairo_move_to (cr, ceil (cx - radius/3.0 - line_width) + line_width, ceil (cy - line_width) + line_width);
542
cairo_line_to (cr, floor (cx + radius/3.0 + line_width) - line_width, ceil (cy - line_width) + line_width);
544
gdk_cairo_set_source_rgba (cr, fg);
549
cairo_new_sub_path (cr);
550
cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
551
gdk_cairo_set_source_rgba (cr, fg);
554
cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
555
cairo_set_source_rgba (cr, highlight.red, highlight.green, highlight.blue, 0.5);
564
gdk_rgba_free (border);
566
gtk_symbolic_color_unref (sym);
567
gtk_symbolic_color_unref (shade);
248
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
249
(engine, cr, x, y, width, height);
571
253
draw_tab_arcs (cairo_t *cr,
581
G_PI, G_PI + G_PI_2);
263
G_PI, G_PI + G_PI_2);
584
width - curve_width, 6.0,
586
G_PI + G_PI_2, 2 * G_PI);
266
width - curve_width, 6.0,
268
G_PI + G_PI_2, 2 * G_PI);
590
272
draw_tab_shape_active (cairo_t *cr,
597
cairo_move_to (cr, 0, height);
599
draw_tab_arcs (cr, curve_width, x, y, width, height);
601
cairo_line_to (cr, width, height);
279
cairo_move_to (cr, 0, height);
281
draw_tab_arcs (cr, curve_width, x, y, width, height);
283
cairo_line_to (cr, width, height);
605
287
render_notebook_extension (GtkThemingEngine *engine,
611
GtkPositionType gap_side)
293
GtkPositionType gap_side)
614
GdkRGBA *color, border_color, background_color;
617
cairo_pattern_t *pattern = NULL, *background_pattern = NULL;
618
cairo_matrix_t matrix;
620
gtk_theming_engine_get_style (engine,
621
"tab-curvature", &tab_curvature,
623
state = gtk_theming_engine_get_state (engine);
624
gtk_theming_engine_get_background_color (engine, state, &background_color);
625
gtk_theming_engine_get_border_color (engine, state, &border_color);
626
gtk_theming_engine_get (engine, state,
627
"-adwaita-selected-tab-color", &color,
628
"-adwaita-border-gradient", &pattern,
629
"background-image", &background_pattern,
633
cairo_set_line_width (cr, 1.0);
635
if (gap_side == GTK_POS_TOP) {
637
cairo_translate (cr, width, height);
640
if (gap_side == GTK_POS_BOTTOM) {
643
(state & GTK_STATE_FLAG_ACTIVE) ?
645
} else if (gap_side == GTK_POS_TOP) {
648
(state & GTK_STATE_FLAG_ACTIVE) ?
652
cairo_rotate (cr, angle);
655
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
657
if (background_pattern != NULL) {
658
cairo_matrix_init_scale (&matrix,
661
cairo_pattern_set_matrix (background_pattern, &matrix);
662
cairo_set_source (cr, background_pattern);
664
gdk_cairo_set_source_rgba (cr, &background_color);
669
if (state & GTK_STATE_FLAG_ACTIVE) {
670
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, 6.0);
671
gdk_cairo_set_source_rgba (cr, color);
675
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
677
if (state & GTK_STATE_FLAG_ACTIVE) {
678
style_pattern_set_matrix (pattern, width, height - 6.0);
679
cairo_set_source (cr, pattern);
681
gdk_cairo_set_source_rgba (cr, &border_color);
686
gdk_rgba_free (color);
688
if (pattern != NULL) {
689
cairo_pattern_destroy (pattern);
692
if (background_pattern != NULL) {
693
cairo_pattern_destroy (background_pattern);
296
GdkRGBA *color, border_color, background_color;
299
cairo_pattern_t *pattern = NULL, *background_pattern = NULL;
300
cairo_matrix_t matrix;
302
gtk_theming_engine_get_style (engine,
303
"tab-curvature", &tab_curvature,
305
state = gtk_theming_engine_get_state (engine);
306
gtk_theming_engine_get_background_color (engine, state, &background_color);
307
gtk_theming_engine_get_border_color (engine, state, &border_color);
308
gtk_theming_engine_get (engine, state,
309
"-adwaita-selected-tab-color", &color,
310
"-adwaita-border-gradient", &pattern,
311
"background-image", &background_pattern,
315
cairo_set_line_width (cr, 1.0);
317
if (gap_side == GTK_POS_TOP)
320
cairo_translate (cr, width, height);
323
if (gap_side == GTK_POS_BOTTOM)
326
(state & GTK_STATE_FLAG_ACTIVE) ?
328
else if (gap_side == GTK_POS_TOP)
331
(state & GTK_STATE_FLAG_ACTIVE) ?
334
cairo_rotate (cr, angle);
337
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
339
if (background_pattern != NULL)
341
cairo_matrix_init_scale (&matrix,
344
cairo_pattern_set_matrix (background_pattern, &matrix);
345
cairo_set_source (cr, background_pattern);
349
gdk_cairo_set_source_rgba (cr, &background_color);
354
if (state & GTK_STATE_FLAG_ACTIVE)
356
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, 6.0);
357
gdk_cairo_set_source_rgba (cr, color);
361
draw_tab_shape_active (cr, tab_curvature, 0, 0, width, height);
363
if (state & GTK_STATE_FLAG_ACTIVE)
365
style_pattern_set_matrix (pattern, width, height - 6.0, FALSE);
366
cairo_set_source (cr, pattern);
370
gdk_cairo_set_source_rgba (cr, &border_color);
375
gdk_rgba_free (color);
378
cairo_pattern_destroy (pattern);
380
if (background_pattern != NULL)
381
cairo_pattern_destroy (background_pattern);
700
387
adwaita_engine_render_extension (GtkThemingEngine *engine,
706
GtkPositionType gap_side)
710
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
711
((gap_side == GTK_POS_TOP) || (gap_side == GTK_POS_BOTTOM))) {
712
render_notebook_extension (engine, cr, x, y, width, height, gap_side);
717
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_extension (engine, cr,
721
state = gtk_theming_engine_get_state (engine);
723
if (state & GTK_STATE_FLAG_ACTIVE)
727
gtk_theming_engine_get (engine, state,
728
"-adwaita-selected-tab-color", &fill,
734
_cairo_round_rectangle (cr, x + 1, y + 1, width - 2, 3, 0);
737
_cairo_round_rectangle (cr, x + 1, y + height - 4, width - 2, 3, 0);
740
_cairo_round_rectangle (cr, x + 1, y + 1, 3, height - 2, 0);
743
_cairo_round_rectangle (cr, x + width - 4, y + 1, 3, height - 2, 0);
747
gdk_cairo_set_source_rgba (cr, fill);
750
gdk_rgba_free (fill);
755
draw_menu_bar_item_shape (cairo_t *cr,
763
/* draw a round rectangle without the bottom side */
764
cairo_move_to (cr, x+radius, y);
765
cairo_arc (cr, x+w-radius, y+radius, radius, G_PI * 1.5, G_PI * 2);
766
cairo_line_to (cr, x+w, y+h);
769
cairo_line_to (cr, x, y+h);
771
cairo_move_to (cr, x, y+h);
774
cairo_arc (cr, x+radius, y+radius, radius, G_PI, G_PI * 1.5);
778
render_menubar_active_frame (GtkThemingEngine *engine,
787
gint radius, border_width;
790
state = gtk_theming_engine_get_state (engine);
791
gtk_theming_engine_get_border_color (engine, state, &color);
792
gtk_theming_engine_get (engine, state,
793
"border-radius", &radius,
794
"border-width", &border,
797
border_width = MIN (MIN (border->top, border->bottom),
798
MIN (border->left, border->right));
800
if (border_width > 1) {
801
x += (gdouble) border_width / 2;
802
y += (gdouble) border_width / 2;
805
} else if (border_width == 1) {
393
GtkPositionType gap_side)
397
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK) &&
398
((gap_side == GTK_POS_TOP) || (gap_side == GTK_POS_BOTTOM)))
400
render_notebook_extension (engine, cr, x, y, width, height, gap_side);
404
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_extension
409
state = gtk_theming_engine_get_state (engine);
411
if (state & GTK_STATE_FLAG_ACTIVE)
415
gtk_theming_engine_get (engine, state,
416
"-adwaita-selected-tab-color", &fill,
428
x + 1, y + height - 4,
438
x + width - 4, y + 1,
814
cairo_set_line_width (cr, border_width);
815
draw_menu_bar_item_shape (cr, radius, x, y, w, h, FALSE);
817
gdk_cairo_set_source_rgba (cr, &color);
822
gtk_border_free (border);
826
render_frame_default (GtkThemingEngine *engine,
833
cairo_pattern_t *pattern = NULL;
836
gint line_width, border_radius;
837
GtkBorderStyle border_style;
839
state = gtk_theming_engine_get_state (engine);
841
gtk_theming_engine_get (engine, state,
842
"-adwaita-border-gradient", &pattern,
843
"border-style", &border_style,
846
if (pattern == NULL || border_style == GTK_BORDER_STYLE_NONE) {
847
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
849
x, y, width, height);
856
gtk_theming_engine_get (engine, state,
857
"border-radius", &border_radius,
858
"border-width", &border,
861
line_width = MIN (MIN (border->top, border->bottom),
862
MIN (border->left, border->right));
863
style_pattern_set_matrix (pattern, width, height);
865
cairo_set_line_width (cr, line_width);
866
_cairo_round_rectangle (cr,
867
x + line_width / 2.0,
868
y + line_width / 2.0,
872
cairo_set_source (cr, pattern);
878
cairo_pattern_destroy (pattern);
879
gtk_border_free (border);
443
gdk_cairo_set_source_rgba (cr, fill);
446
gdk_rgba_free (fill);
883
451
adwaita_engine_render_frame (GtkThemingEngine *engine,
890
const GtkWidgetPath *path;
891
GtkRegionFlags flags = 0;
895
state = gtk_theming_engine_get_state (engine);
897
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
898
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) {
899
render_menubar_active_frame (engine, cr, x, y, width, height);
904
path = gtk_theming_engine_get_path (engine);
905
len = gtk_widget_path_length (path);
909
if (gtk_widget_path_iter_has_region (path, len - 2,
910
GTK_STYLE_REGION_COLUMN_HEADER,
915
if ((flags & GTK_REGION_LAST) != 0)
919
if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL)
921
cairo_move_to (cr, x + 0.5, y + 2);
922
cairo_line_to (cr, x + 0.5, y + height - 4);
926
cairo_move_to (cr, x + width - 0.5, y + 2);
927
cairo_line_to (cr, x + width - 0.5, y + height - 4);
930
gtk_theming_engine_get_border_color (engine, state, &color);
932
cairo_set_line_width (cr, 1);
933
gdk_cairo_set_source_rgba (cr, &color);
938
if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
939
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
941
/* Render GtkScale trough thinner */
942
if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
944
y += height / 2.0 - 2.0;
949
x += width / 2.0 - 2.0;
954
if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
955
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH)) {
956
GtkBorder *border_width;
959
/* draw the border inside the trough itself, so it will
960
* be overdrawn by the fill.
962
gtk_theming_engine_get (engine, state,
963
"border-width", &border_width,
966
border_line = MIN (MIN (border_width->top, border_width->bottom),
967
MIN (border_width->left, border_width->right));
971
width -= 2 * border_line;
972
height -= 2 * border_line;
974
gtk_border_free (border_width);
977
render_frame_default (engine, cr, x, y, width, height);
985
render_menubar_active_background (GtkThemingEngine *engine,
997
state = gtk_theming_engine_get_state (engine);
998
gtk_theming_engine_get_border_color (engine, state, &color);
999
gtk_theming_engine_get (engine, state,
1000
"border-radius", &radius,
1001
"border-width", &border,
1004
gtk_theming_engine_get_background_color (engine, state, &color);
1006
/* omit all the border but the bottom line */
1009
w -= border->left + border->right;
1013
cairo_translate (cr, x, y);
1015
draw_menu_bar_item_shape (cr, radius, 0, 0, w, h, TRUE);
1017
gdk_cairo_set_source_rgba (cr, &color);
1022
gtk_border_free (border);
458
adwaita_trim_allocation_for_scale (engine,
462
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
1026
468
adwaita_engine_render_background (GtkThemingEngine *engine,
1033
const GtkWidgetPath *path;
1034
GtkStateFlags state;
1036
path = gtk_theming_engine_get_path (engine);
1037
state = gtk_theming_engine_get_state (engine);
1039
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
1040
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) {
1041
render_menubar_active_background (engine, cr, x, y, width, height);
1046
if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
1047
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
1049
/* Render GtkScale trough thinner */
1050
if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
1052
y += height / 2 - 2;
1062
if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
1063
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH)) {
1064
GtkBorder *border_width;
1067
/* draw the border inside the trough itself, so it will
1068
* be overdrawn by the fill.
1070
gtk_theming_engine_get (engine, state,
1071
"border-width", &border_width,
1074
border_line = MIN (MIN (border_width->top, border_width->bottom),
1075
MIN (border_width->left, border_width->right));
1079
width -= 2 * border_line;
1080
height -= 2 * border_line;
1082
gtk_border_free (border_width);
1085
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background (engine, cr, x, y,
475
adwaita_trim_allocation_for_scale (engine,
479
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
1090
485
adwaita_engine_render_expander (GtkThemingEngine *engine,
1097
GdkRGBA border, bg, fg;
1098
GtkStateFlags state;
1101
side = MIN (width, height);
1103
x += ((int) width / 2) - (side / 2);
1104
y += ((int) height / 2) - (side / 2);
1106
state = gtk_theming_engine_get_state (engine);
1108
gtk_theming_engine_get_border_color (engine, state, &border);
1109
gtk_theming_engine_get_background_color (engine, state, &bg);
1110
gtk_theming_engine_get_color (engine, state, &fg);
1114
cairo_set_line_width (cr, 1);
1116
_cairo_round_rectangle (cr, x + 0.5, y + 0.5, side, side, 2);
1117
gdk_cairo_set_source_rgba (cr, &bg);
1118
cairo_fill_preserve (cr);
1120
gdk_cairo_set_source_rgba (cr, &border);
1123
cairo_set_line_width (cr, 1);
1124
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1125
gdk_cairo_set_source_rgba (cr, &fg);
1127
cairo_move_to (cr, x + 3, y + side / 2 + 0.5);
1128
cairo_line_to (cr, x + side - 2, y + side / 2 + 0.5);
1130
if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
1132
cairo_move_to (cr, x + side / 2 + 0.5, y + 3);
1133
cairo_line_to (cr, x + side / 2 + 0.5, y + side - 2);
494
gdouble side, offset;
497
const GtkWidgetPath *path = gtk_theming_engine_get_path (engine);
499
side = floor (MIN (width, height));
501
if (gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW) &&
504
/* HACK: draw the expander as if it was 11px instead of the allocated 17px,
505
* so that we can have a bit of padding between the view edge and the
515
x += width / 2 - side / 2;
516
y += height / 2 - side / 2;
521
/* make sure the rendered side length is always odd */
522
if (((gint) side % 2) == 0)
525
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
526
(engine, cr, x, y, side, side);
527
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
528
(engine, cr, x, y, side, side);
530
state = gtk_theming_engine_get_state (engine);
531
gtk_theming_engine_get_color (engine, state, &fg);
532
gtk_theming_engine_get_border (engine, state, &border);
535
offset = (1 + line_width / 2.0);
539
cairo_set_line_width (cr, line_width);
540
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
541
gdk_cairo_set_source_rgba (cr, &fg);
544
x + border.left + offset,
547
x + side - (border.right + offset),
550
if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
554
y + border.top + offset);
557
y + side - (border.bottom + offset));
1142
566
adwaita_engine_render_activity (GtkThemingEngine *engine,
1149
const GtkWidgetPath *path;
1152
path = gtk_theming_engine_get_path (engine);
1154
if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
1155
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
1157
/* Render GtkScale fill level thinner */
1158
if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
1160
y += height / 2.0 - 2.0;
1165
x += width / 2.0 - 2.0;
1170
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity (engine, cr,
1171
x, y, width, height);
1173
if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
1174
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
1176
cairo_pattern_t *pattern;
1178
pattern = cairo_pattern_create_linear (0, 0, 20, 20);
1179
cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0, 0);
1180
cairo_pattern_add_color_stop_rgba (pattern, 0.49, 0, 0, 0, 0);
1181
cairo_pattern_add_color_stop_rgba (pattern, 0.5, 0, 0, 0, 0.1);
1182
cairo_pattern_add_color_stop_rgba (pattern, 0.99, 0, 0, 0, 0.1);
1184
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
1185
cairo_rectangle (cr, x, y, width, height);
1186
cairo_set_source (cr, pattern);
1189
cairo_pattern_destroy (pattern);
1196
draw_round_slider (cairo_t *cr,
1200
cairo_arc (cr, (width) / 2.0, (height) / 2.0,
1201
MIN (height / 2.0, width / 2.0) - 0.5,
1203
cairo_close_path (cr);
1207
draw_mark_slider (cairo_t *cr,
1210
gboolean marks_below,
1211
GtkOrientation orientation)
1213
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
1216
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
1217
cairo_move_to (cr, 0, height / 2.0 + 3.0);
1218
cairo_arc (cr, 2.5, 3.5,
1220
G_PI, G_PI + G_PI_2);
1222
cairo_arc (cr, width - 2.5, 3.5,
1224
G_PI + G_PI_2, 2 * G_PI);
1226
cairo_line_to (cr, width, height / 2.0 + 3.0);
1227
cairo_line_to (cr, width / 2.0, height);
1228
cairo_line_to (cr, 0, height / 2.0 + 3.0);
1230
cairo_close_path (cr);
1232
cairo_move_to (cr, width / 2.0, 0);
1233
cairo_arc (cr, width - 2.5, 2.5,
1235
G_PI + G_PI_2, 2 * G_PI);
1237
cairo_arc (cr, width - 2.5, height - 2.5,
1241
cairo_line_to (cr, width / 2.0, height);
1242
cairo_line_to (cr, 0, height / 2.0);
1243
cairo_line_to (cr, width / 2.0, 0);
1245
cairo_close_path (cr);
1248
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
1249
cairo_move_to (cr, width, height / 2.0 - 3.0);
1250
cairo_arc (cr, width - 2.5, height - 3.5,
1254
cairo_arc (cr, 2.5, height - 3.5,
1258
cairo_line_to (cr, 0, height / 2.0 - 3.0);
1259
cairo_line_to (cr, width / 2.0, 0);
1260
cairo_line_to (cr, width, height / 2.0 - 3.0);
1262
cairo_close_path (cr);
1264
cairo_move_to (cr, width / 2.0, height);
1265
cairo_arc (cr, 2.5, height - 2.5,
1269
cairo_arc (cr, 2.5, 2.5,
1271
G_PI, G_PI + G_PI_2);
1273
cairo_line_to (cr, width / 2.0, 0);
1274
cairo_line_to (cr, width, height / 2.0);
1275
cairo_line_to (cr, width / 2.0, height);
1277
cairo_close_path (cr);
576
state = gtk_theming_engine_get_state (engine);
578
adwaita_trim_allocation_for_scale (engine,
582
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity
584
x, y, width, height);
586
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
588
cairo_pattern_t *pattern = NULL;
590
gtk_theming_engine_get (engine, state,
591
"-adwaita-progressbar-pattern", &pattern,
596
style_pattern_set_matrix (pattern, 20, 20, TRUE);
597
cairo_rectangle (cr, x, y, width, height);
598
cairo_set_source (cr, pattern);
601
cairo_pattern_destroy (pattern);
1283
609
render_switch_lines (GtkThemingEngine *engine,
1289
GtkOrientation orientation)
615
GtkOrientation orientation)
1291
GtkStateFlags state;
1292
GdkRGBA *lines_color;
1294
state = gtk_theming_engine_get_state (engine);
1296
if (state & GTK_STATE_FLAG_INSENSITIVE) {
1300
gtk_theming_engine_get (engine, state,
1301
"-adwaita-switch-grip-color", &lines_color,
1306
cairo_translate (cr,
1307
x + width / 2.0 - 4.0,
1308
y + height / 2.0 - 3.0);
1310
cairo_move_to (cr, 0.0, 0.0);
1311
cairo_set_line_width (cr, 2.0);
1312
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
1314
cairo_line_to (cr, 0.0, 6.0);
1315
cairo_move_to (cr, 4.0, 0.0);
1316
cairo_line_to (cr, 4.0, 6.0);
1317
cairo_move_to (cr, 8.0, 0.0);
1318
cairo_line_to (cr, 8.0, 6.0);
1320
gdk_cairo_set_source_rgba (cr, lines_color);
1325
gdk_rgba_free (lines_color);
618
GdkRGBA *lines_color;
620
state = gtk_theming_engine_get_state (engine);
622
if (state & GTK_STATE_FLAG_INSENSITIVE)
625
gtk_theming_engine_get (engine, state,
626
"-adwaita-switch-grip-color", &lines_color,
632
x + width / 2.0 - 4.0,
633
y + height / 2.0 - 3.0);
635
cairo_move_to (cr, 0.0, 0.0);
636
cairo_set_line_width (cr, 2.0);
637
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
639
cairo_line_to (cr, 0.0, 6.0);
640
cairo_move_to (cr, 4.0, 0.0);
641
cairo_line_to (cr, 4.0, 6.0);
642
cairo_move_to (cr, 8.0, 0.0);
643
cairo_line_to (cr, 8.0, 6.0);
645
gdk_cairo_set_source_rgba (cr, lines_color);
650
gdk_rgba_free (lines_color);
1329
654
adwaita_engine_render_slider (GtkThemingEngine *engine,
1335
GtkOrientation orientation)
660
GtkOrientation orientation)
1337
const GtkWidgetPath *path;
1339
path = gtk_theming_engine_get_path (engine);
1342
if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
1344
cairo_pattern_t *pattern, *border_pattern;
1345
cairo_matrix_t matrix;
1346
GtkStateFlags state;
1348
gboolean marks_above = FALSE, marks_below = FALSE;
1350
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE)) {
1352
} else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW)) {
1356
cairo_translate (cr, x, y);
1358
if ((marks_above && marks_below) || (!marks_above && !marks_below)) {
1359
draw_round_slider (cr, width, height);
1361
draw_mark_slider (cr, width, height, marks_below, orientation);
1364
state = gtk_theming_engine_get_state (engine);
1365
cairo_set_line_width (cr, 1.0);
1367
gtk_theming_engine_get (engine, state,
1368
"background-image", &pattern,
1371
if (pattern != NULL) {
1372
style_pattern_set_matrix (pattern, width, height);
1373
cairo_set_source (cr, pattern);
1375
gtk_theming_engine_get_background_color (engine, state, &color);
1376
gdk_cairo_set_source_rgba (cr, &color);
1379
cairo_fill_preserve (cr);
1381
gtk_theming_engine_get (engine, state,
1382
"-adwaita-border-gradient", &border_pattern,
1385
if (border_pattern != NULL) {
1386
style_pattern_set_matrix (border_pattern, width, height);
1387
cairo_set_source (cr, border_pattern);
1389
gtk_theming_engine_get_border_color (engine, state, &color);
1390
gdk_cairo_set_source_rgba (cr, &color);
1395
if (pattern != NULL) {
1396
cairo_pattern_destroy (pattern);
1399
if (border_pattern != NULL) {
1400
cairo_pattern_destroy (border_pattern);
1405
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider (engine, cr,
1406
x, y, width, height,
1409
if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH)) {
1410
render_switch_lines (engine, cr, x, y, width, height, orientation);
662
const GtkWidgetPath *path;
664
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_slider
669
path = gtk_theming_engine_get_path (engine);
671
if (gtk_widget_path_is_type (path, GTK_TYPE_SWITCH))
672
render_switch_lines (engine, cr, x, y, width, height, orientation);
1418
676
adwaita_engine_render_handle (GtkThemingEngine *engine,
1425
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
1428
GtkJunctionSides sides;
1429
GtkStateFlags state;
1435
state = gtk_theming_engine_get_state (engine);
1436
gtk_theming_engine_get_background_color (engine, state, &bg);
1438
/* The number of dots fitting into the area. Just hardcoded to 3 right now. */
1439
/* dots = MIN (width - 2, height - 2) / 3; */
1444
sides = gtk_theming_engine_get_junction_sides (engine);
1448
case GTK_JUNCTION_CORNER_TOPRIGHT:
1451
cairo_translate (cr, x + width - 4*dots, y + 1);
1453
case GTK_JUNCTION_CORNER_BOTTOMRIGHT:
1456
cairo_translate (cr, x + width - 4*dots, y + height + 1 - 4*dots);
1458
case GTK_JUNCTION_CORNER_BOTTOMLEFT:
1461
cairo_translate (cr, x + 2, y + height + 1 - 4*dots);
1463
case GTK_JUNCTION_CORNER_TOPLEFT:
1466
cairo_translate (cr, x + 2, y + 1);
1469
/* Not implemented. */
1473
for (lx = 0; lx < dots; lx++) /* horizontally */
1475
for (ly = 0; ly <= lx; ly++) /* vertically */
1478
mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
1479
my = y_down * dots + (1 - y_down * 2) * ly - y_down;
1481
gdk_cairo_set_source_rgba (cr, &bg);
1493
} else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR)) {
1495
GtkStateFlags state;
1498
state = gtk_theming_engine_get_state (engine);
1499
gtk_theming_engine_get_background_color (engine, state, &bg);
1500
gtk_theming_engine_get_color (engine, state, &fg);
1504
cairo_rectangle (cr, x, y,
1506
gdk_cairo_set_source_rgba (cr, &bg);
1509
gdk_cairo_set_source_rgba (cr, &fg);
1510
cairo_set_line_width (cr, 2.0);
1511
cairo_line_to (cr, x + width, y + height);
1514
if (width > height) {
1515
for (xx = x + width / 2 - 12; xx <= x + width / 2 + 12; xx += 6) {
1516
cairo_arc (cr, xx, y + height / 2 - 1,
1522
for (yy = y + height / 2 - 12; yy <= y + height / 2 + 12; yy += 6) {
1523
cairo_arc (cr, x + width / 2.0, yy,
1532
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_handle (engine, cr,
1533
x, y, width, height);
1537
/* taken from gtkthemingengine.c */
1539
scale_or_ref (GdkPixbuf *src,
1543
if (width == gdk_pixbuf_get_width (src) &&
1544
height == gdk_pixbuf_get_height (src)) {
1545
return g_object_ref (src);
1547
return gdk_pixbuf_scale_simple (src,
1549
GDK_INTERP_BILINEAR);
1554
lookup_icon_size (GtkThemingEngine *engine,
1560
GtkSettings *settings;
1562
screen = gtk_theming_engine_get_screen (engine);
1563
settings = gtk_settings_get_for_screen (screen);
1565
return gtk_icon_size_lookup_for_settings (settings, size, width, height);
1568
/* Kudos to the gnome-panel guys. */
1570
colorshift_pixbuf (GdkPixbuf *src,
1575
gint width, height, has_alpha, src_rowstride, dest_rowstride;
1576
guchar *target_pixels;
1577
guchar *original_pixels;
1583
has_alpha = gdk_pixbuf_get_has_alpha (src);
1584
width = gdk_pixbuf_get_width (src);
1585
height = gdk_pixbuf_get_height (src);
1586
src_rowstride = gdk_pixbuf_get_rowstride (src);
1587
dest_rowstride = gdk_pixbuf_get_rowstride (dest);
1588
original_pixels = gdk_pixbuf_get_pixels (src);
1589
target_pixels = gdk_pixbuf_get_pixels (dest);
1591
for (i = 0; i < height; i++) {
1592
pix_dest = target_pixels + i * dest_rowstride;
1593
pix_src = original_pixels + i * src_rowstride;
1595
for (j = 0; j < width; j++) {
1601
*(pix_dest++) = CLAMP (val, 0, 255);
1604
*(pix_dest++) = CLAMP (val, 0, 255);
1607
*(pix_dest++) = CLAMP (val, 0, 255);
1610
*(pix_dest++) = *(pix_src++);
1617
adwaita_engine_render_icon_pixbuf (GtkThemingEngine *engine,
1618
const GtkIconSource *source,
1621
GdkPixbuf *base_pixbuf;
1624
GtkStateFlags state;
1628
cairo_surface_t *stated_surface;
1631
base_pixbuf = gtk_icon_source_get_pixbuf (source);
1632
state = gtk_theming_engine_get_state (engine);
1634
g_return_val_if_fail (base_pixbuf != NULL, NULL);
1636
if (size != (GtkIconSize) -1 &&
1637
!lookup_icon_size (engine, size, &width, &height)) {
1638
g_warning (G_STRLOC ": invalid icon size '%d'", size);
1642
/* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
1645
if (size != (GtkIconSize) -1 &&
1646
gtk_icon_source_get_size_wildcarded (source)) {
1647
scaled = scale_or_ref (base_pixbuf, width, height);
1649
scaled = g_object_ref (base_pixbuf);
1652
/* If the state was wildcarded, then generate a state. */
1653
if (gtk_icon_source_get_state_wildcarded (source)) {
1654
if (state & GTK_STATE_FLAG_INSENSITIVE) {
1655
/* dim the pixbuf with a 0.5 alpha black layer */
1656
stated_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1657
gdk_pixbuf_get_width (scaled),
1658
gdk_pixbuf_get_height (scaled));
1659
cr = cairo_create (stated_surface);
1661
gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
1664
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5);
1665
cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
1668
stated = gdk_pixbuf_get_from_surface (stated_surface,
1670
cairo_image_surface_get_width (stated_surface),
1671
cairo_image_surface_get_height (stated_surface));
1673
g_object_unref (scaled);
1675
cairo_surface_destroy (stated_surface);
1676
} else if (state & GTK_STATE_FLAG_PRELIGHT) {
1677
stated = gdk_pixbuf_copy (scaled);
1678
colorshift_pixbuf (scaled, stated, 30);
1679
g_object_unref (scaled);
1691
adwaita_engine_render_line (GtkThemingEngine *engine,
1698
const GtkWidgetPath *path;
1700
path = gtk_theming_engine_get_path (engine);
1702
if ((gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MARK) &&
1703
gtk_widget_path_is_type (path, GTK_TYPE_SCALE)) ||
1704
(gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR) &&
1705
gtk_widget_path_is_type (path, GTK_TYPE_TREE_VIEW))) {
1706
GtkStateFlags state;
1709
state = gtk_theming_engine_get_state (engine);
1710
gtk_theming_engine_get_background_color (engine, state, &bg);
1714
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
1715
cairo_set_line_width (cr, 1);
1717
cairo_move_to (cr, x0 + 0.5, y0 + 0.5);
1718
cairo_line_to (cr, x1 + 0.5, y1 + 0.5);
1720
gdk_cairo_set_source_rgba (cr, &bg);
1725
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_line (engine, cr,
683
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
686
GtkJunctionSides sides;
693
state = gtk_theming_engine_get_state (engine);
694
gtk_theming_engine_get_background_color (engine, state, &bg);
696
/* The number of dots fitting into the area. Just hardcoded to 3 right now. */
697
/* dots = MIN (width - 2, height - 2) / 3; */
702
sides = gtk_theming_engine_get_junction_sides (engine);
706
case GTK_JUNCTION_CORNER_TOPRIGHT:
709
cairo_translate (cr, x + width - 4*dots, y + 1);
711
case GTK_JUNCTION_CORNER_BOTTOMRIGHT:
714
cairo_translate (cr, x + width - 4*dots, y + height + 1 - 4*dots);
716
case GTK_JUNCTION_CORNER_BOTTOMLEFT:
719
cairo_translate (cr, x + 2, y + height + 1 - 4*dots);
721
case GTK_JUNCTION_CORNER_TOPLEFT:
724
cairo_translate (cr, x + 2, y + 1);
727
/* Not implemented. */
732
for (lx = 0; lx < dots; lx++) /* horizontally */
734
for (ly = 0; ly <= lx; ly++) /* vertically */
737
mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
738
my = y_down * dots + (1 - y_down * 2) * ly - y_down;
740
gdk_cairo_set_source_rgba (cr, &bg);
753
else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
759
state = gtk_theming_engine_get_state (engine);
760
gtk_theming_engine_get_color (engine, state, &fg);
762
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
763
(engine, cr, x, y, width, height);
764
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
765
(engine, cr, x, y, width, height);
768
cairo_set_line_width (cr, 2.0);
769
gdk_cairo_set_source_rgba (cr, &fg);
773
for (xx = x + width / 2 - 12; xx <= x + width / 2 + 12; xx += 6)
775
cairo_arc (cr, xx, y + height / 2.0,
783
for (yy = y + height / 2 - 12; yy <= y + height / 2 + 12; yy += 6)
785
cairo_arc (cr, x + width / 2.0, yy,
796
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_handle
798
x, y, width, height);
1731
803
adwaita_engine_class_init (AdwaitaEngineClass *klass)
1733
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
1735
engine_class->render_arrow = adwaita_engine_render_arrow;
1736
engine_class->render_focus = adwaita_engine_render_focus;
1737
engine_class->render_check = adwaita_engine_render_check;
1738
engine_class->render_option = adwaita_engine_render_option;
1739
engine_class->render_extension = adwaita_engine_render_extension;
1740
engine_class->render_frame = adwaita_engine_render_frame;
1741
engine_class->render_background = adwaita_engine_render_background;
1742
engine_class->render_expander = adwaita_engine_render_expander;
1743
engine_class->render_activity = adwaita_engine_render_activity;
1744
engine_class->render_slider = adwaita_engine_render_slider;
1745
engine_class->render_handle = adwaita_engine_render_handle;
1746
engine_class->render_icon_pixbuf = adwaita_engine_render_icon_pixbuf;
1747
engine_class->render_line = adwaita_engine_render_line;
1749
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1750
g_param_spec_boxed ("focus-border-color",
1751
"Focus border color",
1752
"Focus border color",
1754
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1755
g_param_spec_int ("focus-border-radius",
1756
"Focus border radius",
1757
"Focus border radius",
1760
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1761
g_param_spec_boxed ("focus-border-gradient",
1762
"Focus border gradient",
1763
"Focus border gradient",
1764
CAIRO_GOBJECT_TYPE_PATTERN, 0));
1765
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1766
g_param_spec_boxed ("focus-fill-color",
1770
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1771
g_param_spec_boxed ("selected-tab-color",
1772
"Selected tab color",
1773
"Selected tab color",
1775
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1776
g_param_spec_boxed ("border-gradient",
1779
CAIRO_GOBJECT_TYPE_PATTERN, 0));
1780
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1781
g_param_spec_boolean ("focus-border-dashes",
1782
"Focus border uses dashes",
1783
"Focus border uses dashes",
1785
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1786
g_param_spec_boxed ("menuitem-arrow-color",
1787
"Menuitem arrow color",
1788
"Menuitem arrow color",
1790
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
1791
g_param_spec_boxed ("switch-grip-color",
1792
"Switch grip color",
1793
"Switch grip color",
805
GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
807
engine_class->render_arrow = adwaita_engine_render_arrow;
808
engine_class->render_focus = adwaita_engine_render_focus;
809
engine_class->render_check = adwaita_engine_render_check;
810
engine_class->render_option = adwaita_engine_render_option;
811
engine_class->render_extension = adwaita_engine_render_extension;
812
engine_class->render_frame = adwaita_engine_render_frame;
813
engine_class->render_background = adwaita_engine_render_background;
814
engine_class->render_expander = adwaita_engine_render_expander;
815
engine_class->render_activity = adwaita_engine_render_activity;
816
engine_class->render_slider = adwaita_engine_render_slider;
817
engine_class->render_handle = adwaita_engine_render_handle;
819
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
820
g_param_spec_boxed ("focus-border-color",
821
"Focus border color",
822
"Focus border color",
824
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
825
g_param_spec_int ("focus-border-radius",
826
"Focus border radius",
827
"Focus border radius",
830
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
831
g_param_spec_boxed ("focus-border-gradient",
832
"Focus border gradient",
833
"Focus border gradient",
834
CAIRO_GOBJECT_TYPE_PATTERN, 0));
835
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
836
g_param_spec_boxed ("focus-fill-color",
840
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
841
g_param_spec_boxed ("selected-tab-color",
842
"Selected tab color",
843
"Selected tab color",
845
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
846
g_param_spec_boxed ("border-gradient",
849
CAIRO_GOBJECT_TYPE_PATTERN, 0));
850
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
851
g_param_spec_boolean ("focus-border-dashes",
852
"Focus border uses dashes",
853
"Focus border uses dashes",
855
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
856
g_param_spec_boxed ("menuitem-arrow-color",
857
"Menuitem arrow color",
858
"Menuitem arrow color",
860
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
861
g_param_spec_boxed ("switch-grip-color",
865
gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
866
g_param_spec_boxed ("progressbar-pattern",
867
"Progressbar pattern",
868
"Progressbar pattern",
869
CAIRO_GOBJECT_TYPE_PATTERN, 0));