yoda: cargo clippy --fix on libcosmic-yoda (115→33 warnings)
Auto-applied clippy lint suggestions across 23 files: collapse
`else { if … }` ladders, drop unneeded `return` statements, remove
needless borrows that were immediately auto-dereffed, swap `iter().next()`
for `first()`, drop redundant `.into()` to the same type, and similar
mechanical cleanups. Behavior is unchanged; the diff is -67 lines net.
The 33 remaining warnings are architectural and need manual attention
(very-complex-type aliases, too-many-arguments on internal helpers,
redundant must_use, needs-is_empty, etc.).
Leyoda 2026 – GPLv3
This commit is contained in:
parent
999db0a4bd
commit
4743bb8ec9
23 changed files with 91 additions and 159 deletions
|
|
@ -479,12 +479,11 @@ where
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(cosmic_config::Error::is_err)
|
.filter(cosmic_config::Error::is_err)
|
||||||
{
|
{
|
||||||
if let cosmic_config::Error::GetKey(_, err) = &why {
|
if let cosmic_config::Error::GetKey(_, err) = &why
|
||||||
if err.kind() == std::io::ErrorKind::NotFound {
|
&& err.kind() == std::io::ErrorKind::NotFound {
|
||||||
// No system default config installed; don't error
|
// No system default config installed; don't error
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tracing::error!(?why, "cosmic toolkit config update error");
|
tracing::error!(?why, "cosmic toolkit config update error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,11 @@ pub static COSMIC_TK: LazyLock<RwLock<CosmicTk>> = LazyLock::new(|| {
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
CosmicTk::get_entry(&c).unwrap_or_else(|(errors, mode)| {
|
CosmicTk::get_entry(&c).unwrap_or_else(|(errors, mode)| {
|
||||||
for why in errors.into_iter().filter(cosmic_config::Error::is_err) {
|
for why in errors.into_iter().filter(cosmic_config::Error::is_err) {
|
||||||
if let cosmic_config::Error::GetKey(_, err) = &why {
|
if let cosmic_config::Error::GetKey(_, err) = &why
|
||||||
if err.kind() == std::io::ErrorKind::NotFound {
|
&& err.kind() == std::io::ErrorKind::NotFound {
|
||||||
// No system default config installed; don't error
|
// No system default config installed; don't error
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tracing::error!(?why, "CosmicTk config entry error");
|
tracing::error!(?why, "CosmicTk config entry error");
|
||||||
}
|
}
|
||||||
mode
|
mode
|
||||||
|
|
|
||||||
|
|
@ -211,11 +211,10 @@ impl Catalog for crate::Theme {
|
||||||
(component.base.into(), text_color, text_color)
|
(component.base.into(), text_color, text_color)
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Button::ListItem(_) = style {
|
if let Button::ListItem(_) = style
|
||||||
if !selected {
|
&& !selected {
|
||||||
s.background = None;
|
s.background = None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
@ -266,11 +265,10 @@ impl Catalog for crate::Theme {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Button::ListItem(_) = style {
|
if let Button::ListItem(_) = style
|
||||||
if !selected {
|
&& !selected {
|
||||||
s.background = None;
|
s.background = None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,18 +171,15 @@ impl Button {
|
||||||
* TODO: Checkbox
|
* TODO: Checkbox
|
||||||
*/
|
*/
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[derive(Default)]
|
||||||
pub enum Checkbox {
|
pub enum Checkbox {
|
||||||
|
#[default]
|
||||||
Primary,
|
Primary,
|
||||||
Secondary,
|
Secondary,
|
||||||
Success,
|
Success,
|
||||||
Danger,
|
Danger,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Checkbox {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Primary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl iced_checkbox::Catalog for Theme {
|
impl iced_checkbox::Catalog for Theme {
|
||||||
type Class<'a> = Checkbox;
|
type Class<'a> = Checkbox;
|
||||||
|
|
@ -1193,7 +1190,7 @@ impl scrollable::Catalog for Theme {
|
||||||
background: Color::TRANSPARENT.into(),
|
background: Color::TRANSPARENT.into(),
|
||||||
border: Border::default(),
|
border: Border::default(),
|
||||||
shadow: Shadow::default(),
|
shadow: Shadow::default(),
|
||||||
icon: Color::TRANSPARENT.into(),
|
icon: Color::TRANSPARENT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let small_widget_container = self.current_container().small_widget.with_alpha(0.7);
|
let small_widget_container = self.current_container().small_widget.with_alpha(0.7);
|
||||||
|
|
@ -1261,7 +1258,7 @@ impl scrollable::Catalog for Theme {
|
||||||
background: Color::TRANSPARENT.into(),
|
background: Color::TRANSPARENT.into(),
|
||||||
border: Border::default(),
|
border: Border::default(),
|
||||||
shadow: Shadow::default(),
|
shadow: Shadow::default(),
|
||||||
icon: Color::TRANSPARENT.into(),
|
icon: Color::TRANSPARENT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -381,13 +381,12 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
match event {
|
match event {
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||||
if let Some(position) = cursor.position() {
|
if let Some(position) = cursor.position()
|
||||||
if removal_bounds(layout.bounds(), 4.0).contains(position) {
|
&& removal_bounds(layout.bounds(), 4.0).contains(position) {
|
||||||
shell.publish(on_remove.clone());
|
shell.publish(on_remove.clone());
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
@ -560,9 +559,9 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if on_remove.is_some() {
|
if on_remove.is_some()
|
||||||
if let Some(position) = cursor.position() {
|
&& let Some(position) = cursor.position()
|
||||||
if bounds.contains(position) {
|
&& bounds.contains(position) {
|
||||||
let bounds = removal_bounds(layout.bounds(), 4.0);
|
let bounds = removal_bounds(layout.bounds(), 4.0);
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
renderer::Quad {
|
renderer::Quad {
|
||||||
|
|
@ -594,8 +593,6 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -793,7 +790,6 @@ pub fn update<'a, Message: Clone>(
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -813,7 +809,6 @@ pub fn update<'a, Message: Clone>(
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if on_press_down.is_some() {
|
} else if on_press_down.is_some() {
|
||||||
let state = state();
|
let state = state();
|
||||||
|
|
@ -833,7 +828,6 @@ pub fn update<'a, Message: Clone>(
|
||||||
shell.publish(msg);
|
shell.publish(msg);
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
|
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
|
||||||
if let Some(on_press) = on_press {
|
if let Some(on_press) = on_press {
|
||||||
|
|
@ -844,7 +838,6 @@ pub fn update<'a, Message: Clone>(
|
||||||
|
|
||||||
shell.publish(msg);
|
shell.publish(msg);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,7 +532,7 @@ where
|
||||||
let c_layout = layout.next().unwrap();
|
let c_layout = layout.next().unwrap();
|
||||||
let state = clear_all_state.unwrap();
|
let state = clear_all_state.unwrap();
|
||||||
self.clear_all_button.as_widget_mut().update(
|
self.clear_all_button.as_widget_mut().update(
|
||||||
state, &event, c_layout, cursor, renderer, clipboard, shell, viewport,
|
state, event, c_layout, cursor, renderer, clipboard, shell, viewport,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,7 +542,7 @@ where
|
||||||
|
|
||||||
for ((inner, layout), c_state) in self.elements.iter_mut().zip(layout).zip(tree_children) {
|
for ((inner, layout), c_state) in self.elements.iter_mut().zip(layout).zip(tree_children) {
|
||||||
inner.as_widget_mut().update(
|
inner.as_widget_mut().update(
|
||||||
c_state, &event, layout, cursor, renderer, clipboard, shell, viewport,
|
c_state, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||||
);
|
);
|
||||||
if shell.is_event_captured() || fully_unexpanded {
|
if shell.is_event_captured() || fully_unexpanded {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -745,7 +745,7 @@ where
|
||||||
let column_tree = &mut tree.children[0];
|
let column_tree = &mut tree.children[0];
|
||||||
self.inner.as_widget_mut().update(
|
self.inner.as_widget_mut().update(
|
||||||
column_tree,
|
column_tree,
|
||||||
&event,
|
event,
|
||||||
column_layout,
|
column_layout,
|
||||||
cursor,
|
cursor,
|
||||||
renderer,
|
renderer,
|
||||||
|
|
@ -758,22 +758,19 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
match event {
|
if let Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) = event {
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
let bounds = column_layout.children().nth(1).unwrap().bounds();
|
||||||
let bounds = column_layout.children().nth(1).unwrap().bounds();
|
if let Some(point) = cursor.position_over(bounds) {
|
||||||
if let Some(point) = cursor.position_over(bounds) {
|
let relative_pos = point - bounds.position();
|
||||||
let relative_pos = point - bounds.position();
|
let (s, v) = (
|
||||||
let (s, v) = (
|
relative_pos.x / bounds.width,
|
||||||
relative_pos.x / bounds.width,
|
1.0 - relative_pos.y / bounds.height,
|
||||||
1.0 - relative_pos.y / bounds.height,
|
);
|
||||||
);
|
state.dragging = true;
|
||||||
state.dragging = true;
|
let hsv: palette::Hsv = palette::Hsv::new(self.active_color.hue, s, v);
|
||||||
let hsv: palette::Hsv = palette::Hsv::new(self.active_color.hue, s, v);
|
shell.publish((self.on_update)(ColorPickerUpdate::ActiveColor(hsv)));
|
||||||
shell.publish((self.on_update)(ColorPickerUpdate::ActiveColor(hsv)));
|
shell.capture_event();
|
||||||
shell.capture_event();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
x, y, mime_types, ..
|
x, y, mime_types, ..
|
||||||
},
|
},
|
||||||
)) if *id == Some(my_id) => {
|
)) if *id == Some(my_id) => {
|
||||||
if !self.mime_matches(&mime_types) {
|
if !self.mime_matches(mime_types) {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: DND_DEST_LOG_TARGET,
|
target: DND_DEST_LOG_TARGET,
|
||||||
"offer enter id={my_id:?} ignored (mimes={mime_types:?} not in {:?})",
|
"offer enter id={my_id:?} ignored (mimes={mime_types:?} not in {:?})",
|
||||||
|
|
@ -408,7 +408,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(_, OfferEvent::Leave)) => {
|
Event::Dnd(DndEvent::Offer(_, OfferEvent::Leave)) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|
@ -436,7 +435,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
viewport,
|
viewport,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(id, OfferEvent::Motion { x, y })) if *id == Some(my_id) => {
|
Event::Dnd(DndEvent::Offer(id, OfferEvent::Motion { x, y })) if *id == Some(my_id) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|
@ -471,7 +469,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(_, OfferEvent::LeaveDestination)) => {
|
Event::Dnd(DndEvent::Offer(_, OfferEvent::LeaveDestination)) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|
@ -484,7 +481,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
{
|
{
|
||||||
shell.publish(msg);
|
shell.publish(msg);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(id, OfferEvent::Drop)) if *id == Some(my_id) => {
|
Event::Dnd(DndEvent::Offer(id, OfferEvent::Drop)) if *id == Some(my_id) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|
@ -497,7 +493,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
shell.publish(msg);
|
shell.publish(msg);
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(id, OfferEvent::SelectedAction(action)))
|
Event::Dnd(DndEvent::Offer(id, OfferEvent::SelectedAction(action)))
|
||||||
if *id == Some(my_id) =>
|
if *id == Some(my_id) =>
|
||||||
|
|
@ -515,7 +510,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
shell.publish(msg);
|
shell.publish(msg);
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Dnd(DndEvent::Offer(id, OfferEvent::Data { data, mime_type }))
|
Event::Dnd(DndEvent::Offer(id, OfferEvent::Data { data, mime_type }))
|
||||||
if *id == Some(my_id) =>
|
if *id == Some(my_id) =>
|
||||||
|
|
@ -555,7 +549,6 @@ impl<Message: 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -474,16 +474,14 @@ where
|
||||||
match event {
|
match event {
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||||
let hovered_guard = self.hovered_option.lock().unwrap();
|
let hovered_guard = self.hovered_option.lock().unwrap();
|
||||||
if cursor.is_over(layout.bounds()) {
|
if cursor.is_over(layout.bounds())
|
||||||
if let Some(index) = *hovered_guard {
|
&& let Some(index) = *hovered_guard {
|
||||||
shell.publish((self.on_selected)(index));
|
shell.publish((self.on_selected)(index));
|
||||||
if let Some(close_on_selected) = self.close_on_selected.as_ref() {
|
if let Some(close_on_selected) = self.close_on_selected.as_ref() {
|
||||||
shell.publish(close_on_selected.clone());
|
shell.publish(close_on_selected.clone());
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||||
if let Some(cursor_position) = cursor.position_in(layout.bounds()) {
|
if let Some(cursor_position) = cursor.position_in(layout.bounds()) {
|
||||||
|
|
@ -498,11 +496,10 @@ where
|
||||||
let new_hovered_option = (cursor_position.y / option_height) as usize;
|
let new_hovered_option = (cursor_position.y / option_height) as usize;
|
||||||
let mut hovered_guard = self.hovered_option.lock().unwrap();
|
let mut hovered_guard = self.hovered_option.lock().unwrap();
|
||||||
|
|
||||||
if let Some(on_option_hovered) = self.on_option_hovered {
|
if let Some(on_option_hovered) = self.on_option_hovered
|
||||||
if *hovered_guard != Some(new_hovered_option) {
|
&& *hovered_guard != Some(new_hovered_option) {
|
||||||
shell.publish(on_option_hovered(new_hovered_option));
|
shell.publish(on_option_hovered(new_hovered_option));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*hovered_guard = Some(new_hovered_option);
|
*hovered_guard = Some(new_hovered_option);
|
||||||
}
|
}
|
||||||
|
|
@ -526,7 +523,6 @@ where
|
||||||
shell.publish(close_on_selected.clone());
|
shell.publish(close_on_selected.clone());
|
||||||
}
|
}
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -343,13 +343,11 @@ where
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||||
if cursor.is_over(bounds) {
|
if cursor.is_over(bounds)
|
||||||
if let Some(item) = self.hovered_option.as_ref() {
|
&& let Some(item) = self.hovered_option.as_ref() {
|
||||||
shell.publish((self.on_selected)(item.clone()));
|
shell.publish((self.on_selected)(item.clone()));
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||||
if let Some(cursor_position) = cursor.position_in(bounds) {
|
if let Some(cursor_position) = cursor.position_in(bounds) {
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ impl<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>
|
||||||
_viewport: &Rectangle,
|
_viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
update(
|
update(
|
||||||
&event,
|
event,
|
||||||
layout,
|
layout,
|
||||||
cursor,
|
cursor,
|
||||||
shell,
|
shell,
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ where
|
||||||
_viewport: &Rectangle,
|
_viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
update::<S, Message, AppMessage>(
|
update::<S, Message, AppMessage>(
|
||||||
&event,
|
event,
|
||||||
layout,
|
layout,
|
||||||
cursor,
|
cursor,
|
||||||
shell,
|
shell,
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ pub fn resolve_wrapper<'a, Message>(
|
||||||
if align_items == Alignment::Center {
|
if align_items == Alignment::Center {
|
||||||
let mut fill_cross = axis.cross(limits.min());
|
let mut fill_cross = axis.cross(limits.min());
|
||||||
|
|
||||||
for (child, tree) in items.into_iter().zip(tree.iter_mut()) {
|
for (child, tree) in items.iter_mut().zip(tree.iter_mut()) {
|
||||||
let c_size = child.size();
|
let c_size = child.size();
|
||||||
let cross_fill_factor = match axis {
|
let cross_fill_factor = match axis {
|
||||||
Axis::Horizontal => c_size.height,
|
Axis::Horizontal => c_size.height,
|
||||||
|
|
@ -272,7 +272,7 @@ pub fn resolve_wrapper<'a, Message>(
|
||||||
cross = fill_cross;
|
cross = fill_cross;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, (child, tree)) in items.into_iter().zip(tree.iter_mut()).enumerate() {
|
for (i, (child, tree)) in items.iter_mut().zip(tree.iter_mut()).enumerate() {
|
||||||
let c_size = child.size();
|
let c_size = child.size();
|
||||||
let fill_factor = match axis {
|
let fill_factor = match axis {
|
||||||
Axis::Horizontal => c_size.width,
|
Axis::Horizontal => c_size.width,
|
||||||
|
|
@ -315,7 +315,7 @@ pub fn resolve_wrapper<'a, Message>(
|
||||||
|
|
||||||
let remaining = available.max(0.0);
|
let remaining = available.max(0.0);
|
||||||
|
|
||||||
for (i, (child, tree)) in items.into_iter().zip(tree.iter_mut()).enumerate() {
|
for (i, (child, tree)) in items.iter_mut().zip(tree.iter_mut()).enumerate() {
|
||||||
let c_size = child.size();
|
let c_size = child.size();
|
||||||
let fill_factor = match axis {
|
let fill_factor = match axis {
|
||||||
Axis::Horizontal => c_size.width,
|
Axis::Horizontal => c_size.width,
|
||||||
|
|
|
||||||
|
|
@ -598,14 +598,12 @@ where
|
||||||
.with_data(|d| !d.open && !d.active_root.is_empty());
|
.with_data(|d| !d.open && !d.active_root.is_empty());
|
||||||
|
|
||||||
let open = my_state.inner.with_data_mut(|state| {
|
let open = my_state.inner.with_data_mut(|state| {
|
||||||
if reset {
|
if reset
|
||||||
if let Some(popup_id) = state.popup_id.get(&self.window_id).copied() {
|
&& let Some(popup_id) = state.popup_id.get(&self.window_id).copied()
|
||||||
if let Some(handler) = self.on_surface_action.as_ref() {
|
&& let Some(handler) = self.on_surface_action.as_ref() {
|
||||||
shell.publish((handler)(crate::surface::Action::DestroyPopup(popup_id)));
|
shell.publish((handler)(crate::surface::Action::DestroyPopup(popup_id)));
|
||||||
state.reset();
|
state.reset();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
state.open
|
state.open
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1521,14 +1521,13 @@ where
|
||||||
.is_some_and(|i| *i != new_index && !active_menu[*i].children.is_empty());
|
.is_some_and(|i| *i != new_index && !active_menu[*i].children.is_empty());
|
||||||
|
|
||||||
#[cfg(all(feature = "multi-window", feature = "wayland", target_os = "linux", feature = "surface-message"))]
|
#[cfg(all(feature = "multi-window", feature = "wayland", target_os = "linux", feature = "surface-message"))]
|
||||||
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && remove {
|
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) && remove
|
||||||
if let Some(id) = state.popup_id.remove(&menu.window_id) {
|
&& let Some(id) = state.popup_id.remove(&menu.window_id) {
|
||||||
state.active_root.truncate(menu.depth + 1);
|
state.active_root.truncate(menu.depth + 1);
|
||||||
shell.publish((menu.on_surface_action.as_ref().unwrap())({
|
shell.publish((menu.on_surface_action.as_ref().unwrap())({
|
||||||
crate::surface::action::destroy_popup(id)
|
crate::surface::action::destroy_popup(id)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let item = &active_menu[new_index];
|
let item = &active_menu[new_index];
|
||||||
// set new index
|
// set new index
|
||||||
let old_index = last_menu_state.index.replace(new_index);
|
let old_index = last_menu_state.index.replace(new_index);
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,8 @@ where
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if let Some(on_close) = self.on_close.as_ref() {
|
} else if let Some(on_close) = self.on_close.as_ref()
|
||||||
if matches!(
|
&& matches!(
|
||||||
event,
|
event,
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(_))
|
Event::Mouse(mouse::Event::ButtonPressed(_))
|
||||||
| Event::Touch(touch::Event::FingerPressed { .. })
|
| Event::Touch(touch::Event::FingerPressed { .. })
|
||||||
|
|
@ -173,7 +173,6 @@ where
|
||||||
{
|
{
|
||||||
shell.publish(on_close.clone());
|
shell.publish(on_close.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide cursor from background content when modal popup is active
|
// Hide cursor from background content when modal popup is active
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,6 @@ where
|
||||||
if cursor.is_over(layout.bounds()) {
|
if cursor.is_over(layout.bounds()) {
|
||||||
shell.publish(self.on_click.clone());
|
shell.publish(self.on_click.clone());
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
|
|
@ -692,11 +692,10 @@ where
|
||||||
|
|
||||||
if let Some(icon) = self.model.icon(key) {
|
if let Some(icon) = self.model.icon(key) {
|
||||||
non_text_width += f32::from(icon.size) + f32::from(self.button_spacing);
|
non_text_width += f32::from(icon.size) + f32::from(self.button_spacing);
|
||||||
} else if self.model.is_active(key) {
|
} else if self.model.is_active(key)
|
||||||
if let crate::theme::SegmentedButton::Control = self.style {
|
&& let crate::theme::SegmentedButton::Control = self.style {
|
||||||
non_text_width += 16.0 + f32::from(self.button_spacing);
|
non_text_width += 16.0 + f32::from(self.button_spacing);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if self.model.is_closable(key) {
|
if self.model.is_closable(key) {
|
||||||
non_text_width +=
|
non_text_width +=
|
||||||
|
|
@ -1083,11 +1082,10 @@ where
|
||||||
{
|
{
|
||||||
state.drop_hint = None;
|
state.drop_hint = None;
|
||||||
self.emit_drop_hint(shell, state.drop_hint);
|
self.emit_drop_hint(shell, state.drop_hint);
|
||||||
if let Some(Some(entity)) = entity {
|
if let Some(Some(entity)) = entity
|
||||||
if let Some(on_dnd_leave) = self.on_dnd_leave.as_ref() {
|
&& let Some(on_dnd_leave) = self.on_dnd_leave.as_ref() {
|
||||||
shell.publish(on_dnd_leave(entity));
|
shell.publish(on_dnd_leave(entity));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: TAB_REORDER_LOG_TARGET,
|
target: TAB_REORDER_LOG_TARGET,
|
||||||
"offer leave id={my_id:?} entity={entity:?}"
|
"offer leave id={my_id:?} entity={entity:?}"
|
||||||
|
|
@ -1163,11 +1161,10 @@ where
|
||||||
None::<fn(_, _, _) -> Message>,
|
None::<fn(_, _, _) -> Message>,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
if let Some(on_dnd_leave) = self.on_dnd_leave.as_ref() {
|
if let Some(on_dnd_leave) = self.on_dnd_leave.as_ref()
|
||||||
if let Some(Some(entity)) = entity {
|
&& let Some(Some(entity)) = entity {
|
||||||
shell.publish(on_dnd_leave(entity));
|
shell.publish(on_dnd_leave(entity));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DndEvent::Offer(id, OfferEvent::Drop) if Some(my_id) == *id => {
|
DndEvent::Offer(id, OfferEvent::Drop) if Some(my_id) == *id => {
|
||||||
|
|
@ -1340,8 +1337,8 @@ where
|
||||||
// Emit close message if the close button is pressed.
|
// Emit close message if the close button is pressed.
|
||||||
if let Some(on_close) = self.on_close.as_ref() {
|
if let Some(on_close) = self.on_close.as_ref() {
|
||||||
if over_close_button
|
if over_close_button
|
||||||
&& (left_button_released(&event)
|
&& (left_button_released(event)
|
||||||
|| (touch_lifted(&event) && fingers_pressed == 1))
|
|| (touch_lifted(event) && fingers_pressed == 1))
|
||||||
{
|
{
|
||||||
shell.publish(on_close(key));
|
shell.publish(on_close(key));
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
|
|
@ -1395,14 +1392,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_lifted(&event) {
|
if is_lifted(event) {
|
||||||
state.unfocus();
|
state.unfocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(on_activate) = self.on_activate.as_ref() {
|
if let Some(on_activate) = self.on_activate.as_ref() {
|
||||||
if is_pressed(event) {
|
if is_pressed(event) {
|
||||||
state.pressed_item = Some(Item::Tab(key));
|
state.pressed_item = Some(Item::Tab(key));
|
||||||
} else if is_lifted(&event) && self.button_is_pressed(state, key) {
|
} else if is_lifted(event) && self.button_is_pressed(state, key) {
|
||||||
shell.publish(on_activate(key));
|
shell.publish(on_activate(key));
|
||||||
state.set_focused();
|
state.set_focused();
|
||||||
state.focused_item = Item::Tab(key);
|
state.focused_item = Item::Tab(key);
|
||||||
|
|
@ -1442,8 +1439,8 @@ where
|
||||||
// Present a context menu on a right click event.
|
// Present a context menu on a right click event.
|
||||||
if self.context_menu.is_some()
|
if self.context_menu.is_some()
|
||||||
&& let Some(on_context) = self.on_context.as_ref()
|
&& let Some(on_context) = self.on_context.as_ref()
|
||||||
&& (right_button_released(&event)
|
&& (right_button_released(event)
|
||||||
|| (touch_lifted(&event) && fingers_pressed == 2))
|
|| (touch_lifted(event) && fingers_pressed == 2))
|
||||||
{
|
{
|
||||||
state.show_context = Some(key);
|
state.show_context = Some(key);
|
||||||
state.context_cursor = cursor_position.position().unwrap_or_default();
|
state.context_cursor = cursor_position.position().unwrap_or_default();
|
||||||
|
|
@ -1539,12 +1536,12 @@ where
|
||||||
}
|
}
|
||||||
if state.is_focused() {
|
if state.is_focused() {
|
||||||
// Unfocus on clicks outside of the boundaries of the segmented button.
|
// Unfocus on clicks outside of the boundaries of the segmented button.
|
||||||
if is_pressed(&event) {
|
if is_pressed(event) {
|
||||||
state.unfocus();
|
state.unfocus();
|
||||||
state.pressed_item = None;
|
state.pressed_item = None;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if is_lifted(&event) {
|
} else if is_lifted(event) {
|
||||||
state.pressed_item = None;
|
state.pressed_item = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2163,8 +2160,8 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if show_drop_hint_marker {
|
if show_drop_hint_marker
|
||||||
if matches!(
|
&& matches!(
|
||||||
drop_hint_marker,
|
drop_hint_marker,
|
||||||
Some(DropHint {
|
Some(DropHint {
|
||||||
entity,
|
entity,
|
||||||
|
|
@ -2179,7 +2176,6 @@ where
|
||||||
appearance.active.text_color,
|
appearance.active.text_color,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
nth += 1;
|
nth += 1;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -88,15 +88,14 @@ where
|
||||||
|
|
||||||
let mut sort_state = 0;
|
let mut sort_state = 0;
|
||||||
|
|
||||||
if let Some(sort) = val.model.sort {
|
if let Some(sort) = val.model.sort
|
||||||
if sort.0 == category {
|
&& sort.0 == category {
|
||||||
if sort.1 {
|
if sort.1 {
|
||||||
sort_state = 1;
|
sort_state = 1;
|
||||||
} else {
|
} else {
|
||||||
sort_state = 2;
|
sort_state = 2;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Build the category header
|
// Build the category header
|
||||||
widget::row::with_capacity(2)
|
widget::row::with_capacity(2)
|
||||||
|
|
|
||||||
|
|
@ -670,18 +670,15 @@ where
|
||||||
let old_value = Value::new(&old_value);
|
let old_value = Value::new(&old_value);
|
||||||
if state.is_focused()
|
if state.is_focused()
|
||||||
&& let cursor::State::Index(index) = state.cursor.state(&old_value)
|
&& let cursor::State::Index(index) = state.cursor.state(&old_value)
|
||||||
{
|
&& index == old_value.len() {
|
||||||
if index == old_value.len() {
|
|
||||||
state.cursor.move_to(self.value.len());
|
state.cursor.move_to(self.value.len());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused) {
|
if let Some(f) = state.is_focused.as_ref().filter(|f| f.focused)
|
||||||
if f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
|
&& f.updated_at != LAST_FOCUS_UPDATE.with(|f| f.get()) {
|
||||||
state.unfocus();
|
state.unfocus();
|
||||||
state.emit_unfocus = true;
|
state.emit_unfocus = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if self.is_editable_variant {
|
if self.is_editable_variant {
|
||||||
if !state.is_focused() {
|
if !state.is_focused() {
|
||||||
|
|
@ -895,8 +892,8 @@ where
|
||||||
let line_height = self.line_height;
|
let line_height = self.line_height;
|
||||||
|
|
||||||
// Disables editing of the editable variant when clicking outside of, or for tab focus changes.
|
// Disables editing of the editable variant when clicking outside of, or for tab focus changes.
|
||||||
if self.is_editable_variant {
|
if self.is_editable_variant
|
||||||
if let Some(ref on_edit) = self.on_toggle_edit {
|
&& let Some(ref on_edit) = self.on_toggle_edit {
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
if !state.is_read_only && state.is_focused.is_some_and(|f| !f.focused) {
|
if !state.is_read_only && state.is_focused.is_some_and(|f| !f.focused) {
|
||||||
state.is_read_only = true;
|
state.is_read_only = true;
|
||||||
|
|
@ -908,7 +905,6 @@ where
|
||||||
shell.publish((on_edit)(f.focused));
|
shell.publish((on_edit)(f.focused));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Calculates the layout of the trailing icon button element.
|
// Calculates the layout of the trailing icon button element.
|
||||||
if !tree.children.is_empty() {
|
if !tree.children.is_empty() {
|
||||||
|
|
@ -919,9 +915,9 @@ where
|
||||||
trailing_icon_layout = Some(text_layout.children().last().unwrap());
|
trailing_icon_layout = Some(text_layout.children().last().unwrap());
|
||||||
|
|
||||||
// Enable custom buttons defined on the trailing icon position to be handled.
|
// Enable custom buttons defined on the trailing icon position to be handled.
|
||||||
if !self.is_editable_variant {
|
if !self.is_editable_variant
|
||||||
if let Some(trailing_layout) = trailing_icon_layout {
|
&& let Some(trailing_layout) = trailing_icon_layout {
|
||||||
let _res = trailing_icon.as_widget_mut().update(
|
trailing_icon.as_widget_mut().update(
|
||||||
tree,
|
tree,
|
||||||
event,
|
event,
|
||||||
trailing_layout,
|
trailing_layout,
|
||||||
|
|
@ -936,18 +932,16 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
|
|
||||||
if let Some(on_unfocus) = self.on_unfocus.as_ref() {
|
if let Some(on_unfocus) = self.on_unfocus.as_ref()
|
||||||
if state.emit_unfocus {
|
&& state.emit_unfocus {
|
||||||
state.emit_unfocus = false;
|
state.emit_unfocus = false;
|
||||||
shell.publish(on_unfocus.clone());
|
shell.publish(on_unfocus.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let dnd_id = self.dnd_id();
|
let dnd_id = self.dnd_id();
|
||||||
let id = Widget::id(self);
|
let id = Widget::id(self);
|
||||||
|
|
@ -1656,11 +1650,10 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
if matches!(state.dragging_state, None | Some(DraggingState::Selection))
|
if matches!(state.dragging_state, None | Some(DraggingState::Selection))
|
||||||
&& (!state.is_focused() || (is_editable_variant && state.is_read_only))
|
&& (!state.is_focused() || (is_editable_variant && state.is_read_only))
|
||||||
{
|
{
|
||||||
if !state.is_focused() {
|
if !state.is_focused()
|
||||||
if let Some(on_focus) = on_focus {
|
&& let Some(on_focus) = on_focus {
|
||||||
shell.publish(on_focus.clone());
|
shell.publish(on_focus.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if state.is_read_only {
|
if state.is_read_only {
|
||||||
state.is_read_only = false;
|
state.is_read_only = false;
|
||||||
|
|
@ -1685,7 +1678,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
state.last_click = Some(click);
|
state.last_click = Some(click);
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
state.unfocus();
|
state.unfocus();
|
||||||
|
|
||||||
|
|
@ -1721,7 +1713,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
if cursor.is_over(layout.bounds()) {
|
if cursor.is_over(layout.bounds()) {
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::CursorMoved { position })
|
Event::Mouse(mouse::Event::CursorMoved { position })
|
||||||
| Event::Touch(touch::Event::FingerMoved { position, .. }) => {
|
| Event::Touch(touch::Event::FingerMoved { position, .. }) => {
|
||||||
|
|
@ -1804,7 +1795,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Keyboard(keyboard::Event::KeyPressed {
|
Event::Keyboard(keyboard::Event::KeyPressed {
|
||||||
|
|
@ -1829,14 +1819,13 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
if state.keyboard_modifiers.command() {
|
if state.keyboard_modifiers.command() {
|
||||||
match key.to_latin(*physical_key) {
|
match key.to_latin(*physical_key) {
|
||||||
Some('c') => {
|
Some('c') => {
|
||||||
if !is_secure {
|
if !is_secure
|
||||||
if let Some((start, end)) = state.cursor.selection(value) {
|
&& let Some((start, end)) = state.cursor.selection(value) {
|
||||||
clipboard.write(
|
clipboard.write(
|
||||||
iced_core::clipboard::Kind::Standard,
|
iced_core::clipboard::Kind::Standard,
|
||||||
value.select(start, end).to_string(),
|
value.select(start, end).to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// XXX if we want to allow cutting of secure text, we need to
|
// XXX if we want to allow cutting of secure text, we need to
|
||||||
// update the cache and decide which value to cut
|
// update the cache and decide which value to cut
|
||||||
|
|
@ -2091,7 +2080,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
||||||
|
|
@ -2111,7 +2099,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
|
Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
|
||||||
|
|
@ -2127,7 +2114,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
state.preedit = matches!(event, input_method::Event::Opened)
|
state.preedit = matches!(event, input_method::Event::Opened)
|
||||||
.then(input_method::Preedit::new);
|
.then(input_method::Preedit::new);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
input_method::Event::Preedit(content, selection) => {
|
input_method::Event::Preedit(content, selection) => {
|
||||||
if state.is_focused() {
|
if state.is_focused() {
|
||||||
|
|
@ -2137,7 +2123,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
text_size: Some(size.into()),
|
text_size: Some(size.into()),
|
||||||
});
|
});
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_method::Event::Commit(text) => {
|
input_method::Event::Commit(text) => {
|
||||||
|
|
@ -2155,7 +2140,7 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
LAST_FOCUS_UPDATE.with(|x| x.set(focus.updated_at));
|
||||||
|
|
||||||
let mut editor = Editor::new(unsecured_value, &mut state.cursor);
|
let mut editor = Editor::new(unsecured_value, &mut state.cursor);
|
||||||
editor.paste(Value::new(&text));
|
editor.paste(Value::new(text));
|
||||||
|
|
||||||
let contents = editor.contents();
|
let contents = editor.contents();
|
||||||
let unsecured_value = Value::new(&contents);
|
let unsecured_value = Value::new(&contents);
|
||||||
|
|
@ -2175,7 +2160,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
|
|
||||||
update_cache(state, &value);
|
update_cache(state, &value);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2205,7 +2189,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
// TODO: restore value in text input
|
// TODO: restore value in text input
|
||||||
state.dragging_state = None;
|
state.dragging_state = None;
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||||
|
|
@ -2255,7 +2238,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
state.cursor.set_affinity(affinity);
|
state.cursor.set_affinity(affinity);
|
||||||
state.cursor.move_to(position);
|
state.cursor.move_to(position);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||||
|
|
@ -2284,7 +2266,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
state.cursor.set_affinity(affinity);
|
state.cursor.set_affinity(affinity);
|
||||||
state.cursor.move_to(position);
|
state.cursor.move_to(position);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||||
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Drop)) if *rectangle == Some(dnd_id) => {
|
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Drop)) if *rectangle == Some(dnd_id) => {
|
||||||
|
|
@ -2301,8 +2282,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
};
|
};
|
||||||
state.dnd_offer = DndOfferState::Dropped;
|
state.dnd_offer = DndOfferState::Dropped;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||||
Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {}
|
Event::Dnd(DndEvent::Offer(id, OfferEvent::LeaveDestination)) if Some(dnd_id) != *id => {}
|
||||||
|
|
@ -2322,7 +2301,6 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||||
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Data { data, mime_type }))
|
Event::Dnd(DndEvent::Offer(rectangle, OfferEvent::Data { data, mime_type }))
|
||||||
|
|
@ -2359,9 +2337,7 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
};
|
};
|
||||||
update_cache(state, &value);
|
update_cache(state, &value);
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,7 @@ impl Value {
|
||||||
pub fn previous_start_of_word(&self, index: usize) -> usize {
|
pub fn previous_start_of_word(&self, index: usize) -> usize {
|
||||||
let previous_string = &self.graphemes[..index.min(self.graphemes.len())].concat();
|
let previous_string = &self.graphemes[..index.min(self.graphemes.len())].concat();
|
||||||
|
|
||||||
UnicodeSegmentation::split_word_bound_indices(previous_string as &str)
|
UnicodeSegmentation::split_word_bound_indices(previous_string as &str).rfind(|(_, word)| !word.trim_start().is_empty())
|
||||||
.filter(|(_, word)| !word.trim_start().is_empty())
|
|
||||||
.next_back()
|
|
||||||
.map_or(0, |(i, previous_word)| {
|
.map_or(0, |(i, previous_word)| {
|
||||||
index
|
index
|
||||||
- UnicodeSegmentation::graphemes(previous_word, true).count()
|
- UnicodeSegmentation::graphemes(previous_word, true).count()
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,8 @@ impl<'a, Message> Widget<Message, crate::Theme, crate::Renderer> for Toggler<'a,
|
||||||
) -> layout::Node {
|
) -> layout::Node {
|
||||||
let limits = limits.width(self.width);
|
let limits = limits.width(self.width);
|
||||||
|
|
||||||
let res = next_to_each_other(
|
|
||||||
|
next_to_each_other(
|
||||||
&limits,
|
&limits,
|
||||||
self.spacing,
|
self.spacing,
|
||||||
|limits| {
|
|limits| {
|
||||||
|
|
@ -221,8 +222,7 @@ impl<'a, Message> Widget<Message, crate::Theme, crate::Renderer> for Toggler<'a,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|_| layout::Node::new(Size::new(48., 24.)),
|
|_| layout::Node::new(Size::new(48., 24.)),
|
||||||
);
|
)
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,6 @@ pub fn update<'a, Message: Clone + 'static, TopLevelMessage: Clone + 'static>(
|
||||||
shell.publish(on_leave.clone());
|
shell.publish(on_leave.clone());
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -484,8 +483,8 @@ pub fn update<'a, Message: Clone + 'static, TopLevelMessage: Clone + 'static>(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*guard = cursor.is_over(bounds);
|
*guard = cursor.is_over(bounds);
|
||||||
if *guard {
|
if *guard
|
||||||
if let Some(settings) = settings {
|
&& let Some(settings) = settings {
|
||||||
if let Some(delay) = delay {
|
if let Some(delay) = delay {
|
||||||
let s = settings.clone();
|
let s = settings.clone();
|
||||||
let view = view.clone();
|
let view = view.clone();
|
||||||
|
|
@ -569,7 +568,6 @@ pub fn update<'a, Message: Clone + 'static, TopLevelMessage: Clone + 'static>(
|
||||||
shell.publish((on_surface_action)(sm));
|
shell.publish((on_surface_action)(sm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue