pub struct Title { /* private fields */ }Expand description
A builder for positioning block titles with horizontal alignment and vertical placement.
This struct handles only the positioning of titles (alignment and position),
preserving any text styling you’ve already applied. You can style your text
separately using TitleStyle or ratatui’s styling features.
§Examples
use tui_piechart::title::{Title, TitleStyle};
use tui_piechart::border_style::BorderStyle;
// Simple title with defaults (center top)
let simple = Title::new("Statistics");
// Style text first, then position it
let styled_text = TitleStyle::Bold.apply("Results");
let title = Title::new(styled_text)
.right()
.bottom();
// Position plain text
let positioned = Title::new("Dashboard")
.center()
.top();§Method Chaining
All builder methods return Self, allowing for fluent method chaining:
use tui_piechart::title::Title;
let title = Title::new("My Chart")
.center() // horizontal alignment
.bottom(); // vertical positionImplementations§
Source§impl Title
impl Title
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
Creates a new title with the given text and default positioning.
Defaults: Center alignment, Top position
The text is preserved as-is, including any styling you’ve already applied.
Sourcepub fn render(&self) -> Line<'static>
pub fn render(&self) -> Line<'static>
Returns the text as a Line for rendering (preserves original styling).
Sourcepub fn alignment(&self) -> TitleAlignment
pub fn alignment(&self) -> TitleAlignment
Gets the horizontal alignment.
Sourcepub fn position(&self) -> TitlePosition
pub fn position(&self) -> TitlePosition
Gets the vertical position.
Trait Implementations§
impl Eq for Title
impl StructuralPartialEq for Title
Auto Trait Implementations§
impl Freeze for Title
impl RefUnwindSafe for Title
impl Send for Title
impl Sync for Title
impl Unpin for Title
impl UnwindSafe for Title
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more