Commit graph

143 commits

Author SHA1 Message Date
Leonardo Gibrowski Faé
4a41d4296a
Implement '&&' and '||' operators on map
'-' is a valid character for tags.

Commit 03e1c7d (module/network: Add link stats, 2022-04-30) introduced
two new tags for the network module: `ul-speed` and `dl-speed`. These
use the `-` character, that was previously never used in any tag.

We had two options: either change those tags to use `_` instead, or just
accept `-`s as a valid character. Going forward, I can see many people
deciding to name their tags with `-` instead of `_`, so I believe it is
better to just accept it once and for all.

Note that `-` cannot be used as the first character of a tag (e.g.
`-tag1`) since the `-` has a special meaning in `.yml` files. I don't
believe this will happen often, however, and should be easy to both
detect and correct if it does.
2022-12-10 22:53:30 -03:00
Daniel Eklöf
605a6a9ede
particle/string: don’t try to call c32len() on a NULL string 2022-06-13 12:07:24 +02:00
Daniel Eklöf
1b03bd6bc0
particle/string: simplify; no need to call c32len(wtext) twice 2022-06-13 12:06:59 +02:00
Leonardo Gibrowski Faé
82a3b2ae11 Updates CHANGELOG.md and changes map.c formatting 2022-04-24 11:21:40 -03:00
Leonardo Gibrowski Faé
0d878e8b5c Trimming outer '"' when parsing the values. 2022-04-23 17:13:24 -03:00
Leonardo Gibrowski Faé
2b103b7acd Implement conditions on tag
A condition is formed by:
    <tag> <op> <value>

<tag> is the normal yambar tag. <op> is one of '==', '!=', '<', '<=', '>', or
'>='. <value> is what you wish to compare it to.

'boolean' tags must be used directly. They falsehood is matched with '~':

    <tag>
    ~<tag>

Finally, to match an empty string, one must use ' "" ':
    <tag> <op> ""
2022-04-23 17:13:24 -03:00
Daniel Eklöf
ffccabbb13
config: add inheritable option “font-shaping”
This patch adds an inheritable option, “font-shaping”, that controls
whether a particle that renders text should enable font-shaping or
not.

The option works similar to the ‘font’ option: one can set it at the
top-level, and it gets inherited down through all modules and to their
particles.

Or, you can set it on a module and it gets inherited to all its
particles, but not to other modules’ particles.

Finally, you can set it on individual particles, in which case it only
applies to them (or “child” particles).

When font-shaping is enabled (the default), the string particle shapes
full text runs using the fcft_rasterize_text_run_utf32() API. In fcft,
this results in HarfBuzz being used to shape the string.

When disabled, the string particle instead uses the simpler
fcft_rasterize_char_utf32() API, which rasterizes individual
characters.

This gives user greater control over the font rendering. One example
is bitmap fonts, which HarfBuzz often doesn’t get right.

Closes #159
2022-02-23 18:43:13 +01:00
Daniel Eklöf
ff238e62ba
fcft: adapt to API changes in fcft-3.x 2022-02-05 12:51:08 +01:00
Daniel Eklöf
4f0d27bc7e
particles: verify: use conf_verify_unsigned() for options that should be >= 0 2021-11-15 18:17:52 +01:00
Vincent Fischer
535d49e9c3 allow ramp particles to overwrite min and max 2021-09-20 19:08:18 +02:00
Daniel Eklöf
e4e9587322
particle/progress-bar: fix regression in width calculation: = -> += 2021-08-30 18:00:41 +02:00
Daniel Eklöf
af0b7e57d8
particle/ramp: don’t add margins if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero
width.
2021-08-25 18:48:15 +02:00
Daniel Eklöf
def90edde1
particle/progress-bar: don’t add margins if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero
width.
2021-08-25 18:48:15 +02:00
Daniel Eklöf
dab6428859
particle/map: don’t add margins if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero
width.
2021-08-25 18:48:15 +02:00
Daniel Eklöf
73e1d328c3
particle/list: don’t adjust spacing if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero
width, instead of a negative width.
2021-08-25 18:48:15 +02:00
Daniel Eklöf
ca43eb3016
particle/dynlist: don’t adjust spacing if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero
width, instead of a negative width.
2021-08-25 18:48:15 +02:00
Daniel Eklöf
a210d33320
particle/progress-bar: fix ‘where’ tag regression
After implementing support for more mouse buttons (and scrolling), the
‘where’ tag stopped working in the progress-bar.

