Commit Graph

70385 Commits

Author SHA1 Message Date
Matthias Clasen
4bea7bca1f path: Implement gsk_path_parse
Implement the SVG path syntax to read back the strings
that we generate when serializing paths. The tests for
this code are taken from librsvg.

This includes an elliptical arc implementation according
to the SVG spec. The code is mostly taken from librsvg,
but pretty directly follows the SVG spec implementation
notes. We don't export this, since the parametrization
is inconvenient. We do want an arc_to API, but
these are not the arcs we are looking for.
2021-07-13 06:17:36 +02:00
Matthias Clasen
d38198873b path: Implement SVG arcs
This is elliptical arc implementation according to the SVG spec.
The code is mostly taken from librsvg, but pretty directly
follows the SVG spec implementation notes.

We don't export this, since the parametrization is inconvenient.
We do want an arc_to API, but these are not the arcs we are
looking for.

It will be used in parsing SVG path syntax.
2021-07-13 06:17:36 +02:00
Matthias Clasen
aaa2a405a4 stroke: Add miter limit
Add a miter limit to GskStroke. This will be needed to
fully implement line joins.

Also introduce the GSK_LINE_JOIN_MITER_CLIP value,
following SVG 2.0. cairo does not have it, so translate
it to plain miter when using cairo.
2021-07-13 06:17:36 +02:00
Matthias Clasen
53e66377cd Documentation typo fixes 2021-07-13 06:17:36 +02:00
Benjamin Otte
6d7ff1c604 testsuite: Add relative path functions
They're making the paths slightly weirder, but they test public API, so
woohoo!
2021-07-13 06:17:36 +02:00
Benjamin Otte
2dc488db3f pathbuilder: Add relative path commands
And gsk_path_builder_get_current_point().

They will be needed by the string parser.
2021-07-13 06:17:36 +02:00
Benjamin Otte
f035e83d3f path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
This is just splitting out a commonly done operation into a macro.
2021-07-13 06:17:36 +02:00
Benjamin Otte
fe307f03c5 pathbuilder: Redo semantics for starting curves
We now always have a "current point" which is either the last point an
operation was made to, or (0, 0) if no drawing operation has
been made yet.

Adding a contour of any kind to the builder will always update the
current point to that contour's end point.
2021-07-13 06:17:36 +02:00
Benjamin Otte
d44f661929 xxx: demo 2021-07-13 06:17:36 +02:00
Benjamin Otte
a636080a4d path: Split GskPathBuilder into its own file
... and add missing API docs.
2021-07-13 06:17:36 +02:00
Benjamin Otte
8e8e270621 testsuite: Add a test using get_point() and get_closest_point() 2021-07-13 06:17:36 +02:00
Benjamin Otte
9f30152399 testsuite: Add a test for get_point() 2021-07-13 06:17:36 +02:00
Benjamin Otte
44e55c1067 testsuite: Update create_random_path()
1. Allow specifying the max number of contours
2. Be smarter about creating the paths:
   With 10% chance, create a "weird" path like the empty one or only
   points or things like that.
   Otherwise create a bunch of contours, with 2/3 a standard contour,
   with 1/3 a predetermined one.
2021-07-13 06:17:36 +02:00
Benjamin Otte
dec754bb2c gtk-demo: Add cute maze demo 2021-07-13 06:17:36 +02:00
Benjamin Otte
f425a536e6 testsuite: Add tests for gsk_path_measure_get_closest_point() 2021-07-13 06:17:36 +02:00
Benjamin Otte
ae3377f1de path: Add gsk_path_measure_get_closest_point()
... and gsk_path_measure_get_closest_point_full().

