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
11b2978f22
commit
9d16ffa401
3 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) {
|
||||
let settings = self.shared.settings.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 ctx = &win.egui.egui_ctx;
|
||||
theme::apply(ctx, &palette, &settings);
|
||||
|
|
@ -1368,6 +1368,7 @@ impl App {
|
|||
ctx.set_zoom_factor(settings.ui.scale.clamp(0.5, 3.0));
|
||||
}
|
||||
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).
|
||||
|
|
@ -1610,6 +1611,13 @@ impl App {
|
|||
// ── drawing ───────────────────────────────────────────────────────
|
||||
|
||||
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 started = Instant::now();
|
||||
win.needs_redraw = false;
|
||||
|
|
|
|||
21
src/tabs.rs
21
src/tabs.rs
|
|
@ -277,6 +277,11 @@ impl Tab {
|
|||
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 {
|
||||
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)]
|
||||
pub struct WindowUi {
|
||||
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).
|
||||
pub omnibox_edit: Option<String>,
|
||||
pub focus_omnibox: bool,
|
||||
|
|
|
|||
Loading…
Reference in a new issue