Repository navigation
Added Windows support + a lot of fixes - #1
Merged
Merged
Conversation
- 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.
… OpenGL backend with WGL context management
…ent standalone exit
…s changed sized based and scrubber were to long to have decent range.
There was a problem hiding this comment.
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 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.