Closed LucasPickering closed 2 months ago
fn title<T: Into
>(self, title: T, position: Position) -> Self;
<pre-coffee-josh>
This change would be a "break the world" type change, so it is very likely not the right approach. The underlying idea is sound however. Likely title_at or something similar would work.
<post-coffee-josh>
So the idea with removing block::Title is that Line already has an indication of Left/Center/Right as part of it. For the block titles it doesn't seem like there's any possible use of this field other than positioning. Which leaves the position really only needing top / bottom. What's your thoughts on this?
You know, it never occurred to me to use the alignment field for this. The functionality I want is already possible, and would continue to work with the other proposal. I'm going to close this. Thanks!
The alignment field on title also does the same thing. The overlap in having a Title that contains a Line which both have alignment is where the removal proposal comes from.
Problem
I have a use case for adding a title to the top-right of a block. The block already has a primary title in the top-left, but I'd like to add some secondary information to the top-right. The label could go in the bottom-left, but with the layout of my TUI, that makes it harder to notice. Top-right would make it the most discoverable.
Solution
block::Position
:TopLeft
,TopRight
,BottomRight
,BottomLeft
Top
andBottom
Block
to support the new variants, and treatTop
andBottom
the same asTopLeft
andBottomLeft
, respectivelyTop
andBottom
variantsAlternatives
You can manually write text on top of the block border, so this functionality is current possible, just inconvenient.
Additional context
738 proposes to remove
Position
in favor of methods directly onBlock
:Block::top_title
andBlock::bottom_title
. This would conflict with my proposal. We could just add 4 methods toBlock
for titles, but that feels very inflexible and verbose. Instead, I propose updating the signature ofBlock::title
to the following:This would keep the flexibility of having positions be defined in an enum, while still eliminating the redundancy of the
Title
type.