Coder Social home page Coder Social logo

easydialogs's People

Contributors

marcoconti83 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

lamar8

easydialogs's Issues

Form window is not sized properly

Problem

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.

Expected behaviour

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).

How to reproduce

  1. check out the fix/form-window-resizing branch
  2. run carthage bootstrap --platform osx
  3. open XCode and run the EasyDialogExample schema
  4. The app will open an show a window with a button for "Large" or "Small" form. Try both.

Details

The 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.

Attempted solution

Set the scroll size min and max

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.

Set the scroll size to be the stack size

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.

Modify the scroll view 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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.