UNPKG

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