marcoconti83 / easydialogs Goto Github PK
View Code? Open in Web Editor NEWA Swift Cocoa library to create forms and modal input dialogs
License: Other
A Swift Cocoa library to create forms and modal input dialogs
License: Other
The goal is to programmatically display a form (a bunch of controls) inside a window, and automatically resize the window to a "sensible" size that is never larger than the screen.
However when opening a form window (FormWindow
), the window has a size that does not match the size of the controls in the form and needs to be manually resized by the user.
The desired behaviour of the window (FormWindow
) is that the window expands to a size that is large enough to include the form controls (minimum size necessary to display all controls), unless that would make the window larger than the screen. In this case, the window should be limited by the screen size, and the form controls will be clipped (inside a scroll view).
carthage bootstrap --platform osx
EasyDialogExample
schemaThe window in FormWindow
is composed of three sections:
The three sections are constrained to be on top of each other, in that order, filling the entire window. The relevant part for the purpose of this issue is the stack.
The stack is a NSStackView
inside a NSScrollView
. The NSStackView
holds the form controls. The desired behavior is that the scroll view will grow to adjust to the minimum size necessary to accommodate the stack with no clipping, unless this will make the whole window larger than the screen, i.e. the top (or bottom) of the window is far off the screen and it can not be reached with the mouse.
If this were to happen, the NSScrollView
should instead clip the stack view, so that the window is as large as the screen but it does not grow beyond it, and the user can scroll to visit the entire stack.
scroll.height <= stack.height
scroll.height >= 300
Why it doesn't work: the scroll size is always the minimum one. I need to manually resize the window after it's displayed.
scroll.height == stack.height
Why it doesn't work: the window is always as large as needed to display the form. This works as long as the stack plus the rest of the window is smaller than the screen. However it will make the window larger than the screen.
intrinsicContentSize
I subclassed NSStackView
to return an intrinsic content size which is equal to the size of the documentView
. However, the intrinsic size property is accessed before performing the layout, so the intrinsic content size of the subview at that moment is (-1,-1)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.