-
Notifications
You must be signed in to change notification settings - Fork 17
Hide close button feature #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,9 @@ class ViewController: NSViewController { | |
| addViewWithLabel("View", aTabBarView: self.tabBarView, fromTabView: true) | ||
| self.tabBarView.minTabHeight = 28 | ||
| self.tabBarView.minTabItemWidth = 120 | ||
|
|
||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
| tabView21.tabBarView.hideIfOnlyOneTabExists = false | ||
| tabView22.tabBarView.hideIfOnlyOneTabExists = false | ||
| tabView23.tabBarView.hideIfOnlyOneTabExists = false | ||
|
|
@@ -48,6 +50,10 @@ class ViewController: NSViewController { | |
| tabBarView?.addNewTabButtonAction = #selector(addNewTab) | ||
| } | ||
| self.tabBarView.addNewTabButtonTarget = self | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace) |
||
| } | ||
|
|
||
| override func viewWillAppear() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
|
@@ -100,6 +99,8 @@ public class LYTabBarView: NSView { | |
| resetHeight() | ||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -129,6 +130,33 @@ public class LYTabBarView: NSView { | |
| .windowInactive: NSColor(white: 0.86, alpha: 1), | ||
| .inactive: NSColor(white: 0.71, alpha: 1) | ||
| ] | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| ] | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| ] | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| ] | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| ] | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
|
@@ -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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ class LYTabItemView: NSButton { | |
| fileprivate let titleView = NSTextField(frame: .zero) | ||
| fileprivate var closeButton: LYHoverButton! | ||
|
|
||
| public var showCloseButton: Bool = true | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? { | ||
|
|
@@ -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) | ||
| ] | ||
|
|
@@ -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) { | ||
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
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)