Skip to content

Added Windows support + a lot of fixes - #1

Merged
Brokezawa merged 19 commits into
mainfrom
push-nslxtqmluztq
Jun 9, 2026
Merged

Brokezawa merged 19 commits into
mainfrom
push-nslxtqmluztq

Conversation

@Brokezawa

Copy link
Copy Markdown
Owner

No description provided.

Brokezawa added 19 commits June 5, 2026 13:57
- Deferred Silky swapchain creation to tickGui loop until window handle is available, preventing crash when CPLUG calls createGUI before setParent.
- Prevented Figdraw from destroying its Vulkan swapchain context on every frame when the target HWND was fetched repeatedly in tickGui.
- Adapted run_and_capture.ps1 for null HWND handling during automated GUI testing.
…s changed sized based and scrubber were to long to have decent range.
Copilot AI review requested due to automatic review settings June 9, 2026 12:04
@Brokezawa
Brokezawa merged commit a310681 into main Jun 9, 2026
1 of 5 checks passed
@Brokezawa
Brokezawa deleted the push-nslxtqmluztq branch June 9, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on broadening Windows support and improving GUI/packaging behavior across nimplug’s backends (Silky immediate-mode + Figdraw retained-mode). It introduces a shared GUI utilities module, adjusts Windows build/link flags, and fixes several input/DPI/layout behaviors across examples and widgets.

Changes:

  • Add Windows-focused GUI utilities (key normalization, size constraint helper, printable-text filtering, focus-on-click helper) and apply them across Silky/Figdraw.
  • Introduce/adjust Windows GUI rendering paths (notably OpenGL/WGL handling) and DPI-aware sizing logic.
  • Refactor/clean up assorted widgets/examples/config scripts and update dependency/build paths.

Reviewed changes

Copilot reviewed 37 out of 60 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test_dpi.nim Adds a standalone Windows DPI probe script (currently unreferenced).
src/nimplug/util/package.nims Updates packaging helpers and Windows GUI build/link/backend selection logic.
src/nimplug/plugin.nim Adjusts macro-generated code and Windows DPI scaling for init GUI sizing.
src/nimplug/gui/silky/immediate.nim Defers Silky context init; adds Windows WGL OpenGL path; improves event handling and scaling.
src/nimplug/gui/silky/auto.nim Updates Silky layout sizing to use sk.rootSize and tweaks dropdown usage.
src/nimplug/gui/figdraw/widgets/xy_pad.nim Simplifies tree access (removes casts) for theme/focus usage.
src/nimplug/gui/figdraw/widgets/waveform.nim Simplifies tree access (removes casts) for theme usage.
src/nimplug/gui/figdraw/widgets/text_input.nim Improves clipboard sizing, text drawing call signature, selection behavior, and key handling.
src/nimplug/gui/figdraw/widgets/slider.nim Normalizes keycodes to PW_* constants and simplifies tree access.
src/nimplug/gui/figdraw/widgets/preset_panel.nim Removes now-unneeded tree import.
src/nimplug/gui/figdraw/widgets/panel.nim Simplifies theme lookup via c.tree.theme.
src/nimplug/gui/figdraw/widgets/meter.nim Simplifies theme lookup via c.tree.theme.
src/nimplug/gui/figdraw/widgets/knob.nim Simplifies theme/focus lookup via c.tree.
src/nimplug/gui/figdraw/widgets/dropdown.nim Normalizes keycodes and simplifies tree access; minor control-flow tweak.
src/nimplug/gui/figdraw/widgets/basic.nim Uses PW_* key constants for button activation.
src/nimplug/gui/figdraw/types.nim Extends click tracking fields on ComponentTree state.
src/nimplug/gui/figdraw/tree.nim Implements click counting and adjusts theme helper; tab navigation logic changed.
src/nimplug/gui/figdraw/host.nim Moves shared helpers into utils; adjusts event handling + bridge lifecycle; DPI init sizing uses shared helper.
src/nimplug/gui/figdraw/graphics/context.nim Fixes text bounding offset handling; adjusts measureText width behavior.
src/nimplug/gui/figdraw/graphics/bridge.nim Switches Windows rendering path to WGL OpenGL; adds clear color support + teardown.
src/nimplug/gui/common/utils.nim New shared helper module for key normalization, size constraints, printable filtering, focus on click.
nimplug.nimble Switches some dependencies to GitHub URL requires.
nim.cfg Updates Atlas path entries (notably lockfreequeues path and vulkan path).
examples/ui_demo/ui_demo.nim Simplifies figdraw graphics import.
examples/taskpools_demo/taskpools_demo.nim Updates imports after taskpool/messaging refactor.
examples/run_and_capture.sh Adds MSYS2-oriented run + screenshot capture helper.
examples/grid_demo/grid_demo.nim Refactors UI wiring into helper procs; formatting changes; adds initial meter levels.
examples/gain_with_silky/config.nims Adds debug flags/defines and console mode switches.
examples/figdraw_demo/pluginconfig.nim Adds CLAP features; minor formatting.
examples/figdraw_demo/figdraw_demo.nim Simplifies figdraw graphics import.
examples/figdraw_demo/config.nims Adds CLAP/VST3 build tasks; formatting.
examples/dsp_showcase/dsp_showcase.nim Adds bumpy import; refactors params/UI labels; changes bypass semantics for spectral gate; adds fixed-size buttons.
examples/demo_graphics/pluginconfig.nim Adds outputChannels.
examples/demo_graphics/demo_graphics.nim Initializes GUI size fields on create.
examples/delay_with_undo/delay_with_undo.nim Adjusts GUI height; uses sk.rootSize for layout sizing.
examples/animation_demo/animation_demo.nim Tweaks initial/reset direction flags for animation flow.
.gitignore Broadens ignored logs and Windows executables.

Comment thread test_dpi.nim
Comment on lines +1 to +5
proc GetDpiForSystem(): uint32 {.stdcall, dynlib: "user32", importc: "GetDpiForSystem".}
try:
echo GetDpiForSystem()
except CatchableError as e:
echo "Error: ", e.msg
Comment on lines 315 to 319
# Tab navigation
if keyCode == PW_KEY_TAB.int:
if keyCode == 48: # PW_KEY_TAB.int
if kmShift in modifiers:
tree.requestFocus(tree.prevFocusable())
else:
let pt = GPoint(
x: event.anon0.mouse.x.float32 / ptScale, y: event.anon0.mouse.y.float32 / ptScale
)
let ts = 0.0
Comment on lines +454 to +465
let hglrc = wglCreateContext(hdc)
if hglrc.isNil:
discard ReleaseDC(nativeWindow, hdc)
return false
replica.hdc = cast[ptr OpaqueHandle](hdc)
replica.hglrc = cast[ptr OpaqueHandle](hglrc)
if wglMakeCurrent(hdc, hglrc) == 0:
discard wglDeleteContext(hglrc)
discard ReleaseDC(nativeWindow, hdc)
return false
loadExtensions()
elif defined(macosx):
Comment on lines +112 to +135
if not hwnd.isNil:
result.lastHwnd = hwnd
let hdc = getDC(hwnd)
result.hdc = hdc
var pfd = PIXELFORMATDESCRIPTOR(
nSize: uint16(sizeof(PIXELFORMATDESCRIPTOR)),
nVersion: 1,
dwFlags: 0x00000025u32,
# PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER
iPixelType: 0, # PFD_TYPE_RGBA
cColorBits: 32,
cDepthBits: 24,
cStencilBits: 8,
iLayerType: 0, # PFD_MAIN_PLANE
)
let pf = choosePixelFormat(hdc, addr pfd)
discard setPixelFormat(hdc, pf, addr pfd)
let hglrc = wglCreateContext(hdc)
result.hglrc = hglrc
discard wglMakeCurrent(hdc, hglrc)
loadExtensions() # loads extensions via nim opengl package
result.renderer = newFigRenderer(2048)
discard wglMakeCurrent(nil, nil) # Release context
return
Comment on lines 295 to +302
if wantGui:
if not nativeUI:
when defined(macosx):
switch("define", "useMetal4")
elif defined(windows):
switch("define", "useVulkan")
if not defined(useDirectX) and not defined(useOpenGL) and not defined(useGL) and
not defined(useVulkan):
switch("define", "useVulkan")
Comment on lines +15 to +18
switch("define", "debugGui")
switch("app", "console")
switch("passC", "-g")
switch("passL", "-g")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants