tuikit/layouts/offset.py
author Radek Brich <radek.brich@devl.cz>
Sun, 15 Feb 2015 12:52:46 +0100
changeset 115 b4ff7392003a
parent 114 26c02bd94bd9
child 117 8680c2333546
permissions -rw-r--r--
GridLayout: basic implementation.

from .layout import Layout
from tuikit.core.coords import Point


class OffsetLayout(Layout):

    """Offsets widget position. Used by Viewport and ScrollView."""

    def __init__(self):
        Layout.__init__(self)
        self._offset = Point()

    @property
    def offset(self):
        """Offset of child widgets."""
        return self._offset

    def update(self, _w, _h):
        for widget in self._managed_widgets:
            widget.resize(*widget.sizereq)
            widget.pos.update(*(widget.posreq + self.offset))