This patch repairs it.
2021-08-09 18:21:45 +02:00
Daniel Eklöf
8187d60193
particle/string: use HORIZONTAL ELLIPSIS as truncation character
First, apply max-len to the converted wide character string, instead
of the UTF-8 string. This is better, and more correct, since UTF-8 is
multibyte, and applying max-len to that results in strings _shorter_
than max-len.

Second, use HORIZONTAL ELLIPSIS (…) instead of three regular
periods (...) as truncation character. This “saves” 2 characters.

To be able to do this, the conversion to a wide character, and glyph
rasterization is now done when the exposable is instantiated, instead
of in begin_expose().

Closes #73
2021-07-19 12:30:21 +02:00
Daniel Eklöf
e11fe12c98
particles: fix mouse hover on non-primitive particles
If a ramp, map or progress-bar has an on-click handler, then the mouse
should _always_ reflect this.
2021-07-02 16:36:09 +02:00
Daniel Eklöf
46e6539b1a
particle/list: call default handler on motion events if we a have click handler
This ensures the cursor changes shape correctly
2021-07-01 17:15:54 +02:00
Daniel Eklöf
c79ffbe057
Add support binding on-click handlers to other buttons than LEFT
One can now bind the left/middle/right mouse buttons to on-click. In
fact, you can have all three buttons bound to different handlers for
the same particle. The new syntax is

    on-click:
        left: <command>
        middle: <command>
        right: <command>

Leaving one out is the same thing as not mapping it at
all. Furthermore,

    on-click: <command>

is still valid, and is a shorthand for

    on-click:
        left: <commsnd>
2021-07-01 17:15:53 +02:00
Daniel Eklöf
dd724d1bc2
exposable: add ‘btn’ argument to on_mouse() 2021-07-01 17:15:52 +02:00
Daniel Eklöf
15ed0e043b
particle/string: don’t thrash the text-run cache
a5bbf0b769 introduced text-run
shaping.

Do avoid having to re-shape non-changing strings every time the bar is
refreshed, the *particle* (i.e. not the exposable) caches the last
shaped text-run.

Then, in expose(), it then assumes that that cached text-run is
the *same* text-run as returned from begin_expose().

This is true in most cases, but *not* when a single particle is
re-used to instantiate multiple exposables, as is commonly done by
modules generating dynlists. For example, the i3/sway module.

This fixes it, by making the cache growable, and by adding a “lock” to
each cache entry.

The lock is set in begin_expose(), to indicate that this particular
cache entry is needed in expose().

If we can’t find a matching cache entry, we first try to find a free
“slot” by searching for either unused, or used-but-not-locked cache
entries.

If that fails, we grow the cache and add a new entry.

In expose(), we unset the lock.

Closes #47
2021-05-25 21:36:14 +02:00
Daniel Eklöf
a5bbf0b769
particle/string: use fcft_text_run_rasterize() when available
This enables support for text shaping, and is required to render
e.g. 👩‍👩‍👧‍👧 correctly.

Since text-shaping is a fairly expensive operation, and since many
times the text is unchanged, we cache the last *rendered* string.

That is, we hash the instantiated string, and cache it along with the
text-run from fcft in the *particle* object (i.e. not the exposable).

This means two things:

* we only need to call fcft_text_run_rasterize() once per string
* if the string is the same as last time, we don’t have to call it at
  all.
2021-05-24 17:38:43 +02:00
Daniel Eklöf
f9dad99db8
particle/ramp: clamp min/max/value
Make sure that:

* min <= max
* min <= value <= max

Fixes a crash when the tag’s value was out-of-bounds.

