What's the width of a greedy widget that comes after a widget that already exceeded available space? #431
-
Does the greedy widget grow very large? Or, does it become emptyWidget and avoid calculating its contents? Let's assume that the given horizontal space is 15, but a widget in hBox already consumes 16. This is the minimal example. module Main where
import Brick.Types
import Brick.Widgets.Core
import Brick.Widgets.Center
import Brick.Widgets.Border
import Brick.Main
import Brick.AttrMap
import Graphics.Vty.Attributes (defAttr)
import Graphics.Vty.Input
import Control.Monad (void)
drawUi :: () -> [Widget ()]
drawUi () = let
greedyText = Widget Greedy Fixed $ do
render $ hCenter $ str "ok"
mainW = border $ hLimit 15 $ hBox [greedyText, str "1234567890", greedyText, str "123456", greedyText]
doc = str "Prsss Esc to quit"
in [ vCenter $ vBox [ hCenter mainW, hCenter doc ] ]
handleEvent :: BrickEvent () () -> EventM () () ()
handleEvent e = case e of
VtyEvent (EvKey KEsc _) -> halt
_ -> return ()
main :: IO ()
main = do
let app = App { appDraw = drawUi
, appChooseCursor = neverShowCursor
, appHandleEvent = handleEvent
, appStartEvent = return ()
, appAttrMap = const $ attrMap defAttr [] }
void $ defaultMain app () This is what I see. The first two greedyTexts are not rendered. But, I don't know whether or not the third greedyText is rendered because it is cropped out of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst says
Thus, it seems the third greedyText widget is knocked out and not rendered. The basics seem to be understood only after writing some code and reading the documentation multiple times. |
Beta Was this translation helpful? Give feedback.
-
The box layout algorithm always renders |
Beta Was this translation helpful? Give feedback.
https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst says
Thus, it seems the third greedyText widget is knocked out and not rendered.
The basics seem to be understood only after writing some code and reading the documentation multiple times.