wibox.layout.align: Correctly size second widget
In expand nodes "none" and "outside", the variable size_remains describes how much space is available for the first/third widget. Everything else is used by the second widget. Thus, fitting the second widget to anything involving size_remains is wrong. Instead, this commit uses the correct value. This also fixes a messed up argument order for horizontal align layouts. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
769d6acb64
commit
3fbd16d9a3
|
@ -31,6 +31,9 @@ function align:draw(context, cr, width, height)
|
|||
local size_first = 0
|
||||
-- start with all the space given by the parent, subtract as we go along
|
||||
local size_remains = self.dir == "y" and height or width
|
||||
-- This is only set & used if expand ~= "inside" and we have second width.
|
||||
-- It contains the size allocated to the second widget.
|
||||
local size_second
|
||||
|
||||
-- we will prioritize the middle widget unless the expand mode is "inside"
|
||||
-- if it is, we prioritize the first widget by not doing this block also,
|
||||
|
@ -38,7 +41,7 @@ function align:draw(context, cr, width, height)
|
|||
-- instead
|
||||
if self._expand ~= "inside" and self.second then
|
||||
local w, h = base.fit_widget(context, self.second, width, height)
|
||||
local size_second = self.dir == "y" and h or w
|
||||
size_second = self.dir == "y" and h or w
|
||||
-- if all the space is taken, skip the rest, and draw just the middle
|
||||
-- widget
|
||||
if size_second >= size_remains then
|
||||
|
@ -123,10 +126,10 @@ function align:draw(context, cr, width, height)
|
|||
end
|
||||
else
|
||||
if self.dir == "y" then
|
||||
_, h = base.fit_widget(context, self.second, width, size_remains)
|
||||
_, h = base.fit_widget(context, self.second, width, size_second)
|
||||
y = floor( (height - h)/2 )
|
||||
else
|
||||
w, _ = base.fit_widget(context, self.second, width, size_remains)
|
||||
w, _ = base.fit_widget(context, self.second, size_second, height)
|
||||
x = floor( (width -w)/2 )
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue