Update libcosmic/iced

This commit is contained in:
Ian Douglas Scott 2024-02-09 16:48:03 -08:00 committed by Victoria Brekenfeld
parent 7234a81672
commit 39ebf39e4f
11 changed files with 547 additions and 461 deletions

View file

@ -10,7 +10,7 @@ use crate::{
use calloop::LoopHandle;
use cosmic::{
iced::widget::{column, container, horizontal_space, row, vertical_space},
iced_core::{Background, Color, Length},
iced_core::{Background, Border, Color, Length},
theme,
widget::{icon::from_name, text},
Apply,
@ -64,16 +64,19 @@ pub struct ResizeIndicatorInternal {
impl Program for ResizeIndicatorInternal {
type Message = ();
fn view(&self) -> crate::utils::iced::Element<'_, Self::Message> {
fn view(&self) -> cosmic::Element<'_, Self::Message> {
let edges = self.edges.lock().unwrap();
let icon_container_style = || {
theme::Container::custom(|theme| container::Appearance {
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
border_radius: 18.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 18.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
};

View file

@ -17,7 +17,7 @@ use crate::{
use calloop::LoopHandle;
use cosmic::{
iced::{id::Id, widget as iced_widget},
iced_core::{Background, BorderRadius, Color, Length},
iced_core::{border::Radius, Background, Border, Color, Length},
iced_runtime::Command,
iced_widget::scrollable::AbsoluteOffset,
theme, widget as cosmic_widget, Apply, Element as CosmicElement,
@ -866,9 +866,12 @@ impl Program for CosmicStackInternal {
icon_color: Some(Color::from(theme.cosmic().background.on)),
text_color: Some(Color::from(theme.cosmic().background.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
border_radius: BorderRadius::from([8.0, 8.0, 0.0, 0.0]),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: Radius::from([8.0, 8.0, 0.0, 0.0]),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
} else {
theme::Container::custom(|theme| iced_widget::container::Appearance {
@ -877,9 +880,12 @@ impl Program for CosmicStackInternal {
background: Some(Background::Color(tab::primary_container_color(
theme.cosmic(),
))),
border_radius: BorderRadius::from([8.0, 8.0, 0.0, 0.0]),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: Radius::from([8.0, 8.0, 0.0, 0.0]),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
})
.into()

View file

@ -10,7 +10,7 @@ use cosmic::{
tree::Tree,
Id, Widget,
},
Clipboard, Color, Length, Rectangle, Shell, Size,
Border, Clipboard, Color, Length, Rectangle, Shell, Size,
},
iced_widget::scrollable::AbsoluteOffset,
theme,
@ -104,9 +104,12 @@ impl From<TabBackgroundTheme> for theme::Container {
icon_color: Some(Color::from(theme.cosmic().accent_text_color())),
text_color: Some(Color::from(theme.cosmic().accent_text_color())),
background: Some(background_theme.background_color(theme).into()),
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 0.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
}
TabBackgroundTheme::ActiveDeactivated => {
@ -114,9 +117,12 @@ impl From<TabBackgroundTheme> for theme::Container {
icon_color: None,
text_color: None,
background: Some(background_theme.background_color(theme).into()),
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 0.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
}
TabBackgroundTheme::Default => Self::Transparent,
@ -203,7 +209,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
self
}
pub(super) fn internal(self, idx: usize) -> TabInternal<'static, Message> {
pub(super) fn internal<'a>(self, idx: usize) -> TabInternal<'a, Message> {
let mut close_button = from_name("window-close-symbolic")
.size(16)
.prefer_svg(true)
@ -270,7 +276,10 @@ pub(super) struct TabInternal<'a, Message: TabMessage> {
right_click_message: Option<Message>,
}
impl<'a, Message: TabMessage> Widget<Message, cosmic::Renderer> for TabInternal<'a, Message> {
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabInternal<'a, Message>
where
Message: TabMessage,
{
fn id(&self) -> Option<Id> {
Some(self.id.clone())
}
@ -283,12 +292,8 @@ impl<'a, Message: TabMessage> Widget<Message, cosmic::Renderer> for TabInternal<
tree.diff_children(&mut self.elements);
}
fn width(&self) -> Length {
Length::Fill
}
fn height(&self) -> Length {
Length::Fill
fn size(&self) -> Size<Length> {
Size::new(Length::Fill, Length::Fill)
}
fn layout(&self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
@ -305,7 +310,9 @@ impl<'a, Message: TabMessage> Widget<Message, cosmic::Renderer> for TabInternal<
.min_height(min_size.height)
.width(Length::Fill)
.height(Length::Fill);
let size = limits.resolve(min_size).max(min_size);
let size = limits
.resolve(Length::Shrink, Length::Shrink, min_size)
.max(min_size);
let limits = Limits::new(size, size)
.min_width(size.width)
@ -316,6 +323,8 @@ impl<'a, Message: TabMessage> Widget<Message, cosmic::Renderer> for TabInternal<
cosmic::iced_core::layout::flex::Axis::Horizontal,
renderer,
&limits,
Length::Fill,
Length::Fill,
0.into(),
8.,
cosmic::iced::Alignment::Center,
@ -474,7 +483,7 @@ impl<'a, Message: TabMessage> Widget<Message, cosmic::Renderer> for TabInternal<
tree: &'b mut Tree,
layout: Layout<'_>,
renderer: &cosmic::Renderer,
) -> Option<overlay::Element<'b, Message, cosmic::Renderer>> {
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
overlay::from_children(&mut self.elements, tree, layout, renderer)
}
}

View file

@ -9,7 +9,7 @@ use cosmic::{
renderer::{self, Renderer as IcedRenderer},
text::{LineHeight, Paragraph, Renderer as TextRenderer, Shaping},
widget::{tree, Tree, Widget},
Background, Color, Degrees, Gradient, Length, Rectangle, Size, Text,
Background, Border, Color, Degrees, Gradient, Length, Rectangle, Size, Text,
},
};
@ -86,7 +86,7 @@ impl TabText {
}
}
impl<Message> Widget<Message, cosmic::Renderer> for TabText {
impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
fn tag(&self) -> tree::Tag {
tree::Tag::of::<LocalState>()
}
@ -99,20 +99,15 @@ impl<Message> Widget<Message, cosmic::Renderer> for TabText {
})
}
fn width(&self) -> Length {
self.width
}
fn height(&self) -> Length {
self.height
fn size(&self) -> Size<Length> {
Size::new(self.width, self.height)
}
fn layout(&self, tree: &mut Tree, _renderer: &cosmic::Renderer, limits: &Limits) -> Node {
let limits = limits.width(self.width).height(self.height);
let state = tree.state.downcast_mut::<LocalState>();
let text_bounds = state.paragraph.min_bounds();
state.overflowed = limits.max().width < text_bounds.width;
let actual_size = limits.resolve(text_bounds);
let actual_size = limits.resolve(self.width, self.height, text_bounds);
Node::new(actual_size)
}
@ -163,9 +158,12 @@ impl<Message> Widget<Message, cosmic::Renderer> for TabText {
width: 24.0_f32.min(bounds.width),
..bounds
},
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 0.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
},
Background::Gradient(Gradient::Linear(
gradient::Linear::new(Degrees(90.))

View file

@ -13,7 +13,8 @@ use cosmic::{
tree::{self, Tree},
Widget,
},
Background, Clipboard, Color, Length, Point, Rectangle, Renderer, Shell, Size, Vector,
Background, Border, Clipboard, Color, Length, Point, Rectangle, Renderer, Shell, Size,
Vector,
},
iced_style::container::StyleSheet as ContainerStyleSheet,
iced_widget::container::draw_background,
@ -291,15 +292,12 @@ impl State {
}
}
impl<'a, Message> Widget<Message, cosmic::Renderer> for Tabs<'a, Message>
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for Tabs<'a, Message>
where
Message: TabMessage,
{
fn width(&self) -> Length {
self.width
}
fn height(&self) -> Length {
self.height
fn size(&self) -> Size<Length> {
Size::new(self.width, self.height)
}
fn id(&self) -> Option<Id> {
@ -352,7 +350,7 @@ where
width: a.width + b.width,
height: a.height.max(b.height),
});
let size = limits.resolve(min_size);
let size = limits.resolve(self.width, self.height, min_size);
if min_size.width <= size.width {
// we don't need to scroll
@ -366,6 +364,8 @@ where
cosmic::iced_core::layout::flex::Axis::Horizontal,
renderer,
&limits,
self.width,
self.height,
0.into(),
0.,
cosmic::iced::Alignment::Center,
@ -392,15 +392,14 @@ where
.height(Length::Shrink);
let mut node = tab.as_widget().layout(tab_tree, renderer, &child_limits);
node.move_to(Point::new(offset, 0.));
node = node.move_to(Point::new(offset, 0.));
offset += node.bounds().width;
node
})
.collect::<Vec<_>>();
nodes.push({
let mut node = Node::new(Size::new(4., limits.max().height));
node.move_to(Point::new(offset, 0.));
node
let node = Node::new(Size::new(4., limits.max().height));
node.move_to(Point::new(offset, 0.))
});
nodes
};
@ -424,7 +423,7 @@ where
// we scroll, so use the computed min size, but add scroll buttons.
let mut offset = 30.;
for node in &mut nodes {
node.move_to(Point::new(offset, 0.));
*node = node.clone().move_to(Point::new(offset, 0.));
offset += node.bounds().width;
}
let last_position = Point::new(size.width - 34., 0.);
@ -437,7 +436,7 @@ where
Size::new(16., 16.),
vec![Node::new(Size::new(16., 16.))],
);
node.move_to(Point::new(9., (size.height - 16.) / 2.));
node = node.move_to(Point::new(9., (size.height - 16.) / 2.));
node
}]
.into_iter()
@ -445,7 +444,7 @@ where
.chain(vec![
{
let mut node = Node::new(Size::new(4., size.height));
node.move_to(last_position);
node = node.move_to(last_position);
node
},
{
@ -453,12 +452,13 @@ where
Size::new(16., 16.),
vec![Node::new(Size::new(16., 16.))],
);
node.move_to(last_position + Vector::new(9., (size.height - 16.) / 2.));
node =
node.move_to(last_position + Vector::new(9., (size.height - 16.) / 2.));
node
},
{
let mut node = Node::new(Size::new(4., size.height));
node.move_to(last_position + Vector::new(30., 0.));
node = node.move_to(last_position + Vector::new(30., 0.));
node
},
])
@ -498,9 +498,12 @@ where
background: Some(Background::Color(super::tab::primary_container_color(
theme.cosmic(),
))),
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 0.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
}),
);
draw_background(renderer, &background_style, bounds);
@ -990,7 +993,7 @@ where
tree: &'b mut Tree,
layout: Layout<'_>,
renderer: &cosmic::Renderer,
) -> Option<overlay::Element<'b, Message, cosmic::Renderer>> {
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
overlay::from_children(&mut self.elements, tree, layout, renderer)
}
}

View file

@ -6,7 +6,7 @@ use crate::{
use calloop::LoopHandle;
use cosmic::{
iced::widget::{container, row},
iced_core::{Background, Color, Length},
iced_core::{Background, Border, Color, Length},
theme,
widget::{icon::from_name, text},
Apply,
@ -28,7 +28,7 @@ pub struct StackHoverInternal;
impl Program for StackHoverInternal {
type Message = ();
fn view(&self) -> crate::utils::iced::Element<'_, Self::Message> {
fn view(&self) -> cosmic::Element<'_, Self::Message> {
row(vec![
from_name("window-stack-symbolic")
.size(24)
@ -60,9 +60,12 @@ impl Program for StackHoverInternal {
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
border_radius: 24.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 24.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
}))
.width(Length::Shrink)
.height(Length::Fixed(48.))

View file

@ -6,7 +6,7 @@ use crate::{
use calloop::LoopHandle;
use cosmic::{
iced::widget::{container, horizontal_space, row},
iced_core::{Alignment, Background, Color, Length},
iced_core::{Alignment, Background, Border, Color, Length},
theme,
widget::{icon::from_name, text},
Apply,
@ -27,7 +27,7 @@ pub struct SwapIndicatorInternal;
impl Program for SwapIndicatorInternal {
type Message = ();
fn view(&self) -> crate::utils::iced::Element<'_, Self::Message> {
fn view(&self) -> cosmic::Element<'_, Self::Message> {
row(vec![
from_name("window-swap-symbolic")
.size(32)
@ -50,9 +50,12 @@ impl Program for SwapIndicatorInternal {
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
border_radius: 18.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
border: Border {
radius: 18.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
}))
.width(Length::Shrink)
.height(Length::Shrink)

View file

@ -4,28 +4,20 @@ use cosmic::{
event, layout, mouse, overlay,
renderer::{Quad, Style},
widget::{tree, Id, OperationOutputWrapper, Tree, Widget},
Background, Clipboard, Color, Event, Layout, Length, Rectangle, Renderer as IcedRenderer,
Shell,
Background, Border, Clipboard, Color, Event, Layout, Length, Rectangle,
Renderer as IcedRenderer, Shell, Size,
},
widget::button::StyleSheet,
};
pub struct SubmenuItem<'a, Message, Renderer>
where
Renderer: IcedRenderer,
Renderer::Theme: StyleSheet,
{
elem: Element<'a, Message, Renderer>,
pub struct SubmenuItem<'a, Message> {
elem: cosmic::Element<'a, Message>,
idx: usize,
styling: <Renderer::Theme as StyleSheet>::Style,
styling: <cosmic::Theme as StyleSheet>::Style,
}
impl<'a, Message, Renderer> SubmenuItem<'a, Message, Renderer>
where
Renderer: IcedRenderer,
Renderer::Theme: StyleSheet,
{
pub fn new(elem: impl Into<Element<'a, Message, Renderer>>, idx: usize) -> Self {
impl<'a, Message> SubmenuItem<'a, Message> {
pub fn new(elem: impl Into<cosmic::Element<'a, Message>>, idx: usize) -> Self {
Self {
elem: elem.into(),
idx,
@ -33,7 +25,7 @@ where
}
}
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
pub fn style(mut self, style: <cosmic::Theme as StyleSheet>::Style) -> Self {
self.styling = style;
self
}
@ -48,28 +40,22 @@ struct State {
cursor_over: bool,
}
impl<'a, Message, Renderer> Widget<Message, Renderer> for SubmenuItem<'a, Message, Renderer>
impl<'a, Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for SubmenuItem<'a, Message>
where
Renderer: IcedRenderer,
Renderer::Theme: StyleSheet,
Message: CursorEvents,
{
fn id(&self) -> Option<Id> {
None
}
fn width(&self) -> Length {
self.elem.as_widget().width()
}
fn height(&self) -> Length {
self.elem.as_widget().height()
fn size(&self) -> Size<Length> {
self.elem.as_widget().size()
}
fn layout(
&self,
state: &mut Tree,
renderer: &Renderer,
renderer: &cosmic::Renderer,
limits: &layout::Limits,
) -> layout::Node {
let state = &mut state.children[0];
@ -80,8 +66,8 @@ where
fn draw(
&self,
state: &Tree,
renderer: &mut Renderer,
theme: &<Renderer as IcedRenderer>::Theme,
renderer: &mut cosmic::Renderer,
theme: &cosmic::Theme,
style: &Style,
layout: Layout<'_>,
cursor: mouse::Cursor,
@ -89,17 +75,20 @@ where
) {
let widget_state = state.state.downcast_ref::<State>();
let styling = if widget_state.cursor_over {
theme.hovered(true, &self.styling)
theme.hovered(true, false, &self.styling)
} else {
theme.active(true, &self.styling)
theme.active(true, false, &self.styling)
};
renderer.fill_quad(
Quad {
bounds: layout.bounds(),
border_radius: styling.border_radius,
border_width: styling.border_width,
border_color: styling.border_color,
border: Border {
radius: styling.border_radius,
width: styling.border_width,
color: styling.border_color,
},
shadow: Default::default(),
},
styling
.background
@ -143,7 +132,7 @@ where
&self,
state: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
renderer: &cosmic::Renderer,
operation: &mut dyn cosmic::widget::Operation<OperationOutputWrapper<Message>>,
) {
let state = &mut state.children[0];
@ -159,7 +148,7 @@ where
event: Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
renderer: &Renderer,
renderer: &cosmic::Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
@ -203,7 +192,7 @@ where
layout: Layout<'_>,
cursor: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
renderer: &cosmic::Renderer,
) -> mouse::Interaction {
let state = &state.children[0];
let layout = layout.children().next().unwrap();
@ -216,22 +205,19 @@ where
&'b mut self,
state: &'b mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
) -> Option<overlay::Element<'b, Message, Renderer>> {
renderer: &cosmic::Renderer,
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
let state = &mut state.children[0];
let layout = layout.children().next().unwrap();
self.elem.as_widget_mut().overlay(state, layout, renderer)
}
}
impl<'a, Message, Renderer> Into<Element<'a, Message, Renderer>>
for SubmenuItem<'a, Message, Renderer>
impl<'a, Message> Into<cosmic::Element<'a, Message>> for SubmenuItem<'a, Message>
where
Renderer: IcedRenderer + 'a,
Renderer::Theme: StyleSheet,
Message: CursorEvents + 'a,
{
fn into(self) -> Element<'a, Message, Renderer> {
fn into(self) -> cosmic::Element<'a, Message> {
Element::new(self)
}
}

View file

@ -9,7 +9,7 @@ use std::{
use calloop::LoopHandle;
use cosmic::{
iced::Background,
iced_core::{alignment::Horizontal, Length, Pixels, Rectangle as IcedRectangle},
iced_core::{alignment::Horizontal, Border, Length, Pixels, Rectangle as IcedRectangle},
iced_widget::{self, horizontal_rule, text::Appearance as TextAppearance, Column, Row},
theme,
widget::{button, horizontal_space, icon::from_name, text},
@ -319,7 +319,7 @@ impl Program for ContextMenu {
Command::none()
}
fn view(&self) -> crate::utils::iced::Element<'_, Self::Message> {
fn view(&self) -> cosmic::Element<'_, Self::Message> {
let width = self
.row_width
.lock()
@ -331,99 +331,93 @@ impl Program for ContextMenu {
_ => Length::Fill,
};
Column::with_children(
self.items
.iter()
.enumerate()
.map(|(idx, item)| match item {
Item::Separator => horizontal_rule(1)
.style(theme::Rule::LightDivider)
.width(mode)
.into(),
Item::Submenu { title, .. } => Row::with_children(vec![
horizontal_space(16).into(),
text(title).width(mode).into(),
from_name("go-next-symbolic")
.size(16)
.prefer_svg(true)
.icon()
.into(),
])
.spacing(8)
.width(width)
.padding([8, 24])
.apply(|row| item::SubmenuItem::new(row, idx))
.style(theme::Button::MenuItem)
Column::with_children(self.items.iter().enumerate().map(|(idx, item)| {
match item {
Item::Separator => horizontal_rule(1)
.style(theme::Rule::LightDivider)
.width(mode)
.into(),
Item::Entry {
title,
shortcut,
toggled,
disabled,
..
} => {
let mut components = vec![
if *toggled {
from_name("object-select-symbolic")
.size(16)
.prefer_svg(true)
.icon()
.style(theme::Svg::custom(|theme| {
iced_widget::svg::Appearance {
color: Some(theme.cosmic().accent.base.into()),
}
}))
.into()
} else {
horizontal_space(16).into()
},
text(title)
.width(mode)
.style(if *disabled {
theme::Text::Custom(|theme| {
let mut color = theme.cosmic().background.component.on;
color.alpha *= 0.5;
TextAppearance {
color: Some(color.into()),
}
})
} else {
theme::Text::Default
})
.into(),
];
if let Some(shortcut) = shortcut.as_ref() {
components.push(
text(shortcut)
.line_height(Pixels(20.))
.size(14)
.horizontal_alignment(Horizontal::Right)
.width(Length::Shrink)
.style(theme::Text::Custom(|theme| {
let mut color = theme.cosmic().background.component.on;
color.alpha *= 0.75;
TextAppearance {
color: Some(color.into()),
}
}))
.into(),
);
}
components.push(horizontal_space(16).into());
Row::with_children(components)
.spacing(8)
Item::Submenu { title, .. } => Row::with_children(vec![
horizontal_space(16).into(),
text(title).width(mode).into(),
from_name("go-next-symbolic")
.size(16)
.prefer_svg(true)
.icon()
.into(),
])
.spacing(8)
.width(width)
.padding([8, 24])
.apply(|row| item::SubmenuItem::new(row, idx))
.style(theme::Button::MenuItem)
.into(),
Item::Entry {
title,
shortcut,
toggled,
disabled,
..
} => {
let mut components = vec![
if *toggled {
from_name("object-select-symbolic")
.size(16)
.prefer_svg(true)
.icon()
.style(theme::Svg::custom(|theme| iced_widget::svg::Appearance {
color: Some(theme.cosmic().accent.base.into()),
}))
.into()
} else {
horizontal_space(16).into()
},
text(title)
.width(mode)
.apply(button)
.width(width)
.padding([8, 24])
.on_press_maybe((!disabled).then_some(Message::ItemPressed(idx)))
.style(theme::Button::MenuItem)
.into()
.style(if *disabled {
theme::Text::Custom(|theme| {
let mut color = theme.cosmic().background.component.on;
color.alpha *= 0.5;
TextAppearance {
color: Some(color.into()),
}
})
} else {
theme::Text::Default
})
.into(),
];
if let Some(shortcut) = shortcut.as_ref() {
components.push(
text(shortcut)
.line_height(Pixels(20.))
.size(14)
.horizontal_alignment(Horizontal::Right)
.width(Length::Shrink)
.style(theme::Text::Custom(|theme| {
let mut color = theme.cosmic().background.component.on;
color.alpha *= 0.75;
TextAppearance {
color: Some(color.into()),
}
}))
.into(),
);
}
})
.collect(),
)
components.push(horizontal_space(16).into());
Row::with_children(components)
.spacing(8)
.width(mode)
.apply(button)
.width(width)
.padding([8, 24])
.on_press_maybe((!disabled).then_some(Message::ItemPressed(idx)))
.style(theme::Button::MenuItem)
.into()
}
}
}))
.width(Length::Shrink)
.apply(iced_widget::container)
.padding(1)
@ -434,9 +428,12 @@ impl Program for ContextMenu {
icon_color: Some(cosmic.accent.base.into()),
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border_radius: 8.0.into(),
border_width: 1.0,
border_color: component.divider.into(),
border: Border {
radius: 8.0.into(),
width: 1.0,
color: component.divider.into(),
},
shadow: Default::default(),
}
}))
.width(Length::Shrink)