Skip to content

Commit fe012f6

Browse files
qarkaicaclark
authored andcommitted
Simplify pan_item_tri_draw() a bit
1 parent 1af85d0 commit fe012f6

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/pan-view/pan-item.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,25 +273,25 @@ gboolean pan_item_tri_draw(PanWindow *, PanItem *pi, GdkPixbuf *pixbuf, PixbufRe
273273
{
274274
const GdkRectangle request_rect{x, y, width, height};
275275
const GdkRectangle pi_rect{pi->x, pi->y, pi->width, pi->height};
276-
GdkRectangle r;
277276

278-
if (pi->data && gdk_rectangle_intersect(&request_rect, &pi_rect, &r))
277+
if (GdkRectangle r; gdk_rectangle_intersect(&request_rect, &pi_rect, &r))
279278
{
280-
auto coord = static_cast<GqPoint *>(pi->data);
281279
r.x -= x;
282280
r.y -= y;
283-
pixbuf_draw_triangle(pixbuf, r,
284-
{coord[0].x - x, coord[0].y - y},
285-
{coord[1].x - x, coord[1].y - y},
286-
{coord[2].x - x, coord[2].y - y},
287-
pi->color);
288281

289-
const auto draw_line = [pixbuf, &r, x, y, pi](GqPoint start, GqPoint end)
282+
auto *pi_coord = static_cast<GqPoint *>(pi->data);
283+
GqPoint coord[3];
284+
for (gint i = 0; i < 3; ++i)
285+
{
286+
coord[i].x = pi_coord[i].x - x;
287+
coord[i].y = pi_coord[i].y - y;
288+
}
289+
290+
pixbuf_draw_triangle(pixbuf, r, coord[0], coord[1], coord[2], pi->color);
291+
292+
const auto draw_line = [pixbuf, &r, pi](GqPoint start, GqPoint end)
290293
{
291-
pixbuf_draw_line(pixbuf, r,
292-
start.x - x, start.y - y,
293-
end.x - x, end.y - y,
294-
pi->color2);
294+
pixbuf_draw_line(pixbuf, r, start.x, start.y, end.x, end.y, pi->color2);
295295
};
296296

297297
if (pi->borders & PAN_BORDER_1) draw_line(coord[0], coord[1]);

0 commit comments

Comments
 (0)