diff --git a/crates/snowbound/src/main.rs b/crates/snowbound/src/main.rs index 653f4da33a08618cf2912148679a52063101220a..acdf9b164c8b79803770cb0b23cd9801e9199fcc 100644 --- a/crates/snowbound/src/main.rs +++ b/crates/snowbound/src/main.rs @@ -1474,7 +1474,7 @@ impl State { && self.locked.is_none(); self.toolbar(&theme, !welcome)?; if welcome { - self.welcome(&theme); + self.welcome(); return Ok((section, Id::ROOT, None)); } self.ui.open( @@ -1704,7 +1704,7 @@ impl State { recycle::bar(&mut self.ui); } if self.session.is_none() && self.locked.is_some() { - self.locked_page(&theme); + self.locked_page(); self.ui.close(); self.ui.close(); self.ui.close(); @@ -1717,7 +1717,7 @@ impl State { return Ok((section, open_tab, None)); } if let Some(library) = self.sectionless.clone().filter(|_| self.session.is_none()) { - self.no_sections(&theme, library); + self.no_sections(library); self.ui.close(); self.ui.close(); self.ui.close(); @@ -4193,6 +4193,20 @@ impl State { .colored(self.view.editor.page_color()) } + /// The colours of what the page area shows in place of a page, which follow the page's: + /// the light theme's on white pages, as Pages Match UI Theme off keeps them in a dark + /// appearance. + pub(crate) fn page_area_theme(&self) -> Theme { + if self.light_pages { + Theme { + accent: self.ui.theme.accent, + ..Theme::light() + } + } else { + self.ui.theme.clone() + } + } + /// Paints the interface with the page in its box. fn paint(&mut self, target: &draw::Target) -> Result<(), Box> { let start = Instant::now(); diff --git a/crates/snowbound/src/protection.rs b/crates/snowbound/src/protection.rs index 9c0c3c6aee01dc2716c463159c292ac5f92839bf..23a30e49e635cd180b2268358f33464f423c843e 100644 --- a/crates/snowbound/src/protection.rs +++ b/crates/snowbound/src/protection.rs @@ -2,7 +2,7 @@ //! dialogs that unlock one and set, change or remove its password, Lock All, and locking a //! section after a while unused or as it is left. Keys live in memory only (`Library`). -use crate::{Command, Library, State, Theme, art, manage::Structure}; +use crate::{Command, Library, State, art, manage::Structure}; use accesskit::Role; use std::{error::Error, sync::Arc, time::Duration}; use ui::{Anchor, Axis, Flags, Id, Spec, Ui, children, fill, px}; @@ -155,11 +155,13 @@ impl State { } /// The locked section's page, as OneNote 2010 draws it: a click or Enter unlocks. - pub(crate) fn locked_page(&mut self, theme: &Theme) { + pub(crate) fn locked_page(&mut self) { let Some(locked) = &self.locked else { return; }; let (library, path) = (Arc::clone(&locked.library), locked.path.clone()); + let theme = &self.page_area_theme(); + let chrome = std::mem::replace(&mut self.ui.theme, theme.clone()); let ui = &mut self.ui; let entered = ui::popup::navigation(ui, &[notice()], &[NamedKey::Enter]).contains(&NamedKey::Enter); @@ -229,6 +231,7 @@ impl State { ui.close(); ui.close(); ui.close(); + ui.theme = chrome; if ui.signal(open).clicked || entered { self.ask_password(library, path, Dialog::Unlock(Zeroizing::default(), false)); } diff --git a/crates/snowbound/src/sidebar.rs b/crates/snowbound/src/sidebar.rs index 140ce8754ba58f5897bf2dc0c1f32a92679b739d..4c2d22fd082e84e321d72221463f299141a786ea 100644 --- a/crates/snowbound/src/sidebar.rs +++ b/crates/snowbound/src/sidebar.rs @@ -1150,7 +1150,7 @@ impl crate::State { /// The window below the title bar on the first run, or once every notebook is closed: /// what is missing, and the ways to start. - pub(crate) fn welcome(&mut self, theme: &Theme) { + pub(crate) fn welcome(&mut self) { let id = self.ui.id("welcome"); #[cfg(target_os = "linux")] let install = crate::desktop::installable().then_some(( @@ -1163,9 +1163,7 @@ impl crate::State { let install = None; let servers = self.servers.clone(); self.notice( - theme, id, - theme.base, "No notebooks open", &servers, [ @@ -1202,7 +1200,7 @@ impl crate::State { /// The page's place while notebook `library` has no sections, as OneNote 2010 shows /// it, with a button to add one; or while none is on this computer yet. - pub(crate) fn no_sections(&mut self, theme: &Theme, library: Arc) { + pub(crate) fn no_sections(&mut self, library: Arc) { let downloading = library.downloading(); let new = crate::Command::Structure( library, @@ -1219,27 +1217,27 @@ impl crate::State { vec![("new", art::PLUS, "New Section", new)], ) }; - self.notice(theme, id, theme.strip, title, &[], buttons); + self.notice(id, title, &[], buttons); } - /// A box `id` filled with `background`, showing `title` above `buttons` in its middle: each + /// A box `id` in the page's colours, showing `title` above `buttons` in its middle: each /// a part, an icon, a label and what it does; then the saved `servers` to reconnect to. fn notice( &mut self, - theme: &Theme, id: ui::Id, - background: [f32; 4], title: &str, servers: &[String], buttons: Vec<(&str, &'static [&'static str], &str, crate::Command)>, ) { const BUTTON: [f32; 2] = [240.0, 32.0]; + let theme = self.page_area_theme(); + let chrome = std::mem::replace(&mut self.ui.theme, theme.clone()); let [left, top, right, bottom] = self.ui.rect(id).unwrap_or_default(); self.ui.open_as( id, Spec { size: [fill(), fill()], - fill: Some(background), + fill: Some(theme.paper), ..Spec::default() }, ); @@ -1292,6 +1290,7 @@ impl crate::State { let saved = crate::server::saved_servers(&mut self.ui, servers); self.ui.close(); self.ui.close(); + self.ui.theme = chrome; if let Some(saved) = saved { self.saved_server(saved); }