31
31
out_lines (start, end, colour) tuple list to draw outward lines.
34
36
__gproperties__ = {
35
"node": ( gobject.TYPE_PYOBJECT, "node",
37
"node": ( GObject.TYPE_PYOBJECT, "node",
36
38
"revision node instruction",
37
gobject.PARAM_WRITABLE
39
"in-lines": ( gobject.TYPE_PYOBJECT, "in-lines",
39
GObject.PARAM_WRITABLE
41
"tags": ( GObject.TYPE_PYOBJECT, "tags",
42
"list of tags associated with the node",
43
GObject.PARAM_WRITABLE
45
"in-lines": ( GObject.TYPE_PYOBJECT, "in-lines",
40
46
"instructions to draw lines into the cell",
41
gobject.PARAM_WRITABLE
47
GObject.PARAM_WRITABLE
43
"out-lines": ( gobject.TYPE_PYOBJECT, "out-lines",
49
"out-lines": ( GObject.TYPE_PYOBJECT, "out-lines",
44
50
"instructions to draw lines out of the cell",
45
gobject.PARAM_WRITABLE
51
GObject.PARAM_WRITABLE
140
153
box_size = self.box_size(widget)
142
155
ctx.set_line_width(box_size / 8)
143
ctx.set_line_cap(cairo.LINE_CAP_SQUARE)
145
157
# Draw lines into the cell
146
158
for start, end, colour in self.in_lines:
147
ctx.move_to(cell_area.x + box_size * start + box_size / 2,
148
bg_area.y - bg_area.height / 2)
151
ctx.line_to(cell_area.x + box_size * start, bg_area.y)
152
ctx.line_to(cell_area.x + box_size * end + box_size, bg_area.y)
153
elif start - end < -1:
154
ctx.line_to(cell_area.x + box_size * start + box_size,
156
ctx.line_to(cell_area.x + box_size * end, bg_area.y)
158
ctx.line_to(cell_area.x + box_size * end + box_size / 2,
159
bg_area.y + bg_area.height / 2)
161
self.set_colour(ctx, colour, 0.0, 0.65)
159
self.render_line (ctx, cell_area, box_size,
160
bg_area.y, bg_area.height,
161
start, end, colour, flags)
164
163
# Draw lines out of the cell
165
164
for start, end, colour in self.out_lines:
166
ctx.move_to(cell_area.x + box_size * start + box_size / 2,
167
bg_area.y + bg_area.height / 2)
170
ctx.line_to(cell_area.x + box_size * start,
171
bg_area.y + bg_area.height)
172
ctx.line_to(cell_area.x + box_size * end + box_size,
173
bg_area.y + bg_area.height)
174
elif start - end < -1:
175
ctx.line_to(cell_area.x + box_size * start + box_size,
176
bg_area.y + bg_area.height)
177
ctx.line_to(cell_area.x + box_size * end,
178
bg_area.y + bg_area.height)
180
ctx.line_to(cell_area.x + box_size * end + box_size / 2,
181
bg_area.y + bg_area.height / 2 + bg_area.height)
183
self.set_colour(ctx, colour, 0.0, 0.65)
165
self.render_line (ctx, cell_area, box_size,
166
bg_area.y + bg_area.height, bg_area.height,
167
start, end, colour, flags)
186
169
# Draw the revision node in the right column
187
170
(column, colour) = self.node
189
172
cell_area.y + cell_area.height / 2,
190
173
box_size / 4, 0, 2 * math.pi)
175
if flags & Gtk.CELL_RENDERER_SELECTED:
176
ctx.set_source_rgb(1.0, 1.0, 1.0)
177
ctx.set_line_width(box_size / 4)
178
ctx.stroke_preserve()
179
ctx.set_line_width(box_size / 8)
192
181
self.set_colour(ctx, colour, 0.0, 0.5)
193
182
ctx.stroke_preserve()
195
184
self.set_colour(ctx, colour, 0.5, 1.0)
187
self.render_tags(ctx, widget.create_pango_context(), cell_area, box_size)
189
def render_line(self, ctx, cell_area, box_size, mid, height, start, end, colour, flags):
191
ctx.set_line_cap(cairo.LINE_CAP_ROUND)
192
x = cell_area.x + box_size * end + box_size / 2
193
ctx.move_to(x, mid + height / 3)
194
ctx.line_to(x, mid + height / 3)
195
ctx.move_to(x, mid + height / 6)
196
ctx.line_to(x, mid + height / 6)
199
ctx.set_line_cap(cairo.LINE_CAP_ROUND)
200
x = cell_area.x + box_size * start + box_size / 2
201
ctx.move_to(x, mid - height / 3)
202
ctx.line_to(x, mid - height / 3)
203
ctx.move_to(x, mid - height / 6)
204
ctx.line_to(x, mid - height / 6)
207
ctx.set_line_cap(cairo.LINE_CAP_BUTT)
208
startx = cell_area.x + box_size * start + box_size / 2
209
endx = cell_area.x + box_size * end + box_size / 2
211
ctx.move_to(startx, mid - height / 2)
213
if start - end == 0 :
214
ctx.line_to(endx, mid + height / 2 + 1)
216
ctx.curve_to(startx, mid - height / 5,
217
startx, mid - height / 5,
218
startx + (endx - startx) / 2, mid)
220
ctx.curve_to(endx, mid + height / 5,
221
endx, mid + height / 5 ,
222
endx, mid + height / 2 + 1)
224
if flags & Gtk.CELL_RENDERER_SELECTED:
225
ctx.set_source_rgb(1.0, 1.0, 1.0)
226
ctx.set_line_width(box_size / 5)
227
ctx.stroke_preserve()
228
ctx.set_line_width(box_size / 8)
230
self.set_colour(ctx, colour, 0.0, 0.65)
234
def render_tags(self, ctx, pango_ctx, cell_area, box_size):
235
# colour ID used in self.set_colour on the tags
238
(column, colour) = self.node
240
font_desc = Pango.FontDescription()
241
font_desc.set_size(Pango.SCALE * 7)
243
tag_layout = Pango.Layout(pango_ctx)
244
tag_layout.set_font_description(font_desc)
246
# The width of the tag label stack
249
for tag_idx, tag in enumerate(self.tags):
250
tag_layout.set_text(" " + tag + " ")
251
text_width, text_height = tag_layout.get_pixel_size()
254
box_size * (column + 1.3) + width
257
cell_area.height / 2 - \
260
width += text_width + 5
262
# Draw the tag border
263
ctx.move_to(x0 - box_size / 3, y0 + text_height / 2)
265
ctx.line_to(x0 + text_width, y0)
266
ctx.line_to(x0 + text_width, y0 + text_height)
267
ctx.line_to(x0, y0 + text_height)
268
ctx.line_to(x0 - box_size / 3, y0 + text_height / 2)
271
ctx.arc(x0 - box_size / 12,
272
y0 + text_height / 2,
276
self.set_colour(ctx, TAG_COLOUR_ID, 0.0, 0.5)
277
ctx.stroke_preserve()
279
ctx.set_fill_rule (cairo.FILL_RULE_EVEN_ODD)
280
self.set_colour(ctx, TAG_COLOUR_ID, 0.5, 1.0)
284
self.set_colour(ctx, 0, 0.0, 0.0)
286
ctx.show_layout(tag_layout)