Title bar
A window’s themed title bar, 34 points tall: the title on the left and actions on the right. Pair it with fastframe-titlebar to drag the window and draw its buttons.
Window
TitleBar::new()
.title("fastframe gallery")
.leading(12.0)
.show(ui, |bar| {
bar.right(|ui| {
ui.add(Button::ghost("Docs").small());
let bell = glyph(ui.ctx(), "bell");
Badge::new().count(state.notifications).show(ui, |ui| {
let button = ui.add(
Button::icon_only(bell)
.small()
.style(&fastframe_ui::button_styles::Ghost),
);
if button.clicked() {
state.notifications += 1;
}
button
});
});
});
With fastframe-titlebar
// In an app:
// let height = tokens(ui.ctx()).shape.metrics.title_bar.height;
// let room = fastframe_titlebar::footprint(ui.ctx(), height);
let (left, right) = (12.0, 108.0); // room.left, room.right
let shown = TitleBar::new()
.title("Untitled")
.leading(left)
.trailing(right)
// .under_content(|ui, rect| fastframe_titlebar::drag(ui, rect))
.show(ui, |bar| {
bar.center(|ui| {
ui.label("Draft");
});
bar.right(|ui| {
ui.add(Button::primary("Share").small());
});
bar.rect()
});
// fastframe_titlebar::controls(ui, &style, &labels);
Centred title
TitleBar::new().borderless().show(ui, |bar| {
bar.left(|ui| {
ui.add(Button::ghost("Back").small());
});
bar.center(|ui| {
ui.strong("Settings");
});
bar.right(|ui| {
ui.add(Button::ghost("Done").small());
});
});
The story above is gallery/src/stories/title_bar.rs, running in your browser. Every snippet on this page is cut from it.