ai-battery 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -14
- package/bin/ai-battery-macos-rail.applescript +227 -0
- package/bin/ai-battery-macos-status.applescript +5 -12
- package/bin/ai-battery-run +701 -31
- package/bin/ai-battery-tmux.js +17 -0
- package/bin/terminal-compositor.js +111 -0
- package/docs/REFERENCE.md +23 -3
- package/docs/RELEASING.md +30 -7
- package/docs/WINDOWS-TERMINAL-SHARED-BAR.md +74 -0
- package/docs/hud-preview.svg +75 -20
- package/docs/terminal-vertical-preview.svg +73 -0
- package/lib/cli.js +1148 -240
- package/lib/core/atomic-rename.js +18 -0
- package/lib/core/cli-help.js +57 -12
- package/lib/core/cli-messages.js +45 -1
- package/lib/core/cli-output.js +277 -72
- package/lib/core/cli-wrappers.js +410 -0
- package/lib/core/config-editor.js +194 -29
- package/lib/core/display-config.js +45 -0
- package/lib/core/integration-files.js +32 -3
- package/lib/core/shared-bar.js +603 -0
- package/lib/core/statusline-git.js +179 -15
- package/lib/core/terminal.js +25 -7
- package/lib/core/tmux-status.js +172 -0
- package/lib/core/uninstall.js +20 -7
- package/lib/core/usage-store.js +85 -0
- package/lib/hud/launcher.js +32 -33
- package/lib/platforms/linux/gnome-extension/extension.js +7 -6
- package/lib/platforms/linux/hud.js +157 -42
- package/lib/platforms/linux/panel.js +16 -3
- package/lib/platforms/linux/rail.js +412 -0
- package/lib/platforms/macos/hud.js +152 -44
- package/lib/platforms/process-scanner.js +77 -29
- package/lib/platforms/windows/autostart-cleanup.js +1 -1
- package/lib/platforms/windows/codex-runner.js +178 -21
- package/lib/platforms/windows/hud/controls.ps1 +65 -15
- package/lib/platforms/windows/hud/main.ps1 +715 -54
- package/lib/platforms/windows/hud/rendering.ps1 +1284 -2
- package/lib/platforms/windows/hud/snapshot.ps1 +26 -46
- package/lib/platforms/windows/hud-launcher.js +234 -81
- package/lib/platforms/windows/shared-bar-platform.js +972 -0
- package/lib/platforms/windows/terminal-compositor.js +210 -25
- package/lib/platforms/windows/wt-bar.js +729 -0
- package/lib/platforms/windows/wt-fragment.js +665 -0
- package/lib/platforms/windows/wt-keybinding.js +300 -0
- package/lib/providers/antigravity.js +155 -8
- package/package.json +6 -2
- package/vendor/PaneContext.cs +875 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[int]$Interval =
|
|
1
|
+
param(
|
|
2
|
+
[int]$Interval = 2,
|
|
3
3
|
[string]$Position = $(if ($env:AI_BATTERY_HUD_POSITION) { $env:AI_BATTERY_HUD_POSITION } elseif ($env:CLAUDEX_BATTERY_HUD_POSITION) { $env:CLAUDEX_BATTERY_HUD_POSITION } else { "saved" }),
|
|
4
|
-
[ValidateSet("tray", "statusline", "floating")]
|
|
5
|
-
[string]$Mode = $(if ($env:AI_BATTERY_HUD_MODE) { $env:AI_BATTERY_HUD_MODE } elseif ($env:CLAUDEX_BATTERY_HUD_MODE) { $env:CLAUDEX_BATTERY_HUD_MODE } else { "
|
|
4
|
+
[ValidateSet("tray", "statusline", "floating", "icon", "rail", "horizontal")]
|
|
5
|
+
[string]$Mode = $(if ($env:AI_BATTERY_HUD_MODE) { $env:AI_BATTERY_HUD_MODE } elseif ($env:CLAUDEX_BATTERY_HUD_MODE) { $env:CLAUDEX_BATTERY_HUD_MODE } else { "icon" }),
|
|
6
6
|
[string]$BatteryCommand = $(if ($env:AI_BATTERY_COMMAND) { $env:AI_BATTERY_COMMAND } elseif ($env:CLAUDEX_BATTERY_COMMAND) { $env:CLAUDEX_BATTERY_COMMAND } else { "ai-battery --json" }),
|
|
7
7
|
[string]$BatteryCommandBase64 = "",
|
|
8
8
|
[string]$InitialJsonBase64 = "",
|
|
9
9
|
[int]$Width = 282,
|
|
10
|
+
[double]$Scale = $(if ($env:AI_BATTERY_HUD_SCALE) { [double]$env:AI_BATTERY_HUD_SCALE } elseif ($env:CLAUDEX_BATTERY_HUD_SCALE) { [double]$env:CLAUDEX_BATTERY_HUD_SCALE } else { 0.0 }),
|
|
11
|
+
[ValidateSet("", "white", "black")]
|
|
12
|
+
[string]$CodexIcon = $(if ($env:AI_BATTERY_CODEX_ICON_COLOR) { $env:AI_BATTERY_CODEX_ICON_COLOR } else { "" }),
|
|
10
13
|
[string]$Backdrop = $(if ($env:AI_BATTERY_HUD_BACKDROP) { $env:AI_BATTERY_HUD_BACKDROP } elseif ($env:CLAUDEX_BATTERY_HUD_BACKDROP) { $env:CLAUDEX_BATTERY_HUD_BACKDROP } else { "off" }),
|
|
11
14
|
[string]$Text = $(if ($env:AI_BATTERY_HUD_TEXT) { $env:AI_BATTERY_HUD_TEXT } elseif ($env:CLAUDEX_BATTERY_HUD_TEXT) { $env:CLAUDEX_BATTERY_HUD_TEXT } else { "light" }),
|
|
12
15
|
[string]$Transparent = "",
|
|
@@ -31,7 +34,32 @@ param(
|
|
|
31
34
|
$ErrorActionPreference = "Stop"
|
|
32
35
|
Add-Type -AssemblyName System.Drawing
|
|
33
36
|
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
|
|
34
|
-
if ($env:AI_BATTERY_HUD_DEBUG_LOG) { Add-Content $env:AI_BATTERY_HUD_DEBUG_LOG "boot dock=$DockWindowHandle placement=$DockPlacement once=$Once mode=$Mode" }
|
|
37
|
+
if ($env:AI_BATTERY_HUD_DEBUG_LOG) { Add-Content $env:AI_BATTERY_HUD_DEBUG_LOG "boot dock=$DockWindowHandle placement=$DockPlacement once=$Once mode=$Mode scale=$Scale codexIcon=$CodexIcon" }
|
|
38
|
+
|
|
39
|
+
function Get-HudUiLanguage {
|
|
40
|
+
$candidates = @()
|
|
41
|
+
if (-not [string]::IsNullOrWhiteSpace($env:LANGUAGE)) {
|
|
42
|
+
$candidates += ($env:LANGUAGE -split ":")
|
|
43
|
+
} else {
|
|
44
|
+
foreach ($val in @($env:LC_ALL, $env:LC_MESSAGES, $env:LANG)) {
|
|
45
|
+
if (-not [string]::IsNullOrWhiteSpace($val)) { $candidates += $val }
|
|
46
|
+
}
|
|
47
|
+
try { $candidates += [System.Globalization.CultureInfo]::CurrentUICulture.Name } catch { }
|
|
48
|
+
}
|
|
49
|
+
foreach ($candidate in $candidates) {
|
|
50
|
+
$base = ([string]$candidate).Trim().ToLowerInvariant() -replace '[_@.\-].*$', ''
|
|
51
|
+
if ($base -eq "ko") { return "ko" }
|
|
52
|
+
if ($base -eq "en") { return "en" }
|
|
53
|
+
if ((@("c", "posix") -contains $base) -and (-not [string]::IsNullOrWhiteSpace($env:LANGUAGE))) { return "en" }
|
|
54
|
+
}
|
|
55
|
+
return "en"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$script:hudLanguage = Get-HudUiLanguage
|
|
59
|
+
function Get-HudUiText([string]$English, [string]$Korean) {
|
|
60
|
+
if ($script:hudLanguage -eq "ko") { return $Korean }
|
|
61
|
+
return $English
|
|
62
|
+
}
|
|
35
63
|
|
|
36
64
|
if (-not [string]::IsNullOrWhiteSpace($BatteryCommandBase64)) {
|
|
37
65
|
try {
|
|
@@ -130,25 +158,44 @@ function Remove-HudDockHostMarker {
|
|
|
130
158
|
} catch { }
|
|
131
159
|
}
|
|
132
160
|
|
|
161
|
+
function Test-HudMutexRunning([string]$MutexName = "Local\AiBatteryHud") {
|
|
162
|
+
try {
|
|
163
|
+
$mutex = [System.Threading.Mutex]::OpenExisting($MutexName)
|
|
164
|
+
$mutex.Dispose()
|
|
165
|
+
return $true
|
|
166
|
+
} catch {
|
|
167
|
+
return $false
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
133
171
|
function Request-HudStop {
|
|
172
|
+
if ($DockWindowHandle -eq 0 -and -not (Test-HudMutexRunning)) {
|
|
173
|
+
return $false
|
|
174
|
+
}
|
|
134
175
|
$requestPath = Get-HudDockRequestPath
|
|
135
176
|
try {
|
|
136
177
|
$request = @{ stop = $true; at = [datetime]::UtcNow.ToString("o") } | ConvertTo-Json -Compress
|
|
137
178
|
[System.IO.File]::WriteAllText($requestPath, $request, [System.Text.UTF8Encoding]::new($false))
|
|
138
179
|
} catch {
|
|
139
|
-
return
|
|
180
|
+
return $false
|
|
140
181
|
}
|
|
141
182
|
|
|
142
183
|
for ($wait = 0; $wait -lt 40; $wait += 1) {
|
|
143
184
|
Start-Sleep -Milliseconds 150
|
|
144
|
-
if (-not (Test-Path -LiteralPath $requestPath)) { return }
|
|
185
|
+
if (-not (Test-Path -LiteralPath $requestPath)) { return $true }
|
|
186
|
+
if ($DockWindowHandle -eq 0 -and -not (Test-HudMutexRunning)) {
|
|
187
|
+
Remove-Item -LiteralPath $requestPath -Force -ErrorAction SilentlyContinue
|
|
188
|
+
return $true
|
|
189
|
+
}
|
|
145
190
|
}
|
|
146
191
|
Remove-Item -LiteralPath $requestPath -Force -ErrorAction SilentlyContinue
|
|
192
|
+
return $true
|
|
147
193
|
}
|
|
148
194
|
|
|
149
195
|
if ($StopExisting) {
|
|
150
|
-
Request-HudStop
|
|
151
|
-
|
|
196
|
+
if (Request-HudStop) {
|
|
197
|
+
Start-Sleep -Milliseconds 400
|
|
198
|
+
}
|
|
152
199
|
Stop-ExistingHudProcesses
|
|
153
200
|
if (-not $Once) {
|
|
154
201
|
exit 0
|
|
@@ -255,7 +302,20 @@ function Get-HudSnapshotPath {
|
|
|
255
302
|
Join-Path $env:TEMP "ai-battery"
|
|
256
303
|
}
|
|
257
304
|
New-Item -ItemType Directory -Force -Path $root | Out-Null
|
|
258
|
-
return Join-Path $root "hud-snapshot
|
|
305
|
+
return Join-Path $root "hud-snapshot.json"
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function Get-HudSnapshotCandidatePaths {
|
|
309
|
+
$root = if ($env:LOCALAPPDATA) {
|
|
310
|
+
Join-Path $env:LOCALAPPDATA "ai-battery"
|
|
311
|
+
} else {
|
|
312
|
+
Join-Path $env:TEMP "ai-battery"
|
|
313
|
+
}
|
|
314
|
+
return @(
|
|
315
|
+
(Join-Path $root "hud-snapshot.json"),
|
|
316
|
+
(Join-Path $root "hud-snapshot-windows.json"),
|
|
317
|
+
(Join-Path $root "hud-snapshot-wsl.json")
|
|
318
|
+
)
|
|
259
319
|
}
|
|
260
320
|
|
|
261
321
|
function Get-LegacyHudStatePath {
|
|
@@ -272,17 +332,29 @@ $script:hudAnchorY = "top"
|
|
|
272
332
|
$script:codexRowVisible = $true
|
|
273
333
|
$script:claudeRowVisible = $true
|
|
274
334
|
|
|
335
|
+
function Write-HudTextAtomic([string]$Path, [string]$Text) {
|
|
336
|
+
$dir = Split-Path -Parent $Path
|
|
337
|
+
if ($dir) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
|
|
338
|
+
$tempPath = "$Path.$PID.$([guid]::NewGuid().ToString('N').Substring(0, 8).ToLowerInvariant()).tmp"
|
|
339
|
+
try {
|
|
340
|
+
[System.IO.File]::WriteAllText($tempPath, $Text, [System.Text.UTF8Encoding]::new($false))
|
|
341
|
+
Move-Item -LiteralPath $tempPath -Destination $Path -Force
|
|
342
|
+
} catch {
|
|
343
|
+
Remove-Item -LiteralPath $tempPath -Force -ErrorAction SilentlyContinue
|
|
344
|
+
throw
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
275
348
|
function Signal-HudReady {
|
|
276
349
|
if ([string]::IsNullOrWhiteSpace($ReadyPath)) { return }
|
|
277
350
|
try {
|
|
278
|
-
$
|
|
279
|
-
if ($dir) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
|
|
280
|
-
@{
|
|
351
|
+
$payload = @{
|
|
281
352
|
Ready = $true
|
|
282
353
|
Pid = $PID
|
|
283
354
|
At = [datetime]::UtcNow.ToString("o")
|
|
284
355
|
Mode = $Mode
|
|
285
|
-
} | ConvertTo-Json -Compress
|
|
356
|
+
} | ConvertTo-Json -Compress
|
|
357
|
+
Write-HudTextAtomic $ReadyPath $payload
|
|
286
358
|
} catch {
|
|
287
359
|
# Readiness is diagnostic only.
|
|
288
360
|
}
|
|
@@ -317,12 +389,14 @@ function Write-HudPosition($Point) {
|
|
|
317
389
|
$width = [int]$form.Width
|
|
318
390
|
$height = [int]$form.Height
|
|
319
391
|
}
|
|
320
|
-
@{
|
|
392
|
+
$payload = @{
|
|
321
393
|
X = [int]$Point.X
|
|
322
394
|
Y = [int]$Point.Y
|
|
323
395
|
Width = $width
|
|
324
396
|
Height = $height
|
|
325
|
-
|
|
397
|
+
Scale = [double]$script:hudUserScale
|
|
398
|
+
} | ConvertTo-Json -Compress
|
|
399
|
+
Write-HudTextAtomic (Get-HudStatePath) $payload
|
|
326
400
|
} catch {
|
|
327
401
|
# Position persistence is helpful but not required for the HUD to run.
|
|
328
402
|
}
|
|
@@ -338,17 +412,25 @@ function Get-SnapshotAgeSeconds($Snapshot) {
|
|
|
338
412
|
}
|
|
339
413
|
|
|
340
414
|
function Read-HudSnapshot {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
415
|
+
$maxAge = if ($env:AI_BATTERY_HUD_CACHE_SECONDS) { [int]$env:AI_BATTERY_HUD_CACHE_SECONDS } else { 900 }
|
|
416
|
+
$best = $null
|
|
417
|
+
$bestTime = [datetime]::MinValue
|
|
418
|
+
foreach ($path in (Get-HudSnapshotCandidatePaths)) {
|
|
419
|
+
try {
|
|
420
|
+
if (-not (Test-Path -LiteralPath $path)) { continue }
|
|
421
|
+
$snapshot = Get-Content -LiteralPath $path -Raw | ConvertFrom-Json
|
|
422
|
+
$age = Get-SnapshotAgeSeconds $snapshot
|
|
423
|
+
if ($null -eq $age -or $age -gt $maxAge) { continue }
|
|
424
|
+
$generated = ([datetime]$snapshot.generatedAt).ToUniversalTime()
|
|
425
|
+
if ($generated -ge $bestTime) {
|
|
426
|
+
$best = $snapshot
|
|
427
|
+
$bestTime = $generated
|
|
428
|
+
}
|
|
429
|
+
} catch {
|
|
430
|
+
# Cached data is optional.
|
|
431
|
+
}
|
|
350
432
|
}
|
|
351
|
-
return $
|
|
433
|
+
return $best
|
|
352
434
|
}
|
|
353
435
|
|
|
354
436
|
function Read-InitialHudSnapshot {
|
|
@@ -366,7 +448,8 @@ function Write-HudSnapshot($Snapshot) {
|
|
|
366
448
|
try {
|
|
367
449
|
if (-not $Snapshot) { return }
|
|
368
450
|
$Snapshot | Add-Member -NotePropertyName "hudSource" -NotePropertyValue (Get-HudSourceId) -Force
|
|
369
|
-
$Snapshot | ConvertTo-Json -Depth 20 -Compress
|
|
451
|
+
$payload = $Snapshot | ConvertTo-Json -Depth 20 -Compress
|
|
452
|
+
Write-HudTextAtomic (Get-HudSnapshotPath) $payload
|
|
370
453
|
} catch {
|
|
371
454
|
# The HUD can still run without a warm-start cache.
|
|
372
455
|
}
|
|
@@ -386,6 +469,77 @@ if ($Once) {
|
|
|
386
469
|
|
|
387
470
|
Add-Type -AssemblyName System.Windows.Forms
|
|
388
471
|
Add-Type -AssemblyName System.Drawing
|
|
472
|
+
if (-not ("AiBatteryHudForm" -as [type])) {
|
|
473
|
+
# Borderless WinForms windows still inherit Win32 SM_CXMINTRACK (~136px at 100% DPI),
|
|
474
|
+
# which stretches slim vertical rail HUDs far wider than their content. Override
|
|
475
|
+
# WM_GETMINMAXINFO so both the HUD and its transparent hit-test form can shrink to fit.
|
|
476
|
+
$hudFormCode = @"
|
|
477
|
+
using System;
|
|
478
|
+
using System.Runtime.InteropServices;
|
|
479
|
+
using System.Windows.Forms;
|
|
480
|
+
public class AiBatteryHudForm : Form {
|
|
481
|
+
private const int WM_GETMINMAXINFO = 0x0024;
|
|
482
|
+
private const int WM_MOUSEWHEEL = 0x020A;
|
|
483
|
+
private const int MK_CONTROL = 0x0008;
|
|
484
|
+
public event Action<int> HudCtrlWheel;
|
|
485
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
486
|
+
private struct POINT {
|
|
487
|
+
public int X;
|
|
488
|
+
public int Y;
|
|
489
|
+
}
|
|
490
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
491
|
+
private struct MINMAXINFO {
|
|
492
|
+
public POINT ptReserved;
|
|
493
|
+
public POINT ptMaxSize;
|
|
494
|
+
public POINT ptMaxPosition;
|
|
495
|
+
public POINT ptMinTrackSize;
|
|
496
|
+
public POINT ptMaxTrackSize;
|
|
497
|
+
}
|
|
498
|
+
protected override void WndProc(ref Message m) {
|
|
499
|
+
if (m.Msg == WM_MOUSEWHEEL) {
|
|
500
|
+
long wp = m.WParam.ToInt64();
|
|
501
|
+
int keys = (int)(wp & 0xFFFF);
|
|
502
|
+
if ((keys & MK_CONTROL) != 0) {
|
|
503
|
+
int delta = (short)((wp >> 16) & 0xFFFF);
|
|
504
|
+
var handler = HudCtrlWheel;
|
|
505
|
+
if (handler != null) {
|
|
506
|
+
handler(delta);
|
|
507
|
+
m.Result = IntPtr.Zero;
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
base.WndProc(ref m);
|
|
513
|
+
if (m.Msg == WM_GETMINMAXINFO && m.LParam != IntPtr.Zero) {
|
|
514
|
+
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(MINMAXINFO));
|
|
515
|
+
mmi.ptMinTrackSize.X = 1;
|
|
516
|
+
mmi.ptMinTrackSize.Y = 1;
|
|
517
|
+
Marshal.StructureToPtr(mmi, m.LParam, false);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
"@
|
|
522
|
+
try {
|
|
523
|
+
$hudFormRefs = @(
|
|
524
|
+
[System.Windows.Forms.Form].Assembly.Location,
|
|
525
|
+
[System.Windows.Forms.Message].Assembly.Location,
|
|
526
|
+
[System.Drawing.Point].Assembly.Location,
|
|
527
|
+
[System.ComponentModel.Component].Assembly.Location
|
|
528
|
+
) | Where-Object {
|
|
529
|
+
-not [string]::IsNullOrWhiteSpace($_) -and
|
|
530
|
+
@("System.dll", "mscorlib.dll") -notcontains ([System.IO.Path]::GetFileName($_))
|
|
531
|
+
} | Select-Object -Unique
|
|
532
|
+
Add-Type -TypeDefinition $hudFormCode -ReferencedAssemblies $hudFormRefs
|
|
533
|
+
} catch {
|
|
534
|
+
# Fall back to standard Form if dynamic type compilation is unavailable.
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function New-HudForm {
|
|
538
|
+
if ("AiBatteryHudForm" -as [type]) {
|
|
539
|
+
return New-Object AiBatteryHudForm
|
|
540
|
+
}
|
|
541
|
+
return New-Object System.Windows.Forms.Form
|
|
542
|
+
}
|
|
389
543
|
try {
|
|
390
544
|
[System.Windows.Forms.Application]::SetHighDpiMode([System.Windows.Forms.HighDpiMode]::PerMonitorV2) | Out-Null
|
|
391
545
|
} catch {
|
|
@@ -399,6 +553,24 @@ try {
|
|
|
399
553
|
# The default is already GDI text rendering on older WinForms.
|
|
400
554
|
}
|
|
401
555
|
|
|
556
|
+
$script:hudUserScale = 1.0
|
|
557
|
+
if ($DockWindowHandle -eq 0) {
|
|
558
|
+
if ($Scale -gt 0) {
|
|
559
|
+
$script:hudUserScale = [math]::Round([math]::Max(0.5, [math]::Min(3.0, [double]$Scale)), 2)
|
|
560
|
+
} elseif ($Position -eq "saved") {
|
|
561
|
+
$savedForScale = Read-HudPlacement
|
|
562
|
+
if ($savedForScale -and $null -ne $savedForScale.Scale) {
|
|
563
|
+
try {
|
|
564
|
+
$parsedSavedScale = [double]$savedForScale.Scale
|
|
565
|
+
if (-not [double]::IsNaN($parsedSavedScale) -and -not [double]::IsInfinity($parsedSavedScale) -and $parsedSavedScale -ge 0.5 -and $parsedSavedScale -le 3.0) {
|
|
566
|
+
$script:hudUserScale = [math]::Round($parsedSavedScale, 2)
|
|
567
|
+
}
|
|
568
|
+
} catch { }
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
$script:hudCodexIconMode = ([string]$CodexIcon).Trim().ToLowerInvariant()
|
|
573
|
+
|
|
402
574
|
. (Join-Path $PSScriptRoot "rendering.ps1")
|
|
403
575
|
|
|
404
576
|
if ($Mode -eq "tray") {
|
|
@@ -458,6 +630,9 @@ if ($Mode -eq "tray") {
|
|
|
458
630
|
Set-SingleNotifyIcon $texts
|
|
459
631
|
$script:lastBalloonText = $lines -join "`n"
|
|
460
632
|
} catch {
|
|
633
|
+
$codexRow.Host.Visible = $true
|
|
634
|
+
$claudeRow.Host.Visible = $true
|
|
635
|
+
$antigravityRow.Host.Visible = $false
|
|
461
636
|
Set-StatusMenuRow $codexRow @{
|
|
462
637
|
Prefix = "Codex "
|
|
463
638
|
Percent = $null
|
|
@@ -465,6 +640,7 @@ if ($Mode -eq "tray") {
|
|
|
465
640
|
ResetText = ""
|
|
466
641
|
WeekText = ""
|
|
467
642
|
ExtraText = "unavailable"
|
|
643
|
+
Running = $false
|
|
468
644
|
TextColor = [System.Drawing.Color]::FromArgb(255, 92, 92)
|
|
469
645
|
}
|
|
470
646
|
Set-StatusMenuRow $claudeRow @{
|
|
@@ -474,6 +650,7 @@ if ($Mode -eq "tray") {
|
|
|
474
650
|
ResetText = ""
|
|
475
651
|
WeekText = ""
|
|
476
652
|
ExtraText = ""
|
|
653
|
+
Running = $false
|
|
477
654
|
TextColor = [System.Drawing.Color]::FromArgb(145, 145, 145)
|
|
478
655
|
}
|
|
479
656
|
$newIcon = New-SingleBatteryTrayIcon $null
|
|
@@ -519,6 +696,10 @@ if ($Mode -eq "tray") {
|
|
|
519
696
|
}
|
|
520
697
|
|
|
521
698
|
$script:dockTuiStatusline = ($DockWindowHandle -ne 0)
|
|
699
|
+
$script:hudCustomLayout = if ($script:dockTuiStatusline) { "dock" } elseif ($Mode -eq "rail") { "rail" } elseif (@("icon", "horizontal") -contains $Mode) { "icon" } else { "stack" }
|
|
700
|
+
$script:hudHorizontalPanel = ($script:hudCustomLayout -eq "icon") -or ($script:hudCustomLayout -eq "rail")
|
|
701
|
+
$script:latestHudTexts = $null
|
|
702
|
+
$script:hudHorizontalMessage = "AI Battery starting..."
|
|
522
703
|
$script:dockPlacementMode = $DockPlacement
|
|
523
704
|
$script:dockStripHeight = if ($script:dockTuiStatusline) { Scale-HudValue 20 } else { 0 }
|
|
524
705
|
$script:dockJoinOverlap = if ($script:dockTuiStatusline -and $script:dockPlacementMode -eq "bottom") { [math]::Max(1, (Scale-HudValue 8)) } else { 0 }
|
|
@@ -528,15 +709,15 @@ $script:dockSquareCorners = $false
|
|
|
528
709
|
$script:dockTuiResponsiveLayoutName = ""
|
|
529
710
|
$script:dockTuiResponsiveThresholds = ""
|
|
530
711
|
$script:dockOuterBorderColor = [System.Drawing.Color]::FromArgb(72, 72, 72)
|
|
531
|
-
$form = New-
|
|
712
|
+
$form = New-HudForm
|
|
532
713
|
Enable-HudDoubleBuffering $form
|
|
533
714
|
$form.Text = "AI Battery"
|
|
534
715
|
$form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::None
|
|
535
716
|
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
|
|
536
|
-
$form.Width = Scale-HudValue $Width
|
|
537
|
-
$form.Height = if ($script:dockTuiStatusline) { $script:dockStripHeight + $script:dockJoinOverlap } elseif ($Mode -eq "floating") { Scale-HudValue 44 } elseif ($Mode -eq "statusline") { Scale-HudValue 44 } else { Scale-HudValue 54 }
|
|
538
|
-
$script:hudTwoRowHeight =
|
|
539
|
-
$script:hudOneRowHeight = [math]::Max((Scale-HudValue 20), $
|
|
717
|
+
$form.Width = if ($script:hudCustomLayout -eq "rail") { Scale-HudValue 38 } else { Scale-HudValue $Width }
|
|
718
|
+
$form.Height = if ($script:dockTuiStatusline) { $script:dockStripHeight + $script:dockJoinOverlap } elseif ($script:hudCustomLayout -eq "rail") { Scale-HudValue 140 } elseif ($script:hudHorizontalPanel) { Scale-HudValue 34 } elseif ($Mode -eq "floating") { Scale-HudValue 44 } elseif ($Mode -eq "statusline") { Scale-HudValue 44 } else { Scale-HudValue 54 }
|
|
719
|
+
$script:hudTwoRowHeight = Scale-HudValue 44
|
|
720
|
+
$script:hudOneRowHeight = [math]::Max((Scale-HudValue 20), $script:hudTwoRowHeight - (Scale-HudValue 18))
|
|
540
721
|
$form.TopMost = ($DockWindowHandle -eq 0)
|
|
541
722
|
$form.ShowInTaskbar = $false
|
|
542
723
|
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::None
|
|
@@ -545,11 +726,13 @@ $script:hudTransparentSurface = if ($script:dockTuiStatusline) { $false } else {
|
|
|
545
726
|
$script:hudContrastBackdrop = Test-HudContrastBackdrop
|
|
546
727
|
$script:hudChromeBackColor = if ($script:dockTuiStatusline) {
|
|
547
728
|
[System.Drawing.Color]::FromArgb(12, 12, 12)
|
|
729
|
+
} elseif ($script:hudDarkText) {
|
|
730
|
+
[System.Drawing.Color]::FromArgb(244, 244, 248)
|
|
548
731
|
} else {
|
|
549
732
|
[System.Drawing.Color]::FromArgb(24, 24, 24)
|
|
550
733
|
}
|
|
551
734
|
if ($script:hudTransparentSurface) {
|
|
552
|
-
$transparentBackColor = if ($script:hudDarkText
|
|
735
|
+
$transparentBackColor = if ($script:hudDarkText) {
|
|
553
736
|
[System.Drawing.Color]::FromArgb(254, 254, 254)
|
|
554
737
|
} else {
|
|
555
738
|
[System.Drawing.Color]::FromArgb(18, 18, 18)
|
|
@@ -559,10 +742,17 @@ if ($script:hudTransparentSurface) {
|
|
|
559
742
|
} else {
|
|
560
743
|
$form.BackColor = $script:hudChromeBackColor
|
|
561
744
|
}
|
|
562
|
-
$script:hudSurfaceBackColor = if ($script:
|
|
745
|
+
$script:hudSurfaceBackColor = if ($script:hudTransparentSurface) {
|
|
746
|
+
$form.BackColor
|
|
747
|
+
} else {
|
|
748
|
+
$script:hudChromeBackColor
|
|
749
|
+
}
|
|
750
|
+
$script:hudStackBackColor = if ($script:dockTuiStatusline) {
|
|
751
|
+
$script:hudChromeBackColor
|
|
752
|
+
} elseif ($script:hudContrastBackdrop -or (-not $script:hudTransparentSurface)) {
|
|
563
753
|
$script:hudChromeBackColor
|
|
564
754
|
} else {
|
|
565
|
-
$
|
|
755
|
+
$script:hudSurfaceBackColor
|
|
566
756
|
}
|
|
567
757
|
$form.Opacity = if ($script:dockTuiStatusline) {
|
|
568
758
|
1.0
|
|
@@ -581,7 +771,9 @@ function New-HudMainFont {
|
|
|
581
771
|
[System.Drawing.GraphicsUnit]::Pixel
|
|
582
772
|
)
|
|
583
773
|
}
|
|
584
|
-
|
|
774
|
+
$basePt = if ($Mode -eq "statusline") { 8.5 } else { 9.0 }
|
|
775
|
+
$scaledPt = [single][math]::Max(5.5, ($basePt * (Clamp-HudUserScale $script:hudUserScale)))
|
|
776
|
+
return [System.Drawing.Font]::new("Segoe UI", $scaledPt, [System.Drawing.FontStyle]::Regular)
|
|
585
777
|
}
|
|
586
778
|
|
|
587
779
|
function New-HudSymbolFont {
|
|
@@ -593,11 +785,14 @@ function New-HudSymbolFont {
|
|
|
593
785
|
[System.Drawing.GraphicsUnit]::Pixel
|
|
594
786
|
)
|
|
595
787
|
}
|
|
596
|
-
|
|
788
|
+
$basePt = if ($Mode -eq "statusline") { 11.5 } else { 12.0 }
|
|
789
|
+
$scaledPt = [single][math]::Max(7.0, ($basePt * (Clamp-HudUserScale $script:hudUserScale)))
|
|
790
|
+
return [System.Drawing.Font]::new("Cascadia Mono", $scaledPt, [System.Drawing.FontStyle]::Regular)
|
|
597
791
|
}
|
|
598
792
|
|
|
599
793
|
$font = New-HudMainFont
|
|
600
794
|
$symbolFont = New-HudSymbolFont
|
|
795
|
+
$menuFont = [System.Drawing.Font]::new("Segoe UI", 9, [System.Drawing.FontStyle]::Regular)
|
|
601
796
|
|
|
602
797
|
$panel = New-Object System.Windows.Forms.TableLayoutPanel
|
|
603
798
|
Enable-HudDoubleBuffering $panel
|
|
@@ -607,12 +802,12 @@ $panel.ColumnCount = 1
|
|
|
607
802
|
$panel.GrowStyle = [System.Windows.Forms.TableLayoutPanelGrowStyle]::FixedSize
|
|
608
803
|
$panel.Padding = if ($script:dockTuiStatusline) {
|
|
609
804
|
New-HudPadding 8 2 2 2
|
|
610
|
-
} elseif (
|
|
805
|
+
} elseif (@("floating", "statusline", "icon", "rail", "horizontal") -contains $Mode) {
|
|
611
806
|
New-HudPadding 6 4 2 3
|
|
612
807
|
} else {
|
|
613
808
|
New-HudPadding 10 7 10 6
|
|
614
809
|
}
|
|
615
|
-
$panel.BackColor = $script:
|
|
810
|
+
$panel.BackColor = $script:hudStackBackColor
|
|
616
811
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, $(if ($script:dockTuiStatusline) { 100 } else { 50 }))) | Out-Null
|
|
617
812
|
if (-not $script:dockTuiStatusline) {
|
|
618
813
|
$panel.RowStyles.Add([System.Windows.Forms.RowStyle]::new([System.Windows.Forms.SizeType]::Percent, 50)) | Out-Null
|
|
@@ -628,7 +823,7 @@ function New-HudRow {
|
|
|
628
823
|
$row.WrapContents = $false
|
|
629
824
|
$row.Margin = [System.Windows.Forms.Padding]::new(0)
|
|
630
825
|
$row.Padding = [System.Windows.Forms.Padding]::new(0)
|
|
631
|
-
$row.BackColor = $script:hudSurfaceBackColor
|
|
826
|
+
$row.BackColor = if ($null -ne $script:hudStackBackColor) { $script:hudStackBackColor } else { $script:hudSurfaceBackColor }
|
|
632
827
|
return $row
|
|
633
828
|
}
|
|
634
829
|
|
|
@@ -639,7 +834,7 @@ function New-HudLabel([int]$RightMargin = 0) {
|
|
|
639
834
|
$label.Height = Scale-HudValue 18
|
|
640
835
|
$label.Font = $font
|
|
641
836
|
$label.UseCompatibleTextRendering = $false
|
|
642
|
-
$label.BackColor = $script:hudSurfaceBackColor
|
|
837
|
+
$label.BackColor = if ($null -ne $script:hudStackBackColor) { $script:hudStackBackColor } else { $script:hudSurfaceBackColor }
|
|
643
838
|
$label.Margin = New-HudPadding 0 0 $RightMargin 0
|
|
644
839
|
$label.TextAlign = [System.Drawing.ContentAlignment]::MiddleLeft
|
|
645
840
|
return $label
|
|
@@ -650,7 +845,7 @@ function New-HudIconBox {
|
|
|
650
845
|
$box.Width = Scale-HudValue 40
|
|
651
846
|
$box.Height = Scale-HudValue 18
|
|
652
847
|
$box.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::Zoom
|
|
653
|
-
$box.BackColor = $script:hudSurfaceBackColor
|
|
848
|
+
$box.BackColor = if ($null -ne $script:hudStackBackColor) { $script:hudStackBackColor } else { $script:hudSurfaceBackColor }
|
|
654
849
|
$box.ForeColor = Get-HudBatteryTextColor $true
|
|
655
850
|
$box.Margin = New-HudPadding 0 0 2 0
|
|
656
851
|
$box.add_Paint({
|
|
@@ -750,9 +945,13 @@ function Get-TuiProviderDisplayValues($Result, [string]$Name, [int]$BarWidth, [b
|
|
|
750
945
|
Secondary = ""
|
|
751
946
|
}
|
|
752
947
|
if ($ShowWindows -and $Result -and $Result.primary) {
|
|
753
|
-
$
|
|
948
|
+
$primaryLabel = Get-WindowText $Result.primary.windowMinutes
|
|
949
|
+
if ($Result.provider -eq "antigravity" -and -not $Result.primary.windowMinutes -and $Result.primary.id) {
|
|
950
|
+
$primaryLabel = [string]$Result.primary.id
|
|
951
|
+
}
|
|
952
|
+
$values.Primary = "$primaryLabel $(Get-ResetClock $Result.primary)"
|
|
754
953
|
}
|
|
755
|
-
if ($ShowWindows -and -not $PrimaryOnly -and $Result -and $Result.secondary) {
|
|
954
|
+
if ($ShowWindows -and -not $PrimaryOnly -and $Result -and $Result.secondary -and $null -ne $Result.secondary.remainingPercent) {
|
|
756
955
|
$values.Secondary = "$(Get-WindowText $Result.secondary.windowMinutes) $([int]$Result.secondary.remainingPercent)%"
|
|
757
956
|
if ($Result.secondary.remainingPercent -le 10 -and -not $Result.secondary.resetPassed) {
|
|
758
957
|
$values.Secondary += " $(Get-ResetClock $Result.secondary)"
|
|
@@ -878,7 +1077,11 @@ function Get-DockedTuiRenderKey($Snapshot) {
|
|
|
878
1077
|
$name = $result.provider
|
|
879
1078
|
if (-not $result) { $parts += "$name`:missing"; continue }
|
|
880
1079
|
$primary = if ($result.primary) {
|
|
881
|
-
|
|
1080
|
+
$primaryLabel = Get-WindowText $result.primary.windowMinutes
|
|
1081
|
+
if ($result.provider -eq "antigravity" -and -not $result.primary.windowMinutes -and $result.primary.id) {
|
|
1082
|
+
$primaryLabel = [string]$result.primary.id
|
|
1083
|
+
}
|
|
1084
|
+
"${primaryLabel}:$(Get-ResetClock $result.primary)"
|
|
882
1085
|
} else { "" }
|
|
883
1086
|
$secondary = if ($result.secondary) {
|
|
884
1087
|
"$($result.secondary.windowMinutes):$($result.secondary.remainingPercent):$($result.secondary.resetPassed):$(Get-ResetClock $result.secondary)"
|
|
@@ -979,12 +1182,200 @@ function Test-PointInBounds($Bounds, [System.Drawing.Point]$Point) {
|
|
|
979
1182
|
}
|
|
980
1183
|
|
|
981
1184
|
$menu = New-Object System.Windows.Forms.ContextMenuStrip
|
|
982
|
-
$menu.Font = $
|
|
1185
|
+
$menu.Font = $menuFont
|
|
983
1186
|
$menu.AutoClose = $true
|
|
984
1187
|
$script:hudMenuOpenedAt = [datetime]::UtcNow
|
|
985
1188
|
$script:hudMenuLastInsideAt = [datetime]::UtcNow
|
|
986
1189
|
$script:hudMenuReadyForOutsideClick = $false
|
|
987
|
-
$
|
|
1190
|
+
$toggleLayoutItem = $null
|
|
1191
|
+
$iconModeItem = $null
|
|
1192
|
+
$railModeItem = $null
|
|
1193
|
+
$stackModeItem = $null
|
|
1194
|
+
$largerSizeItem = $null
|
|
1195
|
+
$smallerSizeItem = $null
|
|
1196
|
+
$resetSizeItem = $null
|
|
1197
|
+
$whiteTextItem = $null
|
|
1198
|
+
$blackTextItem = $null
|
|
1199
|
+
$backdropItem = $null
|
|
1200
|
+
|
|
1201
|
+
function Update-HudMenuChecks {
|
|
1202
|
+
if ($iconModeItem) { $iconModeItem.Checked = ($script:hudCustomLayout -eq "icon") }
|
|
1203
|
+
if ($railModeItem) { $railModeItem.Checked = ($script:hudCustomLayout -eq "rail") }
|
|
1204
|
+
if ($stackModeItem) { $stackModeItem.Checked = ($script:hudCustomLayout -eq "stack") }
|
|
1205
|
+
if ($whiteTextItem) { $whiteTextItem.Checked = (-not $script:hudDarkText) }
|
|
1206
|
+
if ($blackTextItem) { $blackTextItem.Checked = ([bool]$script:hudDarkText) }
|
|
1207
|
+
if ($backdropItem) { $backdropItem.Checked = ([bool]$script:hudContrastBackdrop) }
|
|
1208
|
+
if ($resetSizeItem) {
|
|
1209
|
+
$pct = [int][math]::Round((Clamp-HudUserScale $script:hudUserScale) * 100)
|
|
1210
|
+
$resetSizeItem.Text = if ($pct -eq 100) {
|
|
1211
|
+
Get-HudUiText "Reset Size (100%)" "기본 크기 (100%)"
|
|
1212
|
+
} else {
|
|
1213
|
+
Get-HudUiText "Reset Size (100%) · $pct%" "기본 크기 (100%) · $pct%"
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function Apply-HudAppearance {
|
|
1219
|
+
if ($script:dockTuiStatusline) { return }
|
|
1220
|
+
$script:hudChromeBackColor = if ($script:hudDarkText) {
|
|
1221
|
+
[System.Drawing.Color]::FromArgb(244, 244, 248)
|
|
1222
|
+
} else {
|
|
1223
|
+
[System.Drawing.Color]::FromArgb(24, 24, 24)
|
|
1224
|
+
}
|
|
1225
|
+
if ($script:hudTransparentSurface) {
|
|
1226
|
+
$transparentBackColor = if ($script:hudDarkText) {
|
|
1227
|
+
[System.Drawing.Color]::FromArgb(254, 254, 254)
|
|
1228
|
+
} else {
|
|
1229
|
+
[System.Drawing.Color]::FromArgb(18, 18, 18)
|
|
1230
|
+
}
|
|
1231
|
+
$form.BackColor = $transparentBackColor
|
|
1232
|
+
$form.TransparencyKey = $transparentBackColor
|
|
1233
|
+
} else {
|
|
1234
|
+
$form.BackColor = $script:hudChromeBackColor
|
|
1235
|
+
}
|
|
1236
|
+
$script:hudSurfaceBackColor = if ($script:hudTransparentSurface) {
|
|
1237
|
+
$form.BackColor
|
|
1238
|
+
} else {
|
|
1239
|
+
$script:hudChromeBackColor
|
|
1240
|
+
}
|
|
1241
|
+
$script:hudStackBackColor = if ($script:hudContrastBackdrop -or (-not $script:hudTransparentSurface)) {
|
|
1242
|
+
$script:hudChromeBackColor
|
|
1243
|
+
} else {
|
|
1244
|
+
$script:hudSurfaceBackColor
|
|
1245
|
+
}
|
|
1246
|
+
$panel.BackColor = $script:hudStackBackColor
|
|
1247
|
+
if ($script:horizontalPaintPanel) {
|
|
1248
|
+
$script:horizontalPaintPanel.BackColor = $script:hudSurfaceBackColor
|
|
1249
|
+
}
|
|
1250
|
+
$dividerColor = Get-DividerColor
|
|
1251
|
+
foreach ($entry in $script:hudProviderRows.Values) {
|
|
1252
|
+
$entry.Row.BackColor = $script:hudStackBackColor
|
|
1253
|
+
foreach ($ctrl in $entry.Controls) {
|
|
1254
|
+
if ($ctrl -is [System.Windows.Forms.Panel]) {
|
|
1255
|
+
$ctrl.BackColor = $dividerColor
|
|
1256
|
+
} else {
|
|
1257
|
+
$ctrl.BackColor = $script:hudStackBackColor
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if ($providerDivider) { $providerDivider.BackColor = $dividerColor }
|
|
1262
|
+
if ($script:detailPopupForm -and -not $script:detailPopupForm.IsDisposed) {
|
|
1263
|
+
$script:detailPopupForm.BackColor = if ($script:hudDarkText) {
|
|
1264
|
+
[System.Drawing.Color]::FromArgb(246, 246, 250)
|
|
1265
|
+
} else {
|
|
1266
|
+
[System.Drawing.Color]::FromArgb(38, 38, 43)
|
|
1267
|
+
}
|
|
1268
|
+
$script:detailPopupForm.Invalidate()
|
|
1269
|
+
}
|
|
1270
|
+
$script:hudBatteryRenderKeys = @{}
|
|
1271
|
+
$script:hudVisualKey = $null
|
|
1272
|
+
Update-HudFromSnapshot $script:latestSnapshot
|
|
1273
|
+
if ($script:horizontalPaintPanel) { $script:horizontalPaintPanel.Invalidate() }
|
|
1274
|
+
$form.Invalidate($true)
|
|
1275
|
+
Update-HudMenuChecks
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
function Set-HudUserScale([double]$NextScale, [switch]$SkipSave) {
|
|
1279
|
+
if ($script:dockTuiStatusline) { return }
|
|
1280
|
+
$clamped = Clamp-HudUserScale $NextScale
|
|
1281
|
+
if ([math]::Abs($clamped - $script:hudUserScale) -lt 0.005) { return }
|
|
1282
|
+
$script:hudUserScale = $clamped
|
|
1283
|
+
Update-HudDpiScale
|
|
1284
|
+
$script:hudTwoRowHeight = Scale-HudValue 44
|
|
1285
|
+
$script:hudOneRowHeight = [math]::Max((Scale-HudValue 20), $script:hudTwoRowHeight - (Scale-HudValue 18))
|
|
1286
|
+
|
|
1287
|
+
$oldFont = $script:font
|
|
1288
|
+
$oldSymbolFont = $script:symbolFont
|
|
1289
|
+
$script:font = New-HudMainFont
|
|
1290
|
+
$script:symbolFont = New-HudSymbolFont
|
|
1291
|
+
|
|
1292
|
+
$panel.Padding = if (@("floating", "statusline", "icon", "rail", "horizontal") -contains $Mode) {
|
|
1293
|
+
New-HudPadding 6 4 2 3
|
|
1294
|
+
} else {
|
|
1295
|
+
New-HudPadding 10 7 10 6
|
|
1296
|
+
}
|
|
1297
|
+
foreach ($entry in $script:hudProviderRows.Values) {
|
|
1298
|
+
foreach ($ctrl in $entry.Controls) {
|
|
1299
|
+
if ($ctrl -is [System.Windows.Forms.Label]) {
|
|
1300
|
+
$ctrl.Font = $script:font
|
|
1301
|
+
$ctrl.Height = Scale-HudValue 18
|
|
1302
|
+
} elseif ($ctrl -is [System.Windows.Forms.PictureBox]) {
|
|
1303
|
+
$ctrl.Width = Scale-HudValue 42
|
|
1304
|
+
$ctrl.Height = Scale-HudValue 18
|
|
1305
|
+
$ctrl.Margin = New-HudPadding 0 0 2 0
|
|
1306
|
+
} elseif ($ctrl -is [System.Windows.Forms.Panel]) {
|
|
1307
|
+
$ctrl.Width = Scale-HudValue 1
|
|
1308
|
+
$ctrl.Height = Scale-HudValue 12
|
|
1309
|
+
$ctrl.Margin = New-HudPadding 4 3 4 3
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if ($oldFont) { try { $oldFont.Dispose() } catch { } }
|
|
1314
|
+
if ($oldSymbolFont) { try { $oldSymbolFont.Dispose() } catch { } }
|
|
1315
|
+
|
|
1316
|
+
$script:hudBatteryRenderKeys = @{}
|
|
1317
|
+
$script:hudVisualKey = $null
|
|
1318
|
+
Update-HudFromSnapshot $script:latestSnapshot
|
|
1319
|
+
if ($script:horizontalPaintPanel) { $script:horizontalPaintPanel.Invalidate() }
|
|
1320
|
+
if (-not $SkipSave) { Save-HudPositionIfReady }
|
|
1321
|
+
Update-HudMenuChecks
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
if (-not $script:dockTuiStatusline) {
|
|
1325
|
+
$setHudLayout = {
|
|
1326
|
+
param([string]$NextLayout)
|
|
1327
|
+
$script:hudCustomLayout = $NextLayout
|
|
1328
|
+
$script:hudHorizontalPanel = ($NextLayout -eq "icon" -or $NextLayout -eq "rail")
|
|
1329
|
+
if ($script:horizontalPaintPanel) {
|
|
1330
|
+
$script:horizontalPaintPanel.Visible = $script:hudHorizontalPanel
|
|
1331
|
+
$panel.Visible = -not $script:hudHorizontalPanel
|
|
1332
|
+
if ($script:hudHorizontalPanel) { $script:horizontalPaintPanel.BringToFront(); $script:horizontalPaintPanel.Invalidate() }
|
|
1333
|
+
else { Hide-HorizontalDetailPopup; $panel.BringToFront() }
|
|
1334
|
+
}
|
|
1335
|
+
$script:hudVisualKey = $null
|
|
1336
|
+
Update-HudFromSnapshot $script:latestSnapshot
|
|
1337
|
+
Update-HudMenuChecks
|
|
1338
|
+
}
|
|
1339
|
+
$iconModeItem = $menu.Items.Add((Get-HudUiText "Icon Panel" "아이콘 패널"))
|
|
1340
|
+
$iconModeItem.add_Click({ & $setHudLayout "icon" })
|
|
1341
|
+
$railModeItem = $menu.Items.Add((Get-HudUiText "Rail Panel" "세로 레일"))
|
|
1342
|
+
$railModeItem.add_Click({ & $setHudLayout "rail" })
|
|
1343
|
+
$stackModeItem = $menu.Items.Add((Get-HudUiText "Stack Panel" "스택 패널"))
|
|
1344
|
+
$stackModeItem.add_Click({ & $setHudLayout "stack" })
|
|
1345
|
+
$menu.Items.Add("-") | Out-Null
|
|
1346
|
+
|
|
1347
|
+
$largerSizeItem = $menu.Items.Add((Get-HudUiText "Larger (+)" "크게 (+)"))
|
|
1348
|
+
$largerSizeItem.add_Click({ Set-HudUserScale ($script:hudUserScale + 0.15) })
|
|
1349
|
+
$smallerSizeItem = $menu.Items.Add((Get-HudUiText "Smaller (-)" "작게 (-)"))
|
|
1350
|
+
$smallerSizeItem.add_Click({ Set-HudUserScale ($script:hudUserScale - 0.15) })
|
|
1351
|
+
$resetSizeItem = $menu.Items.Add((Get-HudUiText "Reset Size (100%)" "기본 크기 (100%)"))
|
|
1352
|
+
$resetSizeItem.add_Click({ Set-HudUserScale 1.0 })
|
|
1353
|
+
$menu.Items.Add("-") | Out-Null
|
|
1354
|
+
|
|
1355
|
+
$whiteTextItem = $menu.Items.Add((Get-HudUiText "White Text" "흰색 글자"))
|
|
1356
|
+
$whiteTextItem.add_Click({
|
|
1357
|
+
$script:hudDarkText = $false
|
|
1358
|
+
$script:hudCodexIconMode = ""
|
|
1359
|
+
Apply-HudAppearance
|
|
1360
|
+
})
|
|
1361
|
+
$blackTextItem = $menu.Items.Add((Get-HudUiText "Black Text" "검은색 글자"))
|
|
1362
|
+
$blackTextItem.add_Click({
|
|
1363
|
+
$script:hudDarkText = $true
|
|
1364
|
+
$script:hudCodexIconMode = ""
|
|
1365
|
+
Apply-HudAppearance
|
|
1366
|
+
})
|
|
1367
|
+
$backdropItem = $menu.Items.Add((Get-HudUiText "Backdrop" "배경 표시"))
|
|
1368
|
+
$backdropItem.add_Click({
|
|
1369
|
+
$script:hudContrastBackdrop = -not $script:hudContrastBackdrop
|
|
1370
|
+
Apply-HudAppearance
|
|
1371
|
+
})
|
|
1372
|
+
$menu.Items.Add("-") | Out-Null
|
|
1373
|
+
|
|
1374
|
+
$refreshMenuItem = $menu.Items.Add((Get-HudUiText "Refresh" "새로고침"))
|
|
1375
|
+
$refreshMenuItem.add_Click({ try { Start-SnapshotFetch } catch { } })
|
|
1376
|
+
Update-HudMenuChecks
|
|
1377
|
+
}
|
|
1378
|
+
$exitItem = $menu.Items.Add((Get-HudUiText "Quit AI Battery" "AI Battery 종료"))
|
|
988
1379
|
$exitItem.add_Click({ $form.Close() })
|
|
989
1380
|
$menu.add_Opened({
|
|
990
1381
|
$script:hudMenuOpenedAt = [datetime]::UtcNow
|
|
@@ -1017,6 +1408,7 @@ $claudeRow.ContextMenuStrip = $menu
|
|
|
1017
1408
|
$providerDivider.ContextMenuStrip = $menu
|
|
1018
1409
|
$script:dockCombinedRow = $null
|
|
1019
1410
|
$script:dockTuiPaintPanel = $null
|
|
1411
|
+
$script:horizontalPaintPanel = $null
|
|
1020
1412
|
if ($script:dockTuiStatusline) {
|
|
1021
1413
|
$script:dockTuiPaintPanel = New-Object System.Windows.Forms.Panel
|
|
1022
1414
|
$script:dockTuiPaintPanel.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
@@ -1039,16 +1431,34 @@ if ($script:dockTuiStatusline) {
|
|
|
1039
1431
|
$panel.Controls.Add($codexRow, 0, 0) | Out-Null
|
|
1040
1432
|
$panel.Controls.Add($claudeRow, 0, 1) | Out-Null
|
|
1041
1433
|
$panel.Controls.Add($antigravityRow, 0, 2) | Out-Null
|
|
1434
|
+
$script:horizontalPaintPanel = New-Object System.Windows.Forms.Panel
|
|
1435
|
+
Enable-HudDoubleBuffering $script:horizontalPaintPanel
|
|
1436
|
+
$script:horizontalPaintPanel.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
1437
|
+
$script:horizontalPaintPanel.Margin = [System.Windows.Forms.Padding]::new(0)
|
|
1438
|
+
$script:horizontalPaintPanel.BackColor = $script:hudSurfaceBackColor
|
|
1439
|
+
$script:horizontalPaintPanel.ContextMenuStrip = $menu
|
|
1440
|
+
$script:horizontalPaintPanel.Visible = $script:hudHorizontalPanel
|
|
1441
|
+
$panel.Visible = -not $script:hudHorizontalPanel
|
|
1442
|
+
$script:horizontalPaintPanel.add_Paint({
|
|
1443
|
+
param($sender, $event)
|
|
1444
|
+
if ($script:hudCustomLayout -eq "rail") {
|
|
1445
|
+
Draw-VerticalRailHud $event.Graphics $sender.Width $sender.Height $script:latestHudTexts
|
|
1446
|
+
} else {
|
|
1447
|
+
Draw-HorizontalBrandHud $event.Graphics $sender.Width $sender.Height $script:latestHudTexts $font
|
|
1448
|
+
}
|
|
1449
|
+
})
|
|
1042
1450
|
}
|
|
1043
1451
|
if ($script:dockTuiStatusline) {
|
|
1044
1452
|
$form.Controls.Add($script:dockTuiPaintPanel)
|
|
1045
1453
|
} else {
|
|
1046
1454
|
$form.Controls.Add($panel)
|
|
1455
|
+
$form.Controls.Add($script:horizontalPaintPanel)
|
|
1456
|
+
if ($script:hudHorizontalPanel) { $script:horizontalPaintPanel.BringToFront() }
|
|
1047
1457
|
}
|
|
1048
1458
|
|
|
1049
1459
|
$hitForm = $null
|
|
1050
1460
|
if ((-not $ClickThrough) -and $script:hudTransparentSurface) {
|
|
1051
|
-
$hitForm = New-
|
|
1461
|
+
$hitForm = New-HudForm
|
|
1052
1462
|
$hitForm.Text = "AI Battery hit area"
|
|
1053
1463
|
$hitForm.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::None
|
|
1054
1464
|
$hitForm.Width = $form.Width
|
|
@@ -1115,13 +1525,183 @@ function Show-HitForm {
|
|
|
1115
1525
|
[AiBatteryNative]::SetWindowLong($hitForm.Handle, [AiBatteryNative]::GWL_EXSTYLE, $style) | Out-Null
|
|
1116
1526
|
}
|
|
1117
1527
|
|
|
1528
|
+
$script:detailPopupForm = $null
|
|
1529
|
+
$script:detailPopupOpenedAt = [datetime]::MinValue
|
|
1530
|
+
$script:detailPopupReadyForOutsideClick = $false
|
|
1531
|
+
|
|
1532
|
+
function Hide-HorizontalDetailPopup {
|
|
1533
|
+
$script:detailPopupReadyForOutsideClick = $false
|
|
1534
|
+
if ($script:detailPopupForm -and -not $script:detailPopupForm.IsDisposed -and $script:detailPopupForm.Visible) {
|
|
1535
|
+
$script:detailPopupForm.Hide()
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function Update-DetailPopupAutoHide {
|
|
1540
|
+
if (-not $script:detailPopupForm -or $script:detailPopupForm.IsDisposed -or -not $script:detailPopupForm.Visible) { return }
|
|
1541
|
+
$now = [datetime]::UtcNow
|
|
1542
|
+
$buttons = [System.Windows.Forms.Control]::MouseButtons
|
|
1543
|
+
if (-not $script:detailPopupReadyForOutsideClick) {
|
|
1544
|
+
if ($buttons -eq [System.Windows.Forms.MouseButtons]::None -and ($now - $script:detailPopupOpenedAt).TotalMilliseconds -ge 150) {
|
|
1545
|
+
$script:detailPopupReadyForOutsideClick = $true
|
|
1546
|
+
}
|
|
1547
|
+
return
|
|
1548
|
+
}
|
|
1549
|
+
if (([AiBatteryNative]::GetAsyncKeyState(0x1B) -band 0x8000) -ne 0) {
|
|
1550
|
+
Hide-HorizontalDetailPopup
|
|
1551
|
+
return
|
|
1552
|
+
}
|
|
1553
|
+
if ($buttons -ne [System.Windows.Forms.MouseButtons]::None) {
|
|
1554
|
+
$point = [System.Windows.Forms.Cursor]::Position
|
|
1555
|
+
$insidePopup = Test-PointInBounds $script:detailPopupForm.Bounds $point
|
|
1556
|
+
$insideHud = Test-PointInBounds $form.Bounds $point
|
|
1557
|
+
if ($hitForm -and -not $hitForm.IsDisposed) {
|
|
1558
|
+
$insideHud = $insideHud -or (Test-PointInBounds $hitForm.Bounds $point)
|
|
1559
|
+
}
|
|
1560
|
+
if (-not $insidePopup -and -not $insideHud) {
|
|
1561
|
+
Hide-HorizontalDetailPopup
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
function Update-HorizontalDetailPopupBounds {
|
|
1567
|
+
if (-not $script:detailPopupForm -or $script:detailPopupForm.IsDisposed) { return }
|
|
1568
|
+
$size = Get-HorizontalDetailCardSize $script:latestHudTexts
|
|
1569
|
+
$script:detailPopupForm.Size = $size
|
|
1570
|
+
$screen = [System.Windows.Forms.Screen]::FromControl($form)
|
|
1571
|
+
$work = $screen.WorkingArea
|
|
1572
|
+
$gap = Scale-HudDpiValue 6
|
|
1573
|
+
$x = $form.Left + [int][math]::Floor(($form.Width - $size.Width) / 2)
|
|
1574
|
+
$x = [math]::Max($work.Left + $gap, [math]::Min($work.Right - $size.Width - $gap, $x))
|
|
1575
|
+
$y = $form.Bottom + $gap
|
|
1576
|
+
if (($y + $size.Height) -gt ($work.Bottom - $gap)) {
|
|
1577
|
+
$y = $form.Top - $size.Height - $gap
|
|
1578
|
+
}
|
|
1579
|
+
$y = [math]::Max($work.Top + $gap, [math]::Min($work.Bottom - $size.Height - $gap, $y))
|
|
1580
|
+
$script:detailPopupForm.Location = [System.Drawing.Point]::new([int]$x, [int]$y)
|
|
1581
|
+
$regionPath = New-RoundedRectPath ([single]0) ([single]0) ([single]$size.Width) ([single]$size.Height) ([single](Scale-HudDpiValue 10))
|
|
1582
|
+
try {
|
|
1583
|
+
$oldRegion = $script:detailPopupForm.Region
|
|
1584
|
+
$script:detailPopupForm.Region = [System.Drawing.Region]::new($regionPath)
|
|
1585
|
+
if ($oldRegion) { $oldRegion.Dispose() }
|
|
1586
|
+
} finally {
|
|
1587
|
+
$regionPath.Dispose()
|
|
1588
|
+
}
|
|
1589
|
+
$script:detailPopupForm.Invalidate()
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
function Toggle-HorizontalDetailPopup {
|
|
1593
|
+
if (-not $script:hudHorizontalPanel) { return }
|
|
1594
|
+
if ($script:detailPopupForm -and -not $script:detailPopupForm.IsDisposed -and $script:detailPopupForm.Visible) {
|
|
1595
|
+
Hide-HorizontalDetailPopup
|
|
1596
|
+
return
|
|
1597
|
+
}
|
|
1598
|
+
if (-not $script:detailPopupForm -or $script:detailPopupForm.IsDisposed) {
|
|
1599
|
+
$popup = New-Object System.Windows.Forms.Form
|
|
1600
|
+
Enable-HudDoubleBuffering $popup
|
|
1601
|
+
$popup.Text = "AI Battery Details"
|
|
1602
|
+
$popup.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::None
|
|
1603
|
+
$popup.StartPosition = [System.Windows.Forms.FormStartPosition]::Manual
|
|
1604
|
+
$popup.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::None
|
|
1605
|
+
$popup.ShowInTaskbar = $false
|
|
1606
|
+
$popup.TopMost = $true
|
|
1607
|
+
$popup.BackColor = if ($script:hudDarkText) {
|
|
1608
|
+
[System.Drawing.Color]::FromArgb(246, 246, 250)
|
|
1609
|
+
} else {
|
|
1610
|
+
[System.Drawing.Color]::FromArgb(38, 38, 43)
|
|
1611
|
+
}
|
|
1612
|
+
$popup.add_Paint({
|
|
1613
|
+
param($sender, $event)
|
|
1614
|
+
Draw-HorizontalDetailCard $event.Graphics $sender.Width $sender.Height $script:latestHudTexts
|
|
1615
|
+
})
|
|
1616
|
+
$popup.add_MouseClick({
|
|
1617
|
+
param($sender, $event)
|
|
1618
|
+
if ($event.Button -ne [System.Windows.Forms.MouseButtons]::Left) { return }
|
|
1619
|
+
$rects = Get-HorizontalDetailFooterRects $sender.Width $sender.Height
|
|
1620
|
+
$pt = [System.Drawing.Point]::new($event.X, $event.Y)
|
|
1621
|
+
if ($rects.Refresh.Contains($pt)) {
|
|
1622
|
+
try { Start-SnapshotFetch } catch { }
|
|
1623
|
+
$sender.Invalidate()
|
|
1624
|
+
} elseif ($rects.Quit.Contains($pt)) {
|
|
1625
|
+
Hide-HorizontalDetailPopup
|
|
1626
|
+
$form.Close()
|
|
1627
|
+
}
|
|
1628
|
+
})
|
|
1629
|
+
$script:detailPopupForm = $popup
|
|
1630
|
+
}
|
|
1631
|
+
Update-HorizontalDetailPopupBounds
|
|
1632
|
+
$script:detailPopupOpenedAt = [datetime]::UtcNow
|
|
1633
|
+
$script:detailPopupReadyForOutsideClick = $false
|
|
1634
|
+
$script:detailPopupForm.Show()
|
|
1635
|
+
$popupStyle = [AiBatteryNative]::GetWindowLong($script:detailPopupForm.Handle, [AiBatteryNative]::GWL_EXSTYLE)
|
|
1636
|
+
$popupStyle = $popupStyle -bor [AiBatteryNative]::WS_EX_TOOLWINDOW -bor [AiBatteryNative]::WS_EX_NOACTIVATE
|
|
1637
|
+
[AiBatteryNative]::SetWindowLong($script:detailPopupForm.Handle, [AiBatteryNative]::GWL_EXSTYLE, $popupStyle) | Out-Null
|
|
1638
|
+
$swpFlags = [AiBatteryNative]::SWP_NOMOVE -bor [AiBatteryNative]::SWP_NOSIZE -bor [AiBatteryNative]::SWP_NOACTIVATE -bor [AiBatteryNative]::SWP_SHOWWINDOW
|
|
1639
|
+
[AiBatteryNative]::SetWindowPos($script:detailPopupForm.Handle, [AiBatteryNative]::HWND_TOPMOST, 0, 0, 0, 0, $swpFlags) | Out-Null
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1118
1642
|
$dragging = $false
|
|
1119
1643
|
$dragOffset = [System.Drawing.Point]::new(0, 0)
|
|
1644
|
+
$script:dragStartScreen = [System.Drawing.Point]::new(0, 0)
|
|
1645
|
+
$script:dragMoved = $false
|
|
1646
|
+
$script:resizeDrag = $null
|
|
1647
|
+
|
|
1648
|
+
function Get-HudResizeCorner([int]$LocalX, [int]$LocalY, [int]$Width, [int]$Height) {
|
|
1649
|
+
if ($script:dockTuiStatusline -or $Width -le 0 -or $Height -le 0) { return $null }
|
|
1650
|
+
$maxZone = [math]::Max(10, (Scale-HudDpiValue 12))
|
|
1651
|
+
$zone = [math]::Max(6, [math]::Min($maxZone, [int][math]::Floor([math]::Min($Width, $Height) / 4)))
|
|
1652
|
+
$left = $LocalX -lt $zone
|
|
1653
|
+
$right = $LocalX -ge ($Width - $zone)
|
|
1654
|
+
$top = $LocalY -lt $zone
|
|
1655
|
+
$bottom = $LocalY -ge ($Height - $zone)
|
|
1656
|
+
if ($top -and $left) { return "nw" }
|
|
1657
|
+
if ($top -and $right) { return "ne" }
|
|
1658
|
+
if ($bottom -and $left) { return "sw" }
|
|
1659
|
+
if ($bottom -and $right) { return "se" }
|
|
1660
|
+
return $null
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
function Set-HudResizeCursor([string]$Corner) {
|
|
1664
|
+
$cursor = if ($Corner -eq "nw" -or $Corner -eq "se") {
|
|
1665
|
+
[System.Windows.Forms.Cursors]::SizeNWSE
|
|
1666
|
+
} elseif ($Corner -eq "ne" -or $Corner -eq "sw") {
|
|
1667
|
+
[System.Windows.Forms.Cursors]::SizeNESW
|
|
1668
|
+
} else {
|
|
1669
|
+
[System.Windows.Forms.Cursors]::Default
|
|
1670
|
+
}
|
|
1671
|
+
foreach ($target in @($form, $hitForm, $panel, $script:horizontalPaintPanel)) {
|
|
1672
|
+
if ($target -and -not $target.IsDisposed -and $target.Cursor -ne $cursor) {
|
|
1673
|
+
$target.Cursor = $cursor
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1120
1678
|
$mouseDown = {
|
|
1121
1679
|
param($sender, $event)
|
|
1122
1680
|
if ($event.Button -eq [System.Windows.Forms.MouseButtons]::Left) {
|
|
1123
|
-
$script:dragging = $true
|
|
1124
1681
|
$screenPoint = $sender.PointToScreen([System.Drawing.Point]::new($event.X, $event.Y))
|
|
1682
|
+
$localX = $screenPoint.X - $form.Left
|
|
1683
|
+
$localY = $screenPoint.Y - $form.Top
|
|
1684
|
+
$corner = Get-HudResizeCorner $localX $localY $form.Width $form.Height
|
|
1685
|
+
if ($corner) {
|
|
1686
|
+
$script:dragging = $false
|
|
1687
|
+
$script:dragMoved = $false
|
|
1688
|
+
$script:resizeDrag = @{
|
|
1689
|
+
Corner = $corner
|
|
1690
|
+
StartX = $screenPoint.X
|
|
1691
|
+
StartY = $screenPoint.Y
|
|
1692
|
+
StartScale = [double]$script:hudUserScale
|
|
1693
|
+
StartLeft = [int]$form.Left
|
|
1694
|
+
StartTop = [int]$form.Top
|
|
1695
|
+
StartWidth = [math]::Max(1, [int]$form.Width)
|
|
1696
|
+
StartHeight = [math]::Max(1, [int]$form.Height)
|
|
1697
|
+
Moved = $false
|
|
1698
|
+
}
|
|
1699
|
+
Set-HudResizeCursor $corner
|
|
1700
|
+
return
|
|
1701
|
+
}
|
|
1702
|
+
$script:dragging = $true
|
|
1703
|
+
$script:dragMoved = $false
|
|
1704
|
+
$script:dragStartScreen = $screenPoint
|
|
1125
1705
|
$script:dragOffset = [System.Drawing.Point]::new(
|
|
1126
1706
|
($screenPoint.X - $form.Location.X),
|
|
1127
1707
|
($screenPoint.Y - $form.Location.Y)
|
|
@@ -1130,23 +1710,83 @@ $mouseDown = {
|
|
|
1130
1710
|
}
|
|
1131
1711
|
$mouseMove = {
|
|
1132
1712
|
param($sender, $event)
|
|
1713
|
+
$screenPoint = $sender.PointToScreen([System.Drawing.Point]::new($event.X, $event.Y))
|
|
1714
|
+
if ($script:resizeDrag) {
|
|
1715
|
+
$dx = $screenPoint.X - $script:resizeDrag.StartX
|
|
1716
|
+
$dy = $screenPoint.Y - $script:resizeDrag.StartY
|
|
1717
|
+
if ((-not $script:resizeDrag.Moved) -and (([math]::Abs($dx) -ge 2) -or ([math]::Abs($dy) -ge 2))) {
|
|
1718
|
+
$script:resizeDrag.Moved = $true
|
|
1719
|
+
Hide-HorizontalDetailPopup
|
|
1720
|
+
}
|
|
1721
|
+
if ($script:resizeDrag.Moved) {
|
|
1722
|
+
$sx = if ($script:resizeDrag.Corner.Contains("w")) { -$dx } else { $dx }
|
|
1723
|
+
$sy = if ($script:resizeDrag.Corner.Contains("n")) { -$dy } else { $dy }
|
|
1724
|
+
$aspect = [double]$script:resizeDrag.StartWidth / [double]$script:resizeDrag.StartHeight
|
|
1725
|
+
$deltaW = ($sx + ($sy * $aspect)) / 2.0
|
|
1726
|
+
$nextScale = Clamp-HudUserScale ($script:resizeDrag.StartScale * (($script:resizeDrag.StartWidth + $deltaW) / [double]$script:resizeDrag.StartWidth))
|
|
1727
|
+
if ([math]::Abs($nextScale - $script:hudUserScale) -ge 0.02) {
|
|
1728
|
+
Set-HudUserScale $nextScale -SkipSave
|
|
1729
|
+
$nextX = if ($script:resizeDrag.Corner.Contains("w")) { $script:resizeDrag.StartLeft + ($script:resizeDrag.StartWidth - $form.Width) } else { $script:resizeDrag.StartLeft }
|
|
1730
|
+
$nextY = if ($script:resizeDrag.Corner.Contains("n")) { $script:resizeDrag.StartTop + ($script:resizeDrag.StartHeight - $form.Height) } else { $script:resizeDrag.StartTop }
|
|
1731
|
+
$form.Location = [System.Drawing.Point]::new([int]$nextX, [int]$nextY)
|
|
1732
|
+
Sync-HitFormBounds
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return
|
|
1736
|
+
}
|
|
1133
1737
|
if ($script:dragging) {
|
|
1134
|
-
$screenPoint
|
|
1135
|
-
|
|
1136
|
-
|
|
1738
|
+
if ((-not $script:dragMoved) -and (([math]::Abs($screenPoint.X - $script:dragStartScreen.X) -ge 4) -or ([math]::Abs($screenPoint.Y - $script:dragStartScreen.Y) -ge 4))) {
|
|
1739
|
+
$script:dragMoved = $true
|
|
1740
|
+
Hide-HorizontalDetailPopup
|
|
1741
|
+
}
|
|
1742
|
+
if ($script:dragMoved) {
|
|
1743
|
+
$form.Location = [System.Drawing.Point]::new(($screenPoint.X - $script:dragOffset.X), ($screenPoint.Y - $script:dragOffset.Y))
|
|
1744
|
+
Sync-HitFormBounds
|
|
1745
|
+
}
|
|
1746
|
+
return
|
|
1137
1747
|
}
|
|
1748
|
+
$localX = $screenPoint.X - $form.Left
|
|
1749
|
+
$localY = $screenPoint.Y - $form.Top
|
|
1750
|
+
Set-HudResizeCursor (Get-HudResizeCorner $localX $localY $form.Width $form.Height)
|
|
1138
1751
|
}
|
|
1139
1752
|
$mouseUp = {
|
|
1753
|
+
param($sender, $event)
|
|
1754
|
+
if ($script:resizeDrag) {
|
|
1755
|
+
$wasResizeMoved = [bool]$script:resizeDrag.Moved
|
|
1756
|
+
$script:resizeDrag = $null
|
|
1757
|
+
$screenPoint = $sender.PointToScreen([System.Drawing.Point]::new($event.X, $event.Y))
|
|
1758
|
+
Set-HudResizeCursor (Get-HudResizeCorner ($screenPoint.X - $form.Left) ($screenPoint.Y - $form.Top) $form.Width $form.Height)
|
|
1759
|
+
if ($wasResizeMoved) {
|
|
1760
|
+
Save-HudPositionIfReady
|
|
1761
|
+
Ensure-HudTopMost
|
|
1762
|
+
} elseif ($script:hudHorizontalPanel) {
|
|
1763
|
+
Toggle-HorizontalDetailPopup
|
|
1764
|
+
}
|
|
1765
|
+
return
|
|
1766
|
+
}
|
|
1767
|
+
$wasDragging = $script:dragging
|
|
1768
|
+
$wasMoved = $script:dragMoved
|
|
1140
1769
|
$script:dragging = $false
|
|
1141
|
-
|
|
1770
|
+
$script:dragMoved = $false
|
|
1771
|
+
if ($wasDragging -and (-not $wasMoved) -and $script:hudHorizontalPanel) {
|
|
1772
|
+
Toggle-HorizontalDetailPopup
|
|
1773
|
+
return
|
|
1774
|
+
}
|
|
1775
|
+
if ($canMove -and $wasMoved) {
|
|
1142
1776
|
Set-HudAnchorFromPlacement $form.Location ([Nullable[int]]$form.Width) ([Nullable[int]]$form.Height)
|
|
1143
1777
|
Write-HudPosition $form.Location
|
|
1144
1778
|
Ensure-HudTopMost
|
|
1145
1779
|
}
|
|
1146
1780
|
}
|
|
1781
|
+
$mouseLeave = {
|
|
1782
|
+
param($sender, $event)
|
|
1783
|
+
if (-not $script:resizeDrag) {
|
|
1784
|
+
Set-HudResizeCursor $null
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1147
1787
|
# A docked HUD is glued to its terminal window; dragging and position saving
|
|
1148
1788
|
# are floating-mode concepts.
|
|
1149
|
-
$canMove = ($DockWindowHandle -eq 0) -and ($Movable -or ((
|
|
1789
|
+
$canMove = ($DockWindowHandle -eq 0) -and ($Movable -or ((@("floating", "icon", "rail", "horizontal") -contains $Mode) -and (-not $Locked)))
|
|
1150
1790
|
$script:positionSaveReady = $false
|
|
1151
1791
|
$script:hudHiddenForFullscreen = $false
|
|
1152
1792
|
|
|
@@ -1158,11 +1798,23 @@ function Save-HudPositionIfReady {
|
|
|
1158
1798
|
|
|
1159
1799
|
if ($canMove) {
|
|
1160
1800
|
$dragControls = @($form, $panel, $codexRow, $claudeRow, $antigravityRow) + $codexHudControls + $claudeHudControls + $antigravityHudControls
|
|
1801
|
+
if ($script:horizontalPaintPanel) { $dragControls += $script:horizontalPaintPanel }
|
|
1161
1802
|
if ($hitForm) { $dragControls += $hitForm }
|
|
1162
1803
|
foreach ($control in $dragControls) {
|
|
1163
1804
|
$control.add_MouseDown($mouseDown)
|
|
1164
1805
|
$control.add_MouseMove($mouseMove)
|
|
1165
1806
|
$control.add_MouseUp($mouseUp)
|
|
1807
|
+
$control.add_MouseLeave($mouseLeave)
|
|
1808
|
+
}
|
|
1809
|
+
$ctrlWheelHandler = [Action[int]]{
|
|
1810
|
+
param($delta)
|
|
1811
|
+
$step = if ($delta -gt 0) { 0.1 } elseif ($delta -lt 0) { -0.1 } else { 0 }
|
|
1812
|
+
if ($step -ne 0) { Set-HudUserScale ($script:hudUserScale + $step) }
|
|
1813
|
+
}
|
|
1814
|
+
foreach ($wheelForm in @($form, $hitForm)) {
|
|
1815
|
+
if ($wheelForm -and ($wheelForm -is [AiBatteryHudForm])) {
|
|
1816
|
+
$wheelForm.add_HudCtrlWheel($ctrlWheelHandler)
|
|
1817
|
+
}
|
|
1166
1818
|
}
|
|
1167
1819
|
}
|
|
1168
1820
|
|
|
@@ -1337,6 +1989,11 @@ $form.add_FormClosed({
|
|
|
1337
1989
|
}
|
|
1338
1990
|
$font.Dispose()
|
|
1339
1991
|
$symbolFont.Dispose()
|
|
1992
|
+
if ($menuFont) { $menuFont.Dispose() }
|
|
1993
|
+
if ($script:detailPopupForm -and -not $script:detailPopupForm.IsDisposed) {
|
|
1994
|
+
$script:detailPopupForm.Close()
|
|
1995
|
+
$script:detailPopupForm.Dispose()
|
|
1996
|
+
}
|
|
1340
1997
|
if ($hitForm -and -not $hitForm.IsDisposed) {
|
|
1341
1998
|
$hitForm.Close()
|
|
1342
1999
|
$hitForm.Dispose()
|
|
@@ -1354,6 +2011,9 @@ $form.add_SizeChanged({
|
|
|
1354
2011
|
Sync-HitFormBounds
|
|
1355
2012
|
})
|
|
1356
2013
|
$form.add_Shown({
|
|
2014
|
+
if (-not $script:dockTuiStatusline) {
|
|
2015
|
+
Resize-HudToContent
|
|
2016
|
+
}
|
|
1357
2017
|
Show-HitForm
|
|
1358
2018
|
Update-HudVisibilityForFullscreen
|
|
1359
2019
|
Update-HudDockPlacement
|
|
@@ -1371,6 +2031,7 @@ if ($script:initialHudSnapshot) {
|
|
|
1371
2031
|
} else {
|
|
1372
2032
|
$script:latestSnapshot = $diskSnapshot
|
|
1373
2033
|
}
|
|
2034
|
+
$script:latestSnapshot = Get-CurrentHudSnapshot $script:latestSnapshot
|
|
1374
2035
|
Update-HudFromSnapshot $script:latestSnapshot
|
|
1375
2036
|
Start-SnapshotFetch
|
|
1376
2037
|
$style = [AiBatteryNative]::GetWindowLong($form.Handle, [AiBatteryNative]::GWL_EXSTYLE)
|