-
Notifications
You must be signed in to change notification settings - Fork 597
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
Conversation
wibox.layout.grid
module and add border supports.wibox.layout.grid
module and add border support.
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
lib/wibox/layout/grid.lua
Outdated
if type(val) == "table" and (val.inner or val.outer) then | ||
self._private.border_color = { | ||
inner = gcolor(val.inner), | ||
outer = gcolor(val.outer), | ||
} |
There was a problem hiding this comment.
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?
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
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 usingwibox.container.margin
doesn't look right). The annoying solution is to actually implementborder_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.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 therow_count
andcolumn_count
properties, which is much more in line with other APIs.