mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
- add toolTip to widget selector
- update toolTip in main settings menu
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user