UNPKG

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