This repository has been archived by the owner on Nov 6, 2019. It is now read-only.
/
stackedpanel.ts
100 lines (87 loc) · 2.24 KB
/
stackedpanel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2017, PhosphorJS Contributors
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
import {
ISignal, Signal
} from '@phosphor/signaling';
import {
Panel
} from './panel';
import {
StackedLayout
} from './stackedlayout';
import {
Widget
} from './widget';
/**
* A panel where visible widgets are stacked atop one another.
*
* #### Notes
* This class provides a convenience wrapper around a [[StackedLayout]].
*/
export
class StackedPanel extends Panel {
/**
* Construct a new stacked panel.
*
* @param options - The options for initializing the panel.
*/
constructor(options: StackedPanel.IOptions = {}) {
super({ layout: Private.createLayout(options) });
this.addClass('p-StackedPanel');
}
/**
* A signal emitted when a widget is removed from a stacked panel.
*/
get widgetRemoved(): ISignal<this, Widget> {
return this._widgetRemoved;
}
/**
* A message handler invoked on a `'child-added'` message.
*/
protected onChildAdded(msg: Widget.ChildMessage): void {
msg.child.addClass('p-StackedPanel-child');
}
/**
* A message handler invoked on a `'child-removed'` message.
*/
protected onChildRemoved(msg: Widget.ChildMessage): void {
msg.child.removeClass('p-StackedPanel-child');
this._widgetRemoved.emit(msg.child);
}
private _widgetRemoved = new Signal<this, Widget>(this);
}
/**
* The namespace for the `StackedPanel` class statics.
*/
export
namespace StackedPanel {
/**
* An options object for creating a stacked panel.
*/
export
interface IOptions {
/**
* The stacked layout to use for the stacked panel.
*
* The default is a new `StackedLayout`.
*/
layout?: StackedLayout;
}
}
/**
* The namespace for the module implementation details.
*/
namespace Private {
/**
* Create a stacked layout for the given panel options.
*/
export
function createLayout(options: StackedPanel.IOptions): StackedLayout {
return options.layout || new StackedLayout();
}
}