libcosmic updates
This commit is contained in:
parent
9c62f19e4b
commit
0491c4baaa
91 changed files with 3550 additions and 2300 deletions
|
|
@ -9,6 +9,7 @@ use super::{
|
|||
};
|
||||
use crate::style::menu_bar::StyleSheet;
|
||||
|
||||
use iced::{Point, Vector};
|
||||
use iced_core::Border;
|
||||
use iced_widget::core::{
|
||||
event,
|
||||
|
|
@ -434,6 +435,7 @@ where
|
|||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
_renderer: &Renderer,
|
||||
translation: Vector,
|
||||
) -> Option<overlay::Element<'b, Message, crate::Theme, Renderer>> {
|
||||
let state = tree.state.downcast_ref::<MenuBarState>();
|
||||
if !state.open {
|
||||
|
|
@ -455,6 +457,7 @@ where
|
|||
root_bounds_list: layout.children().map(|lo| lo.bounds()).collect(),
|
||||
path_highlight: self.path_highlight,
|
||||
style: &self.style,
|
||||
position: Point::new(translation.x, translation.y),
|
||||
}
|
||||
.overlay(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ impl MenuBounds {
|
|||
let offset_bounds = Rectangle::new(offset_position, offset_size);
|
||||
|
||||
let children_bounds = Rectangle::new(children_position, children_size);
|
||||
let check_bounds = pad_rectangle(children_bounds, [bounds_expand; 4].into());
|
||||
let check_bounds = pad_rectangle(children_bounds, bounds_expand.into());
|
||||
|
||||
Self {
|
||||
child_positions,
|
||||
|
|
@ -445,13 +445,14 @@ where
|
|||
pub(crate) root_bounds_list: Vec<Rectangle>,
|
||||
pub(crate) path_highlight: Option<PathHighlight>,
|
||||
pub(crate) style: &'b <crate::Theme as StyleSheet>::Style,
|
||||
pub(crate) position: Point,
|
||||
}
|
||||
impl<'a, 'b, Message, Renderer> Menu<'a, 'b, Message, Renderer>
|
||||
where
|
||||
Renderer: renderer::Renderer,
|
||||
{
|
||||
pub(crate) fn overlay(self) -> overlay::Element<'b, Message, crate::Theme, Renderer> {
|
||||
overlay::Element::new(Point::ORIGIN, Box::new(self))
|
||||
overlay::Element::new(Box::new(self))
|
||||
}
|
||||
}
|
||||
impl<'a, 'b, Message, Renderer> overlay::Overlay<Message, crate::Theme, Renderer>
|
||||
|
|
@ -459,14 +460,9 @@ impl<'a, 'b, Message, Renderer> overlay::Overlay<Message, crate::Theme, Renderer
|
|||
where
|
||||
Renderer: renderer::Renderer,
|
||||
{
|
||||
fn layout(
|
||||
&mut self,
|
||||
renderer: &Renderer,
|
||||
bounds: Size,
|
||||
position: Point,
|
||||
_translation: iced::Vector,
|
||||
) -> Node {
|
||||
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node {
|
||||
// layout children
|
||||
let position = self.position;
|
||||
let state = self.tree.state.downcast_mut::<MenuBarState>();
|
||||
let overlay_offset = Point::ORIGIN - position;
|
||||
let tree_children = &mut self.tree.children;
|
||||
|
|
|
|||
|
|
@ -146,14 +146,14 @@ pub fn menu_button<'a, Message: 'a>(
|
|||
) -> crate::widget::Button<'a, Message> {
|
||||
widget::button::custom(
|
||||
widget::Row::with_children(children)
|
||||
.align_items(Alignment::Center)
|
||||
.align_y(Alignment::Center)
|
||||
.height(Length::Fill)
|
||||
.width(Length::Fill),
|
||||
)
|
||||
.height(Length::Fixed(36.0))
|
||||
.padding([4, 16])
|
||||
.width(Length::Fill)
|
||||
.style(theme::Button::MenuItem)
|
||||
.class(theme::Button::MenuItem)
|
||||
}
|
||||
|
||||
/// Represents a menu item that performs an action when selected or a separator between menu items.
|
||||
|
|
@ -197,7 +197,7 @@ where
|
|||
{
|
||||
widget::button::custom(widget::text(label))
|
||||
.padding([4, 12])
|
||||
.style(theme::Button::MenuRoot)
|
||||
.class(theme::Button::MenuRoot)
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ where
|
|||
let key = find_key(&action, key_binds);
|
||||
let menu_button = menu_button(vec![
|
||||
widget::text(label).into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().width(Length::Fill).into(),
|
||||
widget::text(key).into(),
|
||||
])
|
||||
.on_press(action.message());
|
||||
|
|
@ -256,7 +256,7 @@ where
|
|||
let key = find_key(&action, key_binds);
|
||||
let menu_button = menu_button(vec![
|
||||
widget::text(label).into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().width(Length::Fill).into(),
|
||||
widget::text(key).into(),
|
||||
]);
|
||||
|
||||
|
|
@ -270,8 +270,8 @@ where
|
|||
widget::icon::from_name("object-select-symbolic")
|
||||
.size(16)
|
||||
.icon()
|
||||
.style(theme::Svg::Custom(Rc::new(|theme| {
|
||||
crate::iced_style::svg::Appearance {
|
||||
.class(theme::Svg::Custom(Rc::new(|theme| {
|
||||
iced_widget::svg::Style {
|
||||
color: Some(theme.cosmic().accent_color().into()),
|
||||
}
|
||||
})))
|
||||
|
|
@ -282,9 +282,9 @@ where
|
|||
},
|
||||
widget::Space::with_width(Length::Fixed(8.0)).into(),
|
||||
widget::text(label)
|
||||
.horizontal_alignment(iced::alignment::Horizontal::Left)
|
||||
.align_x(iced::alignment::Horizontal::Left)
|
||||
.into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().width(Length::Fill).into(),
|
||||
widget::text(key).into(),
|
||||
])
|
||||
.on_press(action.message()),
|
||||
|
|
@ -294,13 +294,13 @@ where
|
|||
trees.push(MenuTree::<Message, Renderer>::with_children(
|
||||
menu_button(vec![
|
||||
widget::text(label).into(),
|
||||
widget::horizontal_space(Length::Fill).into(),
|
||||
widget::horizontal_space().width(Length::Fill).into(),
|
||||
widget::icon::from_name("pan-end-symbolic")
|
||||
.size(16)
|
||||
.icon()
|
||||
.into(),
|
||||
])
|
||||
.style(
|
||||
.class(
|
||||
// Menu folders have no on_press so they take on the disabled style by default
|
||||
if children.is_empty() {
|
||||
// This will make the folder use the disabled style if it has no children
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue