1 | import { IIterator } from '@phosphor/algorithm';
|
2 | import { Message } from '@phosphor/messaging';
|
3 | import { Layout } from './layout';
|
4 | import { TabBar } from './tabbar';
|
5 | import { Widget } from './widget';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export declare class DockLayout extends Layout {
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | constructor(options: DockLayout.IOptions);
|
21 | /**
|
22 | * Dispose of the resources held by the layout.
|
23 | *
|
24 | * #### Notes
|
25 | * This will clear and dispose all widgets in the layout.
|
26 | */
|
27 | dispose(): void;
|
28 | /**
|
29 | * The renderer used by the dock layout.
|
30 | */
|
31 | readonly renderer: DockLayout.IRenderer;
|
32 | /**
|
33 | * Get the inter-element spacing for the dock layout.
|
34 | */
|
35 | /**
|
36 | * Set the inter-element spacing for the dock layout.
|
37 | */
|
38 | spacing: number;
|
39 | /**
|
40 | * Whether the dock layout is empty.
|
41 | */
|
42 | readonly isEmpty: boolean;
|
43 | /**
|
44 | * Create an iterator over all widgets in the layout.
|
45 | *
|
46 | * @returns A new iterator over the widgets in the layout.
|
47 | *
|
48 | * #### Notes
|
49 | * This iterator includes the generated tab bars.
|
50 | */
|
51 | iter(): IIterator<Widget>;
|
52 | /**
|
53 | * Create an iterator over the user widgets in the layout.
|
54 | *
|
55 | * @returns A new iterator over the user widgets in the layout.
|
56 | *
|
57 | * #### Notes
|
58 | * This iterator does not include the generated tab bars.
|
59 | */
|
60 | widgets(): IIterator<Widget>;
|
61 | /**
|
62 | * Create an iterator over the selected widgets in the layout.
|
63 | *
|
64 | * @returns A new iterator over the selected user widgets.
|
65 | *
|
66 | * #### Notes
|
67 | * This iterator yields the widgets corresponding to the current tab
|
68 | * of each tab bar in the layout.
|
69 | */
|
70 | selectedWidgets(): IIterator<Widget>;
|
71 | /**
|
72 | * Create an iterator over the tab bars in the layout.
|
73 | *
|
74 | * @returns A new iterator over the tab bars in the layout.
|
75 | *
|
76 | * #### Notes
|
77 | * This iterator does not include the user widgets.
|
78 | */
|
79 | tabBars(): IIterator<TabBar<Widget>>;
|
80 | /**
|
81 | * Create an iterator over the handles in the layout.
|
82 | *
|
83 | * @returns A new iterator over the handles in the layout.
|
84 | */
|
85 | handles(): IIterator<HTMLDivElement>;
|
86 | /**
|
87 | * Move a handle to the given offset position.
|
88 | *
|
89 | * @param handle - The handle to move.
|
90 | *
|
91 | * @param offsetX - The desired offset X position of the handle.
|
92 | *
|
93 | * @param offsetY - The desired offset Y position of the handle.
|
94 | *
|
95 | * #### Notes
|
96 | * If the given handle is not contained in the layout, this is no-op.
|
97 | *
|
98 | * The handle will be moved as close as possible to the desired
|
99 | * position without violating any of the layout constraints.
|
100 | *
|
101 | * Only one of the coordinates is used depending on the orientation
|
102 | * of the handle. This method accepts both coordinates to make it
|
103 | * easy to invoke from a mouse move event without needing to know
|
104 | * the handle orientation.
|
105 | */
|
106 | moveHandle(handle: HTMLDivElement, offsetX: number, offsetY: number): void;
|
107 | /**
|
108 | * Save the current configuration of the dock layout.
|
109 | *
|
110 | * @returns A new config object for the current layout state.
|
111 | *
|
112 | * #### Notes
|
113 | * The return value can be provided to the `restoreLayout` method
|
114 | * in order to restore the layout to its current configuration.
|
115 | */
|
116 | saveLayout(): DockLayout.ILayoutConfig;
|
117 | /**
|
118 | * Restore the layout to a previously saved configuration.
|
119 | *
|
120 | * @param config - The layout configuration to restore.
|
121 | *
|
122 | * #### Notes
|
123 | * Widgets which currently belong to the layout but which are not
|
124 | * contained in the config will be unparented.
|
125 | */
|
126 | restoreLayout(config: DockLayout.ILayoutConfig): void;
|
127 | /**
|
128 | * Add a widget to the dock layout.
|
129 | *
|
130 | * @param widget - The widget to add to the dock layout.
|
131 | *
|
132 | * @param options - The additional options for adding the widget.
|
133 | *
|
134 | * #### Notes
|
135 | * The widget will be moved if it is already contained in the layout.
|
136 | *
|
137 | * An error will be thrown if the reference widget is invalid.
|
138 | */
|
139 | addWidget(widget: Widget, options?: DockLayout.IAddOptions): void;
|
140 | /**
|
141 | * Remove a widget from the layout.
|
142 | *
|
143 | * @param widget - The widget to remove from the layout.
|
144 | *
|
145 | * #### Notes
|
146 | * A widget is automatically removed from the layout when its `parent`
|
147 | * is set to `null`. This method should only be invoked directly when
|
148 | * removing a widget from a layout which has yet to be installed on a
|
149 | * parent widget.
|
150 | *
|
151 | * This method does *not* modify the widget's `parent`.
|
152 | */
|
153 | removeWidget(widget: Widget): void;
|
154 | /**
|
155 | * Find the tab area which contains the given client position.
|
156 | *
|
157 | * @param clientX - The client X position of interest.
|
158 | *
|
159 | * @param clientY - The client Y position of interest.
|
160 | *
|
161 | * @returns The geometry of the tab area at the given position, or
|
162 | * `null` if there is no tab area at the given position.
|
163 | */
|
164 | hitTestTabAreas(clientX: number, clientY: number): DockLayout.ITabAreaGeometry | null;
|
165 | /**
|
166 | * Perform layout initialization which requires the parent widget.
|
167 | */
|
168 | protected init(): void;
|
169 | /**
|
170 | * Attach the widget to the layout parent widget.
|
171 | *
|
172 | * @param widget - The widget to attach to the parent.
|
173 | *
|
174 | * #### Notes
|
175 | * This is a no-op if the widget is already attached.
|
176 | */
|
177 | protected attachWidget(widget: Widget): void;
|
178 | /**
|
179 | * Detach the widget from the layout parent widget.
|
180 | *
|
181 | * @param widget - The widget to detach from the parent.
|
182 | *
|
183 | * #### Notes
|
184 | * This is a no-op if the widget is not attached.
|
185 | */
|
186 | protected detachWidget(widget: Widget): void;
|
187 | /**
|
188 | * A message handler invoked on a `'before-show'` message.
|
189 | */
|
190 | protected onBeforeShow(msg: Message): void;
|
191 | /**
|
192 | * A message handler invoked on a `'before-attach'` message.
|
193 | */
|
194 | protected onBeforeAttach(msg: Message): void;
|
195 | /**
|
196 | * A message handler invoked on a `'child-shown'` message.
|
197 | */
|
198 | protected onChildShown(msg: Widget.ChildMessage): void;
|
199 | /**
|
200 | * A message handler invoked on a `'child-hidden'` message.
|
201 | */
|
202 | protected onChildHidden(msg: Widget.ChildMessage): void;
|
203 | /**
|
204 | * A message handler invoked on a `'resize'` message.
|
205 | */
|
206 | protected onResize(msg: Widget.ResizeMessage): void;
|
207 | /**
|
208 | * A message handler invoked on an `'update-request'` message.
|
209 | */
|
210 | protected onUpdateRequest(msg: Message): void;
|
211 | /**
|
212 | * A message handler invoked on a `'fit-request'` message.
|
213 | */
|
214 | protected onFitRequest(msg: Message): void;
|
215 | /**
|
216 | * Remove the specified widget from the layout structure.
|
217 | *
|
218 | * #### Notes
|
219 | * This is a no-op if the widget is not in the layout tree.
|
220 | *
|
221 | * This does not detach the widget from the parent node.
|
222 | */
|
223 | private _removeWidget;
|
224 | /**
|
225 | * Insert a widget next to an existing tab.
|
226 | *
|
227 | * #### Notes
|
228 | * This does not attach the widget to the parent widget.
|
229 | */
|
230 | private _insertTab;
|
231 | /**
|
232 | * Insert a widget as a new split area.
|
233 | *
|
234 | * #### Notes
|
235 | * This does not attach the widget to the parent widget.
|
236 | */
|
237 | private _insertSplit;
|
238 | /**
|
239 | * Ensure the root is a split node with the given orientation.
|
240 | */
|
241 | private _splitRoot;
|
242 | /**
|
243 | * Fit the layout to the total size required by the widgets.
|
244 | */
|
245 | private _fit;
|
246 | /**
|
247 | * Update the layout position and size of the widgets.
|
248 | *
|
249 | * The parent offset dimensions should be `-1` if unknown.
|
250 | */
|
251 | private _update;
|
252 | /**
|
253 | * Create a new tab bar for use by the dock layout.
|
254 | *
|
255 | * #### Notes
|
256 | * The tab bar will be attached to the parent if it exists.
|
257 | */
|
258 | private _createTabBar;
|
259 | /**
|
260 | * Create a new handle for the dock layout.
|
261 | *
|
262 | * #### Notes
|
263 | * The handle will be attached to the parent if it exists.
|
264 | */
|
265 | private _createHandle;
|
266 | private _spacing;
|
267 | private _dirty;
|
268 | private _root;
|
269 | private _box;
|
270 | private _items;
|
271 | }
|
272 | /**
|
273 | * The namespace for the `DockLayout` class statics.
|
274 | */
|
275 | export declare namespace DockLayout {
|
276 | |
277 |
|
278 |
|
279 | interface IOptions {
|
280 | |
281 |
|
282 |
|
283 | renderer: IRenderer;
|
284 | |
285 |
|
286 |
|
287 |
|
288 |
|
289 | spacing?: number;
|
290 | }
|
291 | |
292 |
|
293 |
|
294 | interface IRenderer {
|
295 | |
296 |
|
297 |
|
298 |
|
299 |
|
300 | createTabBar(): TabBar<Widget>;
|
301 | |
302 |
|
303 |
|
304 |
|
305 |
|
306 | createHandle(): HTMLDivElement;
|
307 | }
|
308 | |
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 | type InsertMode = (
|
315 | |
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 | 'split-top' |
|
324 | |
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 | 'split-left' |
|
333 | |
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 | 'split-right' |
|
342 | |
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 | 'split-bottom' |
|
351 | |
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 | 'tab-before' |
|
360 | |
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 | 'tab-after');
|
369 | |
370 |
|
371 |
|
372 | interface IAddOptions {
|
373 | |
374 |
|
375 |
|
376 |
|
377 |
|
378 | mode?: InsertMode;
|
379 | |
380 |
|
381 |
|
382 |
|
383 |
|
384 | ref?: Widget | null;
|
385 | }
|
386 | |
387 |
|
388 |
|
389 | interface ITabAreaConfig {
|
390 | |
391 |
|
392 |
|
393 | type: 'tab-area';
|
394 | |
395 |
|
396 |
|
397 | widgets: Widget[];
|
398 | |
399 |
|
400 |
|
401 | currentIndex: number;
|
402 | }
|
403 | |
404 |
|
405 |
|
406 | interface ISplitAreaConfig {
|
407 | |
408 |
|
409 |
|
410 | type: 'split-area';
|
411 | |
412 |
|
413 |
|
414 | orientation: 'horizontal' | 'vertical';
|
415 | |
416 |
|
417 |
|
418 | children: AreaConfig[];
|
419 | |
420 |
|
421 |
|
422 | sizes: number[];
|
423 | }
|
424 | |
425 |
|
426 |
|
427 | type AreaConfig = ITabAreaConfig | ISplitAreaConfig;
|
428 | |
429 |
|
430 |
|
431 | interface ILayoutConfig {
|
432 | |
433 |
|
434 |
|
435 | main: AreaConfig | null;
|
436 | }
|
437 | |
438 |
|
439 |
|
440 | interface ITabAreaGeometry {
|
441 | |
442 |
|
443 |
|
444 | tabBar: TabBar<Widget>;
|
445 | |
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 | x: number;
|
453 | |
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | y: number;
|
461 | |
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 | top: number;
|
469 | |
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 | left: number;
|
477 | |
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 | right: number;
|
485 | |
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 | bottom: number;
|
493 | |
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 | width: number;
|
500 | |
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 | height: number;
|
507 | }
|
508 | }
|