gled-ui 2.30.1

gled's egui interface, shared by the desktop app and the browser
Documentation
//! The interface's own settings, which stay on the device showing it: how
//! big the effect thumbnails are and with which palette they are drawn. eframe stores them, in a file on the desktop and in the
//! browser's local storage.

use gled_model::{asset::palette::Palette, asset_id::AssetId};
use serde::{Deserialize, Serialize};

/// The key eframe stores the settings under.
pub const STORAGE_KEY: &str = "gled_client_settings";

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct ClientSettings {
    effects_size: f32,
    preview_palette: Option<AssetId<Palette>>,
}

impl Default for ClientSettings {
    fn default() -> Self {
        Self {
            effects_size: 100.0,
            preview_palette: None,
        }
    }
}

impl ClientSettings {
    pub fn new(effects_size: f32, preview_palette: Option<AssetId<Palette>>) -> Self {
        Self {
            effects_size,
            preview_palette,
        }
    }

    pub(crate) fn effects_size(&self) -> f32 {
        self.effects_size
    }

    pub(crate) fn effects_size_mut(&mut self) -> &mut f32 {
        &mut self.effects_size
    }

    pub(crate) fn preview_palette(&self) -> Option<AssetId<Palette>> {
        self.preview_palette
    }

    pub(crate) fn preview_palette_mut(&mut self) -> &mut Option<AssetId<Palette>> {
        &mut self.preview_palette
    }
}