Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c157937b
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,发现更多精彩内容 >>
提交
c157937b
编写于
12月 02, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#16394 Move VSash to sash.ts
上级
10babbbc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
94 addition
and
93 deletion
+94
-93
src/vs/base/browser/ui/sash/sash.ts
src/vs/base/browser/ui/sash/sash.ts
+92
-2
src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
+2
-91
未找到文件。
src/vs/base/browser/ui/sash/sash.ts
浏览文件 @
c157937b
...
...
@@ -6,8 +6,8 @@
'
use strict
'
;
import
'
vs/css!./sash
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
{
IDisposable
,
Disposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Builder
,
$
,
Dimension
}
from
'
vs/base/browser/builder
'
;
import
{
isIPad
}
from
'
vs/base/browser/browser
'
;
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
...
...
@@ -15,6 +15,7 @@ import DOM = require('vs/base/browser/dom');
import
{
Gesture
,
EventType
,
GestureEvent
}
from
'
vs/base/browser/touch
'
;
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
export
interface
ISashLayoutProvider
{
}
...
...
@@ -276,3 +277,92 @@ export class Sash extends EventEmitter {
super
.
dispose
();
}
}
/**
* A simple Vertical Sash that computes the position of the sash when it is moved between the given dimension.
* Triggers onPositionChange event when the position is changed
*/
export
class
VSash
extends
Disposable
implements
IVerticalSashLayoutProvider
{
private
sash
:
Sash
;
private
ratio
:
number
;
private
startPosition
:
number
;
private
position
:
number
;
private
dimension
:
Dimension
;
private
_onPositionChange
:
Emitter
<
number
>
=
new
Emitter
<
number
>
();
public
get
onPositionChange
():
Event
<
number
>
{
return
this
.
_onPositionChange
.
event
;
}
constructor
(
container
:
HTMLElement
,
private
minWidth
)
{
super
();
this
.
ratio
=
0.5
;
this
.
sash
=
new
Sash
(
container
,
this
);
this
.
_register
(
this
.
sash
.
addListener2
(
'
start
'
,
()
=>
this
.
onSashDragStart
()));
this
.
_register
(
this
.
sash
.
addListener2
(
'
change
'
,
(
e
:
ISashEvent
)
=>
this
.
onSashDrag
(
e
)));
this
.
_register
(
this
.
sash
.
addListener2
(
'
end
'
,
()
=>
this
.
onSashDragEnd
()));
this
.
_register
(
this
.
sash
.
addListener2
(
'
reset
'
,
()
=>
this
.
onSashReset
()));
}
public
getVerticalSashTop
():
number
{
return
0
;
}
public
getVerticalSashLeft
():
number
{
return
this
.
position
;
}
public
getVerticalSashHeight
():
number
{
return
this
.
dimension
.
height
;
}
public
setDimenesion
(
dimension
:
Dimension
)
{
this
.
dimension
=
dimension
;
this
.
compute
(
this
.
ratio
);
}
private
onSashDragStart
():
void
{
this
.
startPosition
=
this
.
position
;
}
private
onSashDrag
(
e
:
ISashEvent
):
void
{
this
.
compute
((
this
.
startPosition
+
(
e
.
currentX
-
e
.
startX
))
/
this
.
dimension
.
width
);
}
private
compute
(
ratio
:
number
)
{
this
.
computeSashPosition
(
ratio
);
this
.
ratio
=
this
.
position
/
this
.
dimension
.
width
;
this
.
_onPositionChange
.
fire
(
this
.
position
);
}
private
onSashDragEnd
():
void
{
this
.
sash
.
layout
();
}
private
onSashReset
():
void
{
this
.
ratio
=
0.5
;
this
.
_onPositionChange
.
fire
(
this
.
position
);
this
.
sash
.
layout
();
}
private
computeSashPosition
(
sashRatio
:
number
=
this
.
ratio
)
{
let
contentWidth
=
this
.
dimension
.
width
;
let
sashPosition
=
Math
.
floor
((
sashRatio
||
0.5
)
*
contentWidth
);
let
midPoint
=
Math
.
floor
(
0.5
*
contentWidth
);
if
(
contentWidth
>
this
.
minWidth
*
2
)
{
if
(
sashPosition
<
this
.
minWidth
)
{
sashPosition
=
this
.
minWidth
;
}
if
(
sashPosition
>
contentWidth
-
this
.
minWidth
)
{
sashPosition
=
contentWidth
-
this
.
minWidth
;
}
}
else
{
sashPosition
=
midPoint
;
}
if
(
this
.
position
!==
sashPosition
)
{
this
.
position
=
sashPosition
;
this
.
sash
.
layout
();
}
}
}
\ No newline at end of file
src/vs/workbench/browser/parts/editor/sideBySideEditor.ts
浏览文件 @
c157937b
...
...
@@ -6,16 +6,14 @@
import
'
vs/css!./media/sidebysideEditor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
{
Dimension
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
,
EditorInput
,
EditorOptions
,
SideBySideEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseEditor
,
EditorDescriptor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
IEditorControl
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Sash
,
ISashEvent
,
IVerticalSashLayoutProvider
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
VSash
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -134,7 +132,7 @@ export class SideBySideEditor extends BaseEditor {
}
private
createSash
(
parentElement
:
HTMLElement
):
void
{
this
.
sash
=
this
.
_register
(
new
VSash
(
parentElement
));
this
.
sash
=
this
.
_register
(
new
VSash
(
parentElement
,
220
));
this
.
_register
(
this
.
sash
.
onPositionChange
(
position
=>
this
.
dolayout
(
position
)));
}
...
...
@@ -176,91 +174,4 @@ export class SideBySideEditor extends BaseEditor {
this
.
masterEditorContainer
=
null
;
}
}
}
class
VSash
extends
Disposable
implements
IVerticalSashLayoutProvider
{
private
static
MINIMUM_EDITOR_WIDTH
=
220
;
private
sash
:
Sash
;
private
ratio
:
number
;
private
startPosition
:
number
;
private
position
:
number
;
private
dimension
:
Dimension
;
private
_onPositionChange
:
Emitter
<
number
>
=
new
Emitter
<
number
>
();
public
get
onPositionChange
():
Event
<
number
>
{
return
this
.
_onPositionChange
.
event
;
}
constructor
(
container
:
HTMLElement
)
{
super
();
this
.
ratio
=
0.5
;
this
.
sash
=
new
Sash
(
container
,
this
);
this
.
_register
(
this
.
sash
.
addListener2
(
'
start
'
,
()
=>
this
.
onSashDragStart
()));
this
.
_register
(
this
.
sash
.
addListener2
(
'
change
'
,
(
e
:
ISashEvent
)
=>
this
.
onSashDrag
(
e
)));
this
.
_register
(
this
.
sash
.
addListener2
(
'
end
'
,
()
=>
this
.
onSashDragEnd
()));
this
.
_register
(
this
.
sash
.
addListener2
(
'
reset
'
,
()
=>
this
.
onSashReset
()));
}
public
getVerticalSashTop
():
number
{
return
0
;
}
public
getVerticalSashLeft
():
number
{
return
this
.
position
;
}
public
getVerticalSashHeight
():
number
{
return
this
.
dimension
.
height
;
}
public
setDimenesion
(
dimension
:
Dimension
)
{
this
.
dimension
=
dimension
;
this
.
compute
(
this
.
ratio
);
}
private
onSashDragStart
():
void
{
this
.
startPosition
=
this
.
position
;
}
private
onSashDrag
(
e
:
ISashEvent
):
void
{
this
.
compute
((
this
.
startPosition
+
(
e
.
currentX
-
e
.
startX
))
/
this
.
dimension
.
width
);
}
private
compute
(
ratio
:
number
)
{
this
.
computeSashPosition
(
ratio
);
this
.
ratio
=
this
.
position
/
this
.
dimension
.
width
;
this
.
_onPositionChange
.
fire
(
this
.
position
);
}
private
onSashDragEnd
():
void
{
this
.
sash
.
layout
();
}
private
onSashReset
():
void
{
this
.
ratio
=
0.5
;
this
.
_onPositionChange
.
fire
(
this
.
position
);
this
.
sash
.
layout
();
}
private
computeSashPosition
(
sashRatio
:
number
=
this
.
ratio
)
{
let
contentWidth
=
this
.
dimension
.
width
;
let
sashPosition
=
Math
.
floor
((
sashRatio
||
0.5
)
*
contentWidth
);
let
midPoint
=
Math
.
floor
(
0.5
*
contentWidth
);
if
(
contentWidth
>
VSash
.
MINIMUM_EDITOR_WIDTH
*
2
)
{
if
(
sashPosition
<
VSash
.
MINIMUM_EDITOR_WIDTH
)
{
sashPosition
=
VSash
.
MINIMUM_EDITOR_WIDTH
;
}
if
(
sashPosition
>
contentWidth
-
VSash
.
MINIMUM_EDITOR_WIDTH
)
{
sashPosition
=
contentWidth
-
VSash
.
MINIMUM_EDITOR_WIDTH
;
}
}
else
{
sashPosition
=
midPoint
;
}
if
(
this
.
position
!==
sashPosition
)
{
this
.
position
=
sashPosition
;
this
.
sash
.
layout
();
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录