Beispiel #1
0
    def __init__(self, workspace):
        Layout.__init__(self, workspace)

        self.maxmasters = 1

        self.root = TileRoot()
        self.root.add_child(TileVerticalBox(self.root))
        self.master = TileHorizontalBox(self.root.child)
        self.slave = TileHorizontalBox(self.root.child)

        self.proportions = (0.5, 0.5)
Beispiel #2
0
class HorizontalLayout(DirectionLayout):
    def __init__(self, workspace):
        Layout.__init__(self, workspace)

        self.maxmasters = 1

        self.root = TileRoot()
        self.root.add_child(TileVerticalBox(self.root))
        self.master = TileHorizontalBox(self.root.child)
        self.slave = TileHorizontalBox(self.root.child)

        self.proportions = (0.5, 0.5)

    def _section_split(self, section, i, client, append=False):
        assert section in (self.master, self.slave)

        section.children[i].split('horizontal', client, append=append)

    def master_size_increase(self):
        if self._masters() and self._slaves():
            self.root.child.proportion_direction('down', self.master, 0.02)
            self.place()
        
    def master_size_decrease(self):
        if self._masters() and self._slaves():
            self.root.child.proportion_direction('up', self.slave, 0.02)
            self.place()

    def _get_direction(self, action):
        assert action in ('previous', 'next')

        def opposite_for_prev(direction):
            if action == 'previous' and direction in ('left', 'right'):
                return { 'left': 'right', 'right': 'left' }[direction]
            return direction

        leaf = self._get_focused_leaf()
        tofocus = None

        if leaf.parent is self.master:
            tofocus = leaf.leaf_direction(opposite_for_prev('left'), 
                                          shallow=True)
            if tofocus is None and self._slaves():
                first_or_last = 0 if action is 'next' else -1
                tofocus = self.slave.children[first_or_last]
        else:
            tofocus = leaf.leaf_direction(opposite_for_prev('right'), 
                                          shallow=True)
            if tofocus is None and self._masters():
                first_or_last = -1 if action is 'next' else 0
                tofocus = self.master.children[first_or_last]

        return tofocus
Beispiel #3
0
class HorizontalLayout(DirectionLayout):
    def __init__(self, workspace):
        Layout.__init__(self, workspace)

        self.maxmasters = 1

        self.root = TileRoot()
        self.root.add_child(TileVerticalBox(self.root))
        self.master = TileHorizontalBox(self.root.child)
        self.slave = TileHorizontalBox(self.root.child)

        self.proportions = (0.5, 0.5)

    def _section_split(self, section, i, client, append=False):
        assert section in (self.master, self.slave)

        section.children[i].split('horizontal', client, append=append)

    def master_size_increase(self):
        if self._masters() and self._slaves():
            self.root.child.proportion_direction('down', self.master, 0.02)
            self.place()

    def master_size_decrease(self):
        if self._masters() and self._slaves():
            self.root.child.proportion_direction('up', self.slave, 0.02)
            self.place()

    def _get_direction(self, action):
        assert action in ('previous', 'next')

        def opposite_for_prev(direction):
            if action == 'previous' and direction in ('left', 'right'):
                return {'left': 'right', 'right': 'left'}[direction]
            return direction

        leaf = self._get_focused_leaf()
        tofocus = None

        if leaf.parent is self.master:
            tofocus = leaf.leaf_direction(opposite_for_prev('left'),
                                          shallow=True)
            if tofocus is None and self._slaves():
                first_or_last = 0 if action is 'next' else -1
                tofocus = self.slave.children[first_or_last]
        else:
            tofocus = leaf.leaf_direction(opposite_for_prev('right'),
                                          shallow=True)
            if tofocus is None and self._masters():
                first_or_last = -1 if action is 'next' else 0
                tofocus = self.master.children[first_or_last]

        return tofocus
Beispiel #4
0
    def __init__(self, workspace):
        Layout.__init__(self, workspace)

        self.maxmasters = 1

        self.root = TileRoot()
        self.root.add_child(TileVerticalBox(self.root))
        self.master = TileHorizontalBox(self.root.child)
        self.slave = TileHorizontalBox(self.root.child)

        self.proportions = (0.5, 0.5)