Skip to content

Commit

Permalink
Brick.Widgets.Core.relativeTo: draw nothing if requested relative pos…
Browse files Browse the repository at this point in the history
…ition extent is not found
  • Loading branch information
jtdaugherty committed Nov 21, 2024
1 parent ca36492 commit adc0fe3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Brick/Widgets/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,8 @@ translateBy off p =
-- | Given a widget, translate it to position it relative to the
-- upper-left coordinates of a reported extent with the specified
-- positioning offset. If the specified name has no reported extent,
-- this just draws the specified widget with no special positioning.
-- this draws nothing on the basis that it only makes sense to draw what
-- was requested when the relative position can be known.
--
-- This is only useful for positioning something in a higher layer
-- relative to a reported extent in a lower layer. Any other use is
Expand All @@ -1103,7 +1104,7 @@ relativeTo n off w =
Widget (hSize w) (vSize w) $ do
mExt <- lookupReportedExtent n
case mExt of
Nothing -> render w
Nothing -> render emptyWidget
Just ext -> render $ translateBy (extentUpperLeft ext <> off) w

-- | Crop the specified widget on the left by the specified number of
Expand Down

0 comments on commit adc0fe3

Please sign in to comment.