chore: use std::syncLazyLock
Also migrates workspace members to Rust 2024.
This commit is contained in:
parent
b72b15d719
commit
ea349aca82
15 changed files with 64 additions and 71 deletions
|
|
@ -15,33 +15,37 @@ use cosmic_theme::Spacing;
|
|||
use cosmic_theme::ThemeMode;
|
||||
use iced_futures::Subscription;
|
||||
use iced_runtime::{Appearance, DefaultStyle};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
pub use style::*;
|
||||
|
||||
pub type CosmicColor = ::palette::rgb::Srgba;
|
||||
pub type CosmicComponent = cosmic_theme::Component;
|
||||
pub type CosmicTheme = cosmic_theme::Theme;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref COSMIC_DARK: CosmicTheme = CosmicTheme::dark_default();
|
||||
pub static ref COSMIC_HC_DARK: CosmicTheme = CosmicTheme::high_contrast_dark_default();
|
||||
pub static ref COSMIC_LIGHT: CosmicTheme = CosmicTheme::light_default();
|
||||
pub static ref COSMIC_HC_LIGHT: CosmicTheme = CosmicTheme::high_contrast_light_default();
|
||||
pub static ref TRANSPARENT_COMPONENT: Component = Component {
|
||||
base: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
hover: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
pressed: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
selected: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
selected_text: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
focus: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
disabled: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
on: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
on_disabled: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
divider: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
border: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
disabled_border: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
};
|
||||
}
|
||||
pub static COSMIC_DARK: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::dark_default());
|
||||
|
||||
pub static COSMIC_HC_DARK: LazyLock<CosmicTheme> =
|
||||
LazyLock::new(|| CosmicTheme::high_contrast_dark_default());
|
||||
|
||||
pub static COSMIC_LIGHT: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::light_default());
|
||||
|
||||
pub static COSMIC_HC_LIGHT: LazyLock<CosmicTheme> =
|
||||
LazyLock::new(|| CosmicTheme::high_contrast_light_default());
|
||||
|
||||
pub static TRANSPARENT_COMPONENT: LazyLock<Component> = LazyLock::new(|| Component {
|
||||
base: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
hover: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
pressed: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
selected: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
selected_text: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
focus: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
disabled: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
on: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
on_disabled: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
divider: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
border: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
disabled_border: CosmicColor::new(0.0, 0.0, 0.0, 0.0),
|
||||
});
|
||||
|
||||
pub(crate) static THEME: Mutex<Theme> = Mutex::new(Theme {
|
||||
theme_type: ThemeType::Dark,
|
||||
|
|
|
|||
|
|
@ -119,22 +119,14 @@ where
|
|||
macro_rules! icon {
|
||||
($name:expr, $on_press:expr) => {{
|
||||
#[cfg(target_os = "linux")]
|
||||
let icon = {
|
||||
icon::from_name($name)
|
||||
.apply(button::icon)
|
||||
};
|
||||
let icon = { icon::from_name($name).apply(button::icon) };
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let icon = {
|
||||
icon::from_svg_bytes(include_bytes!(concat!(
|
||||
"../../res/icons/",
|
||||
$name,
|
||||
".svg"
|
||||
)))
|
||||
.symbolic(true)
|
||||
.apply(button::icon)
|
||||
icon::from_svg_bytes(include_bytes!(concat!("../../res/icons/", $name, ".svg")))
|
||||
.symbolic(true)
|
||||
.apply(button::icon)
|
||||
};
|
||||
icon.padding([0, 12])
|
||||
.on_press($on_press)
|
||||
icon.padding([0, 12]).on_press($on_press)
|
||||
}};
|
||||
}
|
||||
let date = text(this.model.visible.format("%B %Y").to_string()).size(18);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
use std::borrow::Cow;
|
||||
use std::iter;
|
||||
use std::rc::Rc;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
|
|
@ -26,7 +27,6 @@ use iced_core::{
|
|||
|
||||
use iced_widget::slider::HandleShape;
|
||||
use iced_widget::{Row, canvas, column, horizontal_space, row, scrollable, vertical_space};
|
||||
use lazy_static::lazy_static;
|
||||
use palette::{FromColor, RgbHue};
|
||||
|
||||
use super::divider::horizontal;
|
||||
|
|
@ -38,17 +38,17 @@ use super::{Icon, button, segmented_control, text, text_input, tooltip};
|
|||
pub use ColorPickerModel as Model;
|
||||
|
||||
// TODO is this going to look correct enough?
|
||||
lazy_static! {
|
||||
pub static ref HSV_RAINBOW: Vec<iced::Color> = (0u16..8)
|
||||
.map(
|
||||
|h| iced::Color::from(palette::Srgba::from_color(palette::Hsv::new_srgb_const(
|
||||
pub static HSV_RAINBOW: LazyLock<Vec<Color>> = LazyLock::new(|| {
|
||||
(0u16..8)
|
||||
.map(|h| {
|
||||
Color::from(palette::Srgba::from_color(palette::Hsv::new_srgb_const(
|
||||
RgbHue::new(f32::from(h) * 360.0 / 7.0),
|
||||
1.0,
|
||||
1.0
|
||||
1.0,
|
||||
)))
|
||||
)
|
||||
.collect();
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
|
||||
const MAX_RECENT: usize = 20;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue