place: Split internal logic to be reusable.
This will become the base class of a new "tile" container. I also fixed a bug which could cause the output to be blurry for some widget sizes.
This commit is contained in:
parent
6a4e555ae1
commit
78b8756068
|
@ -23,13 +23,8 @@ local align_fct = {
|
||||||
}
|
}
|
||||||
align_fct.top, align_fct.bottom = align_fct.left, align_fct.right
|
align_fct.top, align_fct.bottom = align_fct.left, align_fct.right
|
||||||
|
|
||||||
-- Layout this layout
|
-- Shared with some subclasses like the `tiled` and `scaled` modules.
|
||||||
function place:layout(context, width, height)
|
function place:_layout(context, width, height)
|
||||||
|
|
||||||
if not self._private.widget then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local w, h = base.fit_widget(self, context, self._private.widget, width, height)
|
local w, h = base.fit_widget(self, context, self._private.widget, width, height)
|
||||||
|
|
||||||
if self._private.content_fill_horizontal then
|
if self._private.content_fill_horizontal then
|
||||||
|
@ -45,6 +40,21 @@ function place:layout(context, width, height)
|
||||||
|
|
||||||
local x, y = align_fct[halign](w, width), align_fct[valign](h, height)
|
local x, y = align_fct[halign](w, width), align_fct[valign](h, height)
|
||||||
|
|
||||||
|
-- Sub pixels makes everything blurry. This is now what people expect.
|
||||||
|
x, y = math.floor(x), math.floor(y)
|
||||||
|
|
||||||
|
return x, y, w, h
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Layout this layout
|
||||||
|
function place:layout(context, width, height)
|
||||||
|
|
||||||
|
if not self._private.widget then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local x, y, w, h = self:_layout(context, width, height)
|
||||||
|
|
||||||
return { base.place_widget_at(self._private.widget, x, y, w, h) }
|
return { base.place_widget_at(self._private.widget, x, y, w, h) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue