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:
parent
33d5de52c6
commit
f12bb57c66
|
@ -21,8 +21,22 @@ local template = {
|
||||||
queued_updates = {},
|
queued_updates = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
function template:fit(...)
|
-- Layout this layout
|
||||||
return self._private.widget:fit(...)
|
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
|
end
|
||||||
|
|
||||||
function template:draw(...)
|
function template:draw(...)
|
||||||
|
|
Loading…
Reference in New Issue