- add toolTip to widget selector

- update toolTip in main settings menu
This commit is contained in:
Serhiy Mytrovtsiy
2020-07-23 16:22:10 +02:00
parent ea90a901f9
commit 53ee554380
3 changed files with 18 additions and 1 deletions

View File

@@ -254,6 +254,8 @@ class WidgetPreview: NSView {
self.layer?.borderColor = self.state ? NSColor.systemBlue.cgColor : NSColor(hexString: "#dddddd").cgColor
self.layer?.borderWidth = 1
self.toolTip = "Select \(widget.name) widget"
widget.widthHandler = { [weak self] value in
self?.removeTrackingArea((self?.trackingAreas.first)!)
let newWidth = value + 1

View File

@@ -65,6 +65,7 @@ public enum widget_t: String {
extension widget_t: CaseIterable {}
public protocol Widget_p: NSView {
var name: String { get }
var title: String { get }
var preview: Bool { get }
var type: widget_t { get }
@@ -76,6 +77,20 @@ public protocol Widget_p: NSView {
open class Widget: NSView, Widget_p {
public var widthHandler: ((CGFloat) -> Void)? = nil
public var name: String {
get {
switch self.type {
case .mini: return "Mini"
case .lineChart: return "Line chart"
case .barChart: return "Bar chart"
case .network: return "Network"
case .battery: return "Battery"
case .sensors: return "Text"
case .disk: return "Text"
default: return ""
}
}
}
public var title: String = ""
public var preview: Bool = false
public var type: widget_t = .unknown

View File

@@ -300,7 +300,7 @@ private class MenuView: NSView {
super.init(frame: NSRect(x: 0, y: self.height*CGFloat(n), width: width, height: self.height))
self.wantsLayer = true
self.layer?.backgroundColor = .clear
self.toolTip = "Open \(title == "Stats" ? "application" : title) settings"
self.toolTip = "Open \(title == "Stats" ? "application" : "\(title) module") settings"
let rect = NSRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
let trackingArea = NSTrackingArea(rect: rect, options: [NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.mouseEnteredAndExited, NSTrackingArea.Options.activeInActiveApp], owner: self, userInfo: ["menu": title])