Commit Graph

22 Commits

Author SHA1 Message Date
patrick96 3f03b671bb fix(color): Rename type() function to get_type
In gcc5, this caused compilation errors because the type enum has the
same name.
2021-03-01 00:05:44 +01:00
Patrick Ziegler fd556525a8
New Tag Parser (#2303)
* refactor(color): Use enum class for color type

* Add testcases for tag parser

* Make tag parser a pull-style parser

Being able to parse single elements at a time gives us more fine-grained
error messages, we can also parse as much as possible and only stop
after an exception.

* fix(color): Parser did not check for invalid chars

* tag parser: First full implementation

* tag parser: Fix remaining failing tests

* tag parser: Replace old parser

* tag parser: Treat alignment as formatting tag

Makes the structure less complex and the alignment tags really are
formatting tags, they are structurally no different from the %{R} tag.

* tag parser: Cleanup type definitions

All type definitions for tags now live in tags/types.hpp, the parser.hpp
only contains the definitions necessary for actually calling the parser,
this shouldn't be included in many places (only places that actually do
parsing). But many places need the definitions for the tags themselves.

* Rename components/parser to tags/dispatch

* tag parser: Cleanup

* Add changelog
2020-12-17 20:37:28 +01:00
patrick96 e89da58940
fix(builder): Properly apply alpha for fg and bg
It was not quite clear how try_apply_alpha should behave if the given
color was not ALPHA_ONLY. The implementation just returned 'this'.
However, the build relied on it returning the given color.

This broke all bg and fg settings in the entire bar.

To clear this up, we switch this around take the alpha channel of 'this'
and also return 'this' if it isn't ALPHA_ONLY.

Fixes #2255
2020-12-01 14:53:41 +01:00
patrick96 53c6f3b042 refactor(color): Better channel function names
(alpha|red|green|blue)_(d|i) are used for the four channels using
doubles or integers, respectively.
2020-11-27 22:08:03 +01:00
patrick96 4dfbba11c4 Make rgba class immutable 2020-11-27 22:08:03 +01:00
patrick96 413c911cd1 Move apply_alpha functionality into rgba 2020-11-27 22:08:03 +01:00
patrick96 8e10c046fa Move all channel functions into rgba class
Since we use rgba everywhere, extracting channels from uint32_t directly
is not necessary anymore.
2020-11-27 22:08:03 +01:00
patrick96 64fa6469ab Remove unused hex function
This allows us to also remove the cache class which was only used here
2020-11-27 22:08:03 +01:00
patrick96 b238ec3403 Move most color_util functions into rgba class
The intent is for every color to be stored in a rgba instance

The rgba class now stores the color in a 32 bit integer to save space

This also removes the unused class rgb and moves everything else into a
cpp file.

Many functions also had weird template parameters. For example
alpha_channel<unsigned short int> would give a 2 byte number with the
alpha channel byte in both bytes.
color_util::hex would return a hex string with alpha channel if unsigned
short int was given and without if unsigned char was given. Even more
curiously those parameters were passed to *_channel and the result
nevertheless truncated to 8bits.
2020-11-27 22:08:03 +01:00
Michael Carlberg beedc5ab84 fix(color_util): Parsing 2017-01-27 13:46:27 +01:00
Michael Carlberg c74a1647ab fix(color_util): Add missing header 2017-01-24 12:37:19 +01:00
Michael Carlberg 6cc7a2c093 fix(color_util): Use lambda 2017-01-24 07:11:14 +01:00
Michael Carlberg 452afcdc68 refactor: Integral types 2017-01-24 07:11:14 +01:00
Michael Carlberg 5e1886a312 wip(refactor): Cairo drawing 2017-01-24 07:11:14 +01:00
Michael Carlberg 210695d377 refactor(x11): Merge xlib/xutils with connection 2016-12-31 10:02:32 +01:00
Michael Carlberg 18cf9df86c refactor: Cleanup 2016-12-27 04:58:41 +01:00
Michael Carlberg 84d58e7619 refactor: Cleanup handling of syntax tags 2016-11-25 04:34:24 +01:00
Michael Carlberg 25e33b6aab refactor: Separate render component 2016-11-21 16:16:02 +01:00
Michael Carlberg fd57ab0f3d fix: project rename 2016-11-19 06:26:07 +01:00
Michael Carlberg 869c5fe718 refactor: Code cleanup 2016-11-04 19:21:56 +01:00
Michael Carlberg e7cb345cec wip: Separate source from definitions 2016-11-03 12:54:32 +01:00
Michael Carlberg 26c308cc19 feat(color_util): Utility functions for color handling 2016-10-31 01:25:19 +01:00