Exemple #1
0
def _colgrid(windows, active_window, nrows, ncols):
    '''
    Grid layout, col-major.

    Parameters
    ----------
    windows : list
        A list of window objects.
    active_window : object
        The active window object.
    nrows:
        Number of rows.
    ncols:
        Number of cols.

    Returns
    -------
    None
        None.
    '''
    if len(windows) == 0:
        return

    if nrows * ncols < len(windows):
        logger.w('Warning: Not enough space. Windows may overlap.')

    workarea = get_workarea()
    width = workarea[2] // ncols
    height = workarea[3] // nrows
    x, y, w, h = 0, 0, width, height
    for i, window in enumerate(_order_windows(windows, active_window)):
        x, y = divmod(i % (nrows * ncols), nrows)
        x *= width
        y *= height
        _move_resize_window(window, x, y, w, h)
Exemple #2
0
def bmain(windows, active_window):
    '''
    Two-row layout, bottom row is main row.

    Parameters
    ----------
    windows : list
        A list of window objects.
    active_window : object
        The active window object.

    Returns
    -------
    None
        None.
    '''
    if len(windows) == 0:
        return

    # Process the active window.
    workarea = get_workarea()
    width = workarea[2]
    height = workarea[3] // 2
    _move_resize_window(active_window, 0, height, width, height)

    # Process the rest.
    if len(windows) > 1:
        x, y, w, h = 0, 0, width // (len(windows) - 1), height
        for i, window in enumerate(_order_windows(windows, active_window)):
            if i == len(windows) - 1:
                break
            _move_resize_window(window, x, y, w, h)
            x += w
Exemple #3
0
def rmain(windows, active_window):
    '''
    Two-col layout, right col is main col.

    Parameters
    ----------
    windows : list
        A list of window objects.
    active_window : object
        The active window object.

    Returns
    -------
    None
        None.
    '''
    if len(windows) == 0:
        return

    # Process the active window.
    workarea = get_workarea()
    width = workarea[2] // 2
    height = workarea[3]
    _move_resize_window(active_window, width, 0, width, height)

    # Process the rest.
    if len(windows) > 1:
        x, y, w, h = 0, 0, width, height // (len(windows) - 1)
        for i, window in enumerate(_order_windows(windows, active_window)):
            if i == len(windows) - 1:
                break
            _move_resize_window(window, x, y, w, h)
            y += h
Exemple #4
0
def vstack(windows, active_window):
    '''
    Stack windows vertically.

    Parameters
    ----------
    windows : list
        A list of window objects.
    active_window : object
        The active window object.

    Returns
    -------
    None
        None.
    '''
    if len(windows) == 0:
        return

    # Get work area.
    workarea = get_workarea()

    x = workarea[0]
    y = workarea[1]
    w = workarea[2]
    h = workarea[3] // len(windows)

    for window in _order_windows(windows, active_window):
        logger.d([window, x, y, w, h])
        _move_resize_window(window, x, y, w, h)
        y += h
Exemple #5
0
def cascade(windows, active_window):
    '''
    Cascade windows.

    Parameters
    ----------
    windows : list
        A list of window objects.
    active_window : object
        The active window object.

    Returns
    -------
    None
        None.
    '''
    if len(windows) == 0:
        return

    # Get work area.
    workarea = get_workarea()

    ngrid = 16  # Magic: Number of grids on each axis.
    nwin = 10  # Magic: Number of grids a window occupies on each axis.

    xstep, ystep = workarea[2] // ngrid, workarea[3] // ngrid

    x, y, w, h = xstep, ystep, nwin * xstep, nwin * ystep
    for window in _order_windows(windows, active_window):
        logger.d([window, x, y, w, h])
        _move_resize_window(window, x, y, w, h)
        set_active_window(window)
        if len(windows) == 1:
            break
        x += (ngrid - 2 - nwin) * xstep // (len(windows) - 1)
        y += (ngrid - 2 - nwin) * ystep // (len(windows) - 1)