feat: make macOS HUD default size compact 300x140
This commit is contained in:
@@ -50,13 +50,13 @@ const DEFAULT_STYLE: MacOSHudStyle = {
|
|||||||
fg: "#e8f3ff",
|
fg: "#e8f3ff",
|
||||||
accent: "#22c55e",
|
accent: "#22c55e",
|
||||||
title: "Token Speed",
|
title: "Token Speed",
|
||||||
width: 360,
|
width: 300,
|
||||||
height: 180,
|
height: 140,
|
||||||
bigFont: 30,
|
bigFont: 22,
|
||||||
smallFont: 12,
|
smallFont: 10,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: 260,
|
minWidth: 240,
|
||||||
minHeight: 130,
|
minHeight: 105,
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStyle(raw: string | undefined): MacOSHudStyle {
|
function parseStyle(raw: string | undefined): MacOSHudStyle {
|
||||||
|
|||||||
+15
-15
@@ -13,13 +13,13 @@ const DEFAULT_STYLE: MacOSHudStyle = {
|
|||||||
fg: "#e8f3ff",
|
fg: "#e8f3ff",
|
||||||
accent: "#22c55e",
|
accent: "#22c55e",
|
||||||
title: "Token Speed",
|
title: "Token Speed",
|
||||||
width: 360,
|
width: 300,
|
||||||
height: 180,
|
height: 140,
|
||||||
bigFont: 30,
|
bigFont: 22,
|
||||||
smallFont: 12,
|
smallFont: 10,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
minWidth: 260,
|
minWidth: 240,
|
||||||
minHeight: 130,
|
minHeight: 105,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MacOSPopupOptions {
|
export interface MacOSPopupOptions {
|
||||||
@@ -102,7 +102,7 @@ export function buildHudScript(
|
|||||||
"var inspectParent = function(pid) {",
|
"var inspectParent = function(pid) {",
|
||||||
' try { osa.doShellScript("ps -p " + pid + " >/dev/null 2>&1"); return true } catch (e) { return false }',
|
' try { osa.doShellScript("ps -p " + pid + " >/dev/null 2>&1"); return true } catch (e) { return false }',
|
||||||
"};",
|
"};",
|
||||||
'var framePath = $.NSHomeDirectory().stringByAppendingPathComponent(".plagin-tokens-hud-frame.json");',
|
'var framePath = $.NSHomeDirectory().stringByAppendingPathComponent(".plagin-tokens-hud-frame-v2.json");',
|
||||||
'function decodedStyle(hex) {',
|
'function decodedStyle(hex) {',
|
||||||
' var clean = String(hex || "").replace("#", "");',
|
' var clean = String(hex || "").replace("#", "");',
|
||||||
' if (clean.length === 3) {',
|
' if (clean.length === 3) {',
|
||||||
@@ -160,8 +160,8 @@ export function buildHudScript(
|
|||||||
"var base = " + JSON.stringify(baseUrl) + ";",
|
"var base = " + JSON.stringify(baseUrl) + ";",
|
||||||
"var parentPid = " + parentPid + ";",
|
"var parentPid = " + parentPid + ";",
|
||||||
"var style = " + JSON.stringify(style) + ";",
|
"var style = " + JSON.stringify(style) + ";",
|
||||||
"var width = Number(style.width) || 360;",
|
"var width = Number(style.width) || 300;",
|
||||||
"var height = Number(style.height) || 180;",
|
"var height = Number(style.height) || 140;",
|
||||||
"var defaultRect = $.NSMakeRect(0, 0, width, height);",
|
"var defaultRect = $.NSMakeRect(0, 0, width, height);",
|
||||||
"var saved = savedFrameValue();",
|
"var saved = savedFrameValue();",
|
||||||
"if (validFrame(saved)) {",
|
"if (validFrame(saved)) {",
|
||||||
@@ -178,7 +178,7 @@ export function buildHudScript(
|
|||||||
"window.level = $.NSFloatingWindowLevel;",
|
"window.level = $.NSFloatingWindowLevel;",
|
||||||
"window.title = style.title;",
|
"window.title = style.title;",
|
||||||
"window.collectionBehavior = (1 << 0) | (1 << 8) | (1 << 4);",
|
"window.collectionBehavior = (1 << 0) | (1 << 8) | (1 << 4);",
|
||||||
"window.minSize = $.NSMakeSize(Math.max(120, Number(style.minWidth) || 220), Math.max(90, Number(style.minHeight) || 110));",
|
"window.minSize = $.NSMakeSize(Math.max(110, Number(style.minWidth) || 240), Math.max(80, Number(style.minHeight) || 105));",
|
||||||
"if (validFrame(saved)) {",
|
"if (validFrame(saved)) {",
|
||||||
" window.setFrameDisplay(startRect, true);",
|
" window.setFrameDisplay(startRect, true);",
|
||||||
"}",
|
"}",
|
||||||
@@ -187,15 +187,15 @@ export function buildHudScript(
|
|||||||
"window.titlebarAppearsTransparent = false;",
|
"window.titlebarAppearsTransparent = false;",
|
||||||
'var delegate = $.TokenSpeedWindowDelegate.alloc.init;',
|
'var delegate = $.TokenSpeedWindowDelegate.alloc.init;',
|
||||||
"window.delegate = delegate;",
|
"window.delegate = delegate;",
|
||||||
'var big = $.NSTextField.alloc.initWithFrame($.NSMakeRect(14, height - 54, width - 28, 44));',
|
'var big = $.NSTextField.alloc.initWithFrame($.NSMakeRect(10, height - 36, width - 20, 32));',
|
||||||
"big.editable = false; big.bordered = false; big.drawsBackground = false; big.alignment = 1;",
|
"big.editable = false; big.bordered = false; big.drawsBackground = false; big.alignment = 1;",
|
||||||
'big.font = $.NSFont.boldSystemFontOfSize(Number(style.bigFont) || 30);',
|
'big.font = $.NSFont.boldSystemFontOfSize(Number(style.bigFont) || 22);',
|
||||||
"big.textColor = decodedStyle(style.accent);",
|
"big.textColor = decodedStyle(style.accent);",
|
||||||
'var small = $.NSTextField.alloc.initWithFrame(',
|
'var small = $.NSTextField.alloc.initWithFrame(',
|
||||||
" $.NSMakeRect(14, 14, Math.max(120, width - 28), Math.max(40, height - 70)),",
|
" $.NSMakeRect(14, 14, Math.max(120, width - 28), Math.max(40, height - 70)),",
|
||||||
");",
|
");",
|
||||||
"small.editable = false; small.bordered = false; small.drawsBackground = false;",
|
"small.editable = false; small.bordered = false; small.drawsBackground = false;",
|
||||||
'small.font = $.NSFont.systemFontOfSize(Number(style.smallFont) || 12);',
|
'small.font = $.NSFont.systemFontOfSize(Number(style.smallFont) || 10);',
|
||||||
"small.textColor = decodedStyle(style.fg);",
|
"small.textColor = decodedStyle(style.fg);",
|
||||||
"small.lineBreakMode = 0;",
|
"small.lineBreakMode = 0;",
|
||||||
"window.contentView.addSubview(big);",
|
"window.contentView.addSubview(big);",
|
||||||
@@ -214,8 +214,8 @@ export function buildHudScript(
|
|||||||
" var size = viewFrame.size;",
|
" var size = viewFrame.size;",
|
||||||
" var frameWidth = Number(size.width) || width;",
|
" var frameWidth = Number(size.width) || width;",
|
||||||
" var frameHeight = Number(size.height) || height;",
|
" var frameHeight = Number(size.height) || height;",
|
||||||
' big.frame = $.NSMakeRect(14, Math.max(8, frameHeight - 54), Math.max(10, frameWidth - 28), 44);',
|
' big.frame = $.NSMakeRect(10, Math.max(8, frameHeight - 36), Math.max(10, frameWidth - 20), 32);',
|
||||||
' small.frame = $.NSMakeRect(14, 14, Math.max(10, frameWidth - 28), Math.max(24, frameHeight - 74));',
|
' small.frame = $.NSMakeRect(10, 10, Math.max(10, frameWidth - 20), Math.max(24, frameHeight - 46));',
|
||||||
"}",
|
"}",
|
||||||
"layout();",
|
"layout();",
|
||||||
"while (true) {",
|
"while (true) {",
|
||||||
|
|||||||
Reference in New Issue
Block a user