chore: updates after iced rebase
This commit is contained in:
parent
7bb5ae7cfe
commit
a48c4fc47d
16 changed files with 753 additions and 736 deletions
|
|
@ -12,7 +12,7 @@ use cosmic::{
|
|||
Apply,
|
||||
iced::{
|
||||
Alignment,
|
||||
widget::{column, container, horizontal_space, row, vertical_space},
|
||||
widget::{column, container, row, space},
|
||||
},
|
||||
iced_core::{Background, Border, Color, Length},
|
||||
theme,
|
||||
|
|
@ -70,6 +70,7 @@ impl Program for ResizeIndicatorInternal {
|
|||
let edges = self.edges.lock().unwrap();
|
||||
let icon_container_style = || {
|
||||
theme::Container::custom(|theme| container::Style {
|
||||
snap: true,
|
||||
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())),
|
||||
|
|
@ -99,7 +100,7 @@ impl Program for ResizeIndicatorInternal {
|
|||
.center_x(Length::Fill)
|
||||
.into()
|
||||
} else {
|
||||
vertical_space().height(36).into()
|
||||
space::vertical().height(36).into()
|
||||
},
|
||||
row(vec![
|
||||
if edges.contains(ResizeEdge::LEFT) {
|
||||
|
|
@ -118,12 +119,12 @@ impl Program for ResizeIndicatorInternal {
|
|||
.center_y(Length::Fill)
|
||||
.into()
|
||||
} else {
|
||||
horizontal_space().width(36).into()
|
||||
space::horizontal().width(36).into()
|
||||
},
|
||||
row(vec![
|
||||
text::heading(&self.shortcut1).into(),
|
||||
text::body(fl!("grow-window")).into(),
|
||||
horizontal_space().width(40).into(),
|
||||
space::horizontal().width(40).into(),
|
||||
text::heading(&self.shortcut2).into(),
|
||||
text::body(fl!("shrink-window")).into(),
|
||||
])
|
||||
|
|
@ -155,7 +156,7 @@ impl Program for ResizeIndicatorInternal {
|
|||
.center_y(Length::Fill)
|
||||
.into()
|
||||
} else {
|
||||
horizontal_space().width(36).into()
|
||||
space::horizontal().width(36).into()
|
||||
},
|
||||
])
|
||||
.width(Length::Fill)
|
||||
|
|
@ -177,7 +178,7 @@ impl Program for ResizeIndicatorInternal {
|
|||
.center_x(Length::Fill)
|
||||
.into()
|
||||
} else {
|
||||
vertical_space().height(36).into()
|
||||
space::vertical().height(36).into()
|
||||
},
|
||||
])
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,7 @@ impl Decorations<CosmicStackInternal, Message> for DefaultDecorations {
|
|||
.height(Length::Fill)
|
||||
.width(Length::Fill),
|
||||
),
|
||||
iced_widget::horizontal_space()
|
||||
iced_widget::space::horizontal()
|
||||
.width(Length::Fixed(0.0))
|
||||
.apply(iced_widget::container)
|
||||
.padding([64, 24])
|
||||
|
|
@ -1345,6 +1345,7 @@ impl Decorations<CosmicStackInternal, Message> for DefaultDecorations {
|
|||
};
|
||||
|
||||
iced_widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: Some(cosmic_theme.background.on.into()),
|
||||
text_color: Some(cosmic_theme.background.on.into()),
|
||||
background: Some(Background::Color(background.into())),
|
||||
|
|
|
|||
|
|
@ -30,19 +30,19 @@ impl From<TabRuleTheme> for theme::Rule {
|
|||
match theme {
|
||||
TabRuleTheme::ActiveActivated => Self::custom(|theme| widget::rule::Style {
|
||||
color: theme.cosmic().accent_color().into(),
|
||||
width: 4,
|
||||
snap: true,
|
||||
radius: 0.0.into(),
|
||||
fill_mode: FillMode::Full,
|
||||
}),
|
||||
TabRuleTheme::ActiveDeactivated => Self::custom(|theme| widget::rule::Style {
|
||||
color: theme.cosmic().palette.neutral_5.into(),
|
||||
width: 4,
|
||||
snap: true,
|
||||
radius: 0.0.into(),
|
||||
fill_mode: FillMode::Full,
|
||||
}),
|
||||
TabRuleTheme::Default => Self::custom(|theme| widget::rule::Style {
|
||||
color: theme.cosmic().palette.neutral_5.into(),
|
||||
width: 4,
|
||||
snap: true,
|
||||
radius: 8.0.into(),
|
||||
fill_mode: FillMode::Padded(4),
|
||||
}),
|
||||
|
|
@ -62,6 +62,7 @@ impl From<TabBackgroundTheme> for theme::Container<'_> {
|
|||
match background_theme {
|
||||
TabBackgroundTheme::ActiveActivated => {
|
||||
Self::custom(move |theme| widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: Some(Color::from(theme.cosmic().accent_text_color())),
|
||||
text_color: Some(Color::from(theme.cosmic().accent_text_color())),
|
||||
background: Some(Background::Color(
|
||||
|
|
@ -77,6 +78,7 @@ impl From<TabBackgroundTheme> for theme::Container<'_> {
|
|||
}
|
||||
TabBackgroundTheme::ActiveDeactivated => {
|
||||
Self::custom(move |theme| widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(Background::Color(
|
||||
|
|
@ -186,7 +188,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
|
|||
}
|
||||
|
||||
let items = vec![
|
||||
widget::vertical_rule(4).class(self.rule_theme).into(),
|
||||
widget::rule::vertical(4).class(self.rule_theme).into(),
|
||||
self.app_icon
|
||||
.clone()
|
||||
.apply(widget::container)
|
||||
|
|
@ -262,7 +264,7 @@ where
|
|||
Size::new(Length::Fill, Length::Fill)
|
||||
}
|
||||
|
||||
fn layout(&self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
fn layout(&mut self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
let min_size = Size {
|
||||
height: TAB_HEIGHT as f32,
|
||||
width: if self.active {
|
||||
|
|
@ -295,74 +297,68 @@ where
|
|||
8.,
|
||||
cosmic::iced::Alignment::Center,
|
||||
if size.width >= CLOSE_BREAKPOINT as f32 {
|
||||
&self.elements
|
||||
&mut self.elements
|
||||
} else if size.width >= TEXT_BREAKPOINT as f32 {
|
||||
&self.elements[0..3]
|
||||
&mut self.elements[0..3]
|
||||
} else {
|
||||
&self.elements[0..2]
|
||||
&mut self.elements[0..2]
|
||||
},
|
||||
&mut tree.children,
|
||||
)
|
||||
}
|
||||
|
||||
fn operate(
|
||||
&self,
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
operation: &mut dyn Operation<()>,
|
||||
) {
|
||||
operation.container(None, layout.bounds(), &mut |operation| {
|
||||
operation.container(None, layout.bounds());
|
||||
operation.traverse(&mut |operation| {
|
||||
self.elements
|
||||
.iter()
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.for_each(|((child, state), layout)| {
|
||||
child
|
||||
.as_widget()
|
||||
.as_widget_mut()
|
||||
.operate(state, layout, renderer, operation);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn on_event(
|
||||
fn update(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
event: event::Event,
|
||||
event: &event::Event,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &cosmic::Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
) {
|
||||
let status = self
|
||||
.elements
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().on_event(
|
||||
state,
|
||||
event.clone(),
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
child.as_widget_mut().update(
|
||||
state, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||
)
|
||||
})
|
||||
.fold(event::Status::Ignored, event::Status::merge);
|
||||
});
|
||||
|
||||
if status == event::Status::Ignored && cursor.is_over(layout.bounds()) {
|
||||
if !shell.is_event_captured() && cursor.is_over(layout.bounds()) {
|
||||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||
) {
|
||||
if let Some(message) = self.press_message.clone() {
|
||||
shell.publish(message);
|
||||
return event::Status::Captured;
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if matches!(
|
||||
|
|
@ -371,7 +367,8 @@ where
|
|||
) {
|
||||
if let Some(message) = self.right_click_message.clone() {
|
||||
shell.publish(message);
|
||||
return event::Status::Captured;
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if matches!(
|
||||
|
|
@ -379,11 +376,10 @@ where
|
|||
event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
) {
|
||||
shell.publish(Message::activate(self.idx));
|
||||
return event::Status::Captured;
|
||||
shell.capture_event();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
status
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
@ -447,10 +443,18 @@ where
|
|||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
layout: Layout<'b>,
|
||||
renderer: &cosmic::Renderer,
|
||||
viewport: &Rectangle,
|
||||
translation: cosmic::iced::Vector,
|
||||
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
|
||||
overlay::from_children(&mut self.elements, tree, layout, renderer, translation)
|
||||
overlay::from_children(
|
||||
&mut self.elements,
|
||||
tree,
|
||||
layout,
|
||||
renderer,
|
||||
viewport,
|
||||
translation,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ impl TabText {
|
|||
<cosmic::Renderer as TextRenderer>::Paragraph::with_text(Text {
|
||||
content: &self.text,
|
||||
size: cosmic::iced_core::Pixels(self.font_size),
|
||||
bounds: Size::INFINITY,
|
||||
bounds: Size::INFINITE,
|
||||
font: self.font,
|
||||
horizontal_alignment: alignment::Horizontal::Left,
|
||||
vertical_alignment: alignment::Vertical::Center,
|
||||
align_x: cosmic::iced_core::text::Alignment::Left,
|
||||
align_y: alignment::Vertical::Center,
|
||||
shaping: Shaping::Advanced,
|
||||
line_height: LineHeight::default(),
|
||||
wrapping: Wrapping::None,
|
||||
|
|
@ -107,7 +107,7 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
|
|||
Size::new(self.width, self.height)
|
||||
}
|
||||
|
||||
fn layout(&self, tree: &mut Tree, _renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
fn layout(&mut self, tree: &mut Tree, _renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
let state = tree.state.downcast_mut::<LocalState>();
|
||||
let text_bounds = state.paragraph.min_bounds();
|
||||
state.overflowed = limits.max().width < text_bounds.width;
|
||||
|
|
@ -166,6 +166,7 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
|
|||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
snap: true,
|
||||
bounds: Rectangle {
|
||||
x: (bounds.x + bounds.width - 24.).max(bounds.x),
|
||||
width: 24.0_f32.min(bounds.width),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use crate::backend::render::element;
|
||||
|
||||
use super::tab::{MIN_ACTIVE_TAB_WIDTH, Tab, TabBackgroundTheme, TabMessage, TabRuleTheme};
|
||||
use cosmic::{
|
||||
Apply,
|
||||
|
|
@ -64,12 +66,12 @@ pub struct State {
|
|||
}
|
||||
|
||||
impl Scrollable for State {
|
||||
fn snap_to(&mut self, offset: RelativeOffset) {
|
||||
self.offset_x = Offset::Relative(offset.x.clamp(0.0, 1.0));
|
||||
fn snap_to(&mut self, offset: RelativeOffset<Option<f32>>) {
|
||||
self.offset_x = Offset::Relative(offset.x.unwrap_or(0.0).clamp(0.0, 1.0));
|
||||
}
|
||||
|
||||
fn scroll_to(&mut self, offset: AbsoluteOffset) {
|
||||
let new_offset = Offset::Absolute(offset.x.max(0.0));
|
||||
fn scroll_to(&mut self, offset: AbsoluteOffset<Option<f32>>) {
|
||||
let new_offset = Offset::Absolute(offset.x.unwrap_or(0.0).max(0.0));
|
||||
self.scroll_animation = Some(ScrollAnimationState {
|
||||
start_time: Instant::now(),
|
||||
start: self.offset_x,
|
||||
|
|
@ -159,7 +161,7 @@ where
|
|||
Element::new(tab.internal(i))
|
||||
});
|
||||
|
||||
let tabs_rule = widget::vertical_rule(4).class(if tabs.len() - 1 == active {
|
||||
let tabs_rule = widget::rule::vertical(4).class(if tabs.len() - 1 == active {
|
||||
if activated {
|
||||
TabRuleTheme::ActiveActivated
|
||||
} else {
|
||||
|
|
@ -193,12 +195,12 @@ where
|
|||
|
||||
let mut elements = Vec::with_capacity(tabs.len() + 5);
|
||||
|
||||
elements.push(widget::vertical_rule(4).class(rule_style).into());
|
||||
elements.push(widget::rule::vertical(4).class(rule_style).into());
|
||||
elements.push(prev_button.into());
|
||||
elements.extend(tabs);
|
||||
elements.push(tabs_rule.into());
|
||||
elements.push(next_button.into());
|
||||
elements.push(widget::vertical_rule(4).class(rule_style).into());
|
||||
elements.push(widget::rule::vertical(4).class(rule_style).into());
|
||||
|
||||
Tabs {
|
||||
elements,
|
||||
|
|
@ -340,9 +342,9 @@ where
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn layout(&self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
fn layout(&mut self, tree: &mut Tree, renderer: &cosmic::Renderer, limits: &Limits) -> Node {
|
||||
let limits = limits.width(self.width).height(self.height);
|
||||
|
||||
let element_count = self.elements.len();
|
||||
// calculate the smallest possible size
|
||||
let child_limits = Limits::new(
|
||||
Size::new(0.0, limits.min().height),
|
||||
|
|
@ -351,10 +353,13 @@ where
|
|||
.width(Length::Shrink)
|
||||
.height(Length::Shrink);
|
||||
|
||||
let mut nodes = self.elements[2..self.elements.len() - 2]
|
||||
.iter()
|
||||
let mut nodes = self.elements[2..element_count - 2]
|
||||
.iter_mut()
|
||||
.zip(tree.children.iter_mut().skip(2))
|
||||
.map(|(tab, tab_tree)| tab.as_widget().layout(tab_tree, renderer, &child_limits))
|
||||
.map(|(tab, tab_tree)| {
|
||||
tab.as_widget_mut()
|
||||
.layout(tab_tree, renderer, &child_limits)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// sum up
|
||||
|
|
@ -370,8 +375,9 @@ where
|
|||
if min_size.width <= size.width {
|
||||
// we don't need to scroll
|
||||
|
||||
let element_count = self.elements.len();
|
||||
// can we make every tab equal weight and keep the active large enough?
|
||||
let children = if (size.width / (self.elements.len() as f32 - 5.)).ceil() as i32
|
||||
let children = if (size.width / (element_count as f32 - 5.)).ceil() as i32
|
||||
>= MIN_ACTIVE_TAB_WIDTH
|
||||
{
|
||||
// just use a flex layout
|
||||
|
|
@ -384,20 +390,20 @@ where
|
|||
0.into(),
|
||||
0.,
|
||||
cosmic::iced::Alignment::Center,
|
||||
&self.elements[2..self.elements.len() - 2],
|
||||
&mut tree.children[2..self.elements.len() - 2],
|
||||
&mut self.elements[2..element_count - 2],
|
||||
&mut tree.children[2..element_count - 2],
|
||||
)
|
||||
.children()
|
||||
.to_vec()
|
||||
} else {
|
||||
// otherwise we need a more manual approach
|
||||
let min_width = (size.width - MIN_ACTIVE_TAB_WIDTH as f32 - 4.)
|
||||
/ (self.elements.len() as f32 - 6.);
|
||||
let min_width =
|
||||
(size.width - MIN_ACTIVE_TAB_WIDTH as f32 - 4.) / (element_count as f32 - 6.);
|
||||
let mut offset = 0.;
|
||||
|
||||
let mut nodes = self.elements[2..self.elements.len() - 3]
|
||||
.iter()
|
||||
.zip(tree.children[2..].iter_mut())
|
||||
let mut nodes = self.elements[2..element_count - 3]
|
||||
.iter_mut()
|
||||
.zip(tree.children[2..element_count - 3].iter_mut())
|
||||
.map(|(tab, tab_tree)| {
|
||||
let child_limits = Limits::new(
|
||||
Size::new(min_width, limits.min().height),
|
||||
|
|
@ -406,7 +412,9 @@ where
|
|||
.width(Length::Shrink)
|
||||
.height(Length::Shrink);
|
||||
|
||||
let mut node = tab.as_widget().layout(tab_tree, renderer, &child_limits);
|
||||
let mut node =
|
||||
tab.as_widget_mut()
|
||||
.layout(tab_tree, renderer, &child_limits);
|
||||
node = node.move_to(Point::new(offset, 0.));
|
||||
offset += node.bounds().width;
|
||||
node
|
||||
|
|
@ -508,6 +516,7 @@ where
|
|||
let background_style = Catalog::style(
|
||||
theme,
|
||||
&theme::Container::custom(|theme| widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(Background::Color(
|
||||
|
|
@ -605,6 +614,9 @@ where
|
|||
let cursor = match cursor {
|
||||
mouse::Cursor::Available(point) => mouse::Cursor::Available(point + offset),
|
||||
mouse::Cursor::Unavailable => mouse::Cursor::Unavailable,
|
||||
mouse::Cursor::Levitating(point) => {
|
||||
mouse::Cursor::Levitating(point + offset)
|
||||
}
|
||||
};
|
||||
|
||||
renderer.with_layer(bounds, |renderer| {
|
||||
|
|
@ -677,7 +689,7 @@ where
|
|||
}
|
||||
|
||||
fn operate(
|
||||
&self,
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
|
|
@ -691,38 +703,38 @@ where
|
|||
state.cleanup_old_animations();
|
||||
|
||||
operation.scrollable(
|
||||
state,
|
||||
self.id.as_ref(),
|
||||
bounds,
|
||||
content_bounds,
|
||||
Vector { x: 0.0, y: 0.0 }, /* seemingly unused */
|
||||
Vector { x: 0.0, y: 0.0 },
|
||||
state,
|
||||
);
|
||||
|
||||
operation.container(self.id.as_ref(), bounds, &mut |operation| {
|
||||
self.elements[2..self.elements.len() - 3]
|
||||
.iter()
|
||||
let element_count = self.elements.len();
|
||||
operation.traverse(&mut |operation| {
|
||||
self.elements[2..element_count - 3]
|
||||
.iter_mut()
|
||||
.zip(tree.children.iter_mut().skip(2))
|
||||
.zip(layout.children().skip(2))
|
||||
.for_each(|((child, state), layout)| {
|
||||
child
|
||||
.as_widget()
|
||||
.as_widget_mut()
|
||||
.operate(state, layout, renderer, operation);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn on_event(
|
||||
fn update(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
event: event::Event,
|
||||
event: &event::Event,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &cosmic::Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
) {
|
||||
let state = tree.state.downcast_mut::<State>();
|
||||
state.cleanup_old_animations();
|
||||
|
||||
|
|
@ -849,15 +861,15 @@ where
|
|||
let mut internal_shell = Shell::new(&mut messages);
|
||||
|
||||
let len = self.elements.len();
|
||||
let result = if scrolling && cursor.position().is_some_and(|pos| pos.x < bounds.x) {
|
||||
if scrolling && cursor.position().is_some_and(|pos| pos.x < bounds.x) {
|
||||
self.elements[0..2]
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().on_event(
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event.clone(),
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
|
|
@ -865,8 +877,7 @@ where
|
|||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
})
|
||||
.fold(event::Status::Ignored, event::Status::merge)
|
||||
});
|
||||
} else if scrolling
|
||||
&& cursor
|
||||
.position()
|
||||
|
|
@ -877,9 +888,9 @@ where
|
|||
.zip(tree.children.iter_mut().skip(len - 3))
|
||||
.zip(layout.children().skip(len - 3))
|
||||
.map(|((child, state), layout)| {
|
||||
child.as_widget_mut().on_event(
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event.clone(),
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
|
|
@ -887,8 +898,7 @@ where
|
|||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
})
|
||||
.fold(event::Status::Ignored, event::Status::merge)
|
||||
});
|
||||
} else {
|
||||
self.elements[2..len - 3]
|
||||
.iter_mut()
|
||||
|
|
@ -898,11 +908,14 @@ where
|
|||
let cursor = match cursor {
|
||||
mouse::Cursor::Available(point) => mouse::Cursor::Available(point + offset),
|
||||
mouse::Cursor::Unavailable => mouse::Cursor::Unavailable,
|
||||
mouse::Cursor::Levitating(point) => {
|
||||
mouse::Cursor::Levitating(point + offset)
|
||||
}
|
||||
};
|
||||
|
||||
child.as_widget_mut().on_event(
|
||||
child.as_widget_mut().update(
|
||||
state,
|
||||
event.clone(),
|
||||
event,
|
||||
layout,
|
||||
cursor,
|
||||
renderer,
|
||||
|
|
@ -910,8 +923,7 @@ where
|
|||
&mut internal_shell,
|
||||
viewport,
|
||||
)
|
||||
})
|
||||
.fold(event::Status::Ignored, event::Status::merge)
|
||||
});
|
||||
};
|
||||
|
||||
for mut message in messages {
|
||||
|
|
@ -919,14 +931,12 @@ where
|
|||
x: state.offset_x.absolute(bounds.width, content_bounds.width),
|
||||
y: 0.,
|
||||
}) {
|
||||
state.scroll_to(offset);
|
||||
state.scroll_to(offset.into());
|
||||
continue;
|
||||
}
|
||||
|
||||
shell.publish(message);
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
@ -992,6 +1002,9 @@ where
|
|||
let cursor = match cursor {
|
||||
mouse::Cursor::Available(point) => mouse::Cursor::Available(point + offset),
|
||||
mouse::Cursor::Unavailable => mouse::Cursor::Unavailable,
|
||||
mouse::Cursor::Levitating(point) => {
|
||||
mouse::Cursor::Levitating(point + offset)
|
||||
}
|
||||
};
|
||||
|
||||
child.as_widget().mouse_interaction(
|
||||
|
|
@ -1010,10 +1023,18 @@ where
|
|||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
tree: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
layout: Layout<'b>,
|
||||
renderer: &cosmic::Renderer,
|
||||
viewport: &Rectangle,
|
||||
translation: cosmic::iced::Vector,
|
||||
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
|
||||
overlay::from_children(&mut self.elements, tree, layout, renderer, translation)
|
||||
overlay::from_children(
|
||||
&mut self.elements,
|
||||
tree,
|
||||
layout,
|
||||
renderer,
|
||||
viewport,
|
||||
translation,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use cosmic::{
|
|||
},
|
||||
iced_core::{Background, Border, Color, Length},
|
||||
theme,
|
||||
widget::{horizontal_space, icon::from_name, text},
|
||||
widget::{icon::from_name, space, text},
|
||||
};
|
||||
use smithay::utils::{Logical, Size};
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ impl Program for StackHoverInternal {
|
|||
.prefer_svg(true)
|
||||
.icon()
|
||||
.into(),
|
||||
horizontal_space().width(16).into(),
|
||||
space::horizontal().width(16).into(),
|
||||
text::title3(fl!("stack-windows")).into(),
|
||||
])
|
||||
.align_y(Alignment::Center)
|
||||
|
|
@ -48,6 +48,7 @@ impl Program for StackHoverInternal {
|
|||
.padding(16)
|
||||
.apply(container)
|
||||
.class(theme::Container::custom(|theme| container::Style {
|
||||
snap: true,
|
||||
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())),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
use calloop::LoopHandle;
|
||||
use cosmic::{
|
||||
Apply,
|
||||
iced::widget::{container, horizontal_space, row},
|
||||
iced::widget::{container, row, space},
|
||||
iced_core::{Alignment, Background, Border, Color, Length},
|
||||
theme,
|
||||
widget::{icon::from_name, text},
|
||||
|
|
@ -34,7 +34,7 @@ impl Program for SwapIndicatorInternal {
|
|||
.prefer_svg(true)
|
||||
.icon()
|
||||
.into(),
|
||||
horizontal_space().width(16).into(),
|
||||
space::horizontal().width(16).into(),
|
||||
text::title3(fl!("swap-windows")).into(),
|
||||
])
|
||||
.align_y(Alignment::Center)
|
||||
|
|
@ -44,6 +44,7 @@ impl Program for SwapIndicatorInternal {
|
|||
.padding(16)
|
||||
.apply(container)
|
||||
.class(theme::Container::custom(|theme| container::Style {
|
||||
snap: true,
|
||||
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())),
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ where
|
|||
}
|
||||
|
||||
fn layout(
|
||||
&self,
|
||||
&mut self,
|
||||
state: &mut Tree,
|
||||
renderer: &cosmic::Renderer,
|
||||
limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
let state = &mut state.children[0];
|
||||
let node = self.elem.as_widget().layout(state, renderer, limits);
|
||||
let node = self.elem.as_widget_mut().layout(state, renderer, limits);
|
||||
layout::Node::with_children(node.size(), vec![node])
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +81,7 @@ where
|
|||
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
snap: true,
|
||||
bounds: layout.bounds(),
|
||||
border: Border {
|
||||
radius: styling.border_radius,
|
||||
|
|
@ -128,7 +129,7 @@ where
|
|||
}
|
||||
|
||||
fn operate(
|
||||
&self,
|
||||
&mut self,
|
||||
state: &mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &cosmic::Renderer,
|
||||
|
|
@ -137,21 +138,21 @@ where
|
|||
let state = &mut state.children[0];
|
||||
let layout = layout.children().next().unwrap();
|
||||
self.elem
|
||||
.as_widget()
|
||||
.as_widget_mut()
|
||||
.operate(state, layout, renderer, operation)
|
||||
}
|
||||
|
||||
fn on_event(
|
||||
fn update(
|
||||
&mut self,
|
||||
state: &mut Tree,
|
||||
event: Event,
|
||||
event: &Event,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &cosmic::Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
) {
|
||||
let mut bounds = layout.bounds();
|
||||
|
||||
// fix padding 1 and event... don't ask.
|
||||
|
|
@ -180,9 +181,9 @@ where
|
|||
|
||||
let state = &mut state.children[0];
|
||||
let layout = layout.children().next().unwrap();
|
||||
self.elem.as_widget_mut().on_event(
|
||||
self.elem.as_widget_mut().update(
|
||||
state, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
|
|
@ -203,15 +204,16 @@ where
|
|||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
state: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
layout: Layout<'b>,
|
||||
renderer: &cosmic::Renderer,
|
||||
viewport: &Rectangle,
|
||||
translation: cosmic::iced::Vector,
|
||||
) -> 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, translation)
|
||||
.overlay(state, layout, renderer, viewport, translation)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use cosmic::{
|
|||
iced_core::{Border, Length, Rectangle as IcedRectangle, alignment::Horizontal},
|
||||
iced_widget::{self, Column, Row, text::Style as TextStyle},
|
||||
theme,
|
||||
widget::{button, divider, horizontal_space, icon::from_name, text},
|
||||
widget::{button, divider, icon::from_name, space, text},
|
||||
};
|
||||
use smithay::{
|
||||
backend::{
|
||||
|
|
@ -392,7 +392,7 @@ impl Program for ContextMenu {
|
|||
match item {
|
||||
Item::Separator => divider::horizontal::light().into(),
|
||||
Item::Submenu { title, .. } => Row::with_children(vec![
|
||||
horizontal_space().width(16).into(),
|
||||
space::horizontal().width(16).into(),
|
||||
text::body(title).width(mode).into(),
|
||||
from_name("go-next-symbolic")
|
||||
.size(16)
|
||||
|
|
@ -425,7 +425,7 @@ impl Program for ContextMenu {
|
|||
}))
|
||||
.into()
|
||||
} else {
|
||||
horizontal_space().width(16).into()
|
||||
space::horizontal().width(16).into()
|
||||
},
|
||||
text::body(title)
|
||||
.width(mode)
|
||||
|
|
@ -441,7 +441,7 @@ impl Program for ContextMenu {
|
|||
theme::Text::Default
|
||||
})
|
||||
.into(),
|
||||
horizontal_space().width(16).into(),
|
||||
space::horizontal().width(16).into(),
|
||||
];
|
||||
if let Some(shortcut) = shortcut.as_ref() {
|
||||
components.push(
|
||||
|
|
@ -479,6 +479,7 @@ impl Program for ContextMenu {
|
|||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
iced_widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: Some(cosmic.accent.base.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
|
|
|
|||
|
|
@ -514,6 +514,7 @@ impl Program for ZoomProgram {
|
|||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
iced_widget::container::Style {
|
||||
snap: true,
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue