feat(desktop): add window shadows and corners settings
This commit is contained in:
parent
c77655b097
commit
d7f1cff725
4 changed files with 112 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1485,7 +1485,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-comp-config"
|
name = "cosmic-comp-config"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-comp#15b6b678c1303b6ace3af47d21abb2df1d583824"
|
source = "git+https://github.com/pop-os/cosmic-comp#0116bc0dc28bec0d4b00641faeec637a20609ab4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"input",
|
"input",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ use cosmic::widget::{
|
||||||
};
|
};
|
||||||
use cosmic::{Apply, Task};
|
use cosmic::{Apply, Task};
|
||||||
use cosmic::{Element, widget};
|
use cosmic::{Element, widget};
|
||||||
|
use cosmic_config::ConfigGet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use tracing::error;
|
||||||
|
|
||||||
use crate::app;
|
use crate::app;
|
||||||
use crate::widget::color_picker_context_view;
|
use crate::widget::color_picker_context_view;
|
||||||
|
|
@ -38,7 +40,20 @@ pub struct Content {
|
||||||
icon_themes: IconThemes,
|
icon_themes: IconThemes,
|
||||||
icon_handles: IconHandles,
|
icon_handles: IconHandles,
|
||||||
tk_config: Option<Config>,
|
tk_config: Option<Config>,
|
||||||
|
|
||||||
|
comp_config: cosmic_config::Config,
|
||||||
|
clip_floating: bool,
|
||||||
|
clip_tiled: bool,
|
||||||
|
shadow_tiled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum CornerMessage {
|
||||||
|
ClipFloating(bool),
|
||||||
|
ClipTiled(bool),
|
||||||
|
ShadowTiled(bool),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum FontMessage {
|
pub enum FontMessage {
|
||||||
FontLoaded(Vec<Arc<str>>, Vec<Arc<str>>),
|
FontLoaded(Vec<Arc<str>>, Vec<Arc<str>>),
|
||||||
|
|
@ -63,6 +78,10 @@ crate::cache_dynamic_lazy! {
|
||||||
impl From<&theme_manager::Manager> for Content {
|
impl From<&theme_manager::Manager> for Content {
|
||||||
fn from(theme_manager: &theme_manager::Manager) -> Self {
|
fn from(theme_manager: &theme_manager::Manager) -> Self {
|
||||||
let theme = theme_manager.theme();
|
let theme = theme_manager.theme();
|
||||||
|
let comp_config = cosmic_config::Config::new("com.system76.CosmicComp", 1).unwrap();
|
||||||
|
let appearance_conf = comp_config
|
||||||
|
.get::<cosmic_comp_config::AppearanceConfig>("appearance_settings")
|
||||||
|
.unwrap_or_default();
|
||||||
Self {
|
Self {
|
||||||
context_view: None,
|
context_view: None,
|
||||||
custom_accent: ColorPickerModel::new(
|
custom_accent: ColorPickerModel::new(
|
||||||
|
|
@ -109,6 +128,10 @@ impl From<&theme_manager::Manager> for Content {
|
||||||
icon_themes: Vec::new(),
|
icon_themes: Vec::new(),
|
||||||
icon_handles: Vec::new(),
|
icon_handles: Vec::new(),
|
||||||
tk_config: CosmicTk::config().ok(),
|
tk_config: CosmicTk::config().ok(),
|
||||||
|
comp_config,
|
||||||
|
clip_floating: appearance_conf.clip_floating_windows,
|
||||||
|
clip_tiled: appearance_conf.clip_tiled_windows,
|
||||||
|
shadow_tiled: appearance_conf.shadow_tiled_windows,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +233,7 @@ impl Content {
|
||||||
_ = config.set("apply_theme_global", enabled);
|
_ = config.set("apply_theme_global", enabled);
|
||||||
self.icon_global = enabled;
|
self.icon_global = enabled;
|
||||||
} else {
|
} else {
|
||||||
tracing::error!(
|
error!(
|
||||||
"Failed to apply theme to GNOME config because the CosmicTK config does not exist."
|
"Failed to apply theme to GNOME config because the CosmicTK config does not exist."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +257,35 @@ impl Content {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_shadow_and_corners(
|
||||||
|
&mut self,
|
||||||
|
message: CornerMessage,
|
||||||
|
_context_view: &ContextView,
|
||||||
|
) -> Task<app::Message> {
|
||||||
|
match message {
|
||||||
|
CornerMessage::ClipFloating(enabled) => {
|
||||||
|
self.clip_floating = enabled;
|
||||||
|
}
|
||||||
|
CornerMessage::ClipTiled(enabled) => {
|
||||||
|
self.clip_tiled = enabled;
|
||||||
|
}
|
||||||
|
CornerMessage::ShadowTiled(enabled) => {
|
||||||
|
self.shadow_tiled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let conf = cosmic_comp_config::AppearanceConfig {
|
||||||
|
clip_floating_windows: self.clip_floating,
|
||||||
|
clip_tiled_windows: self.clip_tiled,
|
||||||
|
shadow_tiled_windows: self.shadow_tiled,
|
||||||
|
};
|
||||||
|
if let Err(err) = self.comp_config.set("appearance_settings", conf) {
|
||||||
|
error!(?err, "Failed to set config 'appearance_settings'");
|
||||||
|
}
|
||||||
|
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn on_open(&mut self, context_view: &ContextView) -> Task<app::Message> {
|
pub fn on_open(&mut self, context_view: &ContextView) -> Task<app::Message> {
|
||||||
match *context_view {
|
match *context_view {
|
||||||
ContextView::IconsAndToolkit => {
|
ContextView::IconsAndToolkit => {
|
||||||
|
|
@ -418,6 +470,11 @@ impl Content {
|
||||||
self.icons_and_toolkit(),
|
self.icons_and_toolkit(),
|
||||||
crate::pages::Message::CloseContextDrawer,
|
crate::pages::Message::CloseContextDrawer,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
ContextView::ShadowAndCorners => context_drawer(
|
||||||
|
self.shadow_and_corners(),
|
||||||
|
crate::pages::Message::CloseContextDrawer,
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -469,4 +526,35 @@ impl Content {
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::Appearance)
|
.map(crate::pages::Message::Appearance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn shadow_and_corners(&self) -> Element<'_, crate::pages::Message> {
|
||||||
|
let Spacing { space_m, .. } = cosmic::theme::spacing();
|
||||||
|
|
||||||
|
cosmic::iced::widget::column![
|
||||||
|
settings::section().title(fl!("shadows-floating")).add(
|
||||||
|
settings::item::builder(fl!("shadows-floating", "clip"))
|
||||||
|
.toggler(self.clip_floating, |b| {
|
||||||
|
Message::DrawerCorners(CornerMessage::ClipFloating(b))
|
||||||
|
})
|
||||||
|
),
|
||||||
|
settings::section()
|
||||||
|
.title(fl!("shadows-tiling"))
|
||||||
|
.add(
|
||||||
|
settings::item::builder(fl!("shadows-tiling", "clip"))
|
||||||
|
.toggler(self.clip_tiled, |b| {
|
||||||
|
Message::DrawerCorners(CornerMessage::ClipTiled(b))
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.add(
|
||||||
|
settings::item::builder(fl!("shadows-tiling", "shadow"))
|
||||||
|
.toggler(self.shadow_tiled, |b| {
|
||||||
|
Message::DrawerCorners(CornerMessage::ShadowTiled(b))
|
||||||
|
})
|
||||||
|
)
|
||||||
|
]
|
||||||
|
.spacing(space_m)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.apply(Element::from)
|
||||||
|
.map(crate::pages::Message::Appearance)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ pub enum ContextView {
|
||||||
ApplicationBackground,
|
ApplicationBackground,
|
||||||
ContainerBackground,
|
ContainerBackground,
|
||||||
ControlComponent,
|
ControlComponent,
|
||||||
|
ShadowAndCorners,
|
||||||
CustomAccent,
|
CustomAccent,
|
||||||
IconsAndToolkit,
|
IconsAndToolkit,
|
||||||
InterfaceText,
|
InterfaceText,
|
||||||
|
|
@ -124,6 +125,7 @@ pub enum Message {
|
||||||
|
|
||||||
DrawerOpen(ContextView),
|
DrawerOpen(ContextView),
|
||||||
DrawerColor(ColorPickerUpdate),
|
DrawerColor(ColorPickerUpdate),
|
||||||
|
DrawerCorners(drawer::CornerMessage),
|
||||||
DrawerFont(drawer::FontMessage),
|
DrawerFont(drawer::FontMessage),
|
||||||
DrawerIcon(drawer::IconMessage),
|
DrawerIcon(drawer::IconMessage),
|
||||||
|
|
||||||
|
|
@ -262,6 +264,12 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Message::DrawerCorners(message) => {
|
||||||
|
if let Some(context_view) = self.context_view.as_ref() {
|
||||||
|
tasks.push(self.drawer.update_shadow_and_corners(message, context_view));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Message::WindowHintSize(active_hint) => {
|
Message::WindowHintSize(active_hint) => {
|
||||||
self.theme_manager.set_active_hint(active_hint);
|
self.theme_manager.set_active_hint(active_hint);
|
||||||
}
|
}
|
||||||
|
|
@ -820,6 +828,7 @@ pub fn experimental() -> Section<crate::pages::Message> {
|
||||||
interface_font_txt = fl!("interface-font");
|
interface_font_txt = fl!("interface-font");
|
||||||
monospace_font_txt = fl!("monospace-font");
|
monospace_font_txt = fl!("monospace-font");
|
||||||
icons_and_toolkit_txt = fl!("icons-and-toolkit");
|
icons_and_toolkit_txt = fl!("icons-and-toolkit");
|
||||||
|
shadow_and_corners_txt = fl!("shadow-and-corners");
|
||||||
});
|
});
|
||||||
|
|
||||||
Section::default()
|
Section::default()
|
||||||
|
|
@ -845,11 +854,17 @@ pub fn experimental() -> Section<crate::pages::Message> {
|
||||||
Message::DrawerOpen(ContextView::IconsAndToolkit),
|
Message::DrawerOpen(ContextView::IconsAndToolkit),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let shadow_and_corners = crate::widget::go_next_item(
|
||||||
|
&descriptions[shadow_and_corners_txt],
|
||||||
|
Message::DrawerOpen(ContextView::ShadowAndCorners),
|
||||||
|
);
|
||||||
|
|
||||||
settings::section()
|
settings::section()
|
||||||
.title(&*section.title)
|
.title(&*section.title)
|
||||||
.add(system_font)
|
.add(system_font)
|
||||||
.add(mono_font)
|
.add(mono_font)
|
||||||
.add(icons_and_toolkit)
|
.add(icons_and_toolkit)
|
||||||
|
.add(shadow_and_corners)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::Appearance)
|
.map(crate::pages::Message::Appearance)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
7
i18n/en/cosmic_settings.ftl
vendored
7
i18n/en/cosmic_settings.ftl
vendored
|
|
@ -247,6 +247,12 @@ auto-switch = Automatically switch between light and dark modes
|
||||||
.next-sunrise = Switches to light mode at next sunrise
|
.next-sunrise = Switches to light mode at next sunrise
|
||||||
.next-sunset = Switches to dark mode at next sunset
|
.next-sunset = Switches to dark mode at next sunset
|
||||||
|
|
||||||
|
shadows-floating = Floating windows
|
||||||
|
.clip = Match system corners and apply shadows
|
||||||
|
shadows-tiling = Tiled windows
|
||||||
|
.clip = Match system corners
|
||||||
|
.shadow = Apply shadows
|
||||||
|
|
||||||
container-background = Container background
|
container-background = Container background
|
||||||
.desc-detail = Container background color is used for navigation sidebar, side drawer, dialogs and similar widgets. By default, container background color is automatically derived from the window background.
|
.desc-detail = Container background color is used for navigation sidebar, side drawer, dialogs and similar widgets. By default, container background color is automatically derived from the window background.
|
||||||
.reset = Reset to auto
|
.reset = Reset to auto
|
||||||
|
|
@ -287,6 +293,7 @@ experimental-settings = Experimental settings
|
||||||
icons-and-toolkit = Icons and toolkit theming
|
icons-and-toolkit = Icons and toolkit theming
|
||||||
interface-font = System font
|
interface-font = System font
|
||||||
monospace-font = Monospace font
|
monospace-font = Monospace font
|
||||||
|
shadow-and-corners = Window shadow and corners
|
||||||
|
|
||||||
## Desktop: Notifications
|
## Desktop: Notifications
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue