Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6343e0cc
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,发现更多精彩内容 >>
提交
6343e0cc
编写于
2月 21, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EditorScrollbar is a ViewPart
上级
99e72ce9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
98 addition
and
50 deletion
+98
-50
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+4
-7
src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts
...itor/browser/viewParts/editorScrollbar/editorScrollbar.ts
+94
-43
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
6343e0cc
...
...
@@ -130,8 +130,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
// - line heights updating & co.
this
.
layoutProvider
=
new
LayoutProvider
(
configuration
,
model
.
getLineCount
(),
this
.
eventDispatcher
);
this
.
_scrollbar
=
new
EditorScrollbar
(
this
.
layoutProvider
.
getScrollable
(),
configuration
,
this
.
linesContent
,
this
.
domNode
,
this
.
overflowGuardContainer
);
// The view context is passed on to most classes (basically to reduce param. counts in ctors)
this
.
_context
=
new
ViewContext
(
configuration
,
model
,
this
.
eventDispatcher
);
...
...
@@ -217,6 +215,9 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
private
createViewParts
():
void
{
this
.
viewParts
=
[];
this
.
_scrollbar
=
new
EditorScrollbar
(
this
.
_context
,
this
.
layoutProvider
.
getScrollable
(),
this
.
linesContent
,
this
.
domNode
,
this
.
overflowGuardContainer
);
this
.
viewParts
.
push
(
this
.
_scrollbar
);
// View Lines
this
.
viewLines
=
new
ViewLines
(
this
.
_context
,
this
.
layoutProvider
);
...
...
@@ -547,13 +548,12 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this
.
viewLines
.
dispose
();
// Destroy
IViewPart second
// Destroy
view parts
for
(
let
i
=
0
,
len
=
this
.
viewParts
.
length
;
i
<
len
;
i
++
)
{
this
.
viewParts
[
i
].
dispose
();
}
this
.
viewParts
=
[];
this
.
_scrollbar
.
dispose
();
this
.
layoutProvider
.
dispose
();
}
...
...
@@ -921,9 +921,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
viewPart
.
render
(
renderingContext
);
viewPart
.
onDidRender
();
}
// Render the scrollbar
this
.
_scrollbar
.
renderScrollbar
();
}
private
_setHasFocus
(
newHasFocus
:
boolean
):
void
{
...
...
src/vs/editor/browser/viewParts/editorScrollbar/editorScrollbar.ts
浏览文件 @
6343e0cc
...
...
@@ -8,70 +8,56 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
ScrollableElementCreationOptions
,
ScrollableElementChangeOptions
}
from
'
vs/base/browser/ui/scrollbar/scrollableElementOptions
'
;
import
{
IOverviewRulerLayoutInfo
,
ScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
I
Configuration
,
IConfigurationChangedEvent
,
I
NewScrollPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
INewScrollPosition
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ClassNames
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
PartFingerprint
,
PartFingerprints
}
from
'
vs/editor/browser/view/viewPart
'
;
import
{
ViewPart
,
PartFingerprint
,
PartFingerprints
}
from
'
vs/editor/browser/view/viewPart
'
;
import
{
Scrollable
}
from
'
vs/base/common/scrollable
'
;
import
{
ViewContext
}
from
'
vs/editor/common/view/viewContext
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IRenderingContext
,
IRestrictedRenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
function
addPropertyIfPresent
(
src
:
any
,
dst
:
any
,
prop
:
string
):
void
{
if
(
src
.
hasOwnProperty
(
prop
))
{
dst
[
prop
]
=
src
[
prop
];
}
}
export
class
EditorScrollbar
implements
IDisposable
{
export
class
EditorScrollbar
extends
ViewPart
{
private
scrollable
:
Scrollable
;
private
configuration
:
IConfiguration
;
private
toDispose
:
IDisposable
[];
private
linesContent
:
HTMLElement
;
private
scrollbar
:
ScrollableElement
;
constructor
(
scrollable
:
Scrollable
,
configuration
:
IConfiguration
,
linesContent
:
HTMLElement
,
viewDomNode
:
HTMLElement
,
overflowGuardDomNode
:
HTMLElement
)
{
constructor
(
context
:
ViewContext
,
scrollable
:
Scrollable
,
linesContent
:
HTMLElement
,
viewDomNode
:
HTMLElement
,
overflowGuardDomNode
:
HTMLElement
)
{
super
(
context
);
this
.
toDispose
=
[];
this
.
scrollable
=
scrollable
;
this
.
configuration
=
configuration
;
this
.
linesContent
=
linesContent
;
let
configScrollbarOpts
=
this
.
configuration
.
editor
.
viewInfo
.
scrollbar
;
const
viewInfo
=
this
.
_context
.
configuration
.
editor
.
viewInfo
;
const
configScrollbarOpts
=
viewInfo
.
scrollbar
;
let
scrollbarOptions
:
ScrollableElementCreationOptions
=
{
canUseTranslate3d
:
this
.
configuration
.
editor
.
viewInfo
.
canUseTranslate3d
,
canUseTranslate3d
:
viewInfo
.
canUseTranslate3d
,
listenOnDomNode
:
viewDomNode
,
className
:
ClassNames
.
SCROLLABLE_ELEMENT
+
'
'
+
viewInfo
.
theme
,
useShadows
:
false
,
lazyRender
:
true
,
vertical
:
configScrollbarOpts
.
vertical
,
horizontal
:
configScrollbarOpts
.
horizontal
,
className
:
ClassNames
.
SCROLLABLE_ELEMENT
+
'
'
+
this
.
configuration
.
editor
.
viewInfo
.
theme
,
useShadows
:
false
,
lazyRender
:
true
verticalHasArrows
:
configScrollbarOpts
.
verticalHasArrows
,
horizontalHasArrows
:
configScrollbarOpts
.
horizontalHasArrows
,
verticalScrollbarSize
:
configScrollbarOpts
.
verticalScrollbarSize
,
verticalSliderSize
:
configScrollbarOpts
.
verticalSliderSize
,
horizontalScrollbarSize
:
configScrollbarOpts
.
horizontalScrollbarSize
,
horizontalSliderSize
:
configScrollbarOpts
.
horizontalSliderSize
,
handleMouseWheel
:
configScrollbarOpts
.
handleMouseWheel
,
arrowSize
:
configScrollbarOpts
.
arrowSize
,
mouseWheelScrollSensitivity
:
configScrollbarOpts
.
mouseWheelScrollSensitivity
,
};
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
verticalHasArrows
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
horizontalHasArrows
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
verticalScrollbarSize
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
verticalSliderSize
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
horizontalScrollbarSize
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
horizontalSliderSize
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
handleMouseWheel
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
arrowSize
'
);
addPropertyIfPresent
(
configScrollbarOpts
,
scrollbarOptions
,
'
mouseWheelScrollSensitivity
'
);
this
.
scrollbar
=
new
ScrollableElement
(
linesContent
,
scrollbarOptions
,
this
.
scrollable
);
PartFingerprints
.
write
(
this
.
scrollbar
.
getDomNode
(),
PartFingerprint
.
ScrollableElement
);
this
.
toDispose
.
push
(
this
.
scrollbar
);
this
.
toDispose
.
push
(
this
.
configuration
.
onDidChange
((
e
:
IConfigurationChangedEvent
)
=>
{
this
.
scrollbar
.
updateClassName
(
ClassNames
.
SCROLLABLE_ELEMENT
+
'
'
+
this
.
configuration
.
editor
.
viewInfo
.
theme
);
if
(
e
.
viewInfo
.
scrollbar
||
e
.
viewInfo
.
canUseTranslate3d
)
{
let
newOpts
:
ScrollableElementChangeOptions
=
{
canUseTranslate3d
:
this
.
configuration
.
editor
.
viewInfo
.
canUseTranslate3d
,
handleMouseWheel
:
this
.
configuration
.
editor
.
viewInfo
.
scrollbar
.
handleMouseWheel
,
mouseWheelScrollSensitivity
:
this
.
configuration
.
editor
.
viewInfo
.
scrollbar
.
mouseWheelScrollSensitivity
};
this
.
scrollbar
.
updateOptions
(
newOpts
);
}
}));
// When having a zone widget that calls .focus() on one of its dom elements,
// the browser will try desperately to reveal that dom node, unexpectedly
// changing the .scrollTop of this.linesContent
...
...
@@ -109,10 +95,6 @@ export class EditorScrollbar implements IDisposable {
this
.
toDispose
=
dispose
(
this
.
toDispose
);
}
public
renderScrollbar
():
void
{
this
.
scrollbar
.
renderNow
();
}
public
getOverviewRulerLayoutInfo
():
IOverviewRulerLayoutInfo
{
return
this
.
scrollbar
.
getOverviewRulerLayoutInfo
();
}
...
...
@@ -128,4 +110,73 @@ export class EditorScrollbar implements IDisposable {
public
getVerticalSliderVerticalCenter
():
number
{
return
this
.
scrollbar
.
getVerticalSliderVerticalCenter
();
}
// --- begin event handlers
public
onConfigurationChanged
(
e
:
viewEvents
.
ViewConfigurationChangedEvent
):
boolean
{
const
viewInfo
=
this
.
_context
.
configuration
.
editor
.
viewInfo
;
this
.
scrollbar
.
updateClassName
(
ClassNames
.
SCROLLABLE_ELEMENT
+
'
'
+
viewInfo
.
theme
);
if
(
e
.
viewInfo
.
scrollbar
||
e
.
viewInfo
.
canUseTranslate3d
)
{
let
newOpts
:
ScrollableElementChangeOptions
=
{
canUseTranslate3d
:
viewInfo
.
canUseTranslate3d
,
handleMouseWheel
:
viewInfo
.
scrollbar
.
handleMouseWheel
,
mouseWheelScrollSensitivity
:
viewInfo
.
scrollbar
.
mouseWheelScrollSensitivity
};
this
.
scrollbar
.
updateOptions
(
newOpts
);
}
return
true
;
}
public
onCursorPositionChanged
(
e
:
viewEvents
.
ViewCursorPositionChangedEvent
):
boolean
{
return
false
;
}
public
onCursorSelectionChanged
(
e
:
viewEvents
.
ViewCursorSelectionChangedEvent
):
boolean
{
return
false
;
}
public
onDecorationsChanged
(
e
:
viewEvents
.
ViewDecorationsChangedEvent
):
boolean
{
return
false
;
}
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
return
false
;
}
public
onFocusChanged
(
e
:
viewEvents
.
ViewFocusChangedEvent
):
boolean
{
return
false
;
}
public
onLineChanged
(
e
:
viewEvents
.
ViewLineChangedEvent
):
boolean
{
return
false
;
}
public
onLineMappingChanged
(
e
:
viewEvents
.
ViewLineMappingChangedEvent
):
boolean
{
return
false
;
}
public
onLinesDeleted
(
e
:
viewEvents
.
ViewLinesDeletedEvent
):
boolean
{
return
false
;
}
public
onLinesInserted
(
e
:
viewEvents
.
ViewLinesInsertedEvent
):
boolean
{
return
false
;
}
public
onRevealRangeRequest
(
e
:
viewEvents
.
ViewRevealRangeRequestEvent
):
boolean
{
return
false
;
}
public
onScrollChanged
(
e
:
viewEvents
.
ViewScrollChangedEvent
):
boolean
{
return
true
;
}
public
onScrollRequest
(
e
:
viewEvents
.
ViewScrollRequestEvent
):
boolean
{
return
false
;
}
public
onTokensChanged
(
e
:
viewEvents
.
ViewTokensChangedEvent
):
boolean
{
return
false
;
}
public
onZonesChanged
(
e
:
viewEvents
.
ViewZonesChangedEvent
):
boolean
{
return
false
;
}
// --- end event handlers
public
prepareRender
(
ctx
:
IRenderingContext
):
void
{
// Nothing to do
}
public
render
(
ctx
:
IRestrictedRenderingContext
):
void
{
this
.
scrollbar
.
renderNow
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录