feat: add custom cursor support for classic skins
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -53,6 +53,9 @@ class AppDelegate: FlutterAppDelegate {
|
||||
|
||||
private var _winampChannel: FlutterMethodChannel?
|
||||
|
||||
/// Custom cursors registered by the Dart side, keyed by skin cursor name.
|
||||
private var cursors: [String: NSCursor] = [:]
|
||||
|
||||
private func handleMethodCall(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "setAlwaysOnTop":
|
||||
@@ -81,6 +84,25 @@ class AppDelegate: FlutterAppDelegate {
|
||||
setUiScaleMenuState(scale)
|
||||
}
|
||||
result(nil)
|
||||
case "registerCursor":
|
||||
if let args = call.arguments as? [String: Any],
|
||||
let name = args["name"] as? String,
|
||||
let pngData = (args["png"] as? FlutterStandardTypedData)?.data,
|
||||
let image = NSImage(data: pngData) {
|
||||
let hotX = args["hotspotX"] as? Int ?? 0
|
||||
let hotY = args["hotspotY"] as? Int ?? 0
|
||||
cursors[name] = NSCursor(image: image, hotSpot: NSPoint(x: hotX, y: hotY))
|
||||
}
|
||||
result(nil)
|
||||
case "setCursor":
|
||||
if let args = call.arguments as? [String: Any], let name = args["name"] as? String {
|
||||
if let cursor = cursors[name] {
|
||||
cursor.set()
|
||||
} else {
|
||||
NSCursor.arrow.set()
|
||||
}
|
||||
}
|
||||
result(nil)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user