Add icon size and grid spacing for desktop, fixes #751
This commit is contained in:
parent
06b8132aa3
commit
abf95c0189
4 changed files with 51 additions and 22 deletions
|
|
@ -20,6 +20,12 @@ pub const ICON_SIZE_GRID: u16 = 64;
|
|||
// TODO: 5 is an arbitrary number. Maybe there's a better icon size max
|
||||
pub const ICON_SCALE_MAX: u16 = 5;
|
||||
|
||||
macro_rules! percent {
|
||||
($perc:expr, $pixel:ident) => {
|
||||
(($perc.get() as f32 * $pixel as f32) / 100.).clamp(1., ($pixel * ICON_SCALE_MAX) as _)
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub enum AppTheme {
|
||||
Dark,
|
||||
|
|
@ -151,6 +157,8 @@ impl Default for Config {
|
|||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, CosmicConfigEntry, Deserialize, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct DesktopConfig {
|
||||
pub grid_spacing: NonZeroU16,
|
||||
pub icon_size: NonZeroU16,
|
||||
pub show_content: bool,
|
||||
pub show_mounted_drives: bool,
|
||||
pub show_trash: bool,
|
||||
|
|
@ -159,6 +167,8 @@ pub struct DesktopConfig {
|
|||
impl Default for DesktopConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
grid_spacing: 100.try_into().unwrap(),
|
||||
icon_size: 100.try_into().unwrap(),
|
||||
show_content: true,
|
||||
show_mounted_drives: false,
|
||||
show_trash: false,
|
||||
|
|
@ -166,6 +176,12 @@ impl Default for DesktopConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl DesktopConfig {
|
||||
pub fn grid_spacing_for(&self, space: u16) -> u16 {
|
||||
percent!(self.grid_spacing, space) as _
|
||||
}
|
||||
}
|
||||
|
||||
/// Global and local [`crate::tab::Tab`] config.
|
||||
///
|
||||
/// [`TabConfig`] contains options that are passed to each instance of [`crate::tab::Tab`].
|
||||
|
|
@ -194,12 +210,6 @@ impl Default for TabConfig {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! percent {
|
||||
($perc:expr, $pixel:ident) => {
|
||||
(($perc.get() as f32 * $pixel as f32) / 100.).clamp(1., ($pixel * ICON_SCALE_MAX) as _)
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, CosmicConfigEntry, Deserialize, Serialize)]
|
||||
#[serde(default)]
|
||||
pub struct IconSizes {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue