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