Closes #45
2021-04-22 11:44:09 +02:00
Daniel Eklöf
321d1cdc7d
particle/progress-bar: handle tag_for_name() failing 2020-11-25 20:41:10 +01:00
Daniel Eklöf
31c015c680
particle/ramp: handle tag_for_name() failing 2020-11-25 20:41:10 +01:00
Daniel Eklöf
df2d8fec36
particle/list: assert sub particles where instantiated correctly 2020-11-25 20:41:09 +01:00
Daniel Eklöf
44db9304c5
particle/ramp: assert sub particles where instantiated correctly 2020-11-25 20:41:09 +01:00
Daniel Eklöf
c3cfae13e8
particle/progress-bar: assert sub particles where instantiated correctly 2020-11-25 20:41:09 +01:00
Daniel Eklöf
86ef9dcc02
particle/map: don’t return NULL from instantiate()
Instead return an empty dynlist.
2020-11-25 20:41:09 +01:00
Daniel Eklöf
198a351c7c
meson: particles: data-driven foreach loop, and link map against dynlist 2020-11-25 20:41:09 +01:00
Daniel Eklöf
1e5a1d0341
particle/map: return NULL if we neither find a matching tag, nor have a default tag 2020-11-25 20:36:46 +01:00
Daniel Eklöf
234a787859
fcft: fcft_glyph_for_wc() has been renamed to fcft_glyph_rasterize() 2020-04-24 10:54:15 +02:00
Daniel Eklöf
e5ef81a064
fcft: max/space advance fields have been renamed 2020-04-23 11:57:50 +02:00
Daniel Eklöf
03a5c8746f
fcft: adjust to fcft-2.0 API changes
* font_*() -> fcft_*()
* struct font -> struct fcft_font
* struct glyph -> struct fcft_glyph
* enum subpixel_order -> enum fcft_subpixel
2020-04-22 11:50:29 +02:00
Daniel Eklöf
8294eb5a80
fcft: update to 1.0.0
Allow/disallow subpixel antialiasing in font_glyph_for_wc(), not using
font_enable_subpixel_antialias().
2020-01-19 12:35:29 +01:00
Daniel Eklöf
b644c75586
particle/string: apply font kerning 2020-01-18 09:27:27 +01:00
Daniel Eklöf
8a4d9137ff
particle/string: remove useless debug log 2019-12-01 19:29:27 +01:00
Daniel Eklöf
51a6631c19
fcft: use fcft instead of local copy of font.{c,h} 2019-12-01 16:00:15 +01:00
Daniel Eklöf
2d343755ce
particle/string: mbstowcs() may fail. When it does, don't crash 2019-11-29 23:32:27 +01:00
Daniel Eklöf
b48365aa86
font: remove the fextents sub-struct 2019-11-27 21:38:49 +01:00
Daniel Eklöf
0550d2799d
tllist: use tllist from external git repository 2019-11-17 19:17:34 +01:00
Daniel Eklöf
9dbbc480e4
Rename project: f00bar -> yambar 2019-09-28 20:39:45 +02:00
Daniel Eklöf
012162837d
particle/progress-bar: expand and replace on-click handler on click events only
No need to do it in motion events.
2019-09-23 18:39:03 +02:00
Daniel Eklöf
6e50872933
particle/progress-bar: improve accuracy of 'where' tag
The progress-bar took *all* particle elements into account when
calculating the (relative) mouse position on mouse events.

This is wrong, since only the progress bar (that is, the empty and
filled cells) should be used. Not the start/end elements.

We now also pass the mouse event through to the start/end elements.
2019-09-23 18:34:43 +02:00
Daniel Eklöf
c11fee4ce3
cairo: replace cairo with pixman in decos, particles and modules
All decoration, particle and module interfaces now takes a
pixman_image_t parameter, and all drawing is done using pixman APIs.

The wayland/xcb backends implement a new interface functions,
get_pixman_image(), that should return a pixman image instance that is
suitable for rendering.

In the wayland backend, the image uses the same backing data as the
cairo surface.

In the XCB backend, we create a new image each time, and then blit it
to the cairo surface at commit time.
2019-09-22 01:56:58 +02:00
Daniel Eklöf
95385863ae
particle: remove cairo context from begin_expose() 2019-09-22 00:55:06 +02:00
Daniel Eklöf
b3a5e0b5d7
font: initial port from cairo scaled fonts to raw freetype + pixman 2019-09-22 00:50:11 +02:00
Daniel Eklöf
08e21a4d3b meson: assign get_option('core-plugins-as-shared-libraries') to variable 2019-05-06 21:49:20 +02:00