1
1
import * as React from '@theia/core/shared/react' ;
2
- import { inject , injectable , postConstruct } from '@theia/core/shared/inversify' ;
2
+ import {
3
+ inject ,
4
+ injectable ,
5
+ postConstruct ,
6
+ } from '@theia/core/shared/inversify' ;
3
7
import { TreeNode } from '@theia/core/lib/browser/tree/tree' ;
4
8
import { CommandRegistry } from '@theia/core/lib/common/command' ;
5
9
import {
@@ -22,6 +26,11 @@ import { SelectableTreeNode } from '@theia/core/lib/browser/tree/tree-selection'
22
26
import { Sketch } from '../../contributions/contribution' ;
23
27
import { nls } from '@theia/core/lib/common' ;
24
28
29
+ const customTreeProps : TreeProps = {
30
+ leftPadding : 20 ,
31
+ expansionTogglePadding : 6 ,
32
+ } ;
33
+
25
34
@injectable ( )
26
35
export class SketchbookTreeWidget extends FileTreeWidget {
27
36
@inject ( CommandRegistry )
@@ -57,10 +66,14 @@ export class SketchbookTreeWidget extends FileTreeWidget {
57
66
super . init ( ) ;
58
67
// cache the current open sketch uri
59
68
const currentSketch = await this . sketchServiceClient . currentSketch ( ) ;
60
- this . currentSketchUri = ( CurrentSketch . isValid ( currentSketch ) && currentSketch . uri ) || '' ;
69
+ this . currentSketchUri =
70
+ ( CurrentSketch . isValid ( currentSketch ) && currentSketch . uri ) || '' ;
61
71
}
62
72
63
- protected override createNodeClassNames ( node : TreeNode , props : NodeProps ) : string [ ] {
73
+ protected override createNodeClassNames (
74
+ node : TreeNode ,
75
+ props : NodeProps
76
+ ) : string [ ] {
64
77
const classNames = super . createNodeClassNames ( node , props ) ;
65
78
66
79
if (
@@ -73,7 +86,10 @@ export class SketchbookTreeWidget extends FileTreeWidget {
73
86
return classNames ;
74
87
}
75
88
76
- protected override renderIcon ( node : TreeNode , props : NodeProps ) : React . ReactNode {
89
+ protected override renderIcon (
90
+ node : TreeNode ,
91
+ props : NodeProps
92
+ ) : React . ReactNode {
77
93
if ( SketchbookTree . SketchDirNode . is ( node ) || Sketch . isSketchFile ( node . id ) ) {
78
94
return < div className = "sketch-folder-icon file-icon" > </ div > ;
79
95
}
@@ -199,4 +215,13 @@ export class SketchbookTreeWidget extends FileTreeWidget {
199
215
}
200
216
event . stopPropagation ( ) ;
201
217
}
218
+
219
+ protected override getPaddingLeft ( node : TreeNode , props : NodeProps ) : number {
220
+ return (
221
+ props . depth * customTreeProps . leftPadding +
222
+ ( this . needsExpansionTogglePadding ( node )
223
+ ? customTreeProps . expansionTogglePadding
224
+ : 0 )
225
+ ) ;
226
+ }
202
227
}
0 commit comments