137
unico_draw_cell_background (DRAW_ARGS,
138
GtkRegionFlags flags)
140
GtkJunctionSides junction;
143
junction = GTK_JUNCTION_RIGHT | GTK_JUNCTION_LEFT;
145
hidden_side = SIDE_RIGHT | SIDE_LEFT;
147
if ((flags & GTK_REGION_FIRST) != 0)
149
junction &= ~(GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMLEFT);
150
hidden_side &= ~(SIDE_LEFT);
152
if ((flags & GTK_REGION_LAST) != 0)
154
junction &= ~(GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMRIGHT);
155
hidden_side &= ~(SIDE_RIGHT);
158
unico_cairo_draw_background (engine, cr,
160
hidden_side, junction);
164
unico_draw_cell_frame (DRAW_ARGS,
165
GtkRegionFlags flags)
167
GtkJunctionSides junction;
170
junction = GTK_JUNCTION_RIGHT | GTK_JUNCTION_LEFT;
172
hidden_side = SIDE_RIGHT | SIDE_LEFT;
174
if ((flags & GTK_REGION_FIRST) != 0)
176
junction &= ~(GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMLEFT);
177
hidden_side &= ~(SIDE_LEFT);
179
if ((flags & GTK_REGION_LAST) != 0)
181
junction &= ~(GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMRIGHT);
182
hidden_side &= ~(SIDE_RIGHT);
185
unico_cairo_draw_frame (engine, cr,
187
hidden_side, junction);
191
unico_draw_check (DRAW_ARGS)
195
gboolean draw_bullet, inconsistent;
197
state = gtk_theming_engine_get_state (engine);
199
in_menu = gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM);
200
inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
201
draw_bullet = (state & GTK_STATE_FLAG_ACTIVE) != 0;
202
draw_bullet |= inconsistent;
206
unico_cairo_draw_background (engine, cr,
208
0, gtk_theming_engine_get_junction_sides (engine));
209
unico_cairo_draw_frame (engine, cr,
211
0, gtk_theming_engine_get_junction_sides (engine));
216
GdkRGBA *bullet_color;
218
gtk_theming_engine_get (engine, state,
219
"-unico-bullet-color", &bullet_color,
222
cairo_translate (cr, x, y);
223
cairo_scale (cr, width / 18.0, height / 18.0);
227
GdkRGBA *bullet_outline_color;
229
gtk_theming_engine_get (engine, state,
230
"-unico-bullet-outline-color", &bullet_outline_color,
233
/* thick's outline */
234
cairo_rectangle (cr, 3.5, 7, 11, 4);
236
gdk_cairo_set_source_rgba (cr, bullet_outline_color);
239
cairo_rectangle (cr, 4.5, 8, 9, 2);
241
gdk_rgba_free (bullet_outline_color);
246
cairo_translate (cr, 2.0, 3.0);
249
GdkRGBA *bullet_outline_color;
251
gtk_theming_engine_get (engine, state,
252
"-unico-bullet-outline-color", &bullet_outline_color,
255
/* thick's outline */
256
cairo_move_to (cr, 5.0, 5.65);
257
cairo_line_to (cr, 8.95, 9.57);
258
cairo_line_to (cr, 16.0, 2.54);
259
cairo_line_to (cr, 16.0, 8.36);
260
cairo_line_to (cr, 10.6, 15.1);
261
cairo_line_to (cr, 7.6, 15.1);
262
cairo_line_to (cr, 2.95, 10.48);
263
cairo_line_to (cr, 2.95, 7.65);
264
cairo_close_path (cr);
266
gdk_cairo_set_source_rgba (cr, bullet_outline_color);
269
cairo_translate (cr, 4.0, 2.0);
271
gdk_rgba_free (bullet_outline_color);
275
cairo_move_to (cr, 0.0, 6.0);
276
cairo_line_to (cr, 0.0, 8.0);
277
cairo_line_to (cr, 4.0, 12.0);
278
cairo_line_to (cr, 6.0, 12.0);
279
cairo_line_to (cr, 15.0, 1.0);
280
cairo_line_to (cr, 15.0, 0.0);
281
cairo_line_to (cr, 14.0, 0.0);
282
cairo_line_to (cr, 5.0, 9.0);
283
cairo_line_to (cr, 1.0, 5.0);
284
cairo_close_path (cr);
287
gdk_cairo_set_source_rgba (cr, bullet_color);
290
gdk_rgba_free (bullet_color);
295
unico_draw_common (DRAW_ARGS)
297
unico_cairo_draw_background (engine, cr,
299
0, gtk_theming_engine_get_junction_sides (engine));
300
unico_cairo_draw_frame (engine, cr,
302
0, gtk_theming_engine_get_junction_sides (engine));
306
unico_draw_common_background (DRAW_ARGS)
308
unico_cairo_draw_background (engine, cr,
310
0, gtk_theming_engine_get_junction_sides (engine));
314
unico_draw_common_frame (DRAW_ARGS)
316
unico_cairo_draw_frame (engine, cr,
318
0, gtk_theming_engine_get_junction_sides (engine));
322
129
unico_draw_expander (DRAW_ARGS)
324
131
GtkStateFlags state;
362
unico_draw_extension (DRAW_ARGS,
363
GtkPositionType gap_side)
366
GtkBorder *outer_border;
367
GtkJunctionSides junction = 0;
369
gboolean has_outer_stroke = FALSE;
370
gdouble bg_offset = 0;
371
guint hidden_side = 0;
373
state = gtk_theming_engine_get_state (engine);
375
gtk_theming_engine_get (engine, state,
376
"-unico-outer-stroke-width", &outer_border,
378
gtk_theming_engine_get_border (engine, state, &border);
380
if (!unico_gtk_border_is_zero (outer_border))
381
has_outer_stroke = TRUE;
385
/* FIXME doesn't work properly with not homogenuos border-width,
386
* especially between tab and notebook.
387
* I guess the issue comes from the fact draw_background
388
* is looking at border dimensions while we're not,
389
* or we're doing it wrong.
390
* draw_background is looking at SIDE_BOTTOM and
391
* sets border to 0 for this side */
395
junction = GTK_JUNCTION_TOP;
396
hidden_side = SIDE_TOP;
398
if (has_outer_stroke)
400
y -= outer_border->bottom;
401
height += outer_border->bottom;
404
if ((state & GTK_STATE_FLAG_ACTIVE) != 0)
405
bg_offset = border.bottom;
407
cairo_translate (cr, x + width, y + height);
408
cairo_rotate (cr, G_PI);
412
junction = GTK_JUNCTION_BOTTOM;
413
hidden_side = SIDE_BOTTOM;
415
if (has_outer_stroke)
416
height += outer_border->top;
418
if ((state & GTK_STATE_FLAG_ACTIVE) != 0)
419
bg_offset = border.top;
421
cairo_translate (cr, x, y);
424
junction = GTK_JUNCTION_LEFT;
425
hidden_side = SIDE_LEFT;
427
if (has_outer_stroke)
429
x -= outer_border->right;
430
width += outer_border->right;
433
if ((state & GTK_STATE_FLAG_ACTIVE) != 0)
434
bg_offset = border.right;
436
cairo_translate (cr, x + width, y);
437
cairo_rotate (cr, G_PI / 2);
440
junction = GTK_JUNCTION_RIGHT;
441
hidden_side = SIDE_RIGHT;
443
if (has_outer_stroke)
444
width += outer_border->left;
446
if ((state & GTK_STATE_FLAG_ACTIVE) != 0)
447
bg_offset = border.left;
449
cairo_translate (cr, x, y + height);
450
cairo_rotate (cr, - G_PI / 2);
454
if (gap_side == GTK_POS_TOP ||
455
gap_side == GTK_POS_BOTTOM)
456
unico_cairo_draw_background (engine, cr, 0, 0, width, height + bg_offset, SIDE_BOTTOM, GTK_JUNCTION_BOTTOM);
458
unico_cairo_draw_background (engine, cr, 0, 0, height, width + bg_offset, SIDE_BOTTOM, GTK_JUNCTION_BOTTOM);
461
/* FIXME the frame on bottom bar has the wrong gradient,
462
* while should be reflected */
463
unico_cairo_draw_frame (engine, cr, x, y, width, height, hidden_side, junction);
465
gtk_border_free (outer_border);
469
169
unico_draw_focus (DRAW_ARGS)
471
GdkRGBA *fill_color, *border_color, *outer_stroke_color;
171
GdkRGBA *fill_color, *border_color;
472
172
GtkStateFlags state;
473
173
gint focus_pad, line_width;
476
176
state = gtk_theming_engine_get_state (engine);
178
gtk_theming_engine_get_style (engine,
179
"focus-padding", &focus_pad,
180
"focus-line-width", &line_width,
183
/* Skip rendering if focus-line-width is 0 or less. */
478
187
gtk_theming_engine_get (engine, state,
479
188
"-unico-focus-border-color", &border_color,
480
189
"-unico-focus-border-radius", &radius,
481
190
"-unico-focus-fill-color", &fill_color,
482
"-unico-focus-outer-stroke-color", &outer_stroke_color,
484
gtk_theming_engine_get_style (engine,
485
"focus-padding", &focus_pad,
486
"focus-line-width", &line_width,
521
218
gdk_rgba_free (border_color);
522
219
gdk_rgba_free (fill_color);
523
gdk_rgba_free (outer_stroke_color);
527
unico_draw_frame_gap (DRAW_ARGS,
528
GtkPositionType gap_side,
533
GtkBorder *outer_border;
534
/*GtkCssBorderCornerRadius *top_left_radius, *top_right_radius;
535
GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius;*/
536
GtkJunctionSides junction;
538
gboolean has_outer_stroke = FALSE;
539
gdouble x0, y0, x1, y1, xc, yc, wc, hc;
541
xc = yc = wc = hc = 0;
543
junction = gtk_theming_engine_get_junction_sides (engine);
545
state = gtk_theming_engine_get_state (engine);
547
/* NOTE: Border radius is disabled due to it not working in GTK+ 3.5 */
548
gtk_theming_engine_get (engine, state,
549
/* Can't use border-radius as it's an int for
550
* backwards compat */
551
/*"border-top-left-radius", &top_left_radius,
552
"border-top-right-radius", &top_right_radius,
553
"border-bottom-right-radius", &bottom_right_radius,
554
"border-bottom-left-radius", &bottom_left_radius,*/
555
"-unico-outer-stroke-width", &outer_border,
557
gtk_theming_engine_get_border (engine, state, &border);
559
if (!unico_gtk_border_is_zero (outer_border))
560
has_outer_stroke = TRUE;
567
xc = x + xy0_gap + border.left;
569
wc = MAX (xy1_gap - xy0_gap - (border.left + border.right), 0);
572
if (has_outer_stroke)
574
xc += outer_border->left;
575
wc = MAX (xy1_gap - xy0_gap - (outer_border->left + outer_border->right) - (border.left + border.right), 0);
576
hc += outer_border->top;
579
/*if (xy0_gap < _gtk_css_number_get (&top_left_radius->horizontal, width))
580
junction |= GTK_JUNCTION_CORNER_TOPLEFT;
582
if (xy1_gap > width - _gtk_css_number_get (&top_right_radius->horizontal, width))
583
junction |= GTK_JUNCTION_CORNER_TOPRIGHT;*/
588
xc = x + xy0_gap + border.left;
589
yc = y + height - border.bottom * 2;
590
wc = MAX (xy1_gap - xy0_gap - (border.left + border.right), 0);
591
hc = border.bottom * 2;
593
if (has_outer_stroke)
595
xc += outer_border->left;
596
yc -= outer_border->bottom;
597
wc = MAX (xy1_gap - xy0_gap - (outer_border->left + outer_border->right) - (border.left + border.right), 0);
598
hc += outer_border->bottom;
601
/*if (xy0_gap < _gtk_css_number_get (&bottom_left_radius->horizontal, width))
602
junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
604
if (xy1_gap > width - _gtk_css_number_get (&bottom_right_radius->horizontal, width))
605
junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;*/
610
yc = y + xy0_gap + border.top;
611
wc = border.left * 2;
612
hc = MAX (xy1_gap - xy0_gap - (border.top + border.bottom), 0);
614
if (has_outer_stroke)
616
yc += outer_border->top;
617
wc += outer_border->left;
618
hc = MAX (xy1_gap - xy0_gap - (outer_border->top + outer_border->bottom) - (border.top + border.bottom), 0);
621
/*if (xy0_gap < _gtk_css_number_get (&top_left_radius->vertical, height))
622
junction |= GTK_JUNCTION_CORNER_TOPLEFT;
624
if (xy1_gap > height - _gtk_css_number_get (&bottom_left_radius->vertical, height))
625
junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;*/
629
xc = x + width - border.right * 2;
630
yc = y + xy0_gap + border.top;
631
wc = border.right * 2;
632
hc = MAX (xy1_gap - xy0_gap - (border.top + border.bottom), 0);
634
if (has_outer_stroke)
636
xc -= outer_border->right;
637
yc += outer_border->top;
638
wc += outer_border->right;
639
hc = MAX (xy1_gap - xy0_gap - (outer_border->top + outer_border->bottom) - (border.top + border.bottom), 0);
642
/*if (xy0_gap < _gtk_css_number_get (&top_right_radius->vertical, height))
643
junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
645
if (xy1_gap > height - _gtk_css_number_get (&bottom_right_radius->vertical, height))
646
junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;*/
652
cairo_clip_extents (cr, &x0, &y0, &x1, &y1);
653
cairo_rectangle (cr, x0, y0, x1 - x0, yc - y0);
654
cairo_rectangle (cr, x0, yc, xc - x0, hc);
655
cairo_rectangle (cr, xc + wc, yc, x1 - (xc + wc), hc);
656
cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
659
/* draw the frame, gap area will not be drawn */
660
unico_cairo_draw_frame (engine, cr, x, y, width, height, 0, junction);
664
/*g_free (top_left_radius);
665
g_free (top_right_radius);
666
g_free (bottom_right_radius);
667
g_free (bottom_left_radius);*/
668
gtk_border_free (outer_border);
672
unico_draw_grip (DRAW_ARGS)
674
GdkRGBA border_color;
675
GdkRGBA *inner_stroke_color;
679
if (draw_centroid_texture (engine, cr, x, y, width, height))
682
state = gtk_theming_engine_get_state (engine);
684
gtk_theming_engine_get (engine, state,
685
"-unico-inner-stroke-color", &inner_stroke_color,
687
gtk_theming_engine_get_border_color (engine, state, &border_color);
689
for (ly = 0; ly < 4; ly++)
691
/* vertically, four rows of dots */
692
for (lx = 0; lx <= ly; lx++)
695
int ny = (3.5 - ly) * 3;
698
gdk_cairo_set_source_rgba (cr, inner_stroke_color);
699
cairo_rectangle (cr, x + width - nx - 1, y + height - ny - 1, 2, 2);
702
gdk_cairo_set_source_rgba (cr, &border_color);
703
cairo_rectangle (cr, x + width - nx - 1, y + height - ny - 1, 1, 1);
708
gdk_rgba_free (inner_stroke_color);
712
unico_draw_handle (DRAW_ARGS)
717
gint i, bar_y, num_bars, bar_spacing, bar_width, bar_height;
719
state = gtk_theming_engine_get_state (engine);
720
gtk_theming_engine_get_border (engine, state, &border);
722
unico_cairo_draw_background (engine, cr,
723
x - border.left, y - border.top,
724
width + border.left + border.right, height + border.top + border.bottom,
725
0, GTK_JUNCTION_NONE);
727
if (draw_centroid_texture (engine, cr, x, y, width, height))
730
unico_get_line_width (engine, &line_width);
739
bar_height = num_bars * bar_spacing * line_width;
743
cairo_translate (cr, x + (gint) (width / 2), y + (gint) (height / 2));
746
cairo_translate (cr, - bar_width / 2 - 0.5, - bar_height / 2 + 0.5);
749
cairo_translate (cr, - bar_height / 2 + 0.5, bar_width / 2 + 0.5);
750
cairo_rotate (cr, - G_PI / 2);
753
for (i = 0; i < num_bars; i++)
756
cairo_move_to (cr, 0, bar_y);
757
cairo_line_to (cr, bar_width, bar_y);
758
unico_cairo_set_source_border (engine, cr, bar_width, line_width);
761
cairo_move_to (cr, 0, bar_y + line_width);
762
cairo_line_to (cr, bar_width, bar_y + line_width);
763
unico_cairo_set_source_inner_stroke (engine, cr, bar_width, line_width);
766
bar_y += bar_spacing;
773
unico_draw_line (GtkThemingEngine *engine,
796
cairo_move_to (cr, x0, y0);
797
cairo_line_to (cr, x1, y1);
798
unico_cairo_set_source_border (engine, cr, MAX (x1 - x0, 1), MAX (y1 - y0, 1));
803
unico_draw_notebook (DRAW_ARGS,
804
GtkPositionType gap_side,
808
unico_cairo_draw_background (engine, cr,
810
0, gtk_theming_engine_get_junction_sides (engine));
811
unico_draw_frame_gap (engine, cr,
813
gap_side, xy0_gap, xy1_gap);
817
unico_draw_radio (DRAW_ARGS)
821
gboolean draw_bullet, inconsistent;
823
state = gtk_theming_engine_get_state (engine);
825
in_menu = gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM);
826
inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
827
draw_bullet = (state & GTK_STATE_FLAG_ACTIVE) != 0;
828
draw_bullet |= inconsistent;
832
unico_cairo_draw_background (engine, cr,
834
0, gtk_theming_engine_get_junction_sides (engine));
835
unico_cairo_draw_frame (engine, cr,
837
0, gtk_theming_engine_get_junction_sides (engine));
842
GdkRGBA *bullet_color;
844
gtk_theming_engine_get (engine, state,
845
"-unico-bullet-color", &bullet_color,
850
GdkRGBA *bullet_outline_color;
852
gtk_theming_engine_get (engine, state,
853
"-unico-bullet-outline-color", &bullet_outline_color,
856
/* bullet's outline */
857
cairo_rectangle (cr, x + width / 2.0 - (width + height) / 4.0 + 3, y + height / 2.0 - 2,
858
(width + height) / 4.0 + 2, 4);
860
gdk_cairo_set_source_rgba (cr, bullet_outline_color);
863
cairo_rectangle (cr, x + width / 2.0 - (width + height) / 4.0 + 4, y + height / 2.0 - 1,
864
(width + height) / 4.0, 2);
866
gdk_rgba_free (bullet_outline_color);
871
cairo_arc (cr, x + width / 2.0, y + height / 2.0,
872
(width + height) / 4.0 - 4, 0, G_PI * 2);
875
GdkRGBA *bullet_outline_color;
877
gtk_theming_engine_get (engine, state,
878
"-unico-bullet-outline-color", &bullet_outline_color,
881
/* bullet's outline */
882
cairo_arc (cr, x + width / 2.0, y + height / 2.0,
883
(width + height) / 4.0 - 4, 0, G_PI * 2);
884
gdk_cairo_set_source_rgba (cr, bullet_outline_color);
887
cairo_arc (cr, x + width / 2.0, y + height / 2.0,
888
(width + height) / 4.0 - 5, 0, G_PI * 2);
890
gdk_rgba_free (bullet_outline_color);
895
gdk_cairo_set_source_rgba (cr, bullet_color);
898
gdk_rgba_free (bullet_color);
903
unico_draw_separator (DRAW_ARGS)
907
unico_get_line_width (engine, &line_width);
912
/* FIXME right code should be
913
* if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
914
* but doesn't work for separator tool item. */
917
cairo_move_to (cr, x, y + (gint) (height / 2) + line_width / 2);
918
cairo_line_to (cr, x + width, y + (gint) (height / 2) + line_width / 2);
919
unico_cairo_set_source_inner_stroke (engine, cr, width, line_width);
922
cairo_move_to (cr, x, y + (gint) (height / 2) - line_width / 2);
923
cairo_line_to (cr, x + width, y + (gint) (height / 2) - line_width / 2);
924
unico_cairo_set_source_border (engine, cr, width, line_width);
929
cairo_move_to (cr, x + (gint) (width / 2) + line_width / 2, y);
930
cairo_line_to (cr, x + (gint) (width / 2) + line_width / 2, y + height);
931
unico_cairo_set_source_inner_stroke (engine, cr, line_width, height);
934
cairo_move_to (cr, x + (gint) (width / 2) - line_width / 2, y);
935
cairo_line_to (cr, x + (gint) (width / 2) - line_width / 2, y + height);
936
unico_cairo_set_source_border (engine, cr, line_width, height);
942
unico_draw_slider (DRAW_ARGS,
943
GtkOrientation orientation)
945
/* use orientation, if needed */
946
unico_cairo_draw_background (engine, cr,
948
0, gtk_theming_engine_get_junction_sides (engine));
950
draw_centroid_texture (engine, cr, x, y, width, height);
952
unico_cairo_draw_frame (engine, cr,
954
0, gtk_theming_engine_get_junction_sides (engine));
958
unico_draw_spinbutton_background (DRAW_ARGS)
960
GtkBorder border, *outer_border;
961
GtkJunctionSides junction;
964
junction = gtk_theming_engine_get_junction_sides (engine);
966
state = gtk_theming_engine_get_state (engine);
968
gtk_theming_engine_get (engine, state,
969
"-unico-outer-stroke-width", &outer_border,
971
gtk_theming_engine_get_border (engine, state, &border);
975
cairo_rectangle (cr, x, y, width, height);
978
if (!(junction & GTK_JUNCTION_CORNER_TOPRIGHT))
981
height = floor (height);
982
height += border.bottom + outer_border->bottom;
987
height = ceil (height);
988
y -= outer_border->top;
989
height += outer_border->bottom;
992
unico_cairo_draw_background (engine, cr,
998
gtk_border_free (outer_border);
1002
unico_draw_spinbutton_frame (DRAW_ARGS)
1004
GtkBorder border, *outer_border;
1005
GtkJunctionSides junction;
1006
GtkStateFlags state;
1008
junction = gtk_theming_engine_get_junction_sides (engine);
1010
state = gtk_theming_engine_get_state (engine);
1012
gtk_theming_engine_get (engine, state,
1013
"-unico-outer-stroke-width", &outer_border,
1015
gtk_theming_engine_get_border (engine, state, &border);
1019
cairo_rectangle (cr, x, y, width, height);
1022
if (!(junction & GTK_JUNCTION_CORNER_TOPRIGHT))
1025
height = floor (height);
1026
height += border.bottom + outer_border->bottom;
1031
height = ceil (height);
1032
y -= outer_border->top;
1033
height += outer_border->bottom;
1036
unico_cairo_draw_frame (engine, cr,
1037
x, y, width, height,
1042
gtk_border_free (outer_border);