Commit be7db845 authored by Bartosz Kosiorek's avatar Bartosz Kosiorek Committed by Alexandre Julliard

gdiplus: Add support for Custom Line Indent.

parent b57f635f
...@@ -1876,7 +1876,7 @@ static void widen_joint(const GpPointF *p1, const GpPointF *p2, const GpPointF * ...@@ -1876,7 +1876,7 @@ static void widen_joint(const GpPointF *p1, const GpPointF *p2, const GpPointF *
} }
static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
REAL pen_width, GpLineCap cap, int add_first_points, REAL pen_width, GpLineCap cap, GpCustomLineCap* custom_cap, int add_first_points,
int add_last_point, path_list_node_t **last_point) int add_last_point, path_list_node_t **last_point)
{ {
switch (cap) switch (cap)
...@@ -1889,6 +1889,7 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, ...@@ -1889,6 +1889,7 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
add_bevel_point(endpoint, nextpoint, pen_width, 0, last_point); add_bevel_point(endpoint, nextpoint, pen_width, 0, last_point);
break; break;
case LineCapSquare: case LineCapSquare:
case LineCapCustom:
{ {
REAL segment_dy = nextpoint->Y-endpoint->Y; REAL segment_dy = nextpoint->Y-endpoint->Y;
REAL segment_dx = nextpoint->X-endpoint->X; REAL segment_dx = nextpoint->X-endpoint->X;
...@@ -1897,20 +1898,25 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, ...@@ -1897,20 +1898,25 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
REAL bevel_dx, bevel_dy; REAL bevel_dx, bevel_dy;
REAL extend_dx, extend_dy; REAL extend_dx, extend_dy;
extend_dx = -distance * segment_dx / segment_length; extend_dx = distance * segment_dx / segment_length;
extend_dy = -distance * segment_dy / segment_length; extend_dy = distance * segment_dy / segment_length;
bevel_dx = -distance * segment_dy / segment_length; bevel_dx = -extend_dy;
bevel_dy = distance * segment_dx / segment_length; bevel_dy = extend_dx;
if (cap == LineCapCustom)
{
extend_dx = -2.0 * custom_cap->inset * extend_dx;
extend_dy = -2.0 * custom_cap->inset * extend_dy;
}
if (add_first_points) if (add_first_points)
*last_point = add_path_list_node(*last_point, endpoint->X + extend_dx + bevel_dx, *last_point = add_path_list_node(*last_point, endpoint->X - extend_dx + bevel_dx,
endpoint->Y + extend_dy + bevel_dy, PathPointTypeLine); endpoint->Y - extend_dy + bevel_dy, PathPointTypeLine);
if (add_last_point) if (add_last_point)
*last_point = add_path_list_node(*last_point, endpoint->X + extend_dx - bevel_dx, *last_point = add_path_list_node(*last_point, endpoint->X - extend_dx - bevel_dx,
endpoint->Y + extend_dy - bevel_dy, PathPointTypeLine); endpoint->Y - extend_dy - bevel_dy, PathPointTypeLine);
break; break;
} }
case LineCapRound: case LineCapRound:
...@@ -1983,8 +1989,8 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint, ...@@ -1983,8 +1989,8 @@ static void widen_cap(const GpPointF *endpoint, const GpPointF *nextpoint,
} }
static void widen_open_figure(const GpPointF *points, int start, int end, static void widen_open_figure(const GpPointF *points, int start, int end,
GpPen *pen, REAL pen_width, GpLineCap start_cap, GpPen *pen, REAL pen_width, GpLineCap start_cap, GpCustomLineCap* custom_start,
GpLineCap end_cap, path_list_node_t **last_point); GpLineCap end_cap, GpCustomLineCap* custom_end, path_list_node_t **last_point);
static void widen_closed_figure(const GpPointF *points, int start, int end, static void widen_closed_figure(const GpPointF *points, int start, int end,
GpPen *pen, REAL pen_width, path_list_node_t **last_point); GpPen *pen, REAL pen_width, path_list_node_t **last_point);
...@@ -2145,7 +2151,7 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, ...@@ -2145,7 +2151,7 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint,
if ((custom->pathdata.Types[custom->pathdata.Count - 1] & PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath) if ((custom->pathdata.Types[custom->pathdata.Count - 1] & PathPointTypeCloseSubpath) == PathPointTypeCloseSubpath)
widen_closed_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, last_point); widen_closed_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, last_point);
else else
widen_open_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, custom->strokeEndCap, custom->strokeStartCap, last_point); widen_open_figure(tmp_points, 0, custom->pathdata.Count - 1, pen, pen_width, custom->strokeEndCap, NULL, custom->strokeStartCap, NULL, last_point);
} }
else else
{ {
...@@ -2167,8 +2173,8 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint, ...@@ -2167,8 +2173,8 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint,
} }
static void widen_open_figure(const GpPointF *points, int start, int end, static void widen_open_figure(const GpPointF *points, int start, int end,
GpPen *pen, REAL pen_width, GpLineCap start_cap, GpPen *pen, REAL pen_width, GpLineCap start_cap, GpCustomLineCap* custom_start,
GpLineCap end_cap, path_list_node_t **last_point) GpLineCap end_cap, GpCustomLineCap* custom_end, path_list_node_t **last_point)
{ {
int i; int i;
path_list_node_t *prev_point; path_list_node_t *prev_point;
...@@ -2179,21 +2185,21 @@ static void widen_open_figure(const GpPointF *points, int start, int end, ...@@ -2179,21 +2185,21 @@ static void widen_open_figure(const GpPointF *points, int start, int end,
prev_point = *last_point; prev_point = *last_point;
widen_cap(&points[start], &points[start+1], widen_cap(&points[start], &points[start+1],
pen_width, start_cap, FALSE, TRUE, last_point); pen_width, start_cap, custom_start, FALSE, TRUE, last_point);
for (i=start+1; i<end; i++) for (i=start+1; i<end; i++)
widen_joint(&points[i-1], &points[i], &points[i+1], widen_joint(&points[i-1], &points[i], &points[i+1],
pen, pen_width, last_point); pen, pen_width, last_point);
widen_cap(&points[end], &points[end-1], widen_cap(&points[end], &points[end-1],
pen_width, end_cap, TRUE, TRUE, last_point); pen_width, end_cap, custom_end, TRUE, TRUE, last_point);
for (i=end-1; i>start; i--) for (i=end-1; i>start; i--)
widen_joint(&points[i+1], &points[i], &points[i-1], widen_joint(&points[i+1], &points[i], &points[i-1],
pen, pen_width, last_point); pen, pen_width, last_point);
widen_cap(&points[start], &points[start+1], widen_cap(&points[start], &points[start+1],
pen_width, start_cap, TRUE, FALSE, last_point); pen_width, start_cap, custom_start, TRUE, FALSE, last_point);
prev_point->next->type = PathPointTypeStart; prev_point->next->type = PathPointTypeStart;
(*last_point)->type |= PathPointTypeCloseSubpath; (*last_point)->type |= PathPointTypeCloseSubpath;
...@@ -2337,8 +2343,8 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed, ...@@ -2337,8 +2343,8 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed,
tmp_points[num_tmp_points].Y = path->pathdata.Points[i].Y + segment_dy * segment_pos / segment_length; tmp_points[num_tmp_points].Y = path->pathdata.Points[i].Y + segment_dy * segment_pos / segment_length;
widen_open_figure(tmp_points, 0, num_tmp_points, pen, pen_width, widen_open_figure(tmp_points, 0, num_tmp_points, pen, pen_width,
draw_start_cap ? pen->startcap : LineCapFlat, draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart,
LineCapFlat, last_point); LineCapFlat, NULL, last_point);
draw_start_cap = 0; draw_start_cap = 0;
num_tmp_points = 0; num_tmp_points = 0;
} }
...@@ -2371,8 +2377,8 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed, ...@@ -2371,8 +2377,8 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed,
{ {
/* last dash overflows last segment */ /* last dash overflows last segment */
widen_open_figure(tmp_points, 0, num_tmp_points-1, pen, pen_width, widen_open_figure(tmp_points, 0, num_tmp_points-1, pen, pen_width,
draw_start_cap ? pen->startcap : LineCapFlat, draw_start_cap ? pen->startcap : LineCapFlat, pen->customstart,
closed ? LineCapFlat : pen->endcap, last_point); closed ? LineCapFlat : pen->endcap, pen->customend, last_point);
} }
heap_free(dash_pattern_scaled); heap_free(dash_pattern_scaled);
...@@ -2446,7 +2452,8 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, ...@@ -2446,7 +2452,8 @@ GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
if (pen->dash != DashStyleSolid) if (pen->dash != DashStyleSolid)
widen_dashed_figure(flat_path, subpath_start, i, 0, pen, pen_width, &last_point); widen_dashed_figure(flat_path, subpath_start, i, 0, pen, pen_width, &last_point);
else else
widen_open_figure(flat_path->pathdata.Points, subpath_start, i, pen, pen_width, pen->startcap, pen->endcap, &last_point); widen_open_figure(flat_path->pathdata.Points, subpath_start, i, pen, pen_width,
pen->startcap, pen->customstart, pen->endcap, pen->customend, &last_point);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment