Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize the wibox.layout.grid module and add border support. #3746

Merged
merged 6 commits into from
Mar 24, 2024

Conversation

Elv13
Copy link
Member

@Elv13 Elv13 commented Dec 5, 2022

This is part of a larger branch I have been working on over the last month to implement widget_template everywhere. When it came to the calendar, it has its own "fn_embed" API to implement "templates". I try to prevent regressions when deprecating things. In that case, it is very hard to implement a 1 pixel border using the template (0.5px using wibox.container.margin doesn't look right). The annoying solution is to actually implement border_width in the grid. I gave up on it 5 years ago, but now I rewritten my previous attempt in a much saner way. Rather than try to draw the border, it clip areas where there should be no border and bucket-fill the remaining content.

image

Obviously, table borders are always rather nasty code. This is no exception. There was already a very large number of math code in the grid, now there is more. However, after fighting the corner case, I think it work reasonably well now. Beside the calendar, I can see a lot of place where this code can be useful. A lot of code examples use their own half baked "tables" using the margin container. They are almost never aligned property. Now there is a "correct" way to fix this. This PR doesn't do it. It's large enough already.

The PR also rename a bunch of properties which used abbreviations. It also convert local v, h = w:get_dimentsions() to the row_count and column_count properties, which is much more in line with other APIs.

@Elv13 Elv13 changed the title Modernize the wibox.layout.grid module and add border supports. Modernize the wibox.layout.grid module and add border support. Dec 5, 2022
@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

Attention: 26 lines in your changes are missing coverage. Please review.

Comparison is base (cb72c0a) 91.01% compared to head (eddb83f) 91.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3746      +/-   ##
==========================================
+ Coverage   91.01%   91.05%   +0.04%     
==========================================
  Files         901      909       +8     
  Lines       57566    58202     +636     
==========================================
+ Hits        52392    52998     +606     
- Misses       5174     5204      +30     
Flag Coverage Δ
gcov 91.05% <96.75%> (+0.04%) ⬆️
luacov 93.74% <96.75%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
tests/examples/awful/popup/alttab.lua 100.00% <100.00%> (ø)
tests/examples/awful/popup/wiboxtypes.lua 100.00% <100.00%> (ø)
tests/examples/awful/screenshot/popup.lua 100.00% <100.00%> (ø)
tests/examples/awful/widget/layoutlist/bar.lua 100.00% <100.00%> (ø)
tests/examples/awful/widget/layoutlist/popup.lua 96.55% <100.00%> (ø)
...sts/examples/sequences/client/tasklist_layout1.lua 96.92% <100.00%> (ø)
tests/examples/wibox/layout/defaults/grid.lua 100.00% <100.00%> (ø)
tests/examples/wibox/layout/grid/add.lua 100.00% <100.00%> (ø)
.../examples/wibox/layout/grid/add_column_border1.lua 100.00% <100.00%> (ø)
...sts/examples/wibox/layout/grid/add_row_border1.lua 100.00% <100.00%> (ø)
... and 20 more

... and 2 files with indirect coverage changes

lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
tests/examples/wibox/layout/grid/orientation.lua Outdated Show resolved Hide resolved
lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
Comment on lines 983 to 994
if type(val) == "table" and (val.inner or val.outer) then
self._private.border_color = {
inner = gcolor(val.inner),
outer = gcolor(val.outer),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the use calls the set_border_color method with only one component in the table, the other has to be reset-ed?

lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
lib/wibox/layout/grid.lua Outdated Show resolved Hide resolved
tests/examples/wibox/layout/grid/add_row_border1.lua Outdated Show resolved Hide resolved
Looks like a rebase leftover from an earlier iteration of the code.
This is already used in the `wibox.layout.manual` layout. It makes
the widget easier to use. Previously, using the imperative syntax
was necessary for most grids.
This is long overdue. A bit of historical context. The grid API
is losely somewhat based on the old `radical` module, but was
heavily improved by @getzze. That version had row_span and col_span.

This made the way the previous implementation coded the border
incompatible. I spent some time back then trying to bolt it back on,
but the complexity is quite high and never made it work right.

This commit goes in another direction. Rather than draw the border,
it creates a mask where the border should *not* be, then bucket fill
the widget. This is the equivalent of CSS `border-collapse`.

It also support custom borders. This allows dashed lines and partial
borders.

The main use case will be to add border support to the calendar. It
was previously possible to partially do it using custom cell painters,
but was pretty hacky. Now that the calendar will deprecate the custom
painters in favor of `widget_template`s, a more robust alternative was
required.

The drawback of this commit is obviously the added complexity to the
most complex layout. This is why it adds many tests to cover the various
corner cases.
* Stop using top level properties for vertical/horizontal
* No abbreviations
* Use height/width instead of size
* Don't use methods where properties can be used
@Elv13 Elv13 merged commit 8b1f895 into awesomeWM:master Mar 24, 2024
11 checks passed
@Elv13 Elv13 deleted the grid_border branch March 24, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants