Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion LYTabBarView Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class ViewController: NSViewController {
addViewWithLabel("View", aTabBarView: self.tabBarView, fromTabView: true)
self.tabBarView.minTabHeight = 28
self.tabBarView.minTabItemWidth = 120


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 3. (vertical_whitespace)

tabView21.tabBarView.hideIfOnlyOneTabExists = false
tabView22.tabBarView.hideIfOnlyOneTabExists = false
tabView23.tabBarView.hideIfOnlyOneTabExists = false
Expand All @@ -48,6 +50,10 @@ class ViewController: NSViewController {
tabBarView?.addNewTabButtonAction = #selector(addNewTab)
}
self.tabBarView.addNewTabButtonTarget = self

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

self.tabBarView.showCloseButton = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)
Vertical Whitespace Violation: Limit vertical whitespace to a single empty line. Currently 2. (vertical_whitespace)

}

override func viewWillAppear() {
Expand Down
2 changes: 1 addition & 1 deletion LYTabView/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.27</string>
<string>0.28</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
38 changes: 37 additions & 1 deletion LYTabView/LYTabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class LYTabBarView: NSView {
public var needAnimation: Bool = true
public var isActive: Bool = true {
didSet {

self.needsDisplay = true
for view in self.tabItemViews() {
view.updateColors()
Expand Down Expand Up @@ -100,6 +99,8 @@ public class LYTabBarView: NSView {
resetHeight()
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var showCloseButton: Bool = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)


var status: BarStatus {
let isWindowActive = self.isWindowActive
Expand Down Expand Up @@ -129,6 +130,33 @@ public class LYTabBarView: NSView {
.windowInactive: NSColor(white: 0.86, alpha: 1),
.inactive: NSColor(white: 0.71, alpha: 1)
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var backgroundItemColor: ColorConfig = [
.active: NSColor(white: 0.77, alpha: 1),
.windowInactive: NSColor(white: 0.86, alpha: 1),
.inactive: NSColor(white: 0.70, alpha: 1)
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var hoverItemBackgroundColor: ColorConfig = [
.active: NSColor(white: 0.75, alpha: 1),
.windowInactive: NSColor(white: 0.94, alpha: 1),
.inactive: NSColor(white: 0.68, alpha: 1)
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var selectedBackgroundColor: ColorConfig = [
.active: NSColor(white: 0.86, alpha: 1),
.windowInactive: NSColor(white: 0.96, alpha: 1),
.inactive: NSColor(white: 0.76, alpha: 1)
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var selectedTextColor: ColorConfig = [
.active: NSColor.textColor,
.windowInactive: NSColor(white: 0.4, alpha: 1),
.inactive: NSColor(white: 0.4, alpha: 1)
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

public var unselectedForegroundColor = NSColor(white: 0.4, alpha: 1)
public var closeButtonHoverBackgroundColor = NSColor(white: 0.55, alpha: 0.3)

public var showAddNewTabButton: Bool = true {
didSet {
Expand Down Expand Up @@ -564,6 +592,14 @@ public class LYTabBarView: NSView {
private func createLYTabItemView(_ item: NSTabViewItem) -> LYTabItemView {
let tabItemView = LYTabItemView(tabViewItem: item)
tabItemView.tabBarView = self
tabItemView.showCloseButton = self.showCloseButton
tabItemView.backgroundColor = self.backgroundColor
tabItemView.hoverBackgroundColor = self.hoverItemBackgroundColor
tabItemView.selectedTextColor = self.selectedTextColor
tabItemView.selectedBackgroundColor = self.selectedBackgroundColor
tabItemView.unselectedForegroundColor = self.unselectedForegroundColor
tabItemView.closeButtonHoverBackgroundColor = self.closeButtonHoverBackgroundColor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

tabItemView.translatesAutoresizingMaskIntoConstraints = false
tabItemView.setContentCompressionResistancePriority(NSLayoutConstraint.Priority.defaultLow, for: .horizontal)
return tabItemView
Expand Down
8 changes: 5 additions & 3 deletions LYTabView/LYTabItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class LYTabItemView: NSButton {
fileprivate let titleView = NSTextField(frame: .zero)
fileprivate var closeButton: LYHoverButton!

public var showCloseButton: Bool = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)

var tabBarView: LYTabBarView!
var tabLabelObserver: NSKeyValueObservation?
var tabViewItem: NSTabViewItem? {
Expand All @@ -35,7 +37,7 @@ class LYTabItemView: NSButton {
var ypadding: CGFloat = 2
var closeButtonSize = NSSize(width: 16, height: 16)
var backgroundColor: ColorConfig = [
.active: NSColor(white: 0.77, alpha: 1),
.active: NSColor(white: 0.07, alpha: 1),
.windowInactive: NSColor(white: 0.94, alpha: 1),
.inactive: NSColor(white: 0.70, alpha: 1)
]
Expand Down Expand Up @@ -248,7 +250,7 @@ class LYTabItemView: NSButton {
if !shouldDrawInHighLight {
self.animatorOrNot(needAnimation).realBackgroundColor = hoverBackgroundColor[status]!
}
closeButton.animatorOrNot(needAnimation).isHidden = false
closeButton.animatorOrNot(needAnimation).isHidden = !showCloseButton
}

override func mouseExited(with theEvent: NSEvent) {
Expand Down Expand Up @@ -382,7 +384,7 @@ extension LYTabItemView: NSDraggingSource {
func draggingSession(_ session: NSDraggingSession, endedAt screenPoint: NSPoint, operation: NSDragOperation) {
dragOffset = nil
isDragging = false
closeButton.isHidden = false
closeButton.isHidden = !showCloseButton
self.titleView.isHidden = false
self.draggingView?.removeFromSuperview()
self.draggingViewLeadingConstraint = nil
Expand Down