2022-12-06 16:12:59 +01:00
|
|
|
// Copyright 2022 System76 <info@system76.com>
|
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2024-09-18 20:09:25 +02:00
|
|
|
use crate::cosmic_theme::Density;
|
2023-09-01 07:29:19 +02:00
|
|
|
use crate::{ext::CollectionWidget, widget, Element};
|
2022-10-09 02:35:03 -07:00
|
|
|
use apply::Apply;
|
2022-12-06 16:12:59 +01:00
|
|
|
use derive_setters::Setters;
|
2024-07-30 18:29:01 +02:00
|
|
|
use iced::Length;
|
2024-03-11 15:21:48 -04:00
|
|
|
use iced_core::{widget::tree, Widget};
|
2024-01-30 22:28:31 -05:00
|
|
|
use std::borrow::Cow;
|
2022-12-06 16:12:59 +01:00
|
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> {
|
|
|
|
|
HeaderBar {
|
2023-08-02 11:54:07 +02:00
|
|
|
title: Cow::Borrowed(""),
|
2022-12-06 16:12:59 +01:00
|
|
|
on_close: None,
|
|
|
|
|
on_drag: None,
|
|
|
|
|
on_maximize: None,
|
|
|
|
|
on_minimize: None,
|
2024-02-13 08:10:04 -08:00
|
|
|
on_right_click: None,
|
2023-08-02 11:54:07 +02:00
|
|
|
start: Vec::new(),
|
|
|
|
|
center: Vec::new(),
|
|
|
|
|
end: Vec::new(),
|
2024-05-28 07:46:28 +02:00
|
|
|
density: None,
|
2024-03-11 15:21:48 -04:00
|
|
|
focused: false,
|
2024-07-23 11:58:55 +02:00
|
|
|
on_double_click: None,
|
2022-12-06 16:12:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-09 02:35:03 -07:00
|
|
|
|
2022-10-11 15:27:39 +02:00
|
|
|
#[derive(Setters)]
|
2022-12-06 16:12:59 +01:00
|
|
|
pub struct HeaderBar<'a, Message> {
|
2023-08-02 11:54:07 +02:00
|
|
|
/// Defines the title of the window
|
|
|
|
|
#[setters(skip)]
|
2023-01-16 11:45:25 +01:00
|
|
|
title: Cow<'a, str>,
|
2023-08-02 11:54:07 +02:00
|
|
|
|
|
|
|
|
/// A message emitted when the close button is pressed.
|
2022-10-11 15:27:39 +02:00
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_close: Option<Message>,
|
2023-08-02 11:54:07 +02:00
|
|
|
|
|
|
|
|
/// A message emitted when dragged.
|
2022-10-11 15:27:39 +02:00
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_drag: Option<Message>,
|
2023-08-02 11:54:07 +02:00
|
|
|
|
|
|
|
|
/// A message emitted when the maximize button is pressed.
|
2022-10-11 15:27:39 +02:00
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_maximize: Option<Message>,
|
2023-08-02 11:54:07 +02:00
|
|
|
|
|
|
|
|
/// A message emitted when the minimize button is pressed.
|
2022-10-11 15:27:39 +02:00
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_minimize: Option<Message>,
|
2023-08-02 11:54:07 +02:00
|
|
|
|
2024-07-23 11:58:55 +02:00
|
|
|
/// A message emitted when the header is double clicked,
|
|
|
|
|
/// usually used to maximize the window.
|
|
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_double_click: Option<Message>,
|
|
|
|
|
|
2024-02-13 08:10:04 -08:00
|
|
|
/// A message emitted when the header is right clicked.
|
|
|
|
|
#[setters(strip_option)]
|
|
|
|
|
on_right_click: Option<Message>,
|
|
|
|
|
|
2023-08-02 11:54:07 +02:00
|
|
|
/// Elements packed at the start of the headerbar.
|
|
|
|
|
#[setters(skip)]
|
|
|
|
|
start: Vec<Element<'a, Message>>,
|
|
|
|
|
|
|
|
|
|
/// Elements packed in the center of the headerbar.
|
|
|
|
|
#[setters(skip)]
|
|
|
|
|
center: Vec<Element<'a, Message>>,
|
|
|
|
|
|
|
|
|
|
/// Elements packed at the end of the headerbar.
|
|
|
|
|
#[setters(skip)]
|
|
|
|
|
end: Vec<Element<'a, Message>>,
|
2024-05-28 07:46:28 +02:00
|
|
|
|
|
|
|
|
/// Controls the density of the headerbar.
|
|
|
|
|
#[setters(strip_option)]
|
|
|
|
|
density: Option<Density>,
|
|
|
|
|
|
|
|
|
|
/// Focused state of the window
|
|
|
|
|
focused: bool,
|
2023-08-02 11:54:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|
|
|
|
/// Defines the title of the window
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn title(mut self, title: impl Into<Cow<'a, str>> + 'a) -> Self {
|
|
|
|
|
self.title = title.into();
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Pushes an element to the start region.
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn start(mut self, widget: impl Into<Element<'a, Message>> + 'a) -> Self {
|
|
|
|
|
self.start.push(widget.into());
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Pushes an element to the center region.
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn center(mut self, widget: impl Into<Element<'a, Message>> + 'a) -> Self {
|
|
|
|
|
self.center.push(widget.into());
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Pushes an element to the end region.
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn end(mut self, widget: impl Into<Element<'a, Message>> + 'a) -> Self {
|
|
|
|
|
self.end.push(widget.into());
|
|
|
|
|
self
|
|
|
|
|
}
|
2024-01-11 15:16:21 -05:00
|
|
|
|
|
|
|
|
/// Build the widget
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn build(self) -> HeaderBarWidget<'a, Message> {
|
|
|
|
|
HeaderBarWidget {
|
2024-05-27 21:49:49 +02:00
|
|
|
header_bar_inner: self.view(),
|
2024-01-11 15:16:21 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct HeaderBarWidget<'a, Message> {
|
|
|
|
|
header_bar_inner: Element<'a, Message>,
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 22:14:00 -05:00
|
|
|
impl<'a, Message: Clone + 'static> Widget<Message, crate::Theme, crate::Renderer>
|
2024-01-11 15:16:21 -05:00
|
|
|
for HeaderBarWidget<'a, Message>
|
|
|
|
|
{
|
2024-03-18 16:58:02 -04:00
|
|
|
fn diff(&mut self, tree: &mut tree::Tree) {
|
|
|
|
|
tree.diff_children(&mut [&mut self.header_bar_inner]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-11 15:16:21 -05:00
|
|
|
fn children(&self) -> Vec<tree::Tree> {
|
|
|
|
|
vec![tree::Tree::new(&self.header_bar_inner)]
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 22:14:00 -05:00
|
|
|
fn size(&self) -> iced_core::Size<Length> {
|
|
|
|
|
self.header_bar_inner.as_widget().size()
|
2024-01-11 15:16:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn layout(
|
|
|
|
|
&self,
|
|
|
|
|
tree: &mut tree::Tree,
|
|
|
|
|
renderer: &crate::Renderer,
|
|
|
|
|
limits: &iced_core::layout::Limits,
|
|
|
|
|
) -> iced_core::layout::Node {
|
|
|
|
|
let child_tree = &mut tree.children[0];
|
|
|
|
|
let child = self
|
|
|
|
|
.header_bar_inner
|
|
|
|
|
.as_widget()
|
|
|
|
|
.layout(child_tree, renderer, limits);
|
|
|
|
|
iced_core::layout::Node::with_children(child.size(), vec![child])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw(
|
|
|
|
|
&self,
|
|
|
|
|
tree: &tree::Tree,
|
|
|
|
|
renderer: &mut crate::Renderer,
|
2024-01-30 22:14:00 -05:00
|
|
|
theme: &crate::Theme,
|
2024-01-11 15:16:21 -05:00
|
|
|
style: &iced_core::renderer::Style,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
|
|
|
|
cursor: iced_core::mouse::Cursor,
|
|
|
|
|
viewport: &iced_core::Rectangle,
|
|
|
|
|
) {
|
|
|
|
|
let layout_children = layout.children().next().unwrap();
|
|
|
|
|
let state_children = &tree.children[0];
|
|
|
|
|
self.header_bar_inner.as_widget().draw(
|
|
|
|
|
state_children,
|
|
|
|
|
renderer,
|
|
|
|
|
theme,
|
|
|
|
|
style,
|
|
|
|
|
layout_children,
|
|
|
|
|
cursor,
|
|
|
|
|
viewport,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn on_event(
|
|
|
|
|
&mut self,
|
|
|
|
|
state: &mut tree::Tree,
|
|
|
|
|
event: iced_core::Event,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
|
|
|
|
cursor: iced_core::mouse::Cursor,
|
|
|
|
|
renderer: &crate::Renderer,
|
|
|
|
|
clipboard: &mut dyn iced_core::Clipboard,
|
|
|
|
|
shell: &mut iced_core::Shell<'_, Message>,
|
|
|
|
|
viewport: &iced_core::Rectangle,
|
|
|
|
|
) -> iced_core::event::Status {
|
|
|
|
|
let child_state = &mut state.children[0];
|
|
|
|
|
let child_layout = layout.children().next().unwrap();
|
|
|
|
|
self.header_bar_inner.as_widget_mut().on_event(
|
|
|
|
|
child_state,
|
|
|
|
|
event,
|
|
|
|
|
child_layout,
|
|
|
|
|
cursor,
|
|
|
|
|
renderer,
|
|
|
|
|
clipboard,
|
|
|
|
|
shell,
|
|
|
|
|
viewport,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn mouse_interaction(
|
|
|
|
|
&self,
|
|
|
|
|
state: &tree::Tree,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
|
|
|
|
cursor: iced_core::mouse::Cursor,
|
|
|
|
|
viewport: &iced_core::Rectangle,
|
|
|
|
|
renderer: &crate::Renderer,
|
|
|
|
|
) -> iced_core::mouse::Interaction {
|
|
|
|
|
let child_tree = &state.children[0];
|
|
|
|
|
let child_layout = layout.children().next().unwrap();
|
|
|
|
|
self.header_bar_inner.as_widget().mouse_interaction(
|
|
|
|
|
child_tree,
|
|
|
|
|
child_layout,
|
|
|
|
|
cursor,
|
|
|
|
|
viewport,
|
|
|
|
|
renderer,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn operate(
|
|
|
|
|
&self,
|
|
|
|
|
state: &mut tree::Tree,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
|
|
|
|
renderer: &crate::Renderer,
|
|
|
|
|
operation: &mut dyn iced_core::widget::Operation<
|
|
|
|
|
iced_core::widget::OperationOutputWrapper<Message>,
|
|
|
|
|
>,
|
|
|
|
|
) {
|
|
|
|
|
let child_tree = &mut state.children[0];
|
|
|
|
|
let child_layout = layout.children().next().unwrap();
|
|
|
|
|
self.header_bar_inner
|
|
|
|
|
.as_widget()
|
|
|
|
|
.operate(child_tree, child_layout, renderer, operation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn overlay<'b>(
|
|
|
|
|
&'b mut self,
|
|
|
|
|
state: &'b mut tree::Tree,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
|
|
|
|
renderer: &crate::Renderer,
|
2024-01-30 22:14:00 -05:00
|
|
|
) -> Option<iced_core::overlay::Element<'b, Message, crate::Theme, crate::Renderer>> {
|
2024-01-11 15:16:21 -05:00
|
|
|
let child_tree = &mut state.children[0];
|
|
|
|
|
let child_layout = layout.children().next().unwrap();
|
|
|
|
|
self.header_bar_inner
|
|
|
|
|
.as_widget_mut()
|
|
|
|
|
.overlay(child_tree, child_layout, renderer)
|
|
|
|
|
}
|
2024-04-01 16:12:45 -04:00
|
|
|
|
|
|
|
|
fn drag_destinations(
|
|
|
|
|
&self,
|
|
|
|
|
state: &tree::Tree,
|
|
|
|
|
layout: iced_core::Layout<'_>,
|
2024-05-31 19:10:51 -04:00
|
|
|
renderer: &crate::Renderer,
|
2024-04-01 16:12:45 -04:00
|
|
|
dnd_rectangles: &mut iced_style::core::clipboard::DndDestinationRectangles,
|
|
|
|
|
) {
|
|
|
|
|
if let Some((child_tree, child_layout)) =
|
|
|
|
|
state.children.iter().zip(layout.children()).next()
|
|
|
|
|
{
|
|
|
|
|
self.header_bar_inner.as_widget().drag_destinations(
|
|
|
|
|
child_tree,
|
|
|
|
|
child_layout,
|
2024-05-31 19:10:51 -04:00
|
|
|
renderer,
|
2024-04-01 16:12:45 -04:00
|
|
|
dnd_rectangles,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-09 02:35:03 -07:00
|
|
|
}
|
|
|
|
|
|
2022-12-06 16:12:59 +01:00
|
|
|
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|
|
|
|
/// Converts the headerbar builder into an Iced element.
|
2024-05-27 21:49:49 +02:00
|
|
|
pub fn view(mut self) -> Element<'a, Message> {
|
2023-08-02 11:54:07 +02:00
|
|
|
// Take ownership of the regions to be packed.
|
|
|
|
|
let start = std::mem::take(&mut self.start);
|
|
|
|
|
let center = std::mem::take(&mut self.center);
|
|
|
|
|
let mut end = std::mem::take(&mut self.end);
|
|
|
|
|
|
|
|
|
|
// Also packs the window controls at the very end.
|
2023-09-01 07:29:19 +02:00
|
|
|
end.push(widget::horizontal_space(Length::Fixed(12.0)).into());
|
2023-08-02 11:54:07 +02:00
|
|
|
end.push(self.window_controls());
|
2022-10-09 11:25:46 -07:00
|
|
|
|
2024-10-02 00:32:08 +02:00
|
|
|
let height = match self.density.unwrap_or_else(crate::config::header_size) {
|
|
|
|
|
Density::Compact => 40.0,
|
|
|
|
|
Density::Spacious => 48.0,
|
|
|
|
|
Density::Standard => 48.0,
|
2024-05-27 21:49:49 +02:00
|
|
|
};
|
|
|
|
|
|
2023-08-02 11:54:07 +02:00
|
|
|
// Creates the headerbar widget.
|
2023-09-01 07:29:19 +02:00
|
|
|
let mut widget = widget::row::with_capacity(4)
|
|
|
|
|
// If elements exist in the start region, append them here.
|
2023-11-01 16:29:45 +01:00
|
|
|
.push(
|
2023-09-01 07:29:19 +02:00
|
|
|
widget::row::with_children(start)
|
|
|
|
|
.align_items(iced::Alignment::Center)
|
|
|
|
|
.apply(widget::container)
|
|
|
|
|
.align_x(iced::alignment::Horizontal::Left)
|
2024-01-10 12:56:07 -07:00
|
|
|
.width(Length::Shrink),
|
2023-11-01 16:29:45 +01:00
|
|
|
)
|
2023-09-01 07:29:19 +02:00
|
|
|
// If elements exist in the center region, use them here.
|
|
|
|
|
// This will otherwise use the title as a widget if a title was defined.
|
|
|
|
|
.push(if !center.is_empty() {
|
|
|
|
|
widget::row::with_children(center)
|
|
|
|
|
.align_items(iced::Alignment::Center)
|
|
|
|
|
.apply(widget::container)
|
|
|
|
|
.align_x(iced::alignment::Horizontal::Center)
|
2023-10-24 16:39:37 +02:00
|
|
|
.width(Length::Fill)
|
2023-09-01 07:29:19 +02:00
|
|
|
.into()
|
|
|
|
|
} else if self.title.is_empty() {
|
|
|
|
|
widget::horizontal_space(Length::Fill).into()
|
|
|
|
|
} else {
|
|
|
|
|
self.title_widget()
|
|
|
|
|
})
|
|
|
|
|
.push(
|
|
|
|
|
widget::row::with_children(end)
|
|
|
|
|
.align_items(iced::Alignment::Center)
|
|
|
|
|
.apply(widget::container)
|
2023-10-24 16:39:37 +02:00
|
|
|
.align_x(iced::alignment::Horizontal::Right)
|
2024-01-10 12:56:07 -07:00
|
|
|
.width(Length::Shrink),
|
2023-09-01 07:29:19 +02:00
|
|
|
)
|
2024-01-31 10:03:39 -07:00
|
|
|
.align_items(iced::Alignment::Center)
|
2024-05-27 21:49:49 +02:00
|
|
|
.height(Length::Fixed(height))
|
2024-10-02 00:32:08 +02:00
|
|
|
.padding([0, 8])
|
|
|
|
|
.spacing(8)
|
2022-12-19 17:03:13 +01:00
|
|
|
.apply(widget::container)
|
2024-05-17 19:42:02 +02:00
|
|
|
.style(crate::theme::Container::HeaderBar {
|
|
|
|
|
focused: self.focused,
|
|
|
|
|
})
|
2022-12-19 17:03:13 +01:00
|
|
|
.center_y()
|
2023-05-30 12:03:15 -04:00
|
|
|
.apply(widget::mouse_area);
|
2022-10-09 11:25:46 -07:00
|
|
|
|
2023-08-02 11:54:07 +02:00
|
|
|
// Assigns a message to emit when the headerbar is dragged.
|
2022-12-06 16:12:59 +01:00
|
|
|
if let Some(message) = self.on_drag.clone() {
|
2023-09-13 15:37:29 +02:00
|
|
|
widget = widget.on_drag(message);
|
2022-12-06 16:12:59 +01:00
|
|
|
}
|
2022-10-09 11:25:46 -07:00
|
|
|
|
2023-08-02 11:54:07 +02:00
|
|
|
// Assigns a message to emit when the headerbar is double-clicked.
|
2022-12-06 16:12:59 +01:00
|
|
|
if let Some(message) = self.on_maximize.clone() {
|
|
|
|
|
widget = widget.on_release(message);
|
2022-10-09 02:35:03 -07:00
|
|
|
}
|
2024-07-23 11:58:55 +02:00
|
|
|
if let Some(message) = self.on_double_click.clone() {
|
|
|
|
|
widget = widget.on_double_press(message);
|
|
|
|
|
}
|
2024-02-13 08:10:04 -08:00
|
|
|
if let Some(message) = self.on_right_click.clone() {
|
|
|
|
|
widget = widget.on_right_press(message);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-06 16:12:59 +01:00
|
|
|
widget.into()
|
|
|
|
|
}
|
2022-10-09 02:35:03 -07:00
|
|
|
|
2023-01-23 22:48:06 +01:00
|
|
|
fn title_widget(&mut self) -> Element<'a, Message> {
|
|
|
|
|
let mut title = Cow::default();
|
|
|
|
|
std::mem::swap(&mut title, &mut self.title);
|
|
|
|
|
|
2024-05-27 21:49:49 +02:00
|
|
|
widget::text::heading(title)
|
2023-01-25 06:45:44 +01:00
|
|
|
.apply(widget::container)
|
2022-10-09 02:35:03 -07:00
|
|
|
.center_x()
|
|
|
|
|
.center_y()
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
2022-12-06 16:12:59 +01:00
|
|
|
.into()
|
|
|
|
|
}
|
2022-10-09 02:35:03 -07:00
|
|
|
|
2022-12-06 16:12:59 +01:00
|
|
|
/// Creates the widget for window controls.
|
|
|
|
|
fn window_controls(&mut self) -> Element<'a, Message> {
|
2024-07-30 18:29:01 +02:00
|
|
|
macro_rules! icon {
|
|
|
|
|
($name:expr, $size:expr, $on_press:expr) => {{
|
|
|
|
|
#[cfg(target_os = "linux")]
|
2024-09-17 20:41:46 +02:00
|
|
|
let icon = {
|
|
|
|
|
widget::icon::from_name($name)
|
|
|
|
|
.apply(widget::button::icon)
|
|
|
|
|
.padding(8)
|
|
|
|
|
};
|
2024-07-31 08:06:05 +02:00
|
|
|
|
2024-07-30 18:29:01 +02:00
|
|
|
#[cfg(not(target_os = "linux"))]
|
2024-07-31 08:06:05 +02:00
|
|
|
let icon = {
|
2024-07-30 18:29:01 +02:00
|
|
|
widget::icon::from_svg_bytes(include_bytes!(concat!(
|
|
|
|
|
"../../res/icons/",
|
|
|
|
|
$name,
|
|
|
|
|
".svg"
|
|
|
|
|
)))
|
2024-08-05 04:17:33 -06:00
|
|
|
.symbolic(true)
|
2024-07-30 18:29:01 +02:00
|
|
|
.apply(widget::button::icon)
|
2024-09-17 20:41:46 +02:00
|
|
|
.padding(8)
|
2024-07-31 08:06:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
icon.style(crate::theme::Button::HeaderBar)
|
|
|
|
|
.selected(self.focused)
|
|
|
|
|
.icon_size($size)
|
|
|
|
|
.on_press($on_press)
|
2024-07-30 18:29:01 +02:00
|
|
|
}};
|
|
|
|
|
}
|
2022-10-09 02:35:03 -07:00
|
|
|
|
2023-09-01 07:29:19 +02:00
|
|
|
widget::row::with_capacity(3)
|
2024-07-22 07:23:17 +02:00
|
|
|
.push_maybe(
|
|
|
|
|
self.on_minimize
|
|
|
|
|
.take()
|
2024-07-31 08:06:05 +02:00
|
|
|
.map(|m: Message| icon!("window-minimize-symbolic", 16, m)),
|
2024-07-22 07:23:17 +02:00
|
|
|
)
|
|
|
|
|
.push_maybe(
|
|
|
|
|
self.on_maximize
|
|
|
|
|
.take()
|
2024-07-30 18:29:01 +02:00
|
|
|
.map(|m| icon!("window-maximize-symbolic", 16, m)),
|
2024-07-22 07:23:17 +02:00
|
|
|
)
|
|
|
|
|
.push_maybe(
|
|
|
|
|
self.on_close
|
|
|
|
|
.take()
|
2024-07-30 18:29:01 +02:00
|
|
|
.map(|m| icon!("window-close-symbolic", 16, m)),
|
2024-07-22 07:23:17 +02:00
|
|
|
)
|
2024-10-02 00:32:08 +02:00
|
|
|
.spacing(8)
|
2022-12-06 16:12:59 +01:00
|
|
|
.apply(widget::container)
|
|
|
|
|
.height(Length::Fill)
|
2022-10-09 02:35:03 -07:00
|
|
|
.center_y()
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-06 16:12:59 +01:00
|
|
|
impl<'a, Message: Clone + 'static> From<HeaderBar<'a, Message>> for Element<'a, Message> {
|
|
|
|
|
fn from(headerbar: HeaderBar<'a, Message>) -> Self {
|
2024-01-11 15:16:21 -05:00
|
|
|
Element::new(headerbar.build())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a, Message: Clone + 'static> From<HeaderBarWidget<'a, Message>> for Element<'a, Message> {
|
|
|
|
|
fn from(headerbar: HeaderBarWidget<'a, Message>) -> Self {
|
|
|
|
|
Element::new(headerbar)
|
|
|
|
|
}
|
|
|
|
|
}
|