fix(w.w.template) fit and layout methods

The previous implementation for these methods was a naive attempt at
making the base widget working. We need to make sure computing the
widget's sizes is more robust for complex widget_template definition.
This commit is contained in:
Aire-One 2021-11-11 19:24:24 +01:00 committed by Emmanuel Lepage Vallee
parent 33d5de52c6
commit f12bb57c66
1 changed files with 16 additions and 2 deletions

View File

@ -21,8 +21,22 @@ local template = {
queued_updates = {},
}
function template:fit(...)
return self._private.widget:fit(...)
-- Layout this layout
function template:layout(_, width, height)
if not self._private.widget then
return
end
return { wbase.place_widget_at(self._private.widget, 0, 0, width, height) }
end
-- Fit this layout into the given area.
function template:fit(context, width, height)
if not self._private.widget then
return 0, 0
end
return wbase.fit_widget(self, context, self._private.widget, width, height)
end
function template:draw(...)