Revert change in :push(), remove :pos()
Revert signature if layout:push(x,y, padx,pady) to layout:push(x,y) Makes it possible to use the idiomatic layout:push(layout:row()) again. (layout:row() returns x,y, w,h of last cell) Remove layout:pos([x,y]) because it's not needed and potentially confusing.
This commit is contained in:
parent
86cae4c03b
commit
09a458386c
2 changed files with 5 additions and 27 deletions
|
@ -29,19 +29,6 @@ Get and set the current cell padding.
|
||||||
If given, sets the cell padding to ``pad_x`` and ``pad_y``.
|
If given, sets the cell padding to ``pad_x`` and ``pad_y``.
|
||||||
If only ``pad_x`` is given, set both padding in ``x`` and ``y`` direction to ``pad_x``.
|
If only ``pad_x`` is given, set both padding in ``x`` and ``y`` direction to ``pad_x``.
|
||||||
|
|
||||||
.. function:: pos([x, y])
|
|
||||||
|
|
||||||
:param x,y: New layout position (optional).
|
|
||||||
:returns: The current (or new) layout position.
|
|
||||||
|
|
||||||
Get and set the current layout position, that is, the upper left corner of the
|
|
||||||
*last* cell.
|
|
||||||
|
|
||||||
If given, sets the layout position to ``x,y``.
|
|
||||||
Can be helpful when you want to reset the layout origin without resetting the
|
|
||||||
cell size information.
|
|
||||||
Use with care: Invalidates size information of the whole layout (see below).
|
|
||||||
|
|
||||||
.. function:: size()
|
.. function:: size()
|
||||||
|
|
||||||
:returns: ``width,height`` - The size of the last cell.
|
:returns: ``width,height`` - The size of the last cell.
|
||||||
|
@ -62,17 +49,14 @@ Use for mixing precomputed and immediate mode layouts.
|
||||||
Get the position of the upper left corner of the next cell in a column layout.
|
Get the position of the upper left corner of the next cell in a column layout.
|
||||||
Use for mixing precomputed and immediate mode layouts.
|
Use for mixing precomputed and immediate mode layouts.
|
||||||
|
|
||||||
.. function:: push([x,y, [padx, [pady]]])
|
.. function:: push([x,y])
|
||||||
|
|
||||||
:param numbers x,y: Origin of the layout (optional).
|
:param numbers x,y: Origin of the layout (optional).
|
||||||
:param pad_x,pad_y: Cell padding (optional).
|
|
||||||
|
|
||||||
Saves the layout state (position, padding, sizes, etc.) on a stack, resets the
|
Saves the layout state (position, padding, sizes, etc.) on a stack, resets the
|
||||||
layout with position ``(x,y)`` and sets the cell padding to ``pad_x`` and
|
layout with position ``(x,y)``.
|
||||||
``pad_y``.
|
|
||||||
|
|
||||||
If ``x`` and ``y`` are omitted, they default to ``(0,0)``. If ``pad_x`` is
|
If ``x`` and ``y`` are omitted, they default to ``(0,0)``.
|
||||||
omitted, it defaults to 0. If ``pad_y`` is omitted, it defaults to ``pad_x``.
|
|
||||||
|
|
||||||
Used for nested row/column layouts.
|
Used for nested row/column layouts.
|
||||||
|
|
||||||
|
|
10
layout.lua
10
layout.lua
|
@ -26,13 +26,6 @@ function Layout:padding(padx,pady)
|
||||||
return self._padx, self._pady
|
return self._padx, self._pady
|
||||||
end
|
end
|
||||||
|
|
||||||
function Layout:pos(x,y)
|
|
||||||
if x and y then
|
|
||||||
self._x, self._y = x, y
|
|
||||||
end
|
|
||||||
return self._x, self._y
|
|
||||||
end
|
|
||||||
|
|
||||||
function Layout:size()
|
function Layout:size()
|
||||||
return self._w, self._h
|
return self._w, self._h
|
||||||
end
|
end
|
||||||
|
@ -164,7 +157,8 @@ local function layout_retained_mode(self, t, constructor, string_argument_to_tab
|
||||||
error("Invalid argument `padding' (table expected, got "..type(p)..")", 2)
|
error("Invalid argument `padding' (table expected, got "..type(p)..")", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:push(p[1] or 0, p[2] or 0, pad[1] or self._padx, pad[2] or self._pady)
|
self:push(p[1] or 0, p[2] or 0)
|
||||||
|
self:padding(pad[1] or self._padx, pad[2] or self._pady)
|
||||||
|
|
||||||
-- first pass: get dimensions, add layout info
|
-- first pass: get dimensions, add layout info
|
||||||
local layout = {n_fill_w = 0, n_fill_h = 0}
|
local layout = {n_fill_w = 0, n_fill_h = 0}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue