feat: sorta hacky way of creating header bars for libcosmic + update iced to get support for resizable windows in iced-sctk

This commit is contained in:
Ashley Wulber 2023-05-24 19:36:14 -04:00
parent bf1c474d08
commit 09abcfd03c
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
10 changed files with 43 additions and 15 deletions

View file

@ -6,8 +6,9 @@ use cosmic::{
iced::{
wayland::window::{start_drag_window, toggle_maximize},
widget::{column, container, horizontal_space, pick_list, progress_bar, row, slider},
window,
window, Color,
},
iced_style::application,
theme::{self, Theme},
widget::{
button, header_bar, nav_bar, nav_bar_toggle,
@ -402,6 +403,7 @@ impl Application for Window {
.padding([0, 8, 8, 8])
.width(Length::Fill)
.height(Length::Fill)
.style(theme::Container::Background)
.into();
column(vec![header, content]).into()
@ -421,4 +423,11 @@ impl Application for Window {
fn subscription(&self) -> iced::Subscription<Self::Message> {
rectangle_tracker_subscription(0).map(|(_, e)| Message::Rectangle(e))
}
fn style(&self) -> <Self::Theme as cosmic::iced_style::application::StyleSheet>::Style {
cosmic::theme::Application::Custom(Box::new(|theme| application::Appearance {
background_color: Color::TRANSPARENT,
text_color: theme.cosmic().on_bg_color().into(),
}))
}
}

View file

@ -577,17 +577,21 @@ impl Application for Window {
.padding([0, 8, 8, 8])
.width(Length::Fill)
.height(Length::Fill)
.style(theme::Container::Background)
.into();
let warning = warning(&self.warning_message)
.on_close(Message::ToggleWarning)
.into();
if self.show_warning {
column(vec![
column![
header,
warning,
iced::widget::vertical_space(Length::Fixed(12.0)).into(),
content,
])
container(column(vec![
warning,
iced::widget::vertical_space(Length::Fixed(12.0)).into(),
content,
]))
.style(theme::Container::Background)
]
.into()
} else {
column(vec![header, content]).into()