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