Update libcosmic/iced
This commit is contained in:
parent
7234a81672
commit
39ebf39e4f
11 changed files with 547 additions and 461 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue