Merge pull request #46 from Alloyed/fix-up-left-cells
Fix up/left() cells
This commit is contained in:
commit
3899e6435f
2 changed files with 66 additions and 13 deletions
|
@ -67,6 +67,8 @@ according to the size of the popped layout.
|
|||
|
||||
Used for nested row/column layouts.
|
||||
|
||||
.. _layout-row:
|
||||
|
||||
.. function:: row(w,h)
|
||||
|
||||
:param mixed w,h: Cell width and height (optional).
|
||||
|
@ -91,14 +93,20 @@ Used to provide the last four arguments to a widget, e.g.::
|
|||
suit.Button("Options", suit.layout:row())
|
||||
suit.Button("Quit", suit.layout:row(nil, "median"))
|
||||
|
||||
.. function:: down(w,h)
|
||||
|
||||
An alias for :ref:`layout:row() <layout-row>`.
|
||||
|
||||
.. _layout-col:
|
||||
|
||||
.. function:: col(w,h)
|
||||
|
||||
:param mixed w,h: Cell width and height (optional).
|
||||
:returns: Position and size of the cell: ``x,y,w,h``.
|
||||
|
||||
Creates a new cell right to the current cell with width ``w`` and height ``h``.
|
||||
If either ``w`` or ``h`` is omitted, the value is set the last used value. Both
|
||||
``w`` and ``h`` can be a string, which takes the following meaning:
|
||||
Creates a new cell to the right of the current cell with width ``w`` and height
|
||||
``h``. If either ``w`` or ``h`` is omitted, the value is set the last used
|
||||
value. Both ``w`` and ``h`` can be a string, which takes the following meaning:
|
||||
|
||||
``max``
|
||||
Maximum of all values since the last reset.
|
||||
|
@ -114,6 +122,59 @@ Used to provide the last four arguments to a widget, e.g.::
|
|||
suit.Button("OK", suit.layout:col(100,30))
|
||||
suit.Button("Cancel", suit.layout:col("max"))
|
||||
|
||||
.. function:: right(w,h)
|
||||
|
||||
An alias for :ref:`layout:col() <layout-col>`.
|
||||
|
||||
.. function:: up(w,h)
|
||||
|
||||
:param mixed w,h: Cell width and height (optional).
|
||||
:returns: Position and size of the cell: ``x,y,w,h``.
|
||||
|
||||
Creates a new cell above the current cell with width ``w`` and height ``h``. If
|
||||
either ``w`` or ``h`` is omitted, the value is set the last used value. Both
|
||||
``w`` and ``h`` can be a string, which takes the following meaning:
|
||||
|
||||
``max``
|
||||
Maximum of all values since the last reset.
|
||||
|
||||
``min``
|
||||
Mimimum of all values since the last reset.
|
||||
|
||||
``median``
|
||||
Median of all values since the last reset.
|
||||
|
||||
Be careful when mixing ``up()`` and :ref:`layout:row() <layout-row>`, as suit
|
||||
does no checking to make sure cells don't overlap. e.g.::
|
||||
|
||||
suit.Button("A", suit.layout:row(100,30))
|
||||
suit.Button("B", suit.layout:row())
|
||||
suit.Button("Also A", suit.layout:up())
|
||||
|
||||
.. function:: left(w,h)
|
||||
|
||||
:param mixed w,h: Cell width and height (optional).
|
||||
:returns: Position and size of the cell: ``x,y,w,h``.
|
||||
|
||||
Creates a new cell to the left of the current cell with width ``w`` and height
|
||||
``h``. If either ``w`` or ``h`` is omitted, the value is set the last used
|
||||
value. Both ``w`` and ``h`` can be a string, which takes the following meaning:
|
||||
|
||||
``max``
|
||||
Maximum of all values since the last reset.
|
||||
|
||||
``min``
|
||||
Mimimum of all values since the last reset.
|
||||
|
||||
``median``
|
||||
Median of all values since the last reset.
|
||||
|
||||
Be careful when mixing ``left()`` and :ref:`layout:col() <layout-col>`, as suit
|
||||
does no checking to make sure cells don't overlap. e.g.::
|
||||
|
||||
suit.Button("A", suit.layout:col(100,30))
|
||||
suit.Button("B", suit.layout:col())
|
||||
suit.Button("Also A", suit.layout:left())
|
||||
|
||||
Precomputed Layouts
|
||||
-------------------
|
||||
|
|
12
layout.lua
12
layout.lua
|
@ -37,20 +37,12 @@ end
|
|||
|
||||
Layout.nextDown = Layout.nextRow
|
||||
|
||||
function Layout:nextUp()
|
||||
return self._x, self._y - self._h - self._pady
|
||||
end
|
||||
|
||||
function Layout:nextCol()
|
||||
return self._x + self._w + self._padx, self._y
|
||||
end
|
||||
|
||||
Layout.nextRight = Layout.nextCol
|
||||
|
||||
function Layout:nextLeft()
|
||||
return self._x - self._w - self._padx, self._y
|
||||
end
|
||||
|
||||
function Layout:push(x,y)
|
||||
self._stack[#self._stack+1] = {
|
||||
self._x, self._y,
|
||||
|
@ -152,7 +144,7 @@ Layout.down = Layout.row
|
|||
|
||||
function Layout:up(w, h)
|
||||
w,h = calc_width_height(self, w, h)
|
||||
local x,y = self._x, self._y - (self._h or 0)
|
||||
local x,y = self._x, self._y - (self._h and h or 0)
|
||||
|
||||
if not self._isFirstCell then
|
||||
y = y - self._pady
|
||||
|
@ -184,7 +176,7 @@ Layout.right = Layout.col
|
|||
function Layout:left(w, h)
|
||||
w,h = calc_width_height(self, w, h)
|
||||
|
||||
local x,y = self._x - (self._w or 0), self._y
|
||||
local x,y = self._x - (self._w and w or 0), self._y
|
||||
|
||||
if not self._isFirstCell then
|
||||
x = x - self._padx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue