parent
9894722051
commit
3142c5aa60
|
|
@ -36,6 +36,9 @@ class SurfaceScrollView: NSView {
|
||||||
scrollView.usesPredominantAxisScrolling = true
|
scrollView.usesPredominantAxisScrolling = true
|
||||||
// hide default background to show blur effect properly
|
// hide default background to show blur effect properly
|
||||||
scrollView.drawsBackground = false
|
scrollView.drawsBackground = false
|
||||||
|
// don't let the content view clip it's subviews, to enable the
|
||||||
|
// surface to draw the background behind non-overlay scrollers
|
||||||
|
scrollView.contentView.clipsToBounds = false
|
||||||
|
|
||||||
// The document view is what the scrollview is actually going
|
// The document view is what the scrollview is actually going
|
||||||
// to be directly scrolling. We set it up to a "blank" NSView
|
// to be directly scrolling. We set it up to a "blank" NSView
|
||||||
|
|
@ -142,6 +145,11 @@ class SurfaceScrollView: NSView {
|
||||||
|
|
||||||
// Fill entire bounds with scroll view
|
// Fill entire bounds with scroll view
|
||||||
scrollView.frame = bounds
|
scrollView.frame = bounds
|
||||||
|
surfaceView.frame.size = scrollView.bounds.size
|
||||||
|
|
||||||
|
// We only set the width of the documentView here, as the height depends
|
||||||
|
// on the scrollbar state and is updated in synchronizeScrollView
|
||||||
|
documentView.frame.size.width = scrollView.bounds.width
|
||||||
|
|
||||||
// When our scrollview changes make sure our scroller and surface views are synchronized
|
// When our scrollview changes make sure our scroller and surface views are synchronized
|
||||||
synchronizeScrollView()
|
synchronizeScrollView()
|
||||||
|
|
@ -175,20 +183,13 @@ class SurfaceScrollView: NSView {
|
||||||
/// so the renderer only needs to render what's currently on screen.
|
/// so the renderer only needs to render what's currently on screen.
|
||||||
private func synchronizeSurfaceView() {
|
private func synchronizeSurfaceView() {
|
||||||
let visibleRect = scrollView.contentView.documentVisibleRect
|
let visibleRect = scrollView.contentView.documentVisibleRect
|
||||||
surfaceView.frame = visibleRect
|
surfaceView.frame.origin = visibleRect.origin
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sizes the document view and scrolls the content view according to the scrollbar state
|
/// Sizes the document view and scrolls the content view according to the scrollbar state
|
||||||
private func synchronizeScrollView() {
|
private func synchronizeScrollView() {
|
||||||
// We adjust the document height first, as the content width may depend on it.
|
// Update the document height to give our scroller the correct proportions
|
||||||
documentView.frame.size.height = documentHeight()
|
documentView.frame.size.height = documentHeight()
|
||||||
|
|
||||||
// Our width should be the content width to account for visible scrollers.
|
|
||||||
// We don't do horizontal scrolling in terminals. The surfaceView width is
|
|
||||||
// yoked to the document width (this is distinct from the content width
|
|
||||||
// passed to surfaceView.sizeDidChange, which is only updated on layout).
|
|
||||||
documentView.frame.size.width = scrollView.contentSize.width
|
|
||||||
surfaceView.frame.size.width = scrollView.contentSize.width
|
|
||||||
|
|
||||||
// Only update our actual scroll position if we're not actively scrolling.
|
// Only update our actual scroll position if we're not actively scrolling.
|
||||||
if !isLiveScrolling {
|
if !isLiveScrolling {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue