7
7
SHELL_TABBAR_CONTEXT_MENU ,
8
8
TabBar ,
9
9
Widget ,
10
+ Layout ,
11
+ SplitPanel ,
10
12
} from '@theia/core/lib/browser' ;
11
13
import {
12
14
ConnectionStatus ,
@@ -17,17 +19,23 @@ import { MessageService } from '@theia/core/lib/common/message-service';
17
19
import { inject , injectable } from '@theia/core/shared/inversify' ;
18
20
import { ToolbarAwareTabBar } from './tab-bars' ;
19
21
22
+ interface WidgetOptions
23
+ extends Omit < TheiaApplicationShell . WidgetOptions , 'area' > {
24
+ area ?: TheiaApplicationShell . Area | 'toolbar' ;
25
+ }
26
+
20
27
@injectable ( )
21
28
export class ApplicationShell extends TheiaApplicationShell {
22
29
@inject ( MessageService )
23
30
private readonly messageService : MessageService ;
24
31
25
32
@inject ( ConnectionStatusService )
26
33
private readonly connectionStatusService : ConnectionStatusService ;
34
+ private toolbarPanel : Panel ;
27
35
28
36
override async addWidget (
29
37
widget : Widget ,
30
- options : Readonly < TheiaApplicationShell . WidgetOptions > = { }
38
+ options : Readonly < WidgetOptions > = { }
31
39
) : Promise < void > {
32
40
// By default, Theia open a widget **next** to the currently active in the target area.
33
41
// Instead of this logic, we want to open the new widget after the last of the target area.
@@ -37,8 +45,12 @@ export class ApplicationShell extends TheiaApplicationShell {
37
45
) ;
38
46
return ;
39
47
}
48
+ if ( options . area === 'toolbar' ) {
49
+ this . toolbarPanel . addWidget ( widget ) ;
50
+ return ;
51
+ }
52
+ const area = options . area || 'main' ;
40
53
let ref : Widget | undefined = options . ref ;
41
- const area : TheiaApplicationShell . Area = options . area || 'main' ;
42
54
if ( ! ref && ( area === 'main' || area === 'bottom' ) ) {
43
55
const tabBar = this . getTabBarFor ( area ) ;
44
56
if ( tabBar ) {
@@ -48,14 +60,57 @@ export class ApplicationShell extends TheiaApplicationShell {
48
60
}
49
61
}
50
62
}
51
- return super . addWidget ( widget , { ...options , ref } ) ;
63
+ return super . addWidget ( widget , {
64
+ ...( < TheiaApplicationShell . WidgetOptions > options ) ,
65
+ ref,
66
+ } ) ;
52
67
}
53
68
54
69
override handleEvent ( ) : boolean {
55
70
// NOOP, dragging has been disabled
56
71
return false ;
57
72
}
58
73
74
+ protected override initializeShell ( ) : void {
75
+ this . toolbarPanel = this . createToolbarPanel ( ) ;
76
+ super . initializeShell ( ) ;
77
+ }
78
+
79
+ private createToolbarPanel ( ) : Panel {
80
+ const toolbarPanel = new Panel ( ) ;
81
+ toolbarPanel . id = 'arduino-toolbar-panel' ;
82
+ toolbarPanel . show ( ) ;
83
+ return toolbarPanel ;
84
+ }
85
+
86
+ protected override createLayout ( ) : Layout {
87
+ const bottomSplitLayout = this . createSplitLayout (
88
+ [ this . mainPanel , this . bottomPanel ] ,
89
+ [ 1 , 0 ] ,
90
+ { orientation : 'vertical' , spacing : 0 }
91
+ ) ;
92
+ const panelForBottomArea = new SplitPanel ( { layout : bottomSplitLayout } ) ;
93
+ panelForBottomArea . id = 'theia-bottom-split-panel' ;
94
+
95
+ const leftRightSplitLayout = this . createSplitLayout (
96
+ [
97
+ this . leftPanelHandler . container ,
98
+ panelForBottomArea ,
99
+ this . rightPanelHandler . container ,
100
+ ] ,
101
+ [ 0 , 1 , 0 ] ,
102
+ { orientation : 'horizontal' , spacing : 0 }
103
+ ) ;
104
+ const panelForSideAreas = new SplitPanel ( { layout : leftRightSplitLayout } ) ;
105
+ panelForSideAreas . id = 'theia-left-right-split-panel' ;
106
+
107
+ return this . createBoxLayout (
108
+ [ this . topPanel , this . toolbarPanel , panelForSideAreas , this . statusBar ] ,
109
+ [ 0 , 0 , 1 , 0 ] ,
110
+ { direction : 'top-to-bottom' , spacing : 0 }
111
+ ) ;
112
+ }
113
+
59
114
// Avoid hiding top panel as we use it for arduino toolbar
60
115
protected override createTopPanel ( ) : Panel {
61
116
const topPanel = super . createTopPanel ( ) ;
0 commit comments