Fix win32 widget sizing, slider events, scroll view#123
Open
pmarreck wants to merge 2 commits intocapy-ui:masterfrom
Open
Fix win32 widget sizing, slider events, scroll view#123pmarreck wants to merge 2 commits intocapy-ui:masterfrom
pmarreck wants to merge 2 commits intocapy-ui:masterfrom
Conversation
This migrates the entire codebase from Zig 0.14.1 to Zig 0.15.2. Key API changes: - Remove `usingnamespace` (removed from the language) — all mixins now use explicit re-export of each declaration - `ArrayList.init(allocator)` → `.empty` + pass allocator to each method call (deinit, append, appendSlice, etc.) - `callconv(.C)` → `callconv(.c)` (lowercase enum literals) - `std.os.windows.WINAPI` → `std.builtin.CallingConvention.winapi` - `std.fmt.allocPrintZ` → `std.fmt.allocPrintSentinel` - `std.atomic.Atomic` → `std.atomic.Value` - `std.sort.sort` → `std.mem.sort` - `std.time.sleep` → `std.Thread.sleep` - `SinglyLinkedList` became intrusive (compat wrapper added in data.zig) - `BoundedArray` removed (compat replacement in containers.zig) - `anyframe` removed (async.zig stubbed) - `std.Uri.path` API changes (toRaw signature) - format function signatures changed - zigimg StreamSource → ReadStream API Also updates: - vendor/zigwin32 for 0.15.2 compatibility - build.zig / build_capy.zig for 0.15.2 build API - build.zig.zon dependency hashes (zig-objc, zigimg) - flake.nix / flake.lock for Zig 0.15.2 toolchain All 28 examples compile successfully on both x86_64-windows-gnu (cross-compile) and native macOS (aarch64-macos).
Three win32 backend bug fixes: 1. **Dynamic getPreferredSize**: Widgets now measure their actual text content via GDI (GetTextExtentPoint32W) instead of returning a hardcoded 100×50 fallback. Added measureWindowText() helper and per-widget getPreferredSize_impl for Label, Button, CheckBox, TextField, TextArea, Slider, and Dropdown. 2. **Slider WM_HSCROLL property change**: The trackbar control sends WM_HSCROLL to its parent with lParam pointing to the trackbar HWND. Previously this was handled as a scrollbar event, losing the slider value change notification. Now dispatches through propertyChangeHandler when lParam != 0 (trackbar child) vs lParam == 0 (scrollbar). 3. **ScrollView child sizing**: Child components are now clamped to at least the visible area dimensions, matching NSScrollView/GtkScrolledWindow behavior. Previously a child with a small preferred size would be clipped smaller than the viewport.
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.
Summary
Three win32 backend bug fixes. Depends on #122 (Zig 0.15.2 migration) — please merge that first.
1. Dynamic getPreferredSize (was hardcoded 100×50)
The win32
Events.getPreferredSize()returned a hardcodedSize(100, 50)for all widgets. This caused layout issues when the layout engine used preferred sizes.Fix: Added
measureWindowText()helper that uses GDI text measurement (GetDC→SelectObject(font)→GetTextExtentPoint32W→ReleaseDC), and per-widgetgetPreferredSize_imploverrides:2. Slider WM_HSCROLL not dispatching property changes
The trackbar control sends
WM_HSCROLLto its parent window withlParampointing to the trackbar HWND. The handler was treating allWM_HSCROLLmessages as scrollbar events, so slider value changes were lost.Fix: Check
lParam: when non-zero, dispatch through the child trackbar'spropertyChangeHandler(converting the integer position back to float usingstepSize). When zero, handle as scrollbar event (existing code).3. ScrollView child clipping
When a child's preferred size was smaller than the scroll view's visible area, the child was sized smaller than the viewport, leaving dead space.
Fix: Clamp child dimensions to
@max(preferred, visible_area), matching NSScrollView/GtkScrolledWindow behavior.Test plan
x86_64-windows-gnu(all 22 examples)