1 | import { IIterator } from '@phosphor/algorithm';
|
2 | import { Message } from '@phosphor/messaging';
|
3 | import { ISignal } from '@phosphor/signaling';
|
4 | import { DockLayout } from './docklayout';
|
5 | import { TabBar } from './tabbar';
|
6 | import { Widget } from './widget';
|
7 |
|
8 |
|
9 |
|
10 | export declare class DockPanel extends Widget {
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 | constructor(options?: DockPanel.IOptions);
|
17 | /**
|
18 | * Dispose of the resources held by the panel.
|
19 | */
|
20 | dispose(): void;
|
21 | /**
|
22 | * A signal emitted when the layout configuration is modified.
|
23 | *
|
24 | * #### Notes
|
25 | * This signal is emitted whenever the current layout configuration
|
26 | * may have changed.
|
27 | *
|
28 | * This signal is emitted asynchronously in a collapsed fashion, so
|
29 | * that multiple synchronous modifications results in only a single
|
30 | * emit of the signal.
|
31 | */
|
32 | readonly layoutModified: ISignal<this, void>;
|
33 | /**
|
34 | * The overlay used by the dock panel.
|
35 | */
|
36 | readonly overlay: DockPanel.IOverlay;
|
37 | /**
|
38 | * The renderer used by the dock panel.
|
39 | */
|
40 | readonly renderer: DockPanel.IRenderer;
|
41 | /**
|
42 | * Get the spacing between the widgets.
|
43 | */
|
44 | /**
|
45 | * Set the spacing between the widgets.
|
46 | */
|
47 | spacing: number;
|
48 | /**
|
49 | * Get the mode for the dock panel.
|
50 | */
|
51 | /**
|
52 | * Set the mode for the dock panel.
|
53 | *
|
54 | * #### Notes
|
55 | * Changing the mode is a destructive operation with respect to the
|
56 | * panel's layout configuration. If layout state must be preserved,
|
57 | * save the current layout config before changing the mode.
|
58 | */
|
59 | mode: DockPanel.Mode;
|
60 | /**
|
61 | * Whether the dock panel is empty.
|
62 | */
|
63 | readonly isEmpty: boolean;
|
64 | /**
|
65 | * Create an iterator over the user widgets in the panel.
|
66 | *
|
67 | * @returns A new iterator over the user widgets in the panel.
|
68 | *
|
69 | * #### Notes
|
70 | * This iterator does not include the generated tab bars.
|
71 | */
|
72 | widgets(): IIterator<Widget>;
|
73 | /**
|
74 | * Create an iterator over the selected widgets in the panel.
|
75 | *
|
76 | * @returns A new iterator over the selected user widgets.
|
77 | *
|
78 | * #### Notes
|
79 | * This iterator yields the widgets corresponding to the current tab
|
80 | * of each tab bar in the panel.
|
81 | */
|
82 | selectedWidgets(): IIterator<Widget>;
|
83 | /**
|
84 | * Create an iterator over the tab bars in the panel.
|
85 | *
|
86 | * @returns A new iterator over the tab bars in the panel.
|
87 | *
|
88 | * #### Notes
|
89 | * This iterator does not include the user widgets.
|
90 | */
|
91 | tabBars(): IIterator<TabBar<Widget>>;
|
92 | /**
|
93 | * Create an iterator over the handles in the panel.
|
94 | *
|
95 | * @returns A new iterator over the handles in the panel.
|
96 | */
|
97 | handles(): IIterator<HTMLDivElement>;
|
98 | /**
|
99 | * Select a specific widget in the dock panel.
|
100 | *
|
101 | * @param widget - The widget of interest.
|
102 | *
|
103 | * #### Notes
|
104 | * This will make the widget the current widget in its tab area.
|
105 | */
|
106 | selectWidget(widget: Widget): void;
|
107 | /**
|
108 | * Activate a specified widget in the dock panel.
|
109 | *
|
110 | * @param widget - The widget of interest.
|
111 | *
|
112 | * #### Notes
|
113 | * This will select and activate the given widget.
|
114 | */
|
115 | activateWidget(widget: Widget): void;
|
116 | /**
|
117 | * Save the current layout configuration of the dock panel.
|
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(): DockPanel.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 | * The dock panel automatically reverts to `'multiple-document'`
|
136 | * mode when a layout config is restored.
|
137 | */
|
138 | restoreLayout(config: DockPanel.ILayoutConfig): void;
|
139 | /**
|
140 | * Add a widget to the dock panel.
|
141 | *
|
142 | * @param widget - The widget to add to the dock panel.
|
143 | *
|
144 | * @param options - The additional options for adding the widget.
|
145 | *
|
146 | * #### Notes
|
147 | * If the panel is in single document mode, the options are ignored
|
148 | * and the widget is always added as tab in the hidden tab bar.
|
149 | */
|
150 | addWidget(widget: Widget, options?: DockPanel.IAddOptions): void;
|
151 | /**
|
152 | * Process a message sent to the widget.
|
153 | *
|
154 | * @param msg - The message sent to the widget.
|
155 | */
|
156 | processMessage(msg: Message): void;
|
157 | /**
|
158 | * Handle the DOM events for the dock panel.
|
159 | *
|
160 | * @param event - The DOM event sent to the panel.
|
161 | *
|
162 | * #### Notes
|
163 | * This method implements the DOM `EventListener` interface and is
|
164 | * called in response to events on the panel's DOM node. It should
|
165 | * not be called directly by user code.
|
166 | */
|
167 | handleEvent(event: Event): void;
|
168 | /**
|
169 | * A message handler invoked on a `'before-attach'` message.
|
170 | */
|
171 | protected onBeforeAttach(msg: Message): void;
|
172 | /**
|
173 | * A message handler invoked on an `'after-detach'` message.
|
174 | */
|
175 | protected onAfterDetach(msg: Message): void;
|
176 | /**
|
177 | * A message handler invoked on a `'child-added'` message.
|
178 | */
|
179 | protected onChildAdded(msg: Widget.ChildMessage): void;
|
180 | /**
|
181 | * A message handler invoked on a `'child-removed'` message.
|
182 | */
|
183 | protected onChildRemoved(msg: Widget.ChildMessage): void;
|
184 | /**
|
185 | * Handle the `'p-dragenter'` event for the dock panel.
|
186 | */
|
187 | private _evtDragEnter;
|
188 | /**
|
189 | * Handle the `'p-dragleave'` event for the dock panel.
|
190 | */
|
191 | private _evtDragLeave;
|
192 | /**
|
193 | * Handle the `'p-dragover'` event for the dock panel.
|
194 | */
|
195 | private _evtDragOver;
|
196 | /**
|
197 | * Handle the `'p-drop'` event for the dock panel.
|
198 | */
|
199 | private _evtDrop;
|
200 | /**
|
201 | * Handle the `'keydown'` event for the dock panel.
|
202 | */
|
203 | private _evtKeyDown;
|
204 | /**
|
205 | * Handle the `'mousedown'` event for the dock panel.
|
206 | */
|
207 | private _evtMouseDown;
|
208 | /**
|
209 | * Handle the `'mousemove'` event for the dock panel.
|
210 | */
|
211 | private _evtMouseMove;
|
212 | /**
|
213 | * Handle the `'mouseup'` event for the dock panel.
|
214 | */
|
215 | private _evtMouseUp;
|
216 | /**
|
217 | * Release the mouse grab for the dock panel.
|
218 | */
|
219 | private _releaseMouse;
|
220 | /**
|
221 | * Show the overlay indicator at the given client position.
|
222 | *
|
223 | * Returns the drop zone at the specified client position.
|
224 | *
|
225 | * #### Notes
|
226 | * If the position is not over a valid zone, the overlay is hidden.
|
227 | */
|
228 | private _showOverlay;
|
229 | /**
|
230 | * Create a new tab bar for use by the panel.
|
231 | */
|
232 | private _createTabBar;
|
233 | /**
|
234 | * Create a new handle for use by the panel.
|
235 | */
|
236 | private _createHandle;
|
237 | /**
|
238 | * Handle the `tabMoved` signal from a tab bar.
|
239 | */
|
240 | private _onTabMoved;
|
241 | /**
|
242 | * Handle the `currentChanged` signal from a tab bar.
|
243 | */
|
244 | private _onCurrentChanged;
|
245 | /**
|
246 | * Handle the `tabActivateRequested` signal from a tab bar.
|
247 | */
|
248 | private _onTabActivateRequested;
|
249 | /**
|
250 | * Handle the `tabCloseRequested` signal from a tab bar.
|
251 | */
|
252 | private _onTabCloseRequested;
|
253 | /**
|
254 | * Handle the `tabDetachRequested` signal from a tab bar.
|
255 | */
|
256 | private _onTabDetachRequested;
|
257 | private _edges;
|
258 | private _mode;
|
259 | private _drag;
|
260 | private _renderer;
|
261 | private _pressData;
|
262 | private _layoutModified;
|
263 | }
|
264 | /**
|
265 | * The namespace for the `DockPanel` class statics.
|
266 | */
|
267 | export declare namespace DockPanel {
|
268 | |
269 |
|
270 |
|
271 | interface IOptions {
|
272 | |
273 |
|
274 |
|
275 |
|
276 |
|
277 | overlay?: IOverlay;
|
278 | |
279 |
|
280 |
|
281 |
|
282 |
|
283 | renderer?: IRenderer;
|
284 | |
285 |
|
286 |
|
287 |
|
288 |
|
289 | spacing?: number;
|
290 | |
291 |
|
292 |
|
293 |
|
294 |
|
295 | mode?: DockPanel.Mode;
|
296 | |
297 |
|
298 |
|
299 |
|
300 | edges?: IEdges;
|
301 | }
|
302 | |
303 |
|
304 |
|
305 | interface IEdges {
|
306 | |
307 |
|
308 |
|
309 | top: number;
|
310 | |
311 |
|
312 |
|
313 | right: number;
|
314 | |
315 |
|
316 |
|
317 | bottom: number;
|
318 | |
319 |
|
320 |
|
321 | left: number;
|
322 | }
|
323 | |
324 |
|
325 |
|
326 | type Mode = (
|
327 | |
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 | 'single-document' |
|
334 | |
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 | 'multiple-document');
|
341 | |
342 |
|
343 |
|
344 | type ILayoutConfig = DockLayout.ILayoutConfig;
|
345 | |
346 |
|
347 |
|
348 | type InsertMode = DockLayout.InsertMode;
|
349 | |
350 |
|
351 |
|
352 | type IAddOptions = DockLayout.IAddOptions;
|
353 | |
354 |
|
355 |
|
356 | interface IOverlayGeometry {
|
357 | |
358 |
|
359 |
|
360 | top: number;
|
361 | |
362 |
|
363 |
|
364 | left: number;
|
365 | |
366 |
|
367 |
|
368 | right: number;
|
369 | |
370 |
|
371 |
|
372 | bottom: number;
|
373 | }
|
374 | |
375 |
|
376 |
|
377 | interface IOverlay {
|
378 | |
379 |
|
380 |
|
381 | readonly node: HTMLDivElement;
|
382 | |
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 | show(geo: IOverlayGeometry): void;
|
395 | |
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | hide(delay: number): void;
|
405 | }
|
406 | |
407 |
|
408 |
|
409 |
|
410 |
|
411 | class Overlay implements IOverlay {
|
412 | |
413 |
|
414 |
|
415 | constructor();
|
416 | /**
|
417 | * The DOM node for the overlay.
|
418 | */
|
419 | readonly node: HTMLDivElement;
|
420 | /**
|
421 | * Show the overlay using the given overlay geometry.
|
422 | *
|
423 | * @param geo - The desired geometry for the overlay.
|
424 | */
|
425 | show(geo: IOverlayGeometry): void;
|
426 | /**
|
427 | * Hide the overlay node.
|
428 | *
|
429 | * @param delay - The delay (in ms) before hiding the overlay.
|
430 | * A delay value <= 0 will hide the overlay immediately.
|
431 | */
|
432 | hide(delay: number): void;
|
433 | private _timer;
|
434 | private _hidden;
|
435 | }
|
436 | /**
|
437 | * A type alias for a dock panel renderer;
|
438 | */
|
439 | type IRenderer = DockLayout.IRenderer;
|
440 | /**
|
441 | * The default implementation of `IRenderer`.
|
442 | */
|
443 | class Renderer implements IRenderer {
|
444 | |
445 |
|
446 |
|
447 |
|
448 |
|
449 | createTabBar(): TabBar<Widget>;
|
450 | |
451 |
|
452 |
|
453 |
|
454 |
|
455 | createHandle(): HTMLDivElement;
|
456 | }
|
457 | |
458 |
|
459 |
|
460 | const defaultRenderer: Renderer;
|
461 | }
|