Files
community-plugins/screen-toolkit/widget.luau
T
d5bf4d2168 feat(panel): remove full mode, rename compact to standard and fixed some UI (#328)
* feat(panel): remove full mode, rename compact to standard

- Remove panel-full entry (660×340) and all full-mode code paths
- Rename compact → standard across panel, settings, translations
- Restrict tile hover/click to icon+label only (no border hover)
- Shrink close button to 24×24 with 12px glyph
- Reduce standard section vertical padding to 4px
- Standard panel height: 290 → 260 (matches legacy at 260)
- Fix widget/shortcut/service toggle to respect panel-mode setting
- Update README with correct sizes and behavior

* added new thumbnail.webp

---------

Co-authored-by: Ahmed5Emad <ahmed5emad@users.noreply.github.com>
2026-08-10 20:32:07 -04:00

69 lines
2.2 KiB
Luau

--!nonstrict
-- Screen Toolkit — bar [[widget]].
--
-- Crosshair glyph; a pulsing red dot appears while a recording is active.
-- Left click toggles the main panel; right click quick-picks a color.
-- Recording logic lives in the [[service]] — this widget
-- only reflects the published state and drives the service through the
-- "command" state channel.
local recording = false
local phase = 0
local startedAt = nil
local function elapsed()
if not startedAt then return "00:00" end
local seconds = math.max(0, os.time() - startedAt)
return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
end
local function render()
local container = barWidget.isVertical() and ui.column or ui.row
local children = {}
if recording then
table.insert(children, ui.box({
key = "rec-dot",
width = 7,
height = 7,
radius = 4,
fill = (phase % 2 == 0) and "error" or "error/0.35",
}))
table.insert(children, ui.label({ text = `REC {elapsed()}`, fontSize = 11, fontWeight = "bold", color = "error" }))
end
table.insert(children, ui.glyph({ name = "crosshair", size = 14 }))
barWidget.render(container({ gap = 6, align = "center" }, children))
barWidget.setTooltip(recording and noctalia.tr("widget.recording") or noctalia.tr("widget.tooltip"))
end
-- Pulse the dot: the bar has no frame ticks, so re-render on a half-second cadence.
function update()
noctalia.setUpdateInterval(500)
phase += 1
render()
end
noctalia.state.watch("recording", function(value)
recording = value == true
startedAt = noctalia.state.get("recordStartedAt")
render()
end)
noctalia.state.watch("recordStartedAt", function(value)
startedAt = value
render()
end)
function onClick()
-- The bar icon never stops a recording; it just opens the panel so the
-- stop button (in the panel header, next to the close X) is reachable.
local mode = noctalia.getConfig("panel-mode")
local id = (mode == "legacy") and "alexander/screen-toolkit:panel-legacy" or "alexander/screen-toolkit:panel"
noctalia.togglePanel(id)
end
function onRightClick()
-- Quick pick: copies the color and notifies, but never toggles the panel.
noctalia.state.set("command", { action = "colorPicker", payload = { reopen = false } })
end
render()