fix(appearance): set color from pickers only when needed
This commit is contained in:
parent
077ad931cc
commit
20fc48a8d7
3 changed files with 34 additions and 26 deletions
|
|
@ -148,26 +148,34 @@ impl Content {
|
|||
|
||||
pub fn update_color(
|
||||
&mut self,
|
||||
tasks: &mut Vec<Task<app::Message>>,
|
||||
message: ColorPickerUpdate,
|
||||
context_view: &ContextView,
|
||||
) -> Task<app::Message> {
|
||||
let mut tasks = Vec::new();
|
||||
) -> bool {
|
||||
let mut needs_update = false;
|
||||
|
||||
tasks.push(match message {
|
||||
ColorPickerUpdate::AppliedColor | ColorPickerUpdate::Reset => {
|
||||
self.context_view = None;
|
||||
cosmic::task::message(crate::pages::Message::CloseContextDrawer)
|
||||
match message {
|
||||
ColorPickerUpdate::ActionFinished => {
|
||||
needs_update = true;
|
||||
}
|
||||
|
||||
ColorPickerUpdate::ActionFinished => Task::none(),
|
||||
ColorPickerUpdate::AppliedColor | ColorPickerUpdate::Reset => {
|
||||
needs_update = true;
|
||||
self.context_view = None;
|
||||
tasks.push(cosmic::task::message(
|
||||
crate::pages::Message::CloseContextDrawer,
|
||||
));
|
||||
}
|
||||
|
||||
ColorPickerUpdate::Cancel => {
|
||||
self.context_view = None;
|
||||
cosmic::task::message(crate::pages::Message::CloseContextDrawer)
|
||||
tasks.push(cosmic::task::message(
|
||||
crate::pages::Message::CloseContextDrawer,
|
||||
));
|
||||
}
|
||||
|
||||
_ => Task::none(),
|
||||
});
|
||||
_ => (),
|
||||
}
|
||||
|
||||
tasks.push(match *context_view {
|
||||
ContextView::CustomAccent => self.custom_accent.update(message),
|
||||
|
|
@ -176,10 +184,10 @@ impl Content {
|
|||
ContextView::InterfaceText => self.interface_text.update(message),
|
||||
ContextView::ControlComponent => self.control_component.update(message),
|
||||
ContextView::AccentWindowHint => self.accent_window_hint.update(message),
|
||||
_ => Task::none(),
|
||||
_ => return needs_update,
|
||||
});
|
||||
|
||||
cosmic::Task::batch(tasks)
|
||||
needs_update
|
||||
}
|
||||
|
||||
pub fn update_icon(
|
||||
|
|
|
|||
|
|
@ -248,10 +248,11 @@ impl Page {
|
|||
|
||||
Message::DrawerColor(u) => {
|
||||
if let Some(context_view) = self.context_view.as_ref() {
|
||||
tasks.push(self.drawer.update_color(u, context_view));
|
||||
theme_staged = self
|
||||
.theme_manager
|
||||
.set_color(self.drawer.current_color(context_view), context_view);
|
||||
if self.drawer.update_color(&mut tasks, u, context_view) {
|
||||
theme_staged = self
|
||||
.theme_manager
|
||||
.set_color(self.drawer.current_color(context_view), context_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,10 +299,11 @@ impl Page {
|
|||
Message::Left => {}
|
||||
|
||||
Message::PaletteAccent(c) => {
|
||||
theme_staged = self
|
||||
.theme_manager
|
||||
.selected_customizer_mut()
|
||||
.set_accent(Some(c).map(Srgb::from));
|
||||
theme_staged = dbg!(
|
||||
self.theme_manager
|
||||
.selected_customizer_mut()
|
||||
.set_accent(Some(c).map(Srgb::from))
|
||||
);
|
||||
}
|
||||
|
||||
Message::Reset => {
|
||||
|
|
|
|||
|
|
@ -187,13 +187,11 @@ fn accent_color_palette<'a>(
|
|||
) -> impl Into<Element<'a, Message>> {
|
||||
let Spacing { space_xxs, .. } = cosmic::theme::spacing();
|
||||
let descriptions = §ion.descriptions;
|
||||
let palette = &page.theme_manager.builder().palette.as_ref();
|
||||
let accent = page.theme_manager.accent_palette().as_ref().unwrap();
|
||||
let cur_accent = page
|
||||
.theme_manager
|
||||
.builder()
|
||||
.accent
|
||||
.map_or(palette.accent_blue, Srgba::from);
|
||||
let cur_accent = page.theme_manager.builder().accent.map_or_else(
|
||||
|| page.theme_manager.builder().palette.as_ref().accent_blue,
|
||||
Srgba::from,
|
||||
);
|
||||
let mut accent_palette_row = cosmic::widget::row::with_capacity(accent.len());
|
||||
|
||||
for &color in accent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue