Commit Graph

67410 Commits

Author SHA1 Message Date
Matthias Clasen
7c72d3c19d Allow setting stroke color 2020-11-22 13:53:19 -05:00
Matthias Clasen
156d5125ed Add a setter for stroke color 2020-11-22 13:53:19 -05:00
Matthias Clasen
c7c2a86647 Allow setting cap and join 2020-11-22 13:53:19 -05:00
Matthias Clasen
d70f1602dd Add a getter for the stroke 2020-11-22 13:42:04 -05:00
Matthias Clasen
10b161d77d Implement line caps and joins
This is just passing things through to cairo,
for the most part.
2020-11-22 13:03:30 -05:00
Matthias Clasen
ee3d6d8514 Add a setter for the stroke
Make the stroke used for the curve itself settable,
and add a scale in the demo to set it. This is not
very interesting since the stroke doesn't have many
parameters yet.
2020-11-22 02:00:48 -05:00
Matthias Clasen
d6acea760b Snapshot the curve separately
This will let us use separate strokes for the
curve and the controls.
2020-11-22 01:45:26 -05:00
Matthias Clasen
244364b3dc Add an automatic point type
Points of this type update their control
points when their neighboring points (or
the point itself) move.

This is modeled on what Inkscape does.
2020-11-22 01:39:00 -05:00
Matthias Clasen
24912ce5b3 Introduce point types
This is a bit more organized than the ad hoc
smooth and symmetric booleans, and will let us
introduce more types in the future.
2020-11-22 01:13:48 -05:00
Matthias Clasen
a354ed8694 Plug a memory leak 2020-11-21 22:50:30 -05:00
Matthias Clasen
68276b1b6d Cosmetics 2020-11-21 22:50:30 -05:00
Matthias Clasen
c77d126bf4 Maintain smoothness harder
When removing a point, we need to ensure that
the neighboring point is still smooth.
2020-11-21 22:50:30 -05:00
Matthias Clasen
12ac1dfdbe Maintain symmetry
When turning on symmetry, we need to actually make
the point symmetric.
2020-11-21 22:50:30 -05:00
Matthias Clasen
17ef4a77fe Redo the data structure
Change things around a bit and keep an array of
points. Each point comes with its two neighboring
control points, and each Bezier segment is made up
from points from two neighboring points.
This is much closer to what the ui shows.
2020-11-21 22:50:30 -05:00
Matthias Clasen
0f1122880a Remove leftover code
We are setting smoothness in the menu now,
so we should not be toggling it on right-click
anymore.
2020-11-21 20:00:00 -05:00
Matthias Clasen
4994ea43f9 Reshuffle code 2020-11-21 14:53:59 -05:00
Matthias Clasen
401ff4137c Make symmetric point state
This matches what Inkscape does.
2020-11-21 12:52:18 -05:00
Matthias Clasen
e60057d1a6 Add a helper function
Add a point_is_visible function and use it in
several places. This fixes cases where it was
possible to interact with invisible control points.
2020-11-21 12:43:28 -05:00
Matthias Clasen
c59fd4940b Add hover for points 2020-11-21 12:11:21 -05:00
Matthias Clasen
64b0b117b3 Cosmetics 2020-11-21 11:51:28 -05:00
Matthias Clasen
95867222b8 Implement adding points 2020-11-21 10:36:27 -05:00
Matthias Clasen
4f5d05634a Implement removing points 2020-11-21 09:26:53 -05:00
Matthias Clasen
8a9a067b4b Be more lenient with clicks
Allow clicks to be slightly outside the radius
of the drawn circles, to make clicking easier.
2020-11-21 09:26:40 -05:00
Matthias Clasen
3ef88ba4cf Use graphene point distance function
No need to roll our own.
2020-11-21 09:24:17 -05:00
Matthias Clasen
01abd68455 Add more api
Add curve_editor_get_path.
2020-11-21 08:47:43 -05:00
Matthias Clasen
267c1a277c Rename to CurveEditor
And start separating the widget from the demo
with an api.
2020-11-21 08:47:34 -05:00
Matthias Clasen
ca4d610bf2 Add operations
Allow setting the type of segments to move, line or
curve, from the context menu, and do the necessary
adjustments to maintain smoothness, in particular
between curve and line segments.
2020-11-21 08:47:33 -05:00
Matthias Clasen
8993756a84 Use a context menu
Move the toggling of smoothness to a context menu
on each point. This menu will carry more items in
the future.
2020-11-20 13:30:08 -05:00
Matthias Clasen
4c23a9fa6e Tweak editing some more 2020-11-20 11:11:23 -05:00
Matthias Clasen
93d2b8ba63 Change dragging of non-smooth point
Always move control points along. Feels more natural.
2020-11-20 09:52:12 -05:00
Matthias Clasen
6f45aaf9f4 curve: Introduce the concept of symmetric
Keep the distance of control points equal (ie symmetric)
when dragging control points, unless you hold Control
when initiating the drag.
2020-11-20 09:35:42 -05:00
Matthias Clasen
da503ea4b5 curve: Restructure data a bit
Introduce a separate PointData struct that is going
to hold per-segment information.
2020-11-20 08:45:38 -05:00
Matthias Clasen
8ce6690205 More curve editing
Make right-click on curve points toggle between
smooth and corner.
2020-11-20 00:55:51 -05:00
Matthias Clasen
0d8e052123 Play with paths
Add a simple demo for editing a poly-Bezier curve.
2020-11-19 23:38:20 -05:00
Benjamin Otte
4b04c859b6 gtk-demo: Add a text-on-path demo 2020-11-19 22:41:37 +01:00
Benjamin Otte
39093d5935 xxx: path_fill demo 2020-11-19 22:41:37 +01:00
Benjamin Otte
3abe33fc1d path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2020-11-19 22:41:37 +01:00
Benjamin Otte
6e7df513ab path: Add gsk_path_add_circle()
Adds a circle contour, too.
2020-11-19 22:41:37 +01:00
Benjamin Otte
3cf4bbc9d1 pathmeasure: Implement support for beziers
Instead of treating bezier curves as lines, we properly decompose them
into line segments now so that we can treat those as lines.
2020-11-19 22:41:37 +01:00
Benjamin Otte
eb63c33ce9 path: Implement gsk_path_to_cairo() using foreach() 2020-11-19 22:41:37 +01:00
Benjamin Otte
4aca0358b4 path: Add gsk_path_foreach() 2020-11-19 22:41:37 +01:00
Benjamin Otte
cf930d93e1 path: Collect flags
We don't need them yet, but maybe later.
2020-11-19 22:41:37 +01:00
Benjamin Otte
6f009aa6d7 testsuite: Add path tests 2020-11-19 22:41:37 +01:00
Benjamin Otte
9211e49dd2 pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2020-11-19 22:41:37 +01:00
Benjamin Otte
c7a061bfba path: Add gsk_path_builder_add_path() 2020-11-19 22:41:37 +01:00
Benjamin Otte
099cac301d gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2020-11-19 22:41:37 +01:00
Benjamin Otte
8924a0df00 path: Change data structure for standard path
Instead of the Cairo method and imitating cairo_path_data_t, use the
Skia method and keep points and operations separate.

That way we get a points array that includes the starting point -
because it's always the end point of the previous operation.
2020-11-19 22:41:37 +01:00
Benjamin Otte
0eb30556e9 popover: Use fill and stroke nodes instead of Cairo
... to render the arrow.

The arrow should really be turned into a real thing - maybe an icon?
2020-11-19 22:41:37 +01:00
Benjamin Otte
cd5822dd4c snapshot: Add gtk_snapshot_push_stroke() 2020-11-19 22:41:37 +01:00
Benjamin Otte
f155d7f8d3 gsk: Add GskStrokeNode 2020-11-19 22:41:37 +01:00