UNPKG

6.76 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { ISignal } from '@lumino/signaling';
3import { Panel } from './panel';
4import { SplitLayout } from './splitlayout';
5import { Widget } from './widget';
6/**
7 * A panel which arranges its widgets into resizable sections.
8 *
9 * #### Notes
10 * This class provides a convenience wrapper around a {@link SplitLayout}.
11 */
12export declare class SplitPanel extends Panel {
13 /**
14 * Construct a new split panel.
15 *
16 * @param options - The options for initializing the split panel.
17 */
18 constructor(options?: SplitPanel.IOptions);
19 /**
20 * Dispose of the resources held by the panel.
21 */
22 dispose(): void;
23 /**
24 * Get the layout orientation for the split panel.
25 */
26 get orientation(): SplitPanel.Orientation;
27 /**
28 * Set the layout orientation for the split panel.
29 */
30 set orientation(value: SplitPanel.Orientation);
31 /**
32 * Get the content alignment for the split panel.
33 *
34 * #### Notes
35 * This is the alignment of the widgets in the layout direction.
36 *
37 * The alignment has no effect if the widgets can expand to fill the
38 * entire split panel.
39 */
40 get alignment(): SplitPanel.Alignment;
41 /**
42 * Set the content alignment for the split panel.
43 *
44 * #### Notes
45 * This is the alignment of the widgets in the layout direction.
46 *
47 * The alignment has no effect if the widgets can expand to fill the
48 * entire split panel.
49 */
50 set alignment(value: SplitPanel.Alignment);
51 /**
52 * Get the inter-element spacing for the split panel.
53 */
54 get spacing(): number;
55 /**
56 * Set the inter-element spacing for the split panel.
57 */
58 set spacing(value: number);
59 /**
60 * The renderer used by the split panel.
61 */
62 get renderer(): SplitPanel.IRenderer;
63 /**
64 * A signal emitted when a split handle has moved.
65 */
66 get handleMoved(): ISignal<this, void>;
67 /**
68 * A read-only array of the split handles in the panel.
69 */
70 get handles(): ReadonlyArray<HTMLDivElement>;
71 /**
72 * Get the relative sizes of the widgets in the panel.
73 *
74 * @returns A new array of the relative sizes of the widgets.
75 *
76 * #### Notes
77 * The returned sizes reflect the sizes of the widgets normalized
78 * relative to their siblings.
79 *
80 * This method **does not** measure the DOM nodes.
81 */
82 relativeSizes(): number[];
83 /**
84 * Set the relative sizes for the widgets in the panel.
85 *
86 * @param sizes - The relative sizes for the widgets in the panel.
87 * @param update - Update the layout after setting relative sizes.
88 * Default is True.
89 *
90 * #### Notes
91 * Extra values are ignored, too few will yield an undefined layout.
92 *
93 * The actual geometry of the DOM nodes is updated asynchronously.
94 */
95 setRelativeSizes(sizes: number[], update?: boolean): void;
96 /**
97 * Handle the DOM events for the split panel.
98 *
99 * @param event - The DOM event sent to the panel.
100 *
101 * #### Notes
102 * This method implements the DOM `EventListener` interface and is
103 * called in response to events on the panel's DOM node. It should
104 * not be called directly by user code.
105 */
106 handleEvent(event: Event): void;
107 /**
108 * A message handler invoked on a `'before-attach'` message.
109 */
110 protected onBeforeAttach(msg: Message): void;
111 /**
112 * A message handler invoked on an `'after-detach'` message.
113 */
114 protected onAfterDetach(msg: Message): void;
115 /**
116 * A message handler invoked on a `'child-added'` message.
117 */
118 protected onChildAdded(msg: Widget.ChildMessage): void;
119 /**
120 * A message handler invoked on a `'child-removed'` message.
121 */
122 protected onChildRemoved(msg: Widget.ChildMessage): void;
123 /**
124 * Handle the `'keydown'` event for the split panel.
125 */
126 private _evtKeyDown;
127 /**
128 * Handle the `'pointerdown'` event for the split panel.
129 */
130 private _evtPointerDown;
131 /**
132 * Handle the `'pointermove'` event for the split panel.
133 */
134 private _evtPointerMove;
135 /**
136 * Handle the `'pointerup'` event for the split panel.
137 */
138 private _evtPointerUp;
139 /**
140 * Release the mouse grab for the split panel.
141 */
142 private _releaseMouse;
143 private _handleMoved;
144 private _pressData;
145}
146/**
147 * The namespace for the `SplitPanel` class statics.
148 */
149export declare namespace SplitPanel {
150 /**
151 * A type alias for a split panel orientation.
152 */
153 type Orientation = SplitLayout.Orientation;
154 /**
155 * A type alias for a split panel alignment.
156 */
157 type Alignment = SplitLayout.Alignment;
158 /**
159 * A type alias for a split panel renderer.
160 */
161 type IRenderer = SplitLayout.IRenderer;
162 /**
163 * An options object for initializing a split panel.
164 */
165 interface IOptions {
166 /**
167 * The renderer to use for the split panel.
168 *
169 * The default is a shared renderer instance.
170 */
171 renderer?: IRenderer;
172 /**
173 * The layout orientation of the panel.
174 *
175 * The default is `'horizontal'`.
176 */
177 orientation?: Orientation;
178 /**
179 * The content alignment of the panel.
180 *
181 * The default is `'start'`.
182 */
183 alignment?: Alignment;
184 /**
185 * The spacing between items in the panel.
186 *
187 * The default is `4`.
188 */
189 spacing?: number;
190 /**
191 * The split layout to use for the split panel.
192 *
193 * If this is provided, the other options are ignored.
194 *
195 * The default is a new `SplitLayout`.
196 */
197 layout?: SplitLayout;
198 }
199 /**
200 * The default implementation of `IRenderer`.
201 */
202 class Renderer implements IRenderer {
203 /**
204 * Create a new handle for use with a split panel.
205 *
206 * @returns A new handle element for a split panel.
207 */
208 createHandle(): HTMLDivElement;
209 }
210 /**
211 * The default `Renderer` instance.
212 */
213 const defaultRenderer: Renderer;
214 /**
215 * Get the split panel stretch factor for the given widget.
216 *
217 * @param widget - The widget of interest.
218 *
219 * @returns The split panel stretch factor for the widget.
220 */
221 function getStretch(widget: Widget): number;
222 /**
223 * Set the split panel stretch factor for the given widget.
224 *
225 * @param widget - The widget of interest.
226 *
227 * @param value - The value for the stretch factor.
228 */
229 function setStretch(widget: Widget, value: number): void;
230}