mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-12 12:23:21 +03:00
Core: make fixed padding take precedence over padded widgets (fixes #42)
Prior to this commit, padding a widget meant that if there was room after rendering the widget, the specified amount of padding would be added. This meant that under tight layout constraints padding would disappear before a padded widget would. This is often a desirable outcome but it also led to unexpected behavior when adding padding to a widget that grows greedily: fixed padding would never show up because it was placed in a box adjacent to the widget in question, and boxes always render greedy children before fixed ones. As a result fixed padding would disappear under these conditions. Instead, in the case of fixed padding, since we often intend to *guarantee* that padding is present, all of the padding combinators have been modified so that when the padded widget is rendered with fixed padding in the amount V, the widget is given V fewer rows/columns when it is rendered so that the padding always has room.
This commit is contained in:
parent
568df56630
commit
04755d48f1
@ -153,7 +153,11 @@ padLeft padding p =
|
|||||||
Max -> (id, Greedy)
|
Max -> (id, Greedy)
|
||||||
Pad i -> (hLimit i, hSize p)
|
Pad i -> (hLimit i, hSize p)
|
||||||
in Widget sz (vSize p) $ do
|
in Widget sz (vSize p) $ do
|
||||||
result <- render p
|
c <- getContext
|
||||||
|
let lim = case padding of
|
||||||
|
Max -> c^.availWidthL
|
||||||
|
Pad i -> c^.availWidthL - i
|
||||||
|
result <- render $ hLimit lim p
|
||||||
render $ (f $ vLimit (result^.imageL.to V.imageHeight) $ fill ' ') <+>
|
render $ (f $ vLimit (result^.imageL.to V.imageHeight) $ fill ' ') <+>
|
||||||
(Widget Fixed Fixed $ return result)
|
(Widget Fixed Fixed $ return result)
|
||||||
|
|
||||||
@ -166,7 +170,11 @@ padRight padding p =
|
|||||||
Max -> (id, Greedy)
|
Max -> (id, Greedy)
|
||||||
Pad i -> (hLimit i, hSize p)
|
Pad i -> (hLimit i, hSize p)
|
||||||
in Widget sz (vSize p) $ do
|
in Widget sz (vSize p) $ do
|
||||||
result <- render p
|
c <- getContext
|
||||||
|
let lim = case padding of
|
||||||
|
Max -> c^.availWidthL
|
||||||
|
Pad i -> c^.availWidthL - i
|
||||||
|
result <- render $ hLimit lim p
|
||||||
render $ (Widget Fixed Fixed $ return result) <+>
|
render $ (Widget Fixed Fixed $ return result) <+>
|
||||||
(f $ vLimit (result^.imageL.to V.imageHeight) $ fill ' ')
|
(f $ vLimit (result^.imageL.to V.imageHeight) $ fill ' ')
|
||||||
|
|
||||||
@ -178,7 +186,11 @@ padTop padding p =
|
|||||||
Max -> (id, Greedy)
|
Max -> (id, Greedy)
|
||||||
Pad i -> (vLimit i, vSize p)
|
Pad i -> (vLimit i, vSize p)
|
||||||
in Widget (hSize p) sz $ do
|
in Widget (hSize p) sz $ do
|
||||||
result <- render p
|
c <- getContext
|
||||||
|
let lim = case padding of
|
||||||
|
Max -> c^.availHeightL
|
||||||
|
Pad i -> c^.availHeightL - i
|
||||||
|
result <- render $ vLimit lim p
|
||||||
render $ (f $ hLimit (result^.imageL.to V.imageWidth) $ fill ' ') <=>
|
render $ (f $ hLimit (result^.imageL.to V.imageWidth) $ fill ' ') <=>
|
||||||
(Widget Fixed Fixed $ return result)
|
(Widget Fixed Fixed $ return result)
|
||||||
|
|
||||||
@ -191,7 +203,11 @@ padBottom padding p =
|
|||||||
Max -> (id, Greedy)
|
Max -> (id, Greedy)
|
||||||
Pad i -> (vLimit i, vSize p)
|
Pad i -> (vLimit i, vSize p)
|
||||||
in Widget (hSize p) sz $ do
|
in Widget (hSize p) sz $ do
|
||||||
result <- render p
|
c <- getContext
|
||||||
|
let lim = case padding of
|
||||||
|
Max -> c^.availHeightL
|
||||||
|
Pad i -> c^.availHeightL - i
|
||||||
|
result <- render $ vLimit lim p
|
||||||
render $ (Widget Fixed Fixed $ return result) <=>
|
render $ (Widget Fixed Fixed $ return result) <=>
|
||||||
(f $ hLimit (result^.imageL.to V.imageWidth) $ fill ' ')
|
(f $ hLimit (result^.imageL.to V.imageWidth) $ fill ' ')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user