Code Monkey home page Code Monkey logo

Comments (5)

mitchellwrosen avatar mitchellwrosen commented on July 30, 2024

That was fast :)

from brick.

mitchellwrosen avatar mitchellwrosen commented on July 30, 2024

Ah, I'm still seeing some unintuitive behavior. Other widgets don't seem to affect width/height like I'm expecting. Example:

w :: Widget
w = Widget Fixed Fixed $ do
    c <- getContext
    render (str (show (availWidth c)))

-- shows "123"
main = simpleMain w

-- shows "          113"
main = simpleMain (padLeft (Pad 10) w)

-- shows "hello          113"
main = simpleMain (str "hello" <+> padLeft (Pad 10) w))

I'd expect the last width to be 108 to account for the hello, no?

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

Try with a47f924.

from brick.

mitchellwrosen avatar mitchellwrosen commented on July 30, 2024

Looks good!

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

If you use this technique in a custom widget with a Greedy policy in the relevant dimension (greedy horizontally in a horizontal box) then the value you get for the available width will be the available width divided by the number of remaining widgets in the box since when boxes render greedy children they give each greedy child the same amount of space. That ends up being reasonable more often than not. In your case you'll get the exact remaining space because your widget takes priority due to its Fixed policy. I just bring this up so you know that what you're seeing will/should vary depending on the layout conditions.

from brick.

Related Issues (20)

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.