UNPKG

8.33 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { PanelLayout } from './panellayout';
3import { Widget } from './widget';
4/**
5 * A layout which arranges its widgets into resizable sections.
6 */
7export declare class SplitLayout extends PanelLayout {
8 /**
9 * Construct a new split layout.
10 *
11 * @param options - The options for initializing the layout.
12 */
13 constructor(options: SplitLayout.IOptions);
14 /**
15 * Dispose of the resources held by the layout.
16 */
17 dispose(): void;
18 /**
19 * The renderer used by the split layout.
20 */
21 readonly renderer: SplitLayout.IRenderer;
22 /**
23 * Get the layout orientation for the split layout.
24 */
25 /**
26 * Set the layout orientation for the split layout.
27 */
28 orientation: SplitLayout.Orientation;
29 /**
30 * Get the content alignment for the split layout.
31 *
32 * #### Notes
33 * This is the alignment of the widgets in the layout direction.
34 *
35 * The alignment has no effect if the widgets can expand to fill the
36 * entire split layout.
37 */
38 /**
39 * Set the content alignment for the split layout.
40 *
41 * #### Notes
42 * This is the alignment of the widgets in the layout direction.
43 *
44 * The alignment has no effect if the widgets can expand to fill the
45 * entire split layout.
46 */
47 alignment: SplitLayout.Alignment;
48 /**
49 * Get the inter-element spacing for the split layout.
50 */
51 /**
52 * Set the inter-element spacing for the split layout.
53 */
54 spacing: number;
55 /**
56 * A read-only array of the split handles in the layout.
57 */
58 readonly handles: ReadonlyArray<HTMLDivElement>;
59 /**
60 * Get the absolute sizes of the widgets in the layout.
61 *
62 * @returns A new array of the absolute sizes of the widgets.
63 *
64 * This method **does not** measure the DOM nodes.
65 */
66 absoluteSizes(): number[];
67 /**
68 * Get the relative sizes of the widgets in the layout.
69 *
70 * @returns A new array of the relative sizes of the widgets.
71 *
72 * #### Notes
73 * The returned sizes reflect the sizes of the widgets normalized
74 * relative to their siblings.
75 *
76 * This method **does not** measure the DOM nodes.
77 */
78 relativeSizes(): number[];
79 /**
80 * Set the relative sizes for the widgets in the layout.
81 *
82 * @param sizes - The relative sizes for the widgets in the panel.
83 * @param update - Update the layout after setting relative sizes.
84 * Default is True.
85 *
86 * #### Notes
87 * Extra values are ignored, too few will yield an undefined layout.
88 *
89 * The actual geometry of the DOM nodes is updated asynchronously.
90 */
91 setRelativeSizes(sizes: number[], update?: boolean): void;
92 /**
93 * Move the offset position of a split handle.
94 *
95 * @param index - The index of the handle of the interest.
96 *
97 * @param position - The desired offset position of the handle.
98 *
99 * #### Notes
100 * The position is relative to the offset parent.
101 *
102 * This will move the handle as close as possible to the desired
103 * position. The sibling widgets will be adjusted as necessary.
104 */
105 moveHandle(index: number, position: number): void;
106 /**
107 * Perform layout initialization which requires the parent widget.
108 */
109 protected init(): void;
110 /**
111 * Attach a widget to the parent's DOM node.
112 *
113 * @param index - The current index of the widget in the layout.
114 *
115 * @param widget - The widget to attach to the parent.
116 *
117 * #### Notes
118 * This is a reimplementation of the superclass method.
119 */
120 protected attachWidget(index: number, widget: Widget): void;
121 /**
122 * Move a widget in the parent's DOM node.
123 *
124 * @param fromIndex - The previous index of the widget in the layout.
125 *
126 * @param toIndex - The current index of the widget in the layout.
127 *
128 * @param widget - The widget to move in the parent.
129 *
130 * #### Notes
131 * This is a reimplementation of the superclass method.
132 */
133 protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void;
134 /**
135 * Detach a widget from the parent's DOM node.
136 *
137 * @param index - The previous index of the widget in the layout.
138 *
139 * @param widget - The widget to detach from the parent.
140 *
141 * #### Notes
142 * This is a reimplementation of the superclass method.
143 */
144 protected detachWidget(index: number, widget: Widget): void;
145 /**
146 * A message handler invoked on a `'before-show'` message.
147 */
148 protected onBeforeShow(msg: Message): void;
149 /**
150 * A message handler invoked on a `'before-attach'` message.
151 */
152 protected onBeforeAttach(msg: Message): void;
153 /**
154 * A message handler invoked on a `'child-shown'` message.
155 */
156 protected onChildShown(msg: Widget.ChildMessage): void;
157 /**
158 * A message handler invoked on a `'child-hidden'` message.
159 */
160 protected onChildHidden(msg: Widget.ChildMessage): void;
161 /**
162 * A message handler invoked on a `'resize'` message.
163 */
164 protected onResize(msg: Widget.ResizeMessage): void;
165 /**
166 * A message handler invoked on an `'update-request'` message.
167 */
168 protected onUpdateRequest(msg: Message): void;
169 /**
170 * A message handler invoked on a `'fit-request'` message.
171 */
172 protected onFitRequest(msg: Message): void;
173 /**
174 * Update the item position.
175 *
176 * @param i Item index
177 * @param isHorizontal Whether the layout is horizontal or not
178 * @param left Left position in pixels
179 * @param top Top position in pixels
180 * @param height Item height
181 * @param width Item width
182 * @param size Item size
183 */
184 protected updateItemPosition(i: number, isHorizontal: boolean, left: number, top: number, height: number, width: number, size: number): void;
185 /**
186 * Fit the layout to the total size required by the widgets.
187 */
188 private _fit;
189 /**
190 * Update the layout position and size of the widgets.
191 *
192 * The parent offset dimensions should be `-1` if unknown.
193 */
194 private _update;
195 protected widgetOffset: number;
196 private _fixed;
197 private _spacing;
198 private _dirty;
199 private _hasNormedSizes;
200 private _sizers;
201 private _items;
202 private _handles;
203 private _box;
204 private _alignment;
205 private _orientation;
206}
207/**
208 * The namespace for the `SplitLayout` class statics.
209 */
210export declare namespace SplitLayout {
211 /**
212 * A type alias for a split layout orientation.
213 */
214 type Orientation = 'horizontal' | 'vertical';
215 /**
216 * A type alias for a split layout alignment.
217 */
218 type Alignment = 'start' | 'center' | 'end' | 'justify';
219 /**
220 * An options object for initializing a split layout.
221 */
222 interface IOptions {
223 /**
224 * The renderer to use for the split layout.
225 */
226 renderer: IRenderer;
227 /**
228 * The orientation of the layout.
229 *
230 * The default is `'horizontal'`.
231 */
232 orientation?: Orientation;
233 /**
234 * The content alignment of the layout.
235 *
236 * The default is `'start'`.
237 */
238 alignment?: Alignment;
239 /**
240 * The spacing between items in the layout.
241 *
242 * The default is `4`.
243 */
244 spacing?: number;
245 }
246 /**
247 * A renderer for use with a split layout.
248 */
249 interface IRenderer {
250 /**
251 * Create a new handle for use with a split layout.
252 *
253 * @returns A new handle element.
254 */
255 createHandle(): HTMLDivElement;
256 }
257 /**
258 * Get the split layout stretch factor for the given widget.
259 *
260 * @param widget - The widget of interest.
261 *
262 * @returns The split layout stretch factor for the widget.
263 */
264 function getStretch(widget: Widget): number;
265 /**
266 * Set the split layout stretch factor for the given widget.
267 *
268 * @param widget - The widget of interest.
269 *
270 * @param value - The value for the stretch factor.
271 */
272 function setStretch(widget: Widget, value: number): void;
273}
274//# sourceMappingURL=splitlayout.d.ts.map
\No newline at end of file