Skip to content

Commit a363004

Browse files
author
pinnacle-comp
committed
1 parent 7ad616a commit a363004

5 files changed

Lines changed: 99 additions & 8 deletions

main/classes/pinnacle.layout.LayoutNode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ The gaps the node applies around its children nodes.
4545

4646
The proportion the node takes up relative to its siblings.
4747

48-
### children
48+
### children <Badge type="danger" text="nullable" />
4949

50-
`children`: <code><a href="/lua-reference/main/classes/pinnacle.layout.LayoutNode">pinnacle.layout.LayoutNode</a>[]</code>
50+
`children?`: <code><a href="/lua-reference/main/classes/pinnacle.layout.LayoutNode">pinnacle.layout.LayoutNode</a>[]</code>
5151

5252
Child layout nodes.
5353

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
outline: [2, 3]
3+
---
4+
5+
# Class `pinnacle.layout.LayoutResponse`
6+
7+
8+
A response to a layout request.
9+
10+
## Fields
11+
12+
### root_node
13+
14+
`root_node`: <code><a href="/lua-reference/main/classes/pinnacle.layout.LayoutNode">pinnacle.layout.LayoutNode</a></code>
15+
16+
The root node of the layout tree.
17+
18+
### tree_id
19+
20+
`tree_id`: <code>integer</code>
21+
22+
A non-negative identifier.
23+
24+
Trees that are considered "the same", like trees for a certain tag and layout,
25+
should have the same identifier to allow Pinnacle to remember tile sizing.
26+
27+

main/classes/pinnacle.layout.builtin.Cycle.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,21 @@ Gets the current layout generator for the given tag.
8484

8585

8686

87+
88+
### <Badge type="method" text="method" /> current_tree_id
89+
90+
<div class="language-lua"><pre><code>function pinnacle.layout.builtin.Cycle:current_tree_id()
91+
-> integer</code></pre></div>
92+
93+
Gets a (most-likely) unique identifier for the current layout tree.
94+
This is guaranteed to be greater than zero.
95+
96+
97+
98+
99+
#### Returns
100+
101+
1. <code>integer</code>
102+
103+
104+

main/classes/pinnacle.layout.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,45 @@ Builtin layout generators.
2323

2424
### <Badge type="function" text="function" /> manage
2525

26-
<div class="language-lua"><pre><code>function pinnacle.layout.manage(on_layout: fun(args: <a href="/lua-reference/main/classes/pinnacle.layout.LayoutArgs">pinnacle.layout.LayoutArgs</a>): <a href="/lua-reference/main/classes/pinnacle.layout.LayoutNode">pinnacle.layout.LayoutNode</a>)
26+
<div class="language-lua"><pre><code>function pinnacle.layout.manage(on_layout: fun(args: <a href="/lua-reference/main/classes/pinnacle.layout.LayoutArgs">pinnacle.layout.LayoutArgs</a>): <a href="/lua-reference/main/classes/pinnacle.layout.LayoutResponse">pinnacle.layout.LayoutResponse</a>)
2727
-> <a href="/lua-reference/main/classes/pinnacle.layout.LayoutRequester">pinnacle.layout.LayoutRequester</a></code></pre></div>
2828

2929
Begins managing layout requests from the compositor.
3030

31-
You must call this function to get windows to lay out.
31+
You must call this function to get windows to tile.
3232
The provided function will be run with the arguments of the layout request.
33-
It must return a `LayoutNode` that represents the root of a layout tree.
33+
It must return a `LayoutResponse` containing a `LayoutNode` that represents
34+
the root of a layout tree, along with an identifier.
3435

3536
#### Example
3637

3738
```lua
3839
local layout_requester = Layout.manage(function(args)
3940
local first_tag = args.tags[1]
4041
if not first_tag then
42+
---@type pinnacle.layout.LayoutResponse
4143
return {
42-
children = {},
44+
root_node = {},
45+
tree_id = 0,
4346
}
4447
end
4548
layout_cycler.current_tag = first_tag
46-
return layout_cycler:layout(args.window_count)
49+
local root_node = layout_cycler:layout(args.window_count)
50+
local tree_id = layout_cycler:current_tree_id()
51+
52+
---@type pinnacle.layout.LayoutResponse
53+
return {
54+
root_node = root_node,
55+
tree_id = tree_id,
56+
}
4757
end)
4858
```
4959

5060

5161

5262
#### Parameters
5363

54-
`on_layout`: <code>fun(args: <a href="/lua-reference/main/classes/pinnacle.layout.LayoutArgs">pinnacle.layout.LayoutArgs</a>): <a href="/lua-reference/main/classes/pinnacle.layout.LayoutNode">pinnacle.layout.LayoutNode</a></code> - A function that receives layout arguments and builds and returns a layout tree.
64+
`on_layout`: <code>fun(args: <a href="/lua-reference/main/classes/pinnacle.layout.LayoutArgs">pinnacle.layout.LayoutArgs</a>): <a href="/lua-reference/main/classes/pinnacle.layout.LayoutResponse">pinnacle.layout.LayoutResponse</a></code> - A function that receives layout arguments and builds and returns a layout response.
5565

5666

5767

main/classes/pinnacle.window.WindowHandle.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,42 @@ end
7676

7777

7878

79+
### <Badge type="method" text="method" /> resize_tile
80+
81+
<div class="language-lua"><pre><code>function pinnacle.window.WindowHandle:resize_tile(dimensions: { left?: integer, right?: integer, top?: integer, bottom?: integer })</code></pre></div>
82+
83+
If this window is tiled, resizes its tile by shifting the left, right,
84+
top, and bottom edges by the provided pixel amounts.
85+
86+
Positive amounts shift edges right/down, while negative amounts
87+
shift edges left/up.
88+
89+
If this resizes the tile in a direction that it can no longer resize
90+
towards (e.g. it's at the edge of the screen), it will resize in the opposite
91+
direction.
92+
93+
#### Example
94+
```lua
95+
-- Grow the focused tiled window 10 pixels leftward
96+
Window.get_focused():resize_tile({ left = -10 })
97+
98+
-- Shrink the focused tiled window 10 pixels inward from the right
99+
Window.get_focused():resize_tile({ right = -10 })
100+
101+
-- Grow the focused tiled window 20 pixels centered vertically
102+
Window.get_focused():resize_tile({ top = -10, bottom = 10 })
103+
```
104+
105+
106+
#### Parameters
107+
108+
`dimensions`: <code>{ left?: integer, right?: integer, top?: integer, bottom?: integer }</code>
109+
110+
111+
112+
113+
114+
79115
### <Badge type="method" text="method" /> set_fullscreen
80116

81117
<div class="language-lua"><pre><code>function pinnacle.window.WindowHandle:set_fullscreen(fullscreen: boolean)</code></pre></div>

0 commit comments

Comments
 (0)