|
From: | dr_clow |
Subject: | NSWindow resize and NSView layout method |
Date: | Sat, 19 Aug 2023 19:03:26 -0500 |
Regarding NSView layout. On Mac OS and iOS I have a custom layout engine that I wrote that gets called in an overridden layout (macOS) or layoutSubviews (iOS) Usually, how this works is I set the root view that controls this layout system as the contentView for the window. Then when the window is resized, layout is called, it checks if there are invalidated views (of that the frame size is different than it used too be) and updates them all based on the new frame. (It's actually all written in Swift and it working great with GNUStep bridge btw). On GNUStep, layout is not called when window is resized so none of the layout code gets invoked. To hack this, I just inserted [self layout]; in NSView's setFrame: at the very end of the method. This works, but probably isn't efficient. So I looked to the NSWindowDecorationView. I was thinking maybe we could call [windowContentView _layoutViewAndSubViews] or [windowContentView layout] in GSWindowDecorationView.m in the DecorationView's layout method? I went ahead and tried changing GSWindowDecorationView layout method to include [windowContentView _layoutViewAndSubViews] it didn't work (probably because setFrame, validates the layou causing _layoutViewAndSubViews to exit early?) but [windowContentView layout] does work quite nicely, but I assume that this may not be efficient. Any thoughts on how we should get layout to fire appropriately and efficnielty? For now, I am working with a hacked version of libs-gui to get a lot of these types of things working on GNUStep with my current iOS and macOS projects. Thanks! |
[Prev in Thread] | Current Thread | [Next in Thread] |