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
|
#include "toolbar.h"
#define N_TOOLS 9
#define TOOL_SIZE 72
#define CORNER_SIZE 12
#define BORDER_WIDTH 2
#define MARGIN 6
#define COLOR 1.4 * (0x58 / 255.0), 1.4 * (0x75 / 255.0), 1.4 * (0xA7 / 255.0)
#define STROKE_COLOR (0x58 / 255.0), (0x75 / 255.0), (0xA7 / 255.0)
struct Toolbar
{
int dummy;
/* no content */
};
Toolbar *
toolbar_new (void)
{
return g_new0 (Toolbar, 1);
}
void
toolbar_paint (Toolbar *bar,
FooScrollArea *scroll_area,
cairo_t *cr,
int x,
int y)
{
int i;
int b = BORDER_WIDTH / 2;
int segment = TOOL_SIZE - 2 * b - 2 * CORNER_SIZE;
GdkRectangle viewport;
foo_scroll_area_get_viewport (scroll_area, &viewport);
cairo_move_to (cr, b + x, MARGIN + y);
for (i = 0; i < N_TOOLS; ++i)
{
double x, y;
cairo_get_current_point (cr, &x, &y);
cairo_rel_move_to (cr, CORNER_SIZE, 0);
cairo_rel_line_to (cr, segment, 0);
cairo_rel_curve_to (cr,
CORNER_SIZE, 0,
CORNER_SIZE, 0,
CORNER_SIZE, CORNER_SIZE);
cairo_rel_line_to (cr, 0, segment);
cairo_rel_curve_to (cr,
0, CORNER_SIZE,
0, CORNER_SIZE,
-CORNER_SIZE, CORNER_SIZE);
cairo_rel_line_to (cr, -segment, 0);
cairo_rel_curve_to (cr,
-CORNER_SIZE, 0,
-CORNER_SIZE, 0,
-CORNER_SIZE, -CORNER_SIZE);
cairo_rel_line_to (cr, 0, -segment);
cairo_rel_curve_to (cr,
0, -CORNER_SIZE,
0, -CORNER_SIZE,
CORNER_SIZE, -CORNER_SIZE);
cairo_set_source_rgba (cr, COLOR, 0.8);
cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, STROKE_COLOR, 0.8);
cairo_set_line_width (cr, BORDER_WIDTH);
cairo_stroke (cr);
cairo_move_to (cr, x, y + TOOL_SIZE + MARGIN);
}
}
void
toolbar_invalidate (Toolbar *bar,
FooScrollArea *scroll_area,
int x,
int y)
{
foo_scroll_area_invalidate_rect (scroll_area,
x, y,
TOOL_SIZE + 10,
N_TOOLS * (TOOL_SIZE + MARGIN) + 10);
}
|