Layout Calculations (layout.py
)¶
Layout calculation code
-
class
GravityLayout
(margin_x=0, margin_y=0)[source]¶ Helper for translating top-left relative dimensions to other corners.
Used to generate
quicktile.commands.cycle_dimensions()
presets.Expects to operate on decimal percentage values. (0 ≤ x ≤ 1)
- Parameters
-
GRAVITIES
: Dict[str, Gravity] = {'bottom': <Gravity.BOTTOM: (0.5, 1.0)>, 'bottom-left': <Gravity.BOTTOM_LEFT: (0.0, 1.0)>, 'bottom-right': <Gravity.BOTTOM_RIGHT: (1.0, 1.0)>, 'center': <Gravity.CENTER: (0.5, 0.5)>, 'left': <Gravity.LEFT: (0.0, 0.5)>, 'right': <Gravity.RIGHT: (1.0, 0.5)>, 'top': <Gravity.TOP: (0.5, 0.0)>, 'top-left': <Gravity.TOP_LEFT: (0.0, 0.0)>, 'top-right': <Gravity.TOP_RIGHT: (1.0, 0.0)>}¶ A mapping of possible window alignments relative to the monitor/desktop as a mapping from formerly manually specified command names to values the
quicktile.util.Gravity
enum can take on.
-
__call__
(width, height, gravity='top-left', x=None, y=None)[source]¶ Return a relative
(x, y, w, h)
tuple relative togravity
.This function takes and returns percentages, represented as decimals in the range
0 ≤ x ≤ 1
, which can be multiplied by width and height values in actual units to produce actual window geometry.It can be used in two ways:
1. If called without
x
andy
values, it will compute a geometry tuple which will align a windoww
wide andh
tall according togeometry
.2. If called with
x
andy
values, it will translate a geometry tuple which is relative to the top-left corner so that it is instead relative to another corner.- Parameters
- Return type
- Returns
(x, y, w, h)
with all values represented as decimal-form percentages.
-
check_tolerance
(distance, monitor_geom, tolerance=0.1)[source]¶ - Check whether a distance is within a tolerance value calculated as a
percentage of a monitor’s size.
- Parameters
Note
This is not currently in use but is retained for when future plans make it necessary to design reliable “invalidate cached data if the window was repositioned/resized without QuickTile” code.
- Return type
-
make_winsplit_positions
(columns)[source]¶ Generate the classic WinSplit Revolution tiling presets
- Params columns
The number of columns that each tiling preset should be built around.
- Return type
- Returns
A dict of presets ready to feed into
quicktile.commands.CommandRegistry.add_many()
.
See ColumnCount in the configuration section of the manual for further details.
- Parameters
columns (
int
) –
-
resolve_fractional_geom
(fract_geom, monitor_rect)[source]¶ Resolve proportional (eg.
0.5
) and preserved (None
) coordinates.- Parameters
fract_geom (
Tuple
[float
,float
,float
,float
]) – An(x, y, w, h)
tuple containing monitor-relative values in the range from 0.0 to 1.0, inclusive, or aquicktile.util.Rectangle
which will be passed through without modification.monitor_rect (
Rectangle
) – Aquicktile.util.Rectangle
defining the bounding box of the monitor (or other desired region) within the desktop.
- Return type
- Returns
A rectangle with absolute coordinates derived from
monitor_rect
.