Commit Graph

37 Commits

Author SHA1 Message Date
Uli Schlachter ccaa75f4b4 Make shapes more robust w.r.t pre-existing paths (#2806)
A call to cairo_close_path() adds a straight line to the beginning of
the current sub-path. This is used in some of the shapes to, well, close
the shapes.

Sub-paths can be created explicitly via cairo_new_sub_path(), but also
implicitly via cairo_move_to(). When a new sub-path is started, there is
no current point on the path. This means that e.g. cairo_line_to() is in
this start equivalent to cairo_move_to() (= no line is created) and that
cairo_curve_to() first does a cairo_move_to() to the beginning of the
curve. Similarly, cairo_arc() and cairo_arc_negative() first do a
line_to() to the beginning of the arc, and this line_to() can be
implicitly turned into a curve_to().

The problem with the code in gears.shape is that parts of the code
(implicitly) assume that there is not yet any path when the shape
function is called.  If this assumption is broken, the call to
close_path() could go to the wrong point, because the path did not start
at the expected position.

Most of the functions in gears.shape already implicitly start a new
sub-path via a call to cairo_move_to(). Those that do not (necessarily)
begin with a call to cairo_move_to() are handled in this commit: They
get an explicit call to cairo_new_sub_path().

This change fixes the issue reported at
https://github.com/awesomeWM/awesome/pull/2804, because the shapes will
no longer be influenced by the pre-existing path. The move_to() that was
left around and caused that issue turns into a degenerate part (it only
has a move_to(), so nothing can be drawn) and is then discarded by
cairo.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-07-03 16:56:08 -04:00
Emmanuel Lepage Vallee b4ece0f053 doc: Use an explicit tag for all static functions.
This way their name doesn't get mangle by the broken magic. It will also
eventually allow to `error()` in the template when the implicit
`@function` is used.

This commit also fixes a large number of issues found while
proof-reading everything.
2019-06-08 18:14:13 -04:00
Emmanuel Lepage Vallee cdeafeff94 doc: Add a section for theme related libraries 2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee 9efcf9df87 shape.arc: Prevent an angle underflow when rounded edges are enabled.
Fixes #2604
2019-01-26 12:13:13 -05:00
Daniel Hahler aeab2a70e9 Fix whitespace warnings reported by luacheck (#1229) 2016-11-21 22:38:23 +01:00
Uli Schlachter 259c4f716f Remove @release @AWESOME_VERSION@ everywhere (#1157)
It does not provide much value. The version number is already known to
ldoc globally in the "description" variable.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-10-09 22:36:20 +02:00
Emmanuel Lepage Vallee fb4a48b744 doc: Document where gears.shape can be used. 2016-09-26 01:21:15 -04:00
Emmanuel Lepage Vallee 9b5cecf53e shape: Move_to is necessary for circle strokes 2016-09-24 14:45:09 -04:00
Emmanuel Lepage Vallee d03d63ecae shape: Add circle radius parameter. 2016-09-24 14:45:09 -04:00
Emmanuel Lepage Vallee 2475aa6e9b shape: Add the 'arc' shape. 2016-09-24 14:45:09 -04:00
Emmanuel Lepage Vallee a027589150 shape: Add pie shape. 2016-09-24 14:45:09 -04:00
Emmanuel Lepage Vallee 441587a4de shape: Use an explicit move_to to set rounded_rect position
All other shape did it. While it usually have no side effects,
as seen in #920 screenshot from @actionless, there is instances
where this produce a invalid rectangle.
2016-07-04 14:34:41 -04:00
Emmanuel Lepage Vallee 490306a5fc shape: Add default rounded_rect radius
Add an arbitrary value to avoid all caller setting extra arguments.
2016-05-30 18:00:58 -04:00
Emmanuel Lepage Vallee 44a4eca40e doc: Port the shape images to the doc example system 2016-05-30 17:51:19 -04:00
Emmanuel Lepage Vallee e24cb901cb Typo: Ajust -> Adjust 2016-04-04 00:56:11 -04:00
Uli Schlachter 96055fc86b gears.shape: Stop using _call on a matrix
Instead of using a special _call field on gears.matrix instances which has to be
copied around suitably, this commit changes the code so that the magic is
restricted to a single function in gears.shape.transform. With some metatable
magic, suitable redirection to everything is added.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-26 19:33:10 +01:00
Uli Schlachter 19f146de5f Add missing modeline to gears.shape
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-03-26 19:32:40 +01:00
Emmanuel Lepage Vallee f6556b145f gears.shape: Improve documentation 2016-03-16 18:02:41 -04:00
Emmanuel Lepage Vallee 9bd150f39a shape: Add radial_progress shape 2016-03-16 17:45:11 -04:00
Emmanuel Lepage Vallee 650d8d0cb5 shape: Add partially_rounded_rect shape 2016-03-16 17:44:37 -04:00
Emmanuel Lepage Vallee 57e370700f shape: Add losange shape 2016-03-16 17:44:37 -04:00
Emmanuel Lepage Vallee bc16b75ff5 shape: Add parallelogram shape 2016-03-16 17:44:30 -04:00
Emmanuel Lepage Vallee 7b4109265e shape: Add rectangle shape 2016-03-16 05:57:44 -04:00
Emmanuel Lepage Vallee 990619db5a shape: Add circle shape 2016-03-16 05:57:44 -04:00
Emmanuel Lepage Vallee 3b95d2467f shape: Add octogon shape 2016-03-16 05:57:44 -04:00
Emmanuel Lepage Vallee f0bf642f32 shape: Add cross shape 2016-03-16 05:57:44 -04:00
Emmanuel Lepage Vallee 5dbffc73c1 shape: Minor fixes 2016-03-16 05:57:44 -04:00
Uli Schlachter 8c26e2dab4 Fix all luacheck warnings in lib/gears
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-02-12 09:11:50 +01:00
Emmanuel Lepage Vallee 348cd3a590 gears.shape: Add isosceles_triangle shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee 0bf76dc984 gears.shape: Add powerline shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee 4a44b0dc81 gears.shape: Add hexagon shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee a89b21ba2f gears.shape: Add arrow shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee 1060a3487e gears.shape: Add rectangular_tag shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee a49b259c7f gears.shape: Add infobubble shape 2016-02-02 00:21:42 -05:00
Emmanuel Lepage Vallee 98d8b8a199 gears.shape: Add a transformation mechanism
This allow to take a generic shape and transform it into a more
custom one without bloating the shape code.
2016-02-02 00:21:42 -05:00
Uli Schlachter ad4c62e639 Fix warnings from ldoc
Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-01-30 10:43:41 +01:00
Emmanuel Lepage Vallee fb0c82a798 gears.shape: Add a new module to make it easier to use shapes
This code is imported from Elv13 config and make it very easy
to create shaped objects.

If accepted upstream, other shapes, such as arrow and powerline
will also be added. This commit introsuce the 2 most common
shapes, rounded rectangle and rounded bar.
2016-01-18 17:20:32 -05:00