Those 2 functions allow finding the closest point on a path to a given
point.
2021-07-13 06:17:36 +02:00
Benjamin Otte
4dee03f3a8 spline: Use Skia's tolerance checks
This avoids measuring being too far off (it's still off, but it's less
than a percent now.
2021-07-13 06:17:36 +02:00
Benjamin Otte
1fca8a3db9 testsuite: Add tests for gsk_path_measure_add_segment() 2021-07-13 06:17:36 +02:00
Benjamin Otte
7f1c62b446 gtk-demo: Add a text-on-path demo 2021-07-13 06:17:36 +02:00
Benjamin Otte
4cda2cceab xxx: path_fill demo 2021-07-13 06:17:36 +02:00
Benjamin Otte
b028191010 path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2021-07-13 06:17:36 +02:00
Matthias Clasen
a90ab726c7 path: Add gsk_path_add_circle()
Adds a circle contour, too.
2021-07-13 06:17:36 +02:00
Benjamin Otte
ea9902b979 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.
2021-07-13 06:17:36 +02:00
Benjamin Otte
bb760ce1ed path: Implement gsk_path_to_cairo() using foreach() 2021-07-13 06:17:36 +02:00
Benjamin Otte
548f06e384 path: Add gsk_path_foreach() 2021-07-13 06:17:36 +02:00
Benjamin Otte
890b12e580 path: Collect flags
We don't need them yet, but maybe later.
2021-07-13 06:17:36 +02:00
Benjamin Otte
c69d78fa64 testsuite: Add path tests 2021-07-13 06:17:36 +02:00
Benjamin Otte
23de089362 pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2021-07-13 06:17:36 +02:00
Benjamin Otte
3a93e02758 path: Add gsk_path_builder_add_path() 2021-07-13 06:17:36 +02:00
Benjamin Otte
fc83f18812 gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2021-07-13 06:17:36 +02:00
Benjamin Otte
84f45d4282 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.
2021-07-13 06:17:36 +02:00
Benjamin Otte
c3809d0b3e 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?
2021-07-13 06:17:36 +02:00
Benjamin Otte
b4bb8ddc3d snapshot: Add gtk_snapshot_push_stroke() 2021-07-13 06:17:35 +02:00
Benjamin Otte
973ab15ddc gsk: Add GskStrokeNode 2021-07-13 06:17:35 +02:00
Benjamin Otte
2702b37955 gsk: Add GskStroke
It's unused in this commit. This just prepares the new object.
2021-07-13 06:17:35 +02:00
Benjamin Otte
70d5cf648d demos: Add a simple demo filling a path 2021-07-13 06:17:35 +02:00
Benjamin Otte
03a9fbf151 snapshot: Add gtk_snapshot_push_fill() 2021-07-13 06:17:35 +02:00
Benjamin Otte
ce36ad9d3e gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill the region in the
path just like cairo_fill() would.
2021-07-13 06:17:35 +02:00
Benjamin Otte
29b9216bd6 gsk: Add GskPath 2021-07-13 05:53:54 +02:00
Benjamin Otte
f7f5181f2d API: Add gtk_picture_add_paintable_bounds()
Allows a caller to see where a picture has placed a paintable.
2021-07-13 05:53:38 +02:00
Benjamin Otte
1b2a79f1d1 mediafile: Load extension at startup with GTK_MEDIA
When the GTK_MEDIA env var is set, check at startup that it works, not
only when the first MeidaFile is instantiated.

This has the fortunate side effect that it prints help output for
GTK_MEDIA=help at startup, too.
2021-07-13 05:53:20 +02:00
Matthias Clasen
6818eee859 Merge branch 'wip/exalm/scroll-touch' into 'master'
scrolledwindow: Don't check drag threshold when already scrolling

See merge request GNOME/gtk!3735
2021-07-07 21:37:58 +00:00
Matthias Clasen
e7f1398d85 Merge branch 'text-cursor-extents' into 'master'
text: Add API to compute cursor extents

See merge request GNOME/gtk!3734
2021-07-07 21:37:14 +00:00
Matthias Clasen
880c01f8cc Merge branch 'wl-since' into 'master'
Add missing "Since: 4.X" doc tags

See merge request GNOME/gtk!3736
2021-07-07 21:36:13 +00:00
Marc-André Lureau
337c5e5e59 Add missing "Since: 4.X" tags
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-07-07 23:35:38 +04:00
Florian Müllner
af52ea78c6 text: Add API to compute cursor extents
The extents that correspond to the strong/weak cursor at a given
character position can be used for example to point a popover to
text in the widget.
2021-07-07 19:33:12 +02:00
Alexander Mikhaylenko
fe633d9ef9 scrolledwindow: Don't check drag threshold when already scrolling
Checkout the drag threshold only makes sense when starting a scroll, after
that it just adds jumps when trying to scroll back and forth.
2021-07-07 19:39:06 +05:00
Matthias Clasen
e6cce283a7 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Add a slider to the menu example

See merge request GNOME/gtk!3733
2021-07-06 00:23:30 +00:00
Matthias Clasen
c920236c54 gtk-demo: Add a slider to the menu example
This is a fun way to show that we can scale fast.
2021-07-05 19:31:54 -04:00
Matthias Clasen
6f86b4d220 Merge branch 'js-example' into 'master'
Add a simple Javascript example

See merge request GNOME/gtk!3731
2021-07-05 20:24:30 +00:00