mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
add utility function gdk_quartz_fix_cap_not_last_line() which fixes the
2007-06-08 Michael Natterer <mitch@imendio.com> * gdk/quartz/gdkdrawable-quartz.c: add utility function gdk_quartz_fix_cap_not_last_line() which fixes the coordinates for GDK_CAP_NOT_LAST lines at least for horizontal and vertical lines. (gdk_quartz_draw_segments) (gdk_quartz_draw_lines): use it here. svn path=/trunk/; revision=18080
This commit is contained in:
parent
dde0d5ffa5
commit
6c3637ea3e
@ -1,3 +1,12 @@
|
||||
2007-06-08 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkdrawable-quartz.c: add utility function
|
||||
gdk_quartz_fix_cap_not_last_line() which fixes the coordinates for
|
||||
GDK_CAP_NOT_LAST lines at least for horizontal and vertical lines.
|
||||
|
||||
(gdk_quartz_draw_segments)
|
||||
(gdk_quartz_draw_lines): use it here.
|
||||
|
||||
2007-06-07 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkgc-quartz.c: add gdk_gc_quartz_init() and set
|
||||
|
@ -366,6 +366,33 @@ gdk_quartz_draw_points (GdkDrawable *drawable,
|
||||
gdk_quartz_drawable_release_context (drawable, context);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gdk_quartz_fix_cap_not_last_line (GdkGCQuartz *private,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gint *xfix,
|
||||
gint *yfix)
|
||||
{
|
||||
*xfix = 0;
|
||||
*yfix = 0;
|
||||
|
||||
if (private->cap_style == GDK_CAP_NOT_LAST && private->line_width == 0)
|
||||
{
|
||||
/* fix only vertical and horizontal lines for now */
|
||||
|
||||
if (y1 == y2 && x1 != x2)
|
||||
{
|
||||
*xfix = (x1 < x2) ? -1 : 1;
|
||||
}
|
||||
else if (x1 == x2 && y1 != y2)
|
||||
{
|
||||
*yfix = (y1 < y2) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_draw_segments (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
@ -373,18 +400,28 @@ gdk_quartz_draw_segments (GdkDrawable *drawable,
|
||||
gint nsegs)
|
||||
{
|
||||
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
|
||||
GdkGCQuartz *private;
|
||||
int i;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
private = GDK_GC_QUARTZ (gc);
|
||||
|
||||
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
|
||||
GDK_QUARTZ_CONTEXT_STROKE);
|
||||
|
||||
for (i = 0; i < nsegs; i++)
|
||||
{
|
||||
gint xfix, yfix;
|
||||
|
||||
gdk_quartz_fix_cap_not_last_line (private,
|
||||
segs[i].x1, segs[i].y1,
|
||||
segs[i].x2, segs[i].y2,
|
||||
&xfix, &yfix);
|
||||
|
||||
CGContextMoveToPoint (context, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
|
||||
CGContextAddLineToPoint (context, segs[i].x2 + 0.5, segs[i].y2 + 0.5);
|
||||
CGContextAddLineToPoint (context, segs[i].x2 + 0.5 + xfix, segs[i].y2 + 0.5 + yfix);
|
||||
}
|
||||
|
||||
CGContextStrokePath (context);
|
||||
@ -399,19 +436,32 @@ gdk_quartz_draw_lines (GdkDrawable *drawable,
|
||||
gint npoints)
|
||||
{
|
||||
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
|
||||
int i;
|
||||
GdkGCQuartz *private;
|
||||
gint xfix, yfix;
|
||||
gint i;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
private = GDK_GC_QUARTZ (gc);
|
||||
|
||||
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
|
||||
GDK_QUARTZ_CONTEXT_STROKE);
|
||||
GDK_QUARTZ_CONTEXT_STROKE);
|
||||
|
||||
CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
|
||||
|
||||
for (i = 1; i < npoints; i++)
|
||||
for (i = 1; i < npoints - 1; i++)
|
||||
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
|
||||
|
||||
gdk_quartz_fix_cap_not_last_line (private,
|
||||
points[npoints - 2].x, points[npoints - 2].y,
|
||||
points[npoints - 1].x, points[npoints - 1].y,
|
||||
&xfix, &yfix);
|
||||
|
||||
CGContextAddLineToPoint (context,
|
||||
points[npoints - 1].x + 0.5 + xfix,
|
||||
points[npoints - 1].y + 0.5 + yfix);
|
||||
|
||||
CGContextStrokePath (context);
|
||||
|
||||
gdk_quartz_drawable_release_context (drawable, context);
|
||||
|
Loading…
Reference in New Issue
Block a user