-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate gutter separator view from STGutterView
- Extract logic for drawing the gutter separator into a dedicated STGutterSeparatorView class. This allows the separator view to handle its own drawing and configuration. - Make the gutter separator view a subview of STGutterView, similar to the existing container view and marker container view. - Update properties on STGutterView to pass through to the underlying STGutterSeparatorView instance. - Insert the background effect view as the first subview of STGutterView, below the other subviews, instead of relative to self.
- Loading branch information
1 parent
a85d9ed
commit 773da40
Showing
2 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
Sources/STTextViewAppKit/Gutter/STGutterSeparatorView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Created by Marcin Krzyzanowski | ||
// https://github.com/krzyzanowskim/STTextView/blob/main/LICENSE.md | ||
|
||
import Cocoa | ||
|
||
class STGutterSeparatorView: NSView { | ||
@Invalidating(.display) | ||
var drawSeparator: Bool = true | ||
|
||
@Invalidating(.display) | ||
var separatorColor = NSColor.separatorColor.withAlphaComponent(0.1) | ||
|
||
override var isFlipped: Bool { | ||
true | ||
} | ||
|
||
override func draw(_ rect: CGRect) { | ||
super.draw(rect) | ||
|
||
guard let context = NSGraphicsContext.current?.cgContext else { | ||
return | ||
} | ||
|
||
if drawSeparator { | ||
context.setLineWidth(1) | ||
context.setStrokeColor(separatorColor.cgColor) | ||
context.addLines(between: [CGPoint(x: frame.width - 0.5, y: 0), CGPoint(x: frame.width - 0.5, y: bounds.maxY) ]) | ||
context.strokePath() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters