chore: apply clippy suggestions
This commit is contained in:
parent
34f55d6720
commit
a27bb5e05d
34 changed files with 116 additions and 146 deletions
|
|
@ -229,7 +229,7 @@ impl Config {
|
||||||
|
|
||||||
// Start a transaction (to set multiple configs at the same time)
|
// Start a transaction (to set multiple configs at the same time)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn transaction(&self) -> ConfigTransaction {
|
pub fn transaction(&self) -> ConfigTransaction<'_> {
|
||||||
ConfigTransaction {
|
ConfigTransaction {
|
||||||
config: self,
|
config: self,
|
||||||
updates: Mutex::new(Vec::new()),
|
updates: Mutex::new(Vec::new()),
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ async fn start_listening<T: 'static + Send + Sync + PartialEq + Clone + CosmicCo
|
||||||
}
|
}
|
||||||
Err((errors, t)) => {
|
Err((errors, t)) => {
|
||||||
let update = crate::Update {
|
let update = crate::Update {
|
||||||
errors: errors,
|
errors,
|
||||||
keys: Vec::new(),
|
keys: Vec::new(),
|
||||||
config: t.clone(),
|
config: t.clone(),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -814,7 +814,7 @@ pub struct ThemeBuilder {
|
||||||
impl Default for ThemeBuilder {
|
impl Default for ThemeBuilder {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
palette: DARK_PALETTE.to_owned().into(),
|
palette: DARK_PALETTE.to_owned(),
|
||||||
spacing: Spacing::default(),
|
spacing: Spacing::default(),
|
||||||
corner_radii: CornerRadii::default(),
|
corner_radii: CornerRadii::default(),
|
||||||
neutral_tint: Default::default(),
|
neutral_tint: Default::default(),
|
||||||
|
|
@ -1077,7 +1077,7 @@ impl ThemeBuilder {
|
||||||
component_pressed_overlay = component_hovered_overlay;
|
component_pressed_overlay = component_hovered_overlay;
|
||||||
component_pressed_overlay.alpha = 0.2;
|
component_pressed_overlay.alpha = 0.2;
|
||||||
|
|
||||||
let container = Container::new(
|
Container::new(
|
||||||
Component::component(
|
Component::component(
|
||||||
component_base,
|
component_base,
|
||||||
accent,
|
accent,
|
||||||
|
|
@ -1101,9 +1101,7 @@ impl ThemeBuilder {
|
||||||
),
|
),
|
||||||
get_small_widget_color(base_index, 5, &neutral_steps, &control_steps_array[6]),
|
get_small_widget_color(base_index, 5, &neutral_steps, &control_steps_array[6]),
|
||||||
is_high_contrast,
|
is_high_contrast,
|
||||||
);
|
)
|
||||||
|
|
||||||
container
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let accent_text = if is_dark {
|
let accent_text = if is_dark {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ pub fn get_text(
|
||||||
|
|
||||||
let index = get_index(base_index, 70, step_array.len(), is_dark)
|
let index = get_index(base_index, 70, step_array.len(), is_dark)
|
||||||
.or_else(|| get_index(base_index, 50, step_array.len(), is_dark))
|
.or_else(|| get_index(base_index, 50, step_array.len(), is_dark))
|
||||||
.unwrap_or_else(|| if is_dark { 99 } else { 0 });
|
.unwrap_or(if is_dark { 99 } else { 0 });
|
||||||
|
|
||||||
*step_array.get(index).unwrap_or(fallback)
|
*step_array.get(index).unwrap_or(fallback)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ where
|
||||||
|
|
||||||
(
|
(
|
||||||
Self::new(model),
|
Self::new(model),
|
||||||
Task::batch(vec![
|
Task::batch([
|
||||||
command,
|
command,
|
||||||
iced_runtime::window::run_with_handle(id, init_windowing_system),
|
iced_runtime::window::run_with_handle(id, init_windowing_system),
|
||||||
]),
|
]),
|
||||||
|
|
@ -665,23 +665,21 @@ impl<T: Application> Cosmic<T> {
|
||||||
bottom_left: radii[3].round() as u32,
|
bottom_left: radii[3].round() as u32,
|
||||||
};
|
};
|
||||||
let rounded = !self.app.core().window.sharp_corners;
|
let rounded = !self.app.core().window.sharp_corners;
|
||||||
return Task::batch(vec![
|
return Task::batch([corner_radius(
|
||||||
corner_radius(
|
id,
|
||||||
id,
|
if rounded {
|
||||||
if rounded {
|
Some(cur_rad)
|
||||||
Some(cur_rad)
|
} else {
|
||||||
} else {
|
let rad_0 = t.radius_0();
|
||||||
let rad_0 = t.radius_0();
|
Some(CornerRadius {
|
||||||
Some(CornerRadius {
|
top_left: rad_0[0].round() as u32,
|
||||||
top_left: rad_0[0].round() as u32,
|
top_right: rad_0[1].round() as u32,
|
||||||
top_right: rad_0[1].round() as u32,
|
bottom_right: rad_0[2].round() as u32,
|
||||||
bottom_right: rad_0[2].round() as u32,
|
bottom_left: rad_0[3].round() as u32,
|
||||||
bottom_left: rad_0[3].round() as u32,
|
})
|
||||||
})
|
},
|
||||||
},
|
)
|
||||||
)
|
.discard()]);
|
||||||
.discard(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1061,7 +1059,7 @@ impl<T: Application> Cosmic<T> {
|
||||||
if core.exit_on_main_window_closed
|
if core.exit_on_main_window_closed
|
||||||
&& core.main_window_id().is_some_and(|m_id| id == m_id)
|
&& core.main_window_id().is_some_and(|m_id| id == m_id)
|
||||||
{
|
{
|
||||||
ret = Task::batch(vec![iced::exit::<crate::Action<T::Message>>()]);
|
ret = Task::batch([iced::exit::<crate::Action<T::Message>>()]);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -1231,7 +1229,7 @@ impl<T: Application> Cosmic<T> {
|
||||||
// TODO do we need per window sharp corners?
|
// TODO do we need per window sharp corners?
|
||||||
let rounded = !self.app.core().window.sharp_corners;
|
let rounded = !self.app.core().window.sharp_corners;
|
||||||
|
|
||||||
return Task::batch(vec![
|
return Task::batch([
|
||||||
corner_radius(
|
corner_radius(
|
||||||
id,
|
id,
|
||||||
if rounded {
|
if rounded {
|
||||||
|
|
@ -1326,9 +1324,9 @@ impl<App: Application> Cosmic<App> {
|
||||||
>,
|
>,
|
||||||
) -> Task<crate::Action<App::Message>> {
|
) -> Task<crate::Action<App::Message>> {
|
||||||
use iced_winit::SurfaceIdWrapper;
|
use iced_winit::SurfaceIdWrapper;
|
||||||
*self.opened_surfaces.entry(id.clone()).or_insert_with(|| 0) += 1;
|
*self.opened_surfaces.entry(id).or_insert(0) += 1;
|
||||||
self.surface_views.insert(
|
self.surface_views.insert(
|
||||||
id.clone(),
|
id,
|
||||||
(
|
(
|
||||||
None, // TODO parent for window, platform specific option maybe?
|
None, // TODO parent for window, platform specific option maybe?
|
||||||
SurfaceIdWrapper::Window(id),
|
SurfaceIdWrapper::Window(id),
|
||||||
|
|
|
||||||
|
|
@ -420,10 +420,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs the view for the main window.
|
/// Constructs the view for the main window.
|
||||||
fn view(&self) -> Element<Self::Message>;
|
fn view(&self) -> Element<'_, Self::Message>;
|
||||||
|
|
||||||
/// Constructs views for other windows.
|
/// Constructs views for other windows.
|
||||||
fn view_window(&self, id: window::Id) -> Element<Self::Message> {
|
fn view_window(&self, id: window::Id) -> Element<'_, Self::Message> {
|
||||||
panic!("no view for window {id:?}");
|
panic!("no view for window {id:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ pub fn load_applications_for_app_ids<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn load_desktop_file<'a>(locales: &'a [String], path: PathBuf) -> Option<DesktopEntryData> {
|
pub fn load_desktop_file(locales: &[String], path: PathBuf) -> Option<DesktopEntryData> {
|
||||||
fde::DesktopEntry::from_path(path, Some(locales))
|
fde::DesktopEntry::from_path(path, Some(locales))
|
||||||
.ok()
|
.ok()
|
||||||
.map(|de| DesktopEntryData::from_desktop_entry(locales, de))
|
.map(|de| DesktopEntryData::from_desktop_entry(locales, de))
|
||||||
|
|
@ -144,10 +144,7 @@ pub fn load_desktop_file<'a>(locales: &'a [String], path: PathBuf) -> Option<Des
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
impl DesktopEntryData {
|
impl DesktopEntryData {
|
||||||
pub fn from_desktop_entry<'a>(
|
pub fn from_desktop_entry(locales: &[String], de: fde::DesktopEntry) -> DesktopEntryData {
|
||||||
locales: &'a [String],
|
|
||||||
de: fde::DesktopEntry,
|
|
||||||
) -> DesktopEntryData {
|
|
||||||
let name = de
|
let name = de
|
||||||
.name(locales)
|
.name(locales)
|
||||||
.unwrap_or(Cow::Borrowed(&de.appid))
|
.unwrap_or(Cow::Borrowed(&de.appid))
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,12 @@ impl Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Dialog {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "xdg-portal")]
|
#[cfg(feature = "xdg-portal")]
|
||||||
mod portal {
|
mod portal {
|
||||||
use super::Dialog;
|
use super::Dialog;
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@ pub type CosmicColor = ::palette::rgb::Srgba;
|
||||||
pub type CosmicComponent = cosmic_theme::Component;
|
pub type CosmicComponent = cosmic_theme::Component;
|
||||||
pub type CosmicTheme = cosmic_theme::Theme;
|
pub type CosmicTheme = cosmic_theme::Theme;
|
||||||
|
|
||||||
pub static COSMIC_DARK: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::dark_default());
|
pub static COSMIC_DARK: LazyLock<CosmicTheme> = LazyLock::new(CosmicTheme::dark_default);
|
||||||
|
|
||||||
pub static COSMIC_HC_DARK: LazyLock<CosmicTheme> =
|
pub static COSMIC_HC_DARK: LazyLock<CosmicTheme> =
|
||||||
LazyLock::new(|| CosmicTheme::high_contrast_dark_default());
|
LazyLock::new(CosmicTheme::high_contrast_dark_default);
|
||||||
|
|
||||||
pub static COSMIC_LIGHT: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::light_default());
|
pub static COSMIC_LIGHT: LazyLock<CosmicTheme> = LazyLock::new(CosmicTheme::light_default);
|
||||||
|
|
||||||
pub static COSMIC_HC_LIGHT: LazyLock<CosmicTheme> =
|
pub static COSMIC_HC_LIGHT: LazyLock<CosmicTheme> =
|
||||||
LazyLock::new(|| CosmicTheme::high_contrast_light_default());
|
LazyLock::new(CosmicTheme::high_contrast_light_default);
|
||||||
|
|
||||||
pub static TRANSPARENT_COMPONENT: LazyLock<Component> = LazyLock::new(|| Component {
|
pub static TRANSPARENT_COMPONENT: LazyLock<Component> = LazyLock::new(|| Component {
|
||||||
base: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
base: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||||
|
|
|
||||||
|
|
@ -898,12 +898,10 @@ impl toggler::Catalog for Theme {
|
||||||
let mut active = toggler::Style {
|
let mut active = toggler::Style {
|
||||||
background: if matches!(status, toggler::Status::Active { is_toggled: true }) {
|
background: if matches!(status, toggler::Status::Active { is_toggled: true }) {
|
||||||
cosmic.accent.base.into()
|
cosmic.accent.base.into()
|
||||||
|
} else if cosmic.is_dark {
|
||||||
|
cosmic.palette.neutral_6.into()
|
||||||
} else {
|
} else {
|
||||||
if cosmic.is_dark {
|
cosmic.palette.neutral_5.into()
|
||||||
cosmic.palette.neutral_6.into()
|
|
||||||
} else {
|
|
||||||
cosmic.palette.neutral_5.into()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
foreground: cosmic.palette.neutral_2.into(),
|
foreground: cosmic.palette.neutral_2.into(),
|
||||||
border_radius: cosmic.radius_xl().into(),
|
border_radius: cosmic.radius_xl().into(),
|
||||||
|
|
@ -1166,11 +1164,7 @@ impl scrollable::Catalog for Theme {
|
||||||
},
|
},
|
||||||
gap: None,
|
gap: None,
|
||||||
};
|
};
|
||||||
let small_widget_container = self
|
let small_widget_container = self.current_container().small_widget.with_alpha(0.7);
|
||||||
.current_container()
|
|
||||||
.small_widget
|
|
||||||
.clone()
|
|
||||||
.with_alpha(0.7);
|
|
||||||
|
|
||||||
if matches!(class, Scrollable::Permanent) {
|
if matches!(class, Scrollable::Permanent) {
|
||||||
a.horizontal_rail.background =
|
a.horizontal_rail.background =
|
||||||
|
|
@ -1233,11 +1227,8 @@ impl scrollable::Catalog for Theme {
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches!(class, Scrollable::Permanent) {
|
if matches!(class, Scrollable::Permanent) {
|
||||||
let small_widget_container = self
|
let small_widget_container =
|
||||||
.current_container()
|
self.current_container().small_widget.with_alpha(0.7);
|
||||||
.small_widget
|
|
||||||
.clone()
|
|
||||||
.with_alpha(0.7);
|
|
||||||
|
|
||||||
a.horizontal_rail.background =
|
a.horizontal_rail.background =
|
||||||
Some(Background::Color(small_widget_container.into()));
|
Some(Background::Color(small_widget_container.into()));
|
||||||
|
|
|
||||||
|
|
@ -152,13 +152,11 @@ pub fn about<'a, Message: Clone + 'static>(
|
||||||
let artists_section = section(&about.artists, fl!("artists"));
|
let artists_section = section(&about.artists, fl!("artists"));
|
||||||
let translators_section = section(&about.translators, fl!("translators"));
|
let translators_section = section(&about.translators, fl!("translators"));
|
||||||
let documenters_section = section(&about.documenters, fl!("documenters"));
|
let documenters_section = section(&about.documenters, fl!("documenters"));
|
||||||
let license_section = about.license.as_ref().and_then(|license| {
|
let license_section = about.license.as_ref().map(|license| {
|
||||||
let url = about.license_url.as_deref().unwrap_or_default();
|
let url = about.license_url.as_deref().unwrap_or_default();
|
||||||
Some(
|
widget::settings::section()
|
||||||
widget::settings::section()
|
.title(fl!("license"))
|
||||||
.title(fl!("license"))
|
.add(section_button(license, url))
|
||||||
.add(section_button(license, url)),
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
let copyright = about.copyright.as_ref().map(widget::text::body);
|
let copyright = about.copyright.as_ref().map(widget::text::body);
|
||||||
let comments = about.comments.as_ref().map(widget::text::body);
|
let comments = about.comments.as_ref().map(widget::text::body);
|
||||||
|
|
|
||||||
|
|
@ -793,7 +793,7 @@ pub fn update<'a, Message: Clone>(
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
||||||
if let Some(on_press) = on_press.clone() {
|
if let Some(on_press) = on_press {
|
||||||
let state = state();
|
let state = state();
|
||||||
|
|
||||||
if state.is_pressed {
|
if state.is_pressed {
|
||||||
|
|
@ -816,9 +816,9 @@ pub fn update<'a, Message: Clone>(
|
||||||
#[cfg(feature = "a11y")]
|
#[cfg(feature = "a11y")]
|
||||||
Event::A11y(event_id, iced_accessibility::accesskit::ActionRequest { action, .. }) => {
|
Event::A11y(event_id, iced_accessibility::accesskit::ActionRequest { action, .. }) => {
|
||||||
let state = state();
|
let state = state();
|
||||||
if let Some(Some(on_press)) = (event_id == event_id
|
if let Some(on_press) = matches!(action, iced_accessibility::accesskit::Action::Default)
|
||||||
&& matches!(action, iced_accessibility::accesskit::Action::Default))
|
.then_some(on_press)
|
||||||
.then(|| on_press.clone())
|
.flatten()
|
||||||
{
|
{
|
||||||
state.is_pressed = false;
|
state.is_pressed = false;
|
||||||
let msg = (on_press)(layout.virtual_offset(), layout.bounds());
|
let msg = (on_press)(layout.virtual_offset(), layout.bounds());
|
||||||
|
|
@ -828,7 +828,7 @@ pub fn update<'a, Message: Clone>(
|
||||||
return event::Status::Captured;
|
return event::Status::Captured;
|
||||||
}
|
}
|
||||||
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
|
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
|
||||||
if let Some(on_press) = on_press.clone() {
|
if let Some(on_press) = on_press {
|
||||||
let state = state();
|
let state = state();
|
||||||
if state.is_focused && key == keyboard::Key::Named(keyboard::key::Named::Enter) {
|
if state.is_focused && key == keyboard::Key::Named(keyboard::key::Named::Enter) {
|
||||||
state.is_pressed = true;
|
state.is_pressed = true;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ pub fn calendar<M>(
|
||||||
on_prev: impl Fn() -> M + 'static,
|
on_prev: impl Fn() -> M + 'static,
|
||||||
on_next: impl Fn() -> M + 'static,
|
on_next: impl Fn() -> M + 'static,
|
||||||
first_day_of_week: Weekday,
|
first_day_of_week: Weekday,
|
||||||
) -> Calendar<M> {
|
) -> Calendar<'_, M> {
|
||||||
Calendar {
|
Calendar {
|
||||||
model,
|
model,
|
||||||
on_select: Box::new(on_select),
|
on_select: Box::new(on_select),
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ impl ColorPickerModel {
|
||||||
pub fn builder<Message>(
|
pub fn builder<Message>(
|
||||||
&self,
|
&self,
|
||||||
on_update: fn(ColorPickerUpdate) -> Message,
|
on_update: fn(ColorPickerUpdate) -> Message,
|
||||||
) -> ColorPickerBuilder<Message> {
|
) -> ColorPickerBuilder<'_, Message> {
|
||||||
ColorPickerBuilder {
|
ColorPickerBuilder {
|
||||||
model: &self.segmented_model,
|
model: &self.segmented_model,
|
||||||
active_color: self.active_color,
|
active_color: self.active_color,
|
||||||
|
|
|
||||||
|
|
@ -673,8 +673,8 @@ pub(super) enum OptionElement<'a, S, Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, Message> Model<S, Message> {
|
impl<S, Message> Model<S, Message> {
|
||||||
pub(super) fn elements(&self) -> impl Iterator<Item = OptionElement<S, Message>> + '_ {
|
pub(super) fn elements(&self) -> impl Iterator<Item = OptionElement<'_, S, Message>> + '_ {
|
||||||
let iterator = self.lists.iter().flat_map(|list| {
|
self.lists.iter().flat_map(|list| {
|
||||||
let description = list
|
let description = list
|
||||||
.description
|
.description
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -686,9 +686,7 @@ impl<S, Message> Model<S, Message> {
|
||||||
description
|
description
|
||||||
.chain(options)
|
.chain(options)
|
||||||
.chain(std::iter::once(OptionElement::Separator))
|
.chain(std::iter::once(OptionElement::Separator))
|
||||||
});
|
})
|
||||||
|
|
||||||
iterator
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn element_heights(
|
fn element_heights(
|
||||||
|
|
@ -709,7 +707,7 @@ impl<S, Message> Model<S, Message> {
|
||||||
text_line_height: f32,
|
text_line_height: f32,
|
||||||
offset: f32,
|
offset: f32,
|
||||||
height: f32,
|
height: f32,
|
||||||
) -> impl Iterator<Item = (OptionElement<S, Message>, f32)> + '_ {
|
) -> impl Iterator<Item = (OptionElement<'_, S, Message>, f32)> + '_ {
|
||||||
let heights = self.element_heights(padding_vertical, text_line_height);
|
let heights = self.element_heights(padding_vertical, text_line_height);
|
||||||
|
|
||||||
let mut current = 0.0;
|
let mut current = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -66,9 +66,7 @@ impl<S, Item: PartialEq> Model<S, Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn next(&self) -> Option<&(S, Item)> {
|
pub(super) fn next(&self) -> Option<&(S, Item)> {
|
||||||
let Some(item) = self.selected.as_ref() else {
|
let item = self.selected.as_ref()?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut next = false;
|
let mut next = false;
|
||||||
for list in &self.lists {
|
for list in &self.lists {
|
||||||
|
|
|
||||||
|
|
@ -293,11 +293,9 @@ impl<Message: Clone + 'static> Widget<Message, crate::Theme, crate::Renderer>
|
||||||
) -> iced_accessibility::A11yTree {
|
) -> iced_accessibility::A11yTree {
|
||||||
let c_layout = layout.children().next().unwrap();
|
let c_layout = layout.children().next().unwrap();
|
||||||
let c_state = &state.children[0];
|
let c_state = &state.children[0];
|
||||||
let ret = self
|
self.header_bar_inner
|
||||||
.header_bar_inner
|
|
||||||
.as_widget()
|
.as_widget()
|
||||||
.a11y_nodes(c_layout, c_state, p);
|
.a11y_nodes(c_layout, c_state, p)
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ impl Default for MenuBarStateInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn menu_roots_children<Message>(menu_roots: &Vec<MenuTree<Message>>) -> Vec<Tree>
|
pub(crate) fn menu_roots_children<Message>(menu_roots: &[MenuTree<Message>]) -> Vec<Tree>
|
||||||
where
|
where
|
||||||
Message: Clone + 'static,
|
Message: Clone + 'static,
|
||||||
{
|
{
|
||||||
|
|
@ -126,7 +126,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(invalid_reference_casting)]
|
#[allow(invalid_reference_casting)]
|
||||||
pub(crate) fn menu_roots_diff<Message>(menu_roots: &mut Vec<MenuTree<Message>>, tree: &mut Tree)
|
pub(crate) fn menu_roots_diff<Message>(menu_roots: &mut [MenuTree<Message>], tree: &mut Tree)
|
||||||
where
|
where
|
||||||
Message: Clone + 'static,
|
Message: Clone + 'static,
|
||||||
{
|
{
|
||||||
|
|
@ -381,7 +381,7 @@ where
|
||||||
let surface_action = self.on_surface_action.as_ref().unwrap();
|
let surface_action = self.on_surface_action.as_ref().unwrap();
|
||||||
let old_active_root = my_state
|
let old_active_root = my_state
|
||||||
.inner
|
.inner
|
||||||
.with_data(|state| state.active_root.get(0).copied());
|
.with_data(|state| state.active_root.first().copied());
|
||||||
|
|
||||||
// if position is not on menu bar button skip.
|
// if position is not on menu bar button skip.
|
||||||
let hovered_root = layout
|
let hovered_root = layout
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,7 @@ impl MenuState {
|
||||||
pub(crate) struct Menu<'b, Message: std::clone::Clone> {
|
pub(crate) struct Menu<'b, Message: std::clone::Clone> {
|
||||||
pub(crate) tree: MenuBarState,
|
pub(crate) tree: MenuBarState,
|
||||||
// Flattened menu tree
|
// Flattened menu tree
|
||||||
pub(crate) menu_roots: Cow<'b, Vec<MenuTree<Message>>>,
|
pub(crate) menu_roots: Cow<'b, [MenuTree<Message>]>,
|
||||||
pub(crate) bounds_expand: u16,
|
pub(crate) bounds_expand: u16,
|
||||||
/// Allows menu overlay items to overlap the parent
|
/// Allows menu overlay items to overlap the parent
|
||||||
pub(crate) menu_overlays_parent: bool,
|
pub(crate) menu_overlays_parent: bool,
|
||||||
|
|
@ -740,7 +740,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
|
||||||
let styling = theme.appearance(&self.style);
|
let styling = theme.appearance(&self.style);
|
||||||
let roots = active_root.iter().skip(1).fold(
|
let roots = active_root.iter().skip(1).fold(
|
||||||
&self.menu_roots[active_root[0]].children,
|
&self.menu_roots[active_root[0]].children,
|
||||||
|mt, next_active_root| (&mt[*next_active_root].children),
|
|mt, next_active_root| &mt[*next_active_root].children,
|
||||||
);
|
);
|
||||||
let indices = state.get_trimmed_indices(self.depth).collect::<Vec<_>>();
|
let indices = state.get_trimmed_indices(self.depth).collect::<Vec<_>>();
|
||||||
state.menu_states[if self.is_overlay { 0 } else { self.depth }..=if self.is_overlay {
|
state.menu_states[if self.is_overlay { 0 } else { self.depth }..=if self.is_overlay {
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ impl<Message: Clone + 'static> MenuTree<Message> {
|
||||||
});
|
});
|
||||||
|
|
||||||
mt.children.iter().for_each(|c| {
|
mt.children.iter().for_each(|c| {
|
||||||
rec(&c, flat);
|
rec(c, flat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ pub type Model = segmented_button::SingleSelectModel;
|
||||||
pub fn nav_bar<Message: Clone + 'static>(
|
pub fn nav_bar<Message: Clone + 'static>(
|
||||||
model: &segmented_button::SingleSelectModel,
|
model: &segmented_button::SingleSelectModel,
|
||||||
on_activate: fn(segmented_button::Entity) -> Message,
|
on_activate: fn(segmented_button::Entity) -> Message,
|
||||||
) -> NavBar<Message> {
|
) -> NavBar<'_, Message> {
|
||||||
NavBar {
|
NavBar {
|
||||||
segmented_button: segmented_button::vertical(model).on_activate(on_activate),
|
segmented_button: segmented_button::vertical(model).on_activate(on_activate),
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ pub fn nav_bar_dnd<Message, D: AllowedMimeTypes>(
|
||||||
on_dnd_leave: impl Fn(segmented_button::Entity) -> Message + 'static,
|
on_dnd_leave: impl Fn(segmented_button::Entity) -> Message + 'static,
|
||||||
on_dnd_drop: impl Fn(segmented_button::Entity, Option<D>, DndAction) -> Message + 'static,
|
on_dnd_drop: impl Fn(segmented_button::Entity, Option<D>, DndAction) -> Message + 'static,
|
||||||
id: DragId,
|
id: DragId,
|
||||||
) -> NavBar<Message>
|
) -> NavBar<'_, Message>
|
||||||
where
|
where
|
||||||
Message: Clone + 'static,
|
Message: Clone + 'static,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ impl ResponsiveMenuBar {
|
||||||
key_binds,
|
key_binds,
|
||||||
trees
|
trees
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|mt| menu::Item::Folder(mt.0, mt.1.into()))
|
.map(|mt| menu::Item::Folder(mt.0, mt.1))
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct Horizontal;
|
||||||
/// For details on the model, see the [`segmented_button`](super) module for more details.
|
/// For details on the model, see the [`segmented_button`](super) module for more details.
|
||||||
pub fn horizontal<SelectionMode: Default, Message>(
|
pub fn horizontal<SelectionMode: Default, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> SegmentedButton<Horizontal, SelectionMode, Message>
|
) -> SegmentedButton<'_, Horizontal, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn insert(&mut self) -> EntityMut<SelectionMode> {
|
pub fn insert(&mut self) -> EntityMut<'_, SelectionMode> {
|
||||||
let id = self.items.insert(Settings::default());
|
let id = self.items.insert(Settings::default());
|
||||||
self.order.push_back(id);
|
self.order.push_back(id);
|
||||||
EntityMut { model: self, id }
|
EntityMut { model: self, id }
|
||||||
|
|
@ -447,7 +447,11 @@ where
|
||||||
/// println!("{:?} had text {}", id, old_text)
|
/// println!("{:?} had text {}", id, old_text)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn text_set(&mut self, id: Entity, text: impl Into<Cow<'static, str>>) -> Option<Cow<str>> {
|
pub fn text_set(
|
||||||
|
&mut self,
|
||||||
|
id: Entity,
|
||||||
|
text: impl Into<Cow<'static, str>>,
|
||||||
|
) -> Option<Cow<'_, str>> {
|
||||||
if !self.contains_item(id) {
|
if !self.contains_item(id) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub type VerticalSegmentedButton<'a, SelectionMode, Message> =
|
||||||
/// For details on the model, see the [`segmented_button`](super) module for more details.
|
/// For details on the model, see the [`segmented_button`](super) module for more details.
|
||||||
pub fn vertical<SelectionMode, Message>(
|
pub fn vertical<SelectionMode, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> SegmentedButton<Vertical, SelectionMode, Message>
|
) -> SegmentedButton<'_, Vertical, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
SelectionMode: Default,
|
SelectionMode: Default,
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ where
|
||||||
|
|
||||||
/// Check if an item is enabled.
|
/// Check if an item is enabled.
|
||||||
fn is_enabled(&self, key: Entity) -> bool {
|
fn is_enabled(&self, key: Entity) -> bool {
|
||||||
self.model.items.get(key).map_or(false, |item| item.enabled)
|
self.model.items.get(key).is_some_and(|item| item.enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle the dnd drop event.
|
/// Handle the dnd drop event.
|
||||||
|
|
@ -987,7 +987,7 @@ where
|
||||||
let current = Instant::now();
|
let current = Instant::now();
|
||||||
|
|
||||||
// Permit successive scroll wheel events only after a given delay.
|
// Permit successive scroll wheel events only after a given delay.
|
||||||
if state.wheel_timestamp.map_or(true, |previous| {
|
if state.wheel_timestamp.is_none_or(|previous| {
|
||||||
current.duration_since(previous) > Duration::from_millis(250)
|
current.duration_since(previous) > Duration::from_millis(250)
|
||||||
}) {
|
}) {
|
||||||
state.wheel_timestamp = Some(current);
|
state.wheel_timestamp = Some(current);
|
||||||
|
|
@ -1607,23 +1607,16 @@ where
|
||||||
let state = tree.state.downcast_ref::<LocalState>();
|
let state = tree.state.downcast_ref::<LocalState>();
|
||||||
let menu_state = state.menu_state.clone();
|
let menu_state = state.menu_state.clone();
|
||||||
|
|
||||||
let Some(entity) = state.show_context else {
|
let entity = state.show_context?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let bounds = self
|
let mut bounds =
|
||||||
.variant_bounds(state, layout.bounds())
|
self.variant_bounds(state, layout.bounds())
|
||||||
.find_map(|item| match item {
|
.find_map(|item| match item {
|
||||||
ItemBounds::Button(e, bounds) if e == entity => Some(bounds),
|
ItemBounds::Button(e, bounds) if e == entity => Some(bounds),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
})?;
|
||||||
let Some(mut bounds) = bounds else {
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(context_menu) = self.context_menu.as_mut() else {
|
let context_menu = self.context_menu.as_mut()?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
if !menu_state.inner.with_data(|data| data.open) {
|
if !menu_state.inner.with_data(|data| data.open) {
|
||||||
// If the menu is not open, we don't need to show it.
|
// If the menu is not open, we don't need to show it.
|
||||||
|
|
@ -1777,9 +1770,8 @@ impl LocalState {
|
||||||
|
|
||||||
impl operation::Focusable for LocalState {
|
impl operation::Focusable for LocalState {
|
||||||
fn is_focused(&self) -> bool {
|
fn is_focused(&self) -> bool {
|
||||||
self.focused.map_or(false, |f| {
|
self.focused
|
||||||
f.updated_at == LAST_FOCUS_UPDATE.with(|f| f.get())
|
.is_some_and(|f| f.updated_at == LAST_FOCUS_UPDATE.with(|f| f.get()))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus(&mut self) {
|
fn focus(&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use super::segmented_button::{
|
||||||
/// For details on the model, see the [`segmented_button`] module for more details.
|
/// For details on the model, see the [`segmented_button`] module for more details.
|
||||||
pub fn horizontal<SelectionMode: Default, Message>(
|
pub fn horizontal<SelectionMode: Default, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> HorizontalSegmentedButton<SelectionMode, Message>
|
) -> HorizontalSegmentedButton<'_, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +39,7 @@ where
|
||||||
/// For details on the model, see the [`segmented_button`] module for more details.
|
/// For details on the model, see the [`segmented_button`] module for more details.
|
||||||
pub fn vertical<SelectionMode, Message>(
|
pub fn vertical<SelectionMode, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> VerticalSegmentedButton<SelectionMode, Message>
|
) -> VerticalSegmentedButton<'_, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
SelectionMode: Default,
|
SelectionMode: Default,
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ impl<'a, Message: 'static> Item<'a, Message> {
|
||||||
contents.push(text(self.title).width(Length::Fill).into());
|
contents.push(text(self.title).width(Length::Fill).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
contents.push(widget.into());
|
contents.push(widget);
|
||||||
contents
|
contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use super::segmented_button::{
|
||||||
/// For details on the model, see the [`segmented_button`] module for more details.
|
/// For details on the model, see the [`segmented_button`] module for more details.
|
||||||
pub fn horizontal<SelectionMode: Default, Message>(
|
pub fn horizontal<SelectionMode: Default, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> HorizontalSegmentedButton<SelectionMode, Message>
|
) -> HorizontalSegmentedButton<'_, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +37,7 @@ where
|
||||||
/// For details on the model, see the [`segmented_button`] module for more details.
|
/// For details on the model, see the [`segmented_button`] module for more details.
|
||||||
pub fn vertical<SelectionMode, Message>(
|
pub fn vertical<SelectionMode, Message>(
|
||||||
model: &Model<SelectionMode>,
|
model: &Model<SelectionMode>,
|
||||||
) -> VerticalSegmentedButton<SelectionMode, Message>
|
) -> VerticalSegmentedButton<'_, SelectionMode, Message>
|
||||||
where
|
where
|
||||||
Model<SelectionMode>: Selectable,
|
Model<SelectionMode>: Selectable,
|
||||||
SelectionMode: Default,
|
SelectionMode: Default,
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ where
|
||||||
/// let id = model.insert().text("Item A").icon("custom-icon").id();
|
/// let id = model.insert().text("Item A").icon("custom-icon").id();
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn insert(&mut self, item: Item) -> EntityMut<SelectionMode, Item, Category> {
|
pub fn insert(&mut self, item: Item) -> EntityMut<'_, SelectionMode, Item, Category> {
|
||||||
let id = self.items.insert(item);
|
let id = self.items.insert(item);
|
||||||
self.order.push_back(id);
|
self.order.push_back(id);
|
||||||
EntityMut { model: self, id }
|
EntityMut { model: self, id }
|
||||||
|
|
@ -244,7 +244,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn is_enabled(&self, id: Entity) -> bool {
|
pub fn is_enabled(&self, id: Entity) -> bool {
|
||||||
self.active.get(id).map_or(false, |e| *e)
|
self.active.get(id).is_some_and(|e| *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates across items in the model in the order that they are displayed.
|
/// Iterates across items in the model in the order that they are displayed.
|
||||||
|
|
@ -288,9 +288,7 @@ where
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn position_set(&mut self, id: Entity, position: u16) -> Option<usize> {
|
pub fn position_set(&mut self, id: Entity, position: u16) -> Option<usize> {
|
||||||
let Some(index) = self.position(id) else {
|
let index = self.position(id)?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
self.order.remove(index as usize);
|
self.order.remove(index as usize);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ where
|
||||||
.map(|entity| {
|
.map(|entity| {
|
||||||
let item = val.model.item(entity).unwrap();
|
let item = val.model.item(entity).unwrap();
|
||||||
let selected = val.model.is_active(entity);
|
let selected = val.model.is_active(entity);
|
||||||
let context_menu = (val.item_context_builder)(&item);
|
let context_menu = (val.item_context_builder)(item);
|
||||||
|
|
||||||
widget::column()
|
widget::column()
|
||||||
.spacing(val.item_spacing)
|
.spacing(val.item_spacing)
|
||||||
|
|
@ -89,14 +89,13 @@ where
|
||||||
.categories
|
.categories
|
||||||
.iter()
|
.iter()
|
||||||
.skip_while(|cat| **cat != Category::default())
|
.skip_while(|cat| **cat != Category::default())
|
||||||
.map(|category| {
|
.flat_map(|category| {
|
||||||
vec![
|
[
|
||||||
widget::text::caption(item.get_text(*category))
|
widget::text::caption(item.get_text(*category))
|
||||||
.apply(Element::from),
|
.apply(Element::from),
|
||||||
widget::text::caption("-").apply(Element::from),
|
widget::text::caption("-").apply(Element::from),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<Element<'static, Message>>>();
|
.collect::<Vec<Element<'static, Message>>>();
|
||||||
elements.pop();
|
elements.pop();
|
||||||
elements
|
elements
|
||||||
|
|
@ -201,7 +200,7 @@ where
|
||||||
|
|
||||||
divider_padding: Padding::from(0).left(space_xxxs).right(space_xxxs),
|
divider_padding: Padding::from(0).left(space_xxxs).right(space_xxxs),
|
||||||
|
|
||||||
item_padding: Padding::from(space_xxs).into(),
|
item_padding: Padding::from(space_xxs),
|
||||||
item_spacing: 0,
|
item_spacing: 0,
|
||||||
icon_size: 48,
|
icon_size: 48,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,13 @@ where
|
||||||
} else {
|
} else {
|
||||||
val.model
|
val.model
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |entity| {
|
.flat_map(move |entity| {
|
||||||
let item = val.model.item(entity).unwrap();
|
let item = val.model.item(entity).unwrap();
|
||||||
let categories = &val.model.categories;
|
let categories = &val.model.categories;
|
||||||
let selected = val.model.is_active(entity);
|
let selected = val.model.is_active(entity);
|
||||||
let item_context = (val.item_context_builder)(&item);
|
let item_context = (val.item_context_builder)(item);
|
||||||
|
|
||||||
vec![
|
[
|
||||||
divider::horizontal::default()
|
divider::horizontal::default()
|
||||||
.apply(container)
|
.apply(container)
|
||||||
.padding(val.divider_padding)
|
.padding(val.divider_padding)
|
||||||
|
|
@ -233,13 +233,11 @@ where
|
||||||
.apply(Element::from),
|
.apply(Element::from),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
.collect::<Vec<Element<'a, Message>>>()
|
.collect::<Vec<Element<'a, Message>>>()
|
||||||
};
|
};
|
||||||
vec![vec![header_row], items_full]
|
let mut elements = items_full;
|
||||||
.into_iter()
|
elements.insert(0, header_row);
|
||||||
.flatten()
|
elements
|
||||||
.collect::<Vec<Element<'a, Message>>>()
|
|
||||||
.apply(widget::column::with_children)
|
.apply(widget::column::with_children)
|
||||||
.width(val.width)
|
.width(val.width)
|
||||||
.height(val.height)
|
.height(val.height)
|
||||||
|
|
@ -272,7 +270,7 @@ where
|
||||||
width: Length::Fill,
|
width: Length::Fill,
|
||||||
height: Length::Shrink,
|
height: Length::Shrink,
|
||||||
|
|
||||||
item_padding: Padding::from(space_xxs).into(),
|
item_padding: Padding::from(space_xxs),
|
||||||
item_spacing: 0,
|
item_spacing: 0,
|
||||||
icon_spacing: space_xxxs,
|
icon_spacing: space_xxxs,
|
||||||
icon_size: 24,
|
icon_size: 24,
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the layout node of the actual text input
|
/// Get the layout node of the actual text input
|
||||||
|
|
||||||
fn text_layout<'b>(&'a self, layout: Layout<'b>) -> Layout<'b> {
|
fn text_layout<'b>(&'a self, layout: Layout<'b>) -> Layout<'b> {
|
||||||
if self.dnd_icon {
|
if self.dnd_icon {
|
||||||
layout
|
layout
|
||||||
|
|
@ -1389,8 +1388,8 @@ pub fn update<'a, Message: Clone + 'static>(
|
||||||
|
|
||||||
if let Some(cursor_position) = click_position {
|
if let Some(cursor_position) = click_position {
|
||||||
// Check if the edit button was clicked.
|
// Check if the edit button was clicked.
|
||||||
if state.dragging_state == None
|
if state.dragging_state.is_none()
|
||||||
&& edit_button_layout.map_or(false, |l| cursor.is_over(l.bounds()))
|
&& edit_button_layout.is_some_and(|l| cursor.is_over(l.bounds()))
|
||||||
{
|
{
|
||||||
if is_editable_variant {
|
if is_editable_variant {
|
||||||
state.is_read_only = !state.is_read_only;
|
state.is_read_only = !state.is_read_only;
|
||||||
|
|
@ -2277,7 +2276,7 @@ pub fn draw<'a, Message>(
|
||||||
let (cursor, offset) = if let Some(focus) =
|
let (cursor, offset) = if let Some(focus) =
|
||||||
state.is_focused.filter(|f| f.focused).or_else(|| {
|
state.is_focused.filter(|f| f.focused).or_else(|| {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
handling_dnd_offer.then(|| Focus {
|
handling_dnd_offer.then_some(Focus {
|
||||||
needs_update: false,
|
needs_update: false,
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
now,
|
now,
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,7 @@ impl Value {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn secure(&self) -> Self {
|
pub fn secure(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
graphemes: std::iter::repeat(String::from("•"))
|
graphemes: std::iter::repeat_n(String::from("•"), self.graphemes.len()).collect(),
|
||||||
.take(self.graphemes.len())
|
|
||||||
.collect(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue