Merge branch 'master' into non-uniform-border-radius-for-quads

This commit is contained in:
Héctor Ramón Jiménez 2022-12-02 18:53:21 +01:00
commit 4029a1cdaa
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
147 changed files with 4828 additions and 2184 deletions

View file

@ -104,9 +104,9 @@ where
.draw(renderer, theme, style, layout, cursor_position)
}
/// Applies an [`Operation`] to the [`Element`].
/// Applies a [`widget::Operation`] to the [`Element`].
pub fn operate(
&self,
&mut self,
layout: Layout<'_>,
operation: &mut dyn widget::Operation<Message>,
) {
@ -141,6 +141,57 @@ where
self.content.layout(renderer, bounds, position)
}
fn operate(
&mut self,
layout: Layout<'_>,
operation: &mut dyn widget::Operation<B>,
) {
struct MapOperation<'a, B> {
operation: &'a mut dyn widget::Operation<B>,
}
impl<'a, T, B> widget::Operation<T> for MapOperation<'a, B> {
fn container(
&mut self,
id: Option<&widget::Id>,
operate_on_children: &mut dyn FnMut(
&mut dyn widget::Operation<T>,
),
) {
self.operation.container(id, &mut |operation| {
operate_on_children(&mut MapOperation { operation });
});
}
fn focusable(
&mut self,
state: &mut dyn widget::operation::Focusable,
id: Option<&widget::Id>,
) {
self.operation.focusable(state, id);
}
fn scrollable(
&mut self,
state: &mut dyn widget::operation::Scrollable,
id: Option<&widget::Id>,
) {
self.operation.scrollable(state, id);
}
fn text_input(
&mut self,
state: &mut dyn widget::operation::TextInput,
id: Option<&widget::Id>,
) {
self.operation.text_input(state, id)
}
}
self.content
.operate(layout, &mut MapOperation { operation });
}
fn on_event(
&mut self,
event: Event,

View file

@ -9,7 +9,7 @@ use crate::text::{self, Text};
use crate::touch;
use crate::widget::container::{self, Container};
use crate::widget::scrollable::{self, Scrollable};
use crate::widget::tree::{self, Tree};
use crate::widget::Tree;
use crate::{
Clipboard, Color, Element, Layout, Length, Padding, Point, Rectangle,
Shell, Size, Vector, Widget,
@ -178,7 +178,7 @@ where
font,
text_size,
padding,
style,
style: style.clone(),
}));
state.tree.diff(&container as &dyn Widget<_, _>);
@ -199,18 +199,6 @@ where
Renderer: text::Renderer,
Renderer::Theme: StyleSheet + container::StyleSheet,
{
fn tag(&self) -> tree::Tag {
self.container.tag()
}
fn state(&self) -> tree::State {
self.container.state()
}
fn children(&self) -> Vec<Tree> {
self.container.children()
}
fn layout(
&self,
renderer: &Renderer,
@ -288,7 +276,7 @@ where
layout: Layout<'_>,
cursor_position: Point,
) {
let appearance = theme.appearance(self.style);
let appearance = theme.appearance(&self.style);
let bounds = layout.bounds();
renderer.fill_quad(
@ -460,7 +448,7 @@ where
_cursor_position: Point,
viewport: &Rectangle,
) {
let appearance = theme.appearance(self.style);
let appearance = theme.appearance(&self.style);
let bounds = layout.bounds();
let text_size =