Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
85278013
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
85278013
编写于
6月 19, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
centeredView: store ratios and restore them properly
上级
906007ff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
11 deletion
+46
-11
src/vs/base/browser/ui/centered/centeredViewLayout.ts
src/vs/base/browser/ui/centered/centeredViewLayout.ts
+40
-10
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+6
-1
未找到文件。
src/vs/base/browser/ui/centered/centeredViewLayout.ts
浏览文件 @
85278013
...
...
@@ -5,39 +5,59 @@
import
'
vs/css!./centeredViewLayout
'
;
import
{
SplitView
,
Sizing
,
Orientation
,
ISplitViewStyles
,
IView
as
ISplitViewView
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
import
{
SplitView
,
Orientation
,
ISplitViewStyles
,
IView
as
ISplitViewView
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
import
{
$
}
from
'
vs/base/browser/dom
'
;
import
{
Event
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
Event
,
mapEvent
,
anyEvent
}
from
'
vs/base/common/event
'
;
import
{
IView
}
from
'
vs/base/browser/ui/grid/gridview
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
function
toSplitViewView
(
view
:
IView
,
getHeight
:
()
=>
number
):
ISplitViewView
{
return
{
element
:
view
.
element
,
maximumSize
:
view
.
maximumWidth
,
minimumSize
:
view
.
minimumWidth
,
onDidChange
:
mapEvent
(
view
.
onDidChange
,
widthAndHeight
=>
widthAndHeight
?
widthAndHeight
.
width
:
0
),
onDidChange
:
mapEvent
(
view
.
onDidChange
,
widthAndHeight
=>
widthAndHeight
&&
widthAndHeight
.
width
),
layout
:
size
=>
view
.
layout
(
size
,
getHeight
())
};
}
export
interface
CenteredViewState
{
leftMarginRatio
:
number
;
rightMarginRatio
:
number
;
}
const
GOLDEN_RATIO
=
{
leftMarginRatio
:
0.1909
,
rightMarginRatio
:
0.1909
};
export
class
CenteredViewLayout
{
private
splitView
:
SplitView
;
private
element
:
HTMLElement
;
private
height
:
number
;
private
width
:
number
=
0
;
private
height
:
number
=
0
;
private
style
:
ISplitViewStyles
;
private
didLayout
=
false
;
private
splitViewDisposable
:
IDisposable
[]
=
[];
constructor
(
private
container
:
HTMLElement
,
private
view
:
IView
)
{
constructor
(
private
container
:
HTMLElement
,
private
view
:
IView
,
public
readonly
state
:
CenteredViewState
=
GOLDEN_RATIO
)
{
this
.
container
.
appendChild
(
this
.
view
.
element
);
}
layout
(
width
:
number
,
height
:
number
):
void
{
this
.
width
=
width
;
this
.
height
=
height
;
if
(
this
.
splitView
)
{
this
.
splitView
.
layout
(
width
);
if
(
!
this
.
didLayout
)
{
this
.
splitView
.
resizeView
(
0
,
this
.
state
.
leftMarginRatio
*
this
.
width
);
this
.
splitView
.
resizeView
(
2
,
this
.
state
.
rightMarginRatio
*
this
.
width
);
}
}
else
{
this
.
view
.
layout
(
width
,
height
);
}
this
.
didLayout
=
true
;
}
isActive
():
boolean
{
...
...
@@ -54,8 +74,9 @@ export class CenteredViewLayout {
resetView
(
view
:
IView
):
void
{
this
.
view
=
view
;
if
(
this
.
splitView
)
{
const
size
=
this
.
splitView
.
getViewSize
(
1
);
this
.
splitView
.
removeView
(
1
);
this
.
splitView
.
addView
(
toSplitViewView
(
this
.
view
,
()
=>
this
.
height
),
Sizing
.
Distribut
e
,
1
);
this
.
splitView
.
addView
(
toSplitViewView
(
this
.
view
,
()
=>
this
.
height
),
siz
e
,
1
);
this
.
splitView
.
distributeViewSizes
();
}
}
...
...
@@ -75,18 +96,27 @@ export class CenteredViewLayout {
styles
:
this
.
style
});
const
onDidSizesChange
=
anyEvent
(
this
.
splitView
.
onDidSashChange
,
this
.
splitView
.
onDidSashReset
);
this
.
splitViewDisposable
.
push
(
onDidSizesChange
(()
=>
{
this
.
state
.
leftMarginRatio
=
this
.
splitView
.
getViewSize
(
0
)
/
this
.
width
;
this
.
state
.
rightMarginRatio
=
this
.
splitView
.
getViewSize
(
2
)
/
this
.
width
;
}));
this
.
splitView
.
layout
(
this
.
width
);
const
getEmptyView
=
()
=>
({
element
:
$
(
'
.centered-layout-margin
'
),
layout
:
()
=>
undefined
,
minimumSize
:
2
0
,
minimumSize
:
4
0
,
maximumSize
:
Number
.
POSITIVE_INFINITY
,
onDidChange
:
Event
.
None
});
this
.
splitView
.
addView
(
getEmptyView
(),
Sizing
.
Distribute
);
this
.
splitView
.
addView
(
toSplitViewView
(
this
.
view
,
()
=>
this
.
height
),
Sizing
.
Distribute
);
this
.
splitView
.
addView
(
getEmptyView
(),
Sizing
.
Distribute
);
this
.
splitView
.
addView
(
toSplitViewView
(
this
.
view
,
()
=>
this
.
height
),
0
);
this
.
splitView
.
addView
(
getEmptyView
(),
this
.
state
.
leftMarginRatio
*
this
.
width
,
0
);
this
.
splitView
.
addView
(
getEmptyView
(),
this
.
state
.
rightMarginRatio
*
this
.
width
,
2
);
}
else
{
this
.
splitViewDisposable
=
dispose
(
this
.
splitViewDisposable
);
this
.
splitView
.
dispose
();
this
.
splitView
=
undefined
;
this
.
container
.
removeChild
(
this
.
element
);
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
85278013
...
...
@@ -48,6 +48,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
_serviceBrand
:
any
;
private
static
readonly
EDITOR_PART_UI_STATE_STORAGE_KEY
=
'
editorpart.state
'
;
private
static
readonly
EDITOR_PART_CENTERED_VIEW_STORAGE_KEY
=
'
editorpart.centeredview
'
;
//#region Events
...
...
@@ -79,6 +80,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
private
_preferredSize
:
Dimension
;
private
memento
:
object
;
private
globalMemento
:
object
;
private
_partOptions
:
IEditorPartOptions
;
private
_activeGroup
:
IEditorGroupView
;
...
...
@@ -109,6 +112,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
this
.
_partOptions
=
getEditorPartOptions
(
this
.
configurationService
.
getValue
<
IWorkbenchEditorConfiguration
>
());
this
.
memento
=
this
.
getMemento
(
this
.
storageService
,
Scope
.
WORKSPACE
);
this
.
globalMemento
=
this
.
getMemento
(
this
.
storageService
,
Scope
.
GLOBAL
);
this
.
_whenRestored
=
new
TPromise
(
resolve
=>
{
this
.
whenRestoredComplete
=
resolve
;
...
...
@@ -716,7 +720,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
// Grid control with center layout
this
.
doCreateGridControl
();
this
.
centeredViewLayout
=
new
CenteredViewLayout
(
this
.
container
,
this
.
getGridAsView
());
this
.
centeredViewLayout
=
new
CenteredViewLayout
(
this
.
container
,
this
.
getGridAsView
()
,
this
.
globalMemento
[
EditorPart
.
EDITOR_PART_CENTERED_VIEW_STORAGE_KEY
]
);
// Drop support
this
.
_register
(
this
.
instantiationService
.
createInstance
(
EditorDropTarget
,
this
,
this
.
container
));
...
...
@@ -1020,6 +1024,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
this
.
memento
[
EditorPart
.
EDITOR_PART_UI_STATE_STORAGE_KEY
]
=
uiState
;
}
}
this
.
globalMemento
[
EditorPart
.
EDITOR_PART_CENTERED_VIEW_STORAGE_KEY
]
=
this
.
centeredViewLayout
.
state
;
// Forward to all groups
this
.
groupViews
.
forEach
(
group
=>
group
.
shutdown
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录