fix(dropdown): styling
This commit is contained in:
parent
2d06ec4226
commit
58fc034459
5 changed files with 50 additions and 69 deletions
|
|
@ -703,14 +703,11 @@ impl<App: Application> ApplicationExt for App {
|
||||||
.focused_window()
|
.focused_window()
|
||||||
.is_some_and(|i| Some(i) == self.core().main_window_id());
|
.is_some_and(|i| Some(i) == self.core().main_window_id());
|
||||||
|
|
||||||
// Offset for the window border
|
|
||||||
let window_padding = if sharp_corners { 8 } else { 7 };
|
|
||||||
|
|
||||||
let main_content_padding = if content_container {
|
let main_content_padding = if content_container {
|
||||||
if nav_bar_active {
|
if nav_bar_active {
|
||||||
[0, window_padding, window_padding, 0]
|
[0, 8, 8, 0]
|
||||||
} else {
|
} else {
|
||||||
[0, window_padding, window_padding, window_padding]
|
[0, 8, 8, 8]
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
[0, 0, 0, 0]
|
[0, 0, 0, 0]
|
||||||
|
|
@ -724,11 +721,7 @@ impl<App: Application> ApplicationExt for App {
|
||||||
.nav_bar()
|
.nav_bar()
|
||||||
.map(|nav| id_container(nav, iced_core::id::Id::new("COSMIC_nav_bar")))
|
.map(|nav| id_container(nav, iced_core::id::Id::new("COSMIC_nav_bar")))
|
||||||
{
|
{
|
||||||
widgets.push(
|
widgets.push(container(nav).padding([0, 8, 8, 8]).into());
|
||||||
container(nav)
|
|
||||||
.padding([0, window_padding, window_padding, window_padding])
|
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
@ -760,7 +753,7 @@ impl<App: Application> ApplicationExt for App {
|
||||||
})
|
})
|
||||||
.apply(container)
|
.apply(container)
|
||||||
.padding(if content_container {
|
.padding(if content_container {
|
||||||
[0, window_padding, window_padding, 0]
|
[0, 8, 8, 0]
|
||||||
} else {
|
} else {
|
||||||
[0, 0, 0, 0]
|
[0, 0, 0, 0]
|
||||||
})
|
})
|
||||||
|
|
@ -808,7 +801,7 @@ impl<App: Application> ApplicationExt for App {
|
||||||
})
|
})
|
||||||
.apply(container)
|
.apply(container)
|
||||||
.padding(if content_container {
|
.padding(if content_container {
|
||||||
[0, window_padding, window_padding, 0]
|
[0, 8, 8, 0]
|
||||||
} else {
|
} else {
|
||||||
[0, 0, 0, 0]
|
[0, 0, 0, 0]
|
||||||
})
|
})
|
||||||
|
|
@ -825,14 +818,10 @@ impl<App: Application> ApplicationExt for App {
|
||||||
});
|
});
|
||||||
let content_col = crate::widget::column::with_capacity(2)
|
let content_col = crate::widget::column::with_capacity(2)
|
||||||
.push(content_row)
|
.push(content_row)
|
||||||
.push_maybe(self.footer().map(|footer| {
|
.push_maybe(
|
||||||
container(footer.map(Message::App)).padding([
|
self.footer()
|
||||||
0,
|
.map(|footer| container(footer.map(Message::App)).padding([0, 8, 8, 8])),
|
||||||
window_padding,
|
);
|
||||||
window_padding,
|
|
||||||
window_padding,
|
|
||||||
])
|
|
||||||
}));
|
|
||||||
let content: Element<_> = if core.window.content_container {
|
let content: Element<_> = if core.window.content_container {
|
||||||
content_col
|
content_col
|
||||||
.apply(container)
|
.apply(container)
|
||||||
|
|
@ -851,7 +840,6 @@ impl<App: Application> ApplicationExt for App {
|
||||||
let mut header = crate::widget::header_bar()
|
let mut header = crate::widget::header_bar()
|
||||||
.focused(focused)
|
.focused(focused)
|
||||||
.title(&core.window.header_title)
|
.title(&core.window.header_title)
|
||||||
.horizontal_padding(window_padding)
|
|
||||||
.on_drag(Message::Cosmic(cosmic::Message::Drag))
|
.on_drag(Message::Cosmic(cosmic::Message::Drag))
|
||||||
.on_right_click(Message::Cosmic(cosmic::Message::ShowWindowMenu))
|
.on_right_click(Message::Cosmic(cosmic::Message::ShowWindowMenu))
|
||||||
.on_double_click(Message::Cosmic(cosmic::Message::Maximize));
|
.on_double_click(Message::Cosmic(cosmic::Message::Maximize));
|
||||||
|
|
|
||||||
|
|
@ -536,20 +536,17 @@ impl iced_container::Catalog for Theme {
|
||||||
|
|
||||||
Container::Secondary => Container::secondary(cosmic),
|
Container::Secondary => Container::secondary(cosmic),
|
||||||
|
|
||||||
Container::Dropdown => {
|
Container::Dropdown => iced_container::Style {
|
||||||
let theme = self.cosmic();
|
icon_color: None,
|
||||||
|
text_color: None,
|
||||||
iced_container::Style {
|
background: Some(iced::Background::Color(cosmic.bg_component_color().into())),
|
||||||
icon_color: None,
|
border: Border {
|
||||||
text_color: None,
|
color: cosmic.bg_component_divider().into(),
|
||||||
background: Some(iced::Background::Color(theme.primary.base.into())),
|
width: 1.0,
|
||||||
border: Border {
|
radius: cosmic.corner_radii.radius_s.into(),
|
||||||
radius: cosmic.corner_radii.radius_xs.into(),
|
},
|
||||||
..Default::default()
|
shadow: Shadow::default(),
|
||||||
},
|
},
|
||||||
shadow: Shadow::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Container::Tooltip => iced_container::Style {
|
Container::Tooltip => iced_container::Style {
|
||||||
icon_color: None,
|
icon_color: None,
|
||||||
|
|
|
||||||
|
|
@ -156,21 +156,21 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
style,
|
style,
|
||||||
} = menu;
|
} = menu;
|
||||||
|
|
||||||
let mut container = Container::new(Scrollable::new(List {
|
let mut container = Container::new(Scrollable::new(
|
||||||
options,
|
Container::new(List {
|
||||||
icons,
|
options,
|
||||||
hovered_option,
|
icons,
|
||||||
selected_option,
|
hovered_option,
|
||||||
on_selected,
|
selected_option,
|
||||||
on_option_hovered,
|
on_selected,
|
||||||
text_size,
|
on_option_hovered,
|
||||||
text_line_height,
|
text_size,
|
||||||
padding,
|
text_line_height,
|
||||||
}));
|
padding,
|
||||||
|
})
|
||||||
container = container
|
.padding(padding),
|
||||||
.padding(padding)
|
))
|
||||||
.class(crate::style::Container::Dropdown);
|
.class(crate::style::Container::Dropdown);
|
||||||
|
|
||||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,20 +152,20 @@ impl<'a, Message: 'a> Overlay<'a, Message> {
|
||||||
style,
|
style,
|
||||||
} = menu;
|
} = menu;
|
||||||
|
|
||||||
let mut container = Container::new(Scrollable::new(InnerList {
|
let mut container = Container::new(Scrollable::new(
|
||||||
options,
|
Container::new(InnerList {
|
||||||
hovered_option,
|
options,
|
||||||
selected_option,
|
hovered_option,
|
||||||
on_selected,
|
selected_option,
|
||||||
on_option_hovered,
|
on_selected,
|
||||||
padding,
|
on_option_hovered,
|
||||||
text_size,
|
padding,
|
||||||
text_line_height,
|
text_size,
|
||||||
}));
|
text_line_height,
|
||||||
|
})
|
||||||
container = container
|
.padding(padding),
|
||||||
.padding(padding)
|
))
|
||||||
.class(crate::style::Container::Dropdown);
|
.class(crate::style::Container::Dropdown);
|
||||||
|
|
||||||
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
state.tree.diff(&mut container as &mut dyn Widget<_, _, _>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ pub fn header_bar<'a, Message>() -> HeaderBar<'a, Message> {
|
||||||
center: Vec::new(),
|
center: Vec::new(),
|
||||||
end: Vec::new(),
|
end: Vec::new(),
|
||||||
density: None,
|
density: None,
|
||||||
horizontal_padding: 8,
|
|
||||||
focused: false,
|
focused: false,
|
||||||
on_double_click: None,
|
on_double_click: None,
|
||||||
}
|
}
|
||||||
|
|
@ -75,9 +74,6 @@ pub struct HeaderBar<'a, Message> {
|
||||||
#[setters(strip_option)]
|
#[setters(strip_option)]
|
||||||
density: Option<Density>,
|
density: Option<Density>,
|
||||||
|
|
||||||
/// Horizontal padding of the headerbar
|
|
||||||
horizontal_padding: u16,
|
|
||||||
|
|
||||||
/// Focused state of the window
|
/// Focused state of the window
|
||||||
focused: bool,
|
focused: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +342,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
)
|
)
|
||||||
.align_y(iced::Alignment::Center)
|
.align_y(iced::Alignment::Center)
|
||||||
.height(Length::Fixed(height))
|
.height(Length::Fixed(height))
|
||||||
.padding([0, self.horizontal_padding])
|
.padding([0, 8])
|
||||||
.spacing(8)
|
.spacing(8)
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.class(crate::theme::Container::HeaderBar {
|
.class(crate::theme::Container::HeaderBar {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue