处理动画

This commit is contained in:
2026-02-09 04:07:32 +08:00
parent 85ed0946c8
commit 9822cf901d
5 changed files with 383 additions and 56 deletions

View File

@@ -1,5 +1,11 @@
package utils
import (
"fmt"
"github.com/progrium/darwinkit/macos/appkit"
)
// --- 硬件识别常量 ---
// RAZER_VID (Vendor ID) 是雷蛇在 USB 协会注册的厂商唯一识别码
@@ -60,3 +66,32 @@ const KBD_BACKLIGHT_LED = 0x05 // 键盘背光灯光控制索引
const KBD_CMD_CLASS = 0x0F // 键盘指令分类 (Command Class)
const KBD_CMD_ID = 0x02 // 键盘指令标识 (Command ID)
const KBD_DATA_SIZE = 9 // 键盘数据包的有效负载长度
// 全局变量,追踪当前色盘控制的设备
var (
activeDeviceKey string
colorPanel appkit.ColorPanel
)
func initColorPanel() {
// 修复unsafe.Pointer 与 nil 比较
if colorPanel.Ptr() == nil {
colorPanel = appkit.ColorPanel_SharedColorPanel()
colorPanel.SetContinuous(true)
}
}
func openColorPicker() {
// 1. 获取共享的色盘实例(推荐做法)
colorPanel := appkit.ColorPanel_SharedColorPanel()
// 2. 配置 Target/Action (可选)
// 注意:在 Go 中处理 Selector 回调比较复杂,通常需要注册一个特定的 Class
// 3. 激活应用并显示色盘
// 如果你的程序不是 GUI 模式,色盘可能会隐藏在其他窗口后面
appkit.Application_SharedApplication().ActivateIgnoringOtherApps(true)
colorPanel.MakeKeyAndOrderFront(nil)
fmt.Println("Color Picker 已经尝试打开")
}