-
Notifications
You must be signed in to change notification settings - Fork 598
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
wibox.layout.manual:insert()
implementation
#2557
wibox.layout.manual:insert()
implementation
#2557
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2557 +/- ##
==========================================
- Coverage 84.58% 84.54% -0.04%
==========================================
Files 497 497
Lines 33720 33641 -79
==========================================
- Hits 28521 28442 -79
Misses 5199 5199
|
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.
Another way would have been manual_layout.insert = manual_layout.add
, but both are ok. Thanks for fixing that.
@Elv13 i see the implementation of those 2 methods is slightly different so i have to clarify, what is the difference in expected result of both? |
A right nevermind, that would be |
sorry, i still didn't got it clearly |
In the end there is little difference. |
i still can't understand if it makes sense to just use the same implementation instead of copying the code or those differences are intended? |
@Aire-One version is better as it produces the correct |
Sorry, I'm a little late in the discussion, I was studying for an exam... I'm glad you approved my code. However I have to disagree with these statements:
While the order does theoretically not have an impact, I found out it has. It changes the drawing order of the widgets. When some children of a manual layout overlaps each other, the order will change the one that is drawn on top of the others. Here is a short test code I wrote to run within require('rc')
local awful = require('awful')
local beautiful = require('beautiful')
local gears = require('gears')
local wibox = require('wibox')
local w_background = wibox.widget {
widget = wibox.widget.imagebox,
resize = true,
image = beautiful.awesome_icon,
forced_height = 16,
forced_width = 16,
point = awful.placement.centered
}
local w_icon = wibox.widget {
layout = wibox.container.background,
wibox.widget.base.empty_widget(),
bg = '#eeeeee',na
shape = gears.shape.rounded_bar,
forced_height = 16,
point = awful.placement.maximize_horizontally + awful.placement.bottom
}
local w1 = wibox.widget {
layout = wibox.layout.manual,
w_background,
w_icon
}
local w2 = wibox.widget {
layout = wibox.layout.manual,
w_icon,
w_background
}
awful.screen.w = wibox {
type = 'dock', ontop = true,
visible = true, opacity = 1,
width = 200, height = 30
}
awful.screen.w:setup {
layout = wibox.layout.flex.horizontal,
w1,
w2
} And here is a preview of the result: So, order do have an impact on the visual aspect of the layout. That's why the implementation of
But it still misses something because you can't access inserted children by their ids. Here is an example of what I mean: local my_manual_layout = wibox.widget {
layout = wibox.layout.manual,
{ id = 'w_role', ... }
}
my_manual_layout:insert(1, wibox.widget { id = 'insert_role', ...})
my_manual_layout.w_role -- this works
my_manual_layout.new_role -- this fails I suspect it have something to do with #2181 but I'm not sure on how it actually works... |
It has indeed
It does not ;). The original "scope" of |
It was documented but not implemented. It is necessary when the "Z index" needs to be manually specified.
443764c
to
a2a8649
Compare
Thanks (the force push was to set a commit message instead of "try 1") |
It was documented but not implemented. It is necessary when the "Z index" needs to be manually specified.
It was documented but not implemented. It is necessary when the "Z index" needs to be manually specified.
Following my issue #2556, here is my implementation try :)
Some notes:
manual_layout._private.widgets
andmanual_layout._private.pos
are arrays so elements can be "magically" shifted/organized ;table.insert
because it shifts up the elements, so it will keep the widgets ordered (https://www.lua.org/manual/5.3/manual.html#pdf-table.insert) ;