UNPKG

15.5 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { ISignal } from '@lumino/signaling';
3import { DockLayout } from './docklayout';
4import { TabBar } from './tabbar';
5import { Widget } from './widget';
6/**
7 * A widget which provides a flexible docking area for widgets.
8 */
9export declare class DockPanel extends Widget {
10 /**
11 * Construct a new dock panel.
12 *
13 * @param options - The options for initializing the panel.
14 */
15 constructor(options?: DockPanel.IOptions);
16 /**
17 * Dispose of the resources held by the panel.
18 */
19 dispose(): void;
20 /**
21 * The method for hiding widgets.
22 */
23 get hiddenMode(): Widget.HiddenMode;
24 /**
25 * Set the method for hiding widgets.
26 */
27 set hiddenMode(v: Widget.HiddenMode);
28 /**
29 * A signal emitted when the layout configuration is modified.
30 *
31 * #### Notes
32 * This signal is emitted whenever the current layout configuration
33 * may have changed.
34 *
35 * This signal is emitted asynchronously in a collapsed fashion, so
36 * that multiple synchronous modifications results in only a single
37 * emit of the signal.
38 */
39 get layoutModified(): ISignal<this, void>;
40 /**
41 * A signal emitted when the add button on a tab bar is clicked.
42 *
43 */
44 get addRequested(): ISignal<this, TabBar<Widget>>;
45 /**
46 * The overlay used by the dock panel.
47 */
48 readonly overlay: DockPanel.IOverlay;
49 /**
50 * The renderer used by the dock panel.
51 */
52 get renderer(): DockPanel.IRenderer;
53 /**
54 * Get the spacing between the widgets.
55 */
56 get spacing(): number;
57 /**
58 * Set the spacing between the widgets.
59 */
60 set spacing(value: number);
61 /**
62 * Get the mode for the dock panel.
63 */
64 get mode(): DockPanel.Mode;
65 /**
66 * Set the mode for the dock panel.
67 *
68 * #### Notes
69 * Changing the mode is a destructive operation with respect to the
70 * panel's layout configuration. If layout state must be preserved,
71 * save the current layout config before changing the mode.
72 */
73 set mode(value: DockPanel.Mode);
74 /**
75 * Whether the tabs can be dragged / moved at runtime.
76 */
77 get tabsMovable(): boolean;
78 /**
79 * Enable / Disable draggable / movable tabs.
80 */
81 set tabsMovable(value: boolean);
82 /**
83 * Whether the tabs are constrained to their source dock panel
84 */
85 get tabsConstrained(): boolean;
86 /**
87 * Constrain/Allow tabs to be dragged outside of this dock panel
88 */
89 set tabsConstrained(value: boolean);
90 /**
91 * Whether the add buttons for each tab bar are enabled.
92 */
93 get addButtonEnabled(): boolean;
94 /**
95 * Set whether the add buttons for each tab bar are enabled.
96 */
97 set addButtonEnabled(value: boolean);
98 /**
99 * Whether the dock panel is empty.
100 */
101 get isEmpty(): boolean;
102 /**
103 * Create an iterator over the user widgets in the panel.
104 *
105 * @returns A new iterator over the user widgets in the panel.
106 *
107 * #### Notes
108 * This iterator does not include the generated tab bars.
109 */
110 widgets(): IterableIterator<Widget>;
111 /**
112 * Create an iterator over the selected widgets in the panel.
113 *
114 * @returns A new iterator over the selected user widgets.
115 *
116 * #### Notes
117 * This iterator yields the widgets corresponding to the current tab
118 * of each tab bar in the panel.
119 */
120 selectedWidgets(): IterableIterator<Widget>;
121 /**
122 * Create an iterator over the tab bars in the panel.
123 *
124 * @returns A new iterator over the tab bars in the panel.
125 *
126 * #### Notes
127 * This iterator does not include the user widgets.
128 */
129 tabBars(): IterableIterator<TabBar<Widget>>;
130 /**
131 * Create an iterator over the handles in the panel.
132 *
133 * @returns A new iterator over the handles in the panel.
134 */
135 handles(): IterableIterator<HTMLDivElement>;
136 /**
137 * Select a specific widget in the dock panel.
138 *
139 * @param widget - The widget of interest.
140 *
141 * #### Notes
142 * This will make the widget the current widget in its tab area.
143 */
144 selectWidget(widget: Widget): void;
145 /**
146 * Activate a specified widget in the dock panel.
147 *
148 * @param widget - The widget of interest.
149 *
150 * #### Notes
151 * This will select and activate the given widget.
152 */
153 activateWidget(widget: Widget): void;
154 /**
155 * Save the current layout configuration of the dock panel.
156 *
157 * @returns A new config object for the current layout state.
158 *
159 * #### Notes
160 * The return value can be provided to the `restoreLayout` method
161 * in order to restore the layout to its current configuration.
162 */
163 saveLayout(): DockPanel.ILayoutConfig;
164 /**
165 * Restore the layout to a previously saved configuration.
166 *
167 * @param config - The layout configuration to restore.
168 *
169 * #### Notes
170 * Widgets which currently belong to the layout but which are not
171 * contained in the config will be unparented.
172 *
173 * The dock panel automatically reverts to `'multiple-document'`
174 * mode when a layout config is restored.
175 */
176 restoreLayout(config: DockPanel.ILayoutConfig): void;
177 /**
178 * Add a widget to the dock panel.
179 *
180 * @param widget - The widget to add to the dock panel.
181 *
182 * @param options - The additional options for adding the widget.
183 *
184 * #### Notes
185 * If the panel is in single document mode, the options are ignored
186 * and the widget is always added as tab in the hidden tab bar.
187 */
188 addWidget(widget: Widget, options?: DockPanel.IAddOptions): void;
189 /**
190 * Process a message sent to the widget.
191 *
192 * @param msg - The message sent to the widget.
193 */
194 processMessage(msg: Message): void;
195 /**
196 * Handle the DOM events for the dock panel.
197 *
198 * @param event - The DOM event sent to the panel.
199 *
200 * #### Notes
201 * This method implements the DOM `EventListener` interface and is
202 * called in response to events on the panel's DOM node. It should
203 * not be called directly by user code.
204 */
205 handleEvent(event: Event): void;
206 /**
207 * A message handler invoked on a `'before-attach'` message.
208 */
209 protected onBeforeAttach(msg: Message): void;
210 /**
211 * A message handler invoked on an `'after-detach'` message.
212 */
213 protected onAfterDetach(msg: Message): void;
214 /**
215 * A message handler invoked on a `'child-added'` message.
216 */
217 protected onChildAdded(msg: Widget.ChildMessage): void;
218 /**
219 * A message handler invoked on a `'child-removed'` message.
220 */
221 protected onChildRemoved(msg: Widget.ChildMessage): void;
222 /**
223 * Handle the `'lm-dragenter'` event for the dock panel.
224 */
225 private _evtDragEnter;
226 /**
227 * Handle the `'lm-dragleave'` event for the dock panel.
228 */
229 private _evtDragLeave;
230 /**
231 * Handle the `'lm-dragover'` event for the dock panel.
232 */
233 private _evtDragOver;
234 /**
235 * Handle the `'lm-drop'` event for the dock panel.
236 */
237 private _evtDrop;
238 /**
239 * Handle the `'keydown'` event for the dock panel.
240 */
241 private _evtKeyDown;
242 /**
243 * Handle the `'pointerdown'` event for the dock panel.
244 */
245 private _evtPointerDown;
246 /**
247 * Handle the `'pointermove'` event for the dock panel.
248 */
249 private _evtPointerMove;
250 /**
251 * Handle the `'pointerup'` event for the dock panel.
252 */
253 private _evtPointerUp;
254 /**
255 * Release the mouse grab for the dock panel.
256 */
257 private _releaseMouse;
258 /**
259 * Show the overlay indicator at the given client position.
260 *
261 * Returns the drop zone at the specified client position.
262 *
263 * #### Notes
264 * If the position is not over a valid zone, the overlay is hidden.
265 */
266 private _showOverlay;
267 /**
268 * Create a new tab bar for use by the panel.
269 */
270 private _createTabBar;
271 /**
272 * Create a new handle for use by the panel.
273 */
274 private _createHandle;
275 /**
276 * Handle the `tabMoved` signal from a tab bar.
277 */
278 private _onTabMoved;
279 /**
280 * Handle the `currentChanged` signal from a tab bar.
281 */
282 private _onCurrentChanged;
283 /**
284 * Handle the `addRequested` signal from a tab bar.
285 */
286 private _onTabAddRequested;
287 /**
288 * Handle the `tabActivateRequested` signal from a tab bar.
289 */
290 private _onTabActivateRequested;
291 /**
292 * Handle the `tabCloseRequested` signal from a tab bar.
293 */
294 private _onTabCloseRequested;
295 /**
296 * Handle the `tabDetachRequested` signal from a tab bar.
297 */
298 private _onTabDetachRequested;
299 private _edges;
300 private _document;
301 private _mode;
302 private _drag;
303 private _renderer;
304 private _tabsMovable;
305 private _tabsConstrained;
306 private _addButtonEnabled;
307 private _pressData;
308 private _layoutModified;
309 private _addRequested;
310}
311/**
312 * The namespace for the `DockPanel` class statics.
313 */
314export declare namespace DockPanel {
315 /**
316 * An options object for creating a dock panel.
317 */
318 interface IOptions {
319 /**
320 * The document to use with the dock panel.
321 *
322 * The default is the global `document` instance.
323 */
324 document?: Document | ShadowRoot;
325 /**
326 * The overlay to use with the dock panel.
327 *
328 * The default is a new `Overlay` instance.
329 */
330 overlay?: IOverlay;
331 /**
332 * The renderer to use for the dock panel.
333 *
334 * The default is a shared renderer instance.
335 */
336 renderer?: IRenderer;
337 /**
338 * The spacing between the items in the panel.
339 *
340 * The default is `4`.
341 */
342 spacing?: number;
343 /**
344 * The mode for the dock panel.
345 *
346 * The default is `'multiple-document'`.
347 */
348 mode?: DockPanel.Mode;
349 /**
350 * The sizes of the edge drop zones, in pixels.
351 * If not given, default values will be used.
352 */
353 edges?: IEdges;
354 /**
355 * The method for hiding widgets.
356 *
357 * The default is `Widget.HiddenMode.Display`.
358 */
359 hiddenMode?: Widget.HiddenMode;
360 /**
361 * Allow tabs to be draggable / movable by user.
362 *
363 * The default is `'true'`.
364 */
365 tabsMovable?: boolean;
366 /**
367 * Constrain tabs to this dock panel
368 *
369 * The default is `'false'`.
370 */
371 tabsConstrained?: boolean;
372 /**
373 * Enable add buttons in each of the dock panel's tab bars.
374 *
375 * The default is `'false'`.
376 */
377 addButtonEnabled?: boolean;
378 }
379 /**
380 * The sizes of the edge drop zones, in pixels.
381 */
382 interface IEdges {
383 /**
384 * The size of the top edge drop zone.
385 */
386 top: number;
387 /**
388 * The size of the right edge drop zone.
389 */
390 right: number;
391 /**
392 * The size of the bottom edge drop zone.
393 */
394 bottom: number;
395 /**
396 * The size of the left edge drop zone.
397 */
398 left: number;
399 }
400 /**
401 * A type alias for the supported dock panel modes.
402 */
403 type Mode = /**
404 * The single document mode.
405 *
406 * In this mode, only a single widget is visible at a time, and that
407 * widget fills the available layout space. No tab bars are visible.
408 */ 'single-document'
409 /**
410 * The multiple document mode.
411 *
412 * In this mode, multiple documents are displayed in separate tab
413 * areas, and those areas can be individually resized by the user.
414 */
415 | 'multiple-document';
416 /**
417 * A type alias for a layout configuration object.
418 */
419 type ILayoutConfig = DockLayout.ILayoutConfig;
420 /**
421 * A type alias for the supported insertion modes.
422 */
423 type InsertMode = DockLayout.InsertMode;
424 /**
425 * A type alias for the add widget options.
426 */
427 type IAddOptions = DockLayout.IAddOptions;
428 /**
429 * An object which holds the geometry for overlay positioning.
430 */
431 interface IOverlayGeometry {
432 /**
433 * The distance between the overlay and parent top edges.
434 */
435 top: number;
436 /**
437 * The distance between the overlay and parent left edges.
438 */
439 left: number;
440 /**
441 * The distance between the overlay and parent right edges.
442 */
443 right: number;
444 /**
445 * The distance between the overlay and parent bottom edges.
446 */
447 bottom: number;
448 }
449 /**
450 * An object which manages the overlay node for a dock panel.
451 */
452 interface IOverlay {
453 /**
454 * The DOM node for the overlay.
455 */
456 readonly node: HTMLDivElement;
457 /**
458 * Show the overlay using the given overlay geometry.
459 *
460 * @param geo - The desired geometry for the overlay.
461 *
462 * #### Notes
463 * The given geometry values assume the node will use absolute
464 * positioning.
465 *
466 * This is called on every mouse move event during a drag in order
467 * to update the position of the overlay. It should be efficient.
468 */
469 show(geo: IOverlayGeometry): void;
470 /**
471 * Hide the overlay node.
472 *
473 * @param delay - The delay (in ms) before hiding the overlay.
474 * A delay value <= 0 should hide the overlay immediately.
475 *
476 * #### Notes
477 * This is called whenever the overlay node should been hidden.
478 */
479 hide(delay: number): void;
480 }
481 /**
482 * A concrete implementation of `IOverlay`.
483 *
484 * This is the default overlay implementation for a dock panel.
485 */
486 class Overlay implements IOverlay {
487 /**
488 * Construct a new overlay.
489 */
490 constructor();
491 /**
492 * The DOM node for the overlay.
493 */
494 readonly node: HTMLDivElement;
495 /**
496 * Show the overlay using the given overlay geometry.
497 *
498 * @param geo - The desired geometry for the overlay.
499 */
500 show(geo: IOverlayGeometry): void;
501 /**
502 * Hide the overlay node.
503 *
504 * @param delay - The delay (in ms) before hiding the overlay.
505 * A delay value <= 0 will hide the overlay immediately.
506 */
507 hide(delay: number): void;
508 private _timer;
509 private _hidden;
510 }
511 /**
512 * A type alias for a dock panel renderer;
513 */
514 type IRenderer = DockLayout.IRenderer;
515 /**
516 * The default implementation of `IRenderer`.
517 */
518 class Renderer implements IRenderer {
519 /**
520 * Create a new tab bar for use with a dock panel.
521 *
522 * @returns A new tab bar for a dock panel.
523 */
524 createTabBar(document?: Document | ShadowRoot): TabBar<Widget>;
525 /**
526 * Create a new handle node for use with a dock panel.
527 *
528 * @returns A new handle node for a dock panel.
529 */
530 createHandle(): HTMLDivElement;
531 }
532 /**
533 * The default `Renderer` instance.
534 */
535 const defaultRenderer: Renderer;
536}