S016: R1-11 internal pages drop the site colour, window restyles when it changes
A nacre:// page typed into a web tab kept the site's theme-color, and style_window used it, so with the Website source palette and fallback picks didn't show. Tab::site_colour is None on internal pages; draw() restyles when the active tab's site colour differs from the one the palette was built from. Regression test + tests/smoke/colours.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
9709dcd162
commit
f99500fe76
5 changed files with 86 additions and 1 deletions
10
src/app.rs
10
src/app.rs
|
|
@ -1360,7 +1360,7 @@ impl App {
|
||||||
pub fn style_window(&self, win: &mut BrowserWindow) {
|
pub fn style_window(&self, win: &mut BrowserWindow) {
|
||||||
let settings = self.shared.settings.borrow();
|
let settings = self.shared.settings.borrow();
|
||||||
let dark = theme::is_dark(&settings, *self.shared.system_dark.borrow());
|
let dark = theme::is_dark(&settings, *self.shared.system_dark.borrow());
|
||||||
let site = win.tab().and_then(|t| t.theme_color);
|
let site = win.tab().and_then(Tab::site_colour);
|
||||||
let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent), dark, &settings.theme.variant, settings.theme.contrast);
|
let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent), dark, &settings.theme.variant, settings.theme.contrast);
|
||||||
let ctx = &win.egui.egui_ctx;
|
let ctx = &win.egui.egui_ctx;
|
||||||
theme::apply(ctx, &palette, &settings);
|
theme::apply(ctx, &palette, &settings);
|
||||||
|
|
@ -1368,6 +1368,7 @@ impl App {
|
||||||
ctx.set_zoom_factor(settings.ui.scale.clamp(0.5, 3.0));
|
ctx.set_zoom_factor(settings.ui.scale.clamp(0.5, 3.0));
|
||||||
}
|
}
|
||||||
win.ui.palette = Some(palette);
|
win.ui.palette = Some(palette);
|
||||||
|
win.ui.site_colour = site;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create the web view for the active tab if it doesn't have one yet (lazy restore, unloaded tab).
|
/// Create the web view for the active tab if it doesn't have one yet (lazy restore, unloaded tab).
|
||||||
|
|
@ -1610,6 +1611,13 @@ impl App {
|
||||||
// ── drawing ───────────────────────────────────────────────────────
|
// ── drawing ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
fn draw(&mut self, window: WindowId) {
|
fn draw(&mut self, window: WindowId) {
|
||||||
|
// An internal page shown in a web tab, or Back to the page behind it, changes the site colour.
|
||||||
|
if self.windows.get(&window).is_some_and(|w| w.tab().and_then(Tab::site_colour) != w.ui.site_colour)
|
||||||
|
&& let Some(mut win) = self.windows.remove(&window)
|
||||||
|
{
|
||||||
|
self.style_window(&mut win);
|
||||||
|
self.windows.insert(window, win);
|
||||||
|
}
|
||||||
let Some(win) = self.windows.get_mut(&window) else { return };
|
let Some(win) = self.windows.get_mut(&window) else { return };
|
||||||
let started = Instant::now();
|
let started = Instant::now();
|
||||||
win.needs_redraw = false;
|
win.needs_redraw = false;
|
||||||
|
|
|
||||||
21
src/tabs.rs
21
src/tabs.rs
|
|
@ -277,6 +277,11 @@ impl Tab {
|
||||||
self.page.is_some()
|
self.page.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The colour the "Website" colour source follows: none on an internal page, even one shown over a web page.
|
||||||
|
pub fn site_colour(&self) -> Option<egui::Color32> {
|
||||||
|
if self.is_internal() { None } else { self.theme_color }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn loading(&self) -> bool {
|
pub fn loading(&self) -> bool {
|
||||||
self.page.is_none() && matches!(self.load_status, Some(LoadStatus::Started | LoadStatus::HeadParsed))
|
self.page.is_none() && matches!(self.load_status, Some(LoadStatus::Started | LoadStatus::HeadParsed))
|
||||||
}
|
}
|
||||||
|
|
@ -334,3 +339,19 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
// R1-11: a nacre:// page opened in a web tab kept the site's colour, so palette picks didn't show.
|
||||||
|
#[test]
|
||||||
|
fn internal_page_has_no_site_colour() {
|
||||||
|
let mut tab = Tab::new(1);
|
||||||
|
tab.page = None;
|
||||||
|
tab.theme_color = Some(egui::Color32::from_rgb(0xDE, 0x58, 0x33));
|
||||||
|
assert_eq!(tab.site_colour(), tab.theme_color);
|
||||||
|
tab.page = Some(Page::Settings(String::new()));
|
||||||
|
assert_eq!(tab.site_colour(), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ pub fn fonts() -> egui::FontDefinitions {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WindowUi {
|
pub struct WindowUi {
|
||||||
pub palette: Option<Palette>,
|
pub palette: Option<Palette>,
|
||||||
|
/// The site colour `palette` was built from; the window restyles when the active tab's differs.
|
||||||
|
pub site_colour: Option<Color32>,
|
||||||
/// Address bar text while the user edits it (None = show the page's URL).
|
/// Address bar text while the user edits it (None = show the page's URL).
|
||||||
pub omnibox_edit: Option<String>,
|
pub omnibox_edit: Option<String>,
|
||||||
pub focus_omnibox: bool,
|
pub focus_omnibox: bool,
|
||||||
|
|
|
||||||
49
tests/smoke/colours.txt
Normal file
49
tests/smoke/colours.txt
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# R1-11: colours still change after the welcome setup, also when Settings is typed into a web tab whose page has a
|
||||||
|
# theme-color. Hidden 1280x1100 layout (tap positions): SMOKE_SIZE=1280x1100, fresh outdir. Expect: site-* orange
|
||||||
|
# chrome (#DE5833 seed); s-website NOT orange (an internal page has no site colour); s-teal teal; back-site orange
|
||||||
|
# again (Website source, back on the page); s-palette and tab-palette teal; s-custom blue. settings.json afterwards:
|
||||||
|
# theme.source "custom", theme.fallback "palette", theme.preset "#006A6A".
|
||||||
|
wait 3
|
||||||
|
resize 1280 1060
|
||||||
|
key enter
|
||||||
|
wait 0.6
|
||||||
|
key enter
|
||||||
|
wait 0.6
|
||||||
|
key enter
|
||||||
|
wait 0.6
|
||||||
|
key enter
|
||||||
|
wait 0.6
|
||||||
|
key enter
|
||||||
|
wait 0.6
|
||||||
|
key enter
|
||||||
|
wait 1.5
|
||||||
|
shot welcome-done
|
||||||
|
open @PAGES@/theme-colour.html
|
||||||
|
waitload
|
||||||
|
wait 1
|
||||||
|
shot site
|
||||||
|
cmd navigate nacre://settings/appearance
|
||||||
|
wait 1.5
|
||||||
|
shot s-website
|
||||||
|
tap 614 690
|
||||||
|
wait 1
|
||||||
|
shot s-teal
|
||||||
|
status teal
|
||||||
|
cmd back
|
||||||
|
wait 1.5
|
||||||
|
shot back-site
|
||||||
|
page nacre://settings/appearance
|
||||||
|
wait 1.5
|
||||||
|
tap 747 491
|
||||||
|
wait 1
|
||||||
|
shot s-palette
|
||||||
|
cmd select 0
|
||||||
|
wait 1
|
||||||
|
shot tab-palette
|
||||||
|
page nacre://settings/appearance
|
||||||
|
wait 1
|
||||||
|
tap 883 491
|
||||||
|
wait 1
|
||||||
|
shot s-custom
|
||||||
|
status done
|
||||||
|
quit
|
||||||
5
tests/smoke/pages/theme-colour.html
Normal file
5
tests/smoke/pages/theme-colour.html
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="theme-color" content="#DE5833">
|
||||||
|
<title>Theme colour</title>
|
||||||
|
<body style="font: 16px sans-serif; margin: 40px">A page with an orange theme-color (colours.txt).</body>
|
||||||
Loading…
Reference in a new issue