Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
07cd08c7
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
07cd08c7
编写于
9月 18, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce PanelViewlet
上级
3233f1aa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
240 addition
and
1 deletion
+240
-1
src/vs/base/browser/ui/splitview/panelview.ts
src/vs/base/browser/ui/splitview/panelview.ts
+2
-1
src/vs/workbench/browser/parts/views/views2.ts
src/vs/workbench/browser/parts/views/views2.ts
+238
-0
未找到文件。
src/vs/base/browser/ui/splitview/panelview.ts
浏览文件 @
07cd08c7
...
@@ -37,8 +37,9 @@ export abstract class Panel implements IView {
...
@@ -37,8 +37,9 @@ export abstract class Panel implements IView {
private
_minimumBodySize
:
number
;
private
_minimumBodySize
:
number
;
private
_maximumBodySize
:
number
;
private
_maximumBodySize
:
number
;
private
ariaHeaderLabel
:
string
;
private
ariaHeaderLabel
:
string
;
readonly
header
:
HTMLElement
;
readonly
header
:
HTMLElement
;
pr
ivate
disposables
:
IDisposable
[]
=
[];
pr
otected
disposables
:
IDisposable
[]
=
[];
get
minimumBodySize
():
number
{
get
minimumBodySize
():
number
{
return
this
.
_minimumBodySize
;
return
this
.
_minimumBodySize
;
...
...
src/vs/workbench/browser/parts/views/views2.ts
0 → 100644
浏览文件 @
07cd08c7
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
attachStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
Dimension
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
{
append
,
$
}
from
'
vs/base/browser/dom
'
;
import
{
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
firstIndex
}
from
'
vs/base/common/arrays
'
;
import
{
IAction
,
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IActionItem
,
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
prepareActions
}
from
'
vs/workbench/browser/actions
'
;
import
{
Viewlet
,
ViewletRegistry
,
Extensions
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
SIDE_BAR_DRAG_AND_DROP_BACKGROUND
}
from
'
vs/workbench/common/theme
'
;
import
{
PanelView
,
IPanelOptions
,
Panel
}
from
'
vs/base/browser/ui/splitview/panelview
'
;
export
interface
IViewletPanelOptions
extends
IPanelOptions
{
actionRunner
?:
IActionRunner
;
}
export
abstract
class
ViewletPanel
extends
Panel
{
private
_onDidFocus
=
new
Emitter
<
void
>
();
readonly
onDidFocus
:
Event
<
void
>
=
this
.
_onDidFocus
.
event
;
private
actionRunner
:
IActionRunner
;
private
toolbar
:
ToolBar
;
constructor
(
readonly
name
:
string
,
initialSize
:
number
,
options
:
IViewletPanelOptions
,
protected
keybindingService
:
IKeybindingService
,
protected
contextMenuService
:
IContextMenuService
)
{
super
(
options
);
this
.
actionRunner
=
options
.
actionRunner
;
}
render
(
container
:
HTMLElement
):
void
{
super
.
render
(
container
);
const
title
=
append
(
this
.
header
,
$
(
'
div.title
'
));
title
.
textContent
=
this
.
name
;
const
actions
=
append
(
this
.
header
,
$
(
'
div.actions
'
));
this
.
toolbar
=
new
ToolBar
(
actions
,
this
.
contextMenuService
,
{
orientation
:
ActionsOrientation
.
HORIZONTAL
,
actionItemProvider
:
action
=>
this
.
getActionItem
(
action
),
ariaLabel
:
nls
.
localize
(
'
viewToolbarAriaLabel
'
,
"
{0} actions
"
,
this
.
name
),
getKeyBinding
:
action
=>
this
.
keybindingService
.
lookupKeybinding
(
action
.
id
),
actionRunner
:
this
.
actionRunner
});
this
.
disposables
.
push
(
this
.
toolbar
);
this
.
updateActions
();
}
focus
():
void
{
super
.
focus
();
this
.
_onDidFocus
.
fire
();
}
protected
updateActions
():
void
{
this
.
toolbar
.
setActions
(
prepareActions
(
this
.
getActions
()),
prepareActions
(
this
.
getSecondaryActions
()))();
this
.
toolbar
.
context
=
this
.
getActionsContext
();
}
getActions
():
IAction
[]
{
return
[];
}
getSecondaryActions
():
IAction
[]
{
return
[];
}
getActionItem
(
action
:
IAction
):
IActionItem
{
return
null
;
}
getActionsContext
():
any
{
return
undefined
;
}
getOptimalWidth
():
number
{
return
0
;
}
}
export
interface
IViewsViewletOptions
{
showHeaderInTitleWhenSingleView
:
boolean
;
}
const
SplitViewThemeMapping
=
{
dropBackground
:
SIDE_BAR_DRAG_AND_DROP_BACKGROUND
};
interface
IViewletPanelItem
{
panel
:
ViewletPanel
;
disposable
:
IDisposable
;
}
export
class
PanelViewlet
extends
Viewlet
{
protected
lastFocusedPanel
:
ViewletPanel
|
undefined
;
private
panelItems
:
IViewletPanelItem
[]
=
[];
private
panelview
:
PanelView
;
protected
get
isSingleView
():
boolean
{
return
this
.
options
.
showHeaderInTitleWhenSingleView
&&
this
.
panelItems
.
length
===
1
;
}
protected
get
length
():
number
{
return
this
.
panelItems
.
length
;
}
constructor
(
id
:
string
,
private
options
:
Partial
<
IViewsViewletOptions
>
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
id
,
telemetryService
,
themeService
);
}
async
create
(
parent
:
Builder
):
TPromise
<
void
>
{
super
.
create
(
parent
);
const
container
=
parent
.
getHTMLElement
();
this
.
panelview
=
this
.
_register
(
new
PanelView
(
container
));
this
.
_register
(
attachStyler
(
this
.
themeService
,
SplitViewThemeMapping
,
this
.
panelview
));
// this._register(this.panelview.onFocus(view => this.lastFocusedView = view));
}
getTitle
():
string
{
let
title
=
Registry
.
as
<
ViewletRegistry
>
(
Extensions
.
Viewlets
).
getViewlet
(
this
.
getId
()).
name
;
if
(
this
.
isSingleView
)
{
title
+=
'
:
'
+
this
.
panelItems
[
0
].
panel
.
name
;
}
return
title
;
}
getActions
():
IAction
[]
{
if
(
this
.
isSingleView
)
{
return
this
.
panelItems
[
0
].
panel
.
getActions
();
}
return
[];
}
getSecondaryActions
():
IAction
[]
{
if
(
this
.
isSingleView
)
{
return
this
.
panelItems
[
0
].
panel
.
getSecondaryActions
();
}
return
[];
}
focus
():
void
{
super
.
focus
();
if
(
this
.
lastFocusedPanel
)
{
this
.
lastFocusedPanel
.
focus
();
}
else
if
(
this
.
panelItems
.
length
>
0
)
{
this
.
panelItems
[
0
].
panel
.
focus
();
}
}
layout
(
dimension
:
Dimension
):
void
{
this
.
panelview
.
layout
(
dimension
.
height
);
}
getOptimalWidth
():
number
{
const
sizes
=
this
.
panelItems
.
map
(
panelItem
=>
panelItem
.
panel
.
getOptimalWidth
()
||
0
);
return
Math
.
max
(...
sizes
);
}
addView
(
panel
:
ViewletPanel
,
index
=
this
.
panelItems
.
length
-
1
):
void
{
const
disposables
:
IDisposable
[]
=
[];
const
onDidFocus
=
panel
.
onDidFocus
(()
=>
this
.
lastFocusedPanel
=
panel
,
null
,
disposables
);
const
disposable
=
combinedDisposable
([
onDidFocus
]);
const
panelItem
:
IViewletPanelItem
=
{
panel
,
disposable
};
this
.
panelItems
.
splice
(
index
,
0
,
panelItem
);
this
.
panelview
.
addPanel
(
panel
,
200
,
index
);
this
.
updateViewHeaders
();
this
.
updateTitleArea
();
}
removeView
(
panel
:
ViewletPanel
):
void
{
const
index
=
firstIndex
(
this
.
panelItems
,
i
=>
i
.
panel
===
panel
);
if
(
index
===
-
1
)
{
return
;
}
if
(
this
.
lastFocusedPanel
===
panel
)
{
this
.
lastFocusedPanel
=
undefined
;
}
this
.
panelview
.
removePanel
(
panel
);
const
[
panelItem
]
=
this
.
panelItems
.
splice
(
index
,
1
);
panelItem
.
disposable
.
dispose
();
this
.
updateViewHeaders
();
this
.
updateTitleArea
();
}
private
updateViewHeaders
():
void
{
if
(
this
.
isSingleView
)
{
this
.
panelItems
[
0
].
panel
.
headerVisible
=
false
;
}
else
{
this
.
panelItems
.
forEach
(
i
=>
i
.
panel
.
headerVisible
=
true
);
}
}
dispose
():
void
{
super
.
dispose
();
this
.
panelItems
.
forEach
(
i
=>
i
.
disposable
.
dispose
());
this
.
panelview
.
dispose
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录