fix(appearance): color picker resize and drag, fixed size, and re-use color picker window if it exists
This commit is contained in:
parent
a549e8bb5f
commit
e4c47058e0
5 changed files with 389 additions and 232 deletions
501
Cargo.lock
generated
501
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -27,7 +27,7 @@ git = "https://github.com/pop-os/cosmic-panel"
|
|||
# cosmic-config = { path = "../libcosmic/cosmic-config" }
|
||||
|
||||
[patch."https://github.com/Smithay/client-toolkit"]
|
||||
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "dc8c4a0"}
|
||||
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f"}
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use cosmic_settings_page::{self as page, section};
|
|||
|
||||
use crate::config::Config;
|
||||
|
||||
use crate::pages::desktop::appearance::COLOR_PICKER_DIALOG_ID;
|
||||
use crate::pages::desktop::{
|
||||
self, appearance,
|
||||
dock::{self, applets::ADD_DOCK_APPLET_DIALOGUE_ID},
|
||||
|
|
@ -114,6 +115,10 @@ impl cosmic::Application for SettingsApp {
|
|||
Message::PageMessage(crate::pages::Message::DockApplet(dock::applets::Message(
|
||||
applets_inner::Message::ClosedAppletDialogue,
|
||||
)))
|
||||
} else if id == COLOR_PICKER_DIALOG_ID {
|
||||
Message::PageMessage(crate::pages::Message::Appearance(
|
||||
appearance::Message::CloseRequested,
|
||||
))
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
|
@ -293,7 +298,7 @@ impl cosmic::Application for SettingsApp {
|
|||
.filter_map(|p| applets_inner::Applet::try_from(Cow::from(p)).ok())
|
||||
.collect();
|
||||
|
||||
_ = page::update!(
|
||||
page::update!(
|
||||
self.pages,
|
||||
dock::applets::Message(applets_inner::Message::Applets(info_list.clone())),
|
||||
dock::applets::Page
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ impl From<(Option<Config>, ThemeMode)> for Page {
|
|||
pub enum Message {
|
||||
Entered,
|
||||
DarkMode(bool),
|
||||
DragColorPicker,
|
||||
Autoswitch(bool),
|
||||
Frosted(bool),
|
||||
WindowHintSize(spin_button::Message),
|
||||
|
|
@ -208,7 +209,7 @@ pub enum Message {
|
|||
CustomAccent(ColorPickerUpdate),
|
||||
InterfaceText(ColorPickerUpdate),
|
||||
ControlComponent(ColorPickerUpdate),
|
||||
CloseRequested(window::Id),
|
||||
CloseRequested,
|
||||
Roundness(Roundness),
|
||||
StartImport,
|
||||
StartExport,
|
||||
|
|
@ -311,6 +312,7 @@ impl Page {
|
|||
// close the color picker dialog
|
||||
// apply changes
|
||||
theme_builder_needs_update = true;
|
||||
self.active_dialog = None;
|
||||
close_window::<app::Message>(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
// TODO apply changes
|
||||
|
|
@ -323,13 +325,18 @@ impl Page {
|
|||
}
|
||||
ColorPickerUpdate::Cancel => {
|
||||
// close the color picker dialog
|
||||
self.active_dialog = None;
|
||||
close_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
ColorPickerUpdate::ToggleColorPicker => {
|
||||
// create the color picker dialog
|
||||
// set the active picker
|
||||
self.active_dialog = Some(NamedColorPicker::AccentWindowHint);
|
||||
get_window(color_picker_window_settings())
|
||||
let prev = self
|
||||
.active_dialog
|
||||
.replace(NamedColorPicker::AccentWindowHint);
|
||||
if prev.is_none() {
|
||||
get_window(color_picker_window_settings())
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
_ => Command::none(),
|
||||
};
|
||||
|
|
@ -366,6 +373,7 @@ impl Page {
|
|||
// close the color picker dialog
|
||||
// apply changes
|
||||
theme_builder_needs_update = true;
|
||||
self.active_dialog = None;
|
||||
close_window::<app::Message>(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
// TODO apply changes
|
||||
|
|
@ -378,13 +386,18 @@ impl Page {
|
|||
}
|
||||
ColorPickerUpdate::Cancel => {
|
||||
// close the color picker dialog
|
||||
self.active_dialog = None;
|
||||
close_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
ColorPickerUpdate::ToggleColorPicker => {
|
||||
// create the color picker dialog
|
||||
// set the active picker
|
||||
self.active_dialog = Some(NamedColorPicker::ApplicationBackground);
|
||||
get_window(color_picker_window_settings())
|
||||
let prev = self
|
||||
.active_dialog
|
||||
.replace(NamedColorPicker::ApplicationBackground);
|
||||
if prev.is_none() {
|
||||
get_window(color_picker_window_settings())
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
_ => Command::none(),
|
||||
};
|
||||
|
|
@ -425,6 +438,7 @@ impl Page {
|
|||
// close the color picker dialog
|
||||
// apply changes
|
||||
theme_builder_needs_update = true;
|
||||
self.active_dialog = None;
|
||||
close_window::<app::Message>(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
// TODO apply changes
|
||||
|
|
@ -437,13 +451,16 @@ impl Page {
|
|||
}
|
||||
ColorPickerUpdate::Cancel => {
|
||||
// close the color picker dialog
|
||||
self.active_dialog = None;
|
||||
close_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
ColorPickerUpdate::ToggleColorPicker => {
|
||||
// create the color picker dialog
|
||||
// set the active picker
|
||||
self.active_dialog = Some(NamedColorPicker::CustomAccent);
|
||||
get_window(color_picker_window_settings())
|
||||
let prev = self.active_dialog.replace(NamedColorPicker::CustomAccent);
|
||||
if prev.is_none() {
|
||||
get_window(color_picker_window_settings())
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
_ => Command::none(),
|
||||
};
|
||||
|
|
@ -458,6 +475,7 @@ impl Page {
|
|||
// close the color picker dialog
|
||||
// apply changes
|
||||
theme_builder_needs_update = true;
|
||||
self.active_dialog = None;
|
||||
close_window::<app::Message>(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
// TODO apply changes
|
||||
|
|
@ -470,13 +488,16 @@ impl Page {
|
|||
}
|
||||
ColorPickerUpdate::Cancel => {
|
||||
// close the color picker dialog
|
||||
self.active_dialog = None;
|
||||
close_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
ColorPickerUpdate::ToggleColorPicker => {
|
||||
// create the color picker dialog
|
||||
// set the active picker
|
||||
self.active_dialog = Some(NamedColorPicker::InterfaceText);
|
||||
get_window(color_picker_window_settings())
|
||||
let prev = self.active_dialog.replace(NamedColorPicker::InterfaceText);
|
||||
if prev.is_none() {
|
||||
get_window(color_picker_window_settings())
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
_ => Command::none(),
|
||||
};
|
||||
|
|
@ -488,6 +509,7 @@ impl Page {
|
|||
// close the color picker dialog
|
||||
// apply changes
|
||||
theme_builder_needs_update = true;
|
||||
self.active_dialog = None;
|
||||
close_window::<app::Message>(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
// TODO apply changes
|
||||
|
|
@ -500,19 +522,24 @@ impl Page {
|
|||
}
|
||||
ColorPickerUpdate::Cancel => {
|
||||
// close the color picker dialog
|
||||
self.active_dialog = None;
|
||||
close_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
ColorPickerUpdate::ToggleColorPicker => {
|
||||
// create the color picker dialog
|
||||
// set the active picker
|
||||
self.active_dialog = Some(NamedColorPicker::ControlComponent);
|
||||
get_window(color_picker_window_settings())
|
||||
let prev = self
|
||||
.active_dialog
|
||||
.replace(NamedColorPicker::ControlComponent);
|
||||
if prev.is_none() {
|
||||
get_window(color_picker_window_settings())
|
||||
} else {
|
||||
Command::none()
|
||||
}
|
||||
}
|
||||
_ => Command::none(),
|
||||
};
|
||||
Command::batch(vec![cmd, self.control_component.update::<app::Message>(u)])
|
||||
}
|
||||
Message::CloseRequested(_) => {
|
||||
Message::CloseRequested => {
|
||||
match self.active_dialog.take() {
|
||||
Some(NamedColorPicker::ApplicationBackground) => {
|
||||
_ = self
|
||||
|
|
@ -775,6 +802,9 @@ impl Page {
|
|||
};
|
||||
Command::none()
|
||||
}
|
||||
Message::DragColorPicker => {
|
||||
cosmic::iced_sctk::commands::window::start_drag_window(COLOR_PICKER_DIALOG_ID)
|
||||
}
|
||||
};
|
||||
|
||||
if theme_builder_needs_update {
|
||||
|
|
@ -851,17 +881,24 @@ impl Page {
|
|||
column![
|
||||
header_bar()
|
||||
.title(fl!("color-picker"))
|
||||
.on_close(msg(ColorPickerUpdate::AppliedColor)),
|
||||
picker
|
||||
.builder(msg)
|
||||
.width(Length::Fixed(254.0))
|
||||
.height(Length::Fixed(174.0))
|
||||
.reset_label(fl!("reset-to-default"))
|
||||
.build(
|
||||
fl!("recent-colors"),
|
||||
fl!("copy-to-clipboard"),
|
||||
fl!("copied-to-clipboard"),
|
||||
)
|
||||
.on_close(msg(ColorPickerUpdate::AppliedColor))
|
||||
.on_drag(Message::DragColorPicker),
|
||||
container(
|
||||
picker
|
||||
.builder(msg)
|
||||
.width(Length::Fixed(254.0))
|
||||
.height(Length::Fixed(174.0))
|
||||
.reset_label(fl!("reset-to-default"))
|
||||
.build(
|
||||
fl!("recent-colors"),
|
||||
fl!("copy-to-clipboard"),
|
||||
fl!("copied-to-clipboard"),
|
||||
)
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.align_x(cosmic::iced_core::alignment::Horizontal::Center)
|
||||
.style(cosmic::theme::style::Container::Background)
|
||||
]
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
|
|
@ -1333,10 +1370,10 @@ fn color_picker_window_settings() -> SctkWindowSettings {
|
|||
size_limits: layout::Limits::NONE
|
||||
.min_width(300.0)
|
||||
.max_width(800.0)
|
||||
.min_height(200.0)
|
||||
.min_height(520.0)
|
||||
.max_height(1080.0),
|
||||
size: (286, 424),
|
||||
resizable: None,
|
||||
size: (300, 520),
|
||||
resizable: Some(8.0),
|
||||
client_decorations: true,
|
||||
transparent: true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ impl PageInner {
|
|||
.iter()
|
||||
.find(|b| b.to_string() == self.backgrounds[a])
|
||||
{
|
||||
panel_config.background = b.clone().into();
|
||||
panel_config.background = (*b).into();
|
||||
}
|
||||
}
|
||||
Message::ExtendToEdge(enabled) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue