S016: chrome and menus redesign: pill tabs on springs, address pill, toolbar badges, page card, floating flyouts

Tabs slide to their slots with a sliding selection pill and drag under the
pointer; the address field is a pill with a site chip, host emphasis and a
star that fills; flyouts and menus share one floating surface that springs
open and fades closed. Web page corners are masked over the GL blit.
tests/smoke/chrome.txt shoots the chrome and every flyout dark and light.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-11 20:11:33 -06:00
commit 72d06510b2
7 changed files with 1758 additions and 722 deletions

View file

@ -9,7 +9,9 @@
//! resize <w> <h> resize the window (logical pixels)
//! status <name> save tabs, downloads, VPN, ad blocker and so on as <name>.json
//! set <json pointer> <json> change a setting, e.g. `set /privacy/https_only true`
//! flyout <name> main, downloads, shield, vpn, media, siteinfo, profiles, apps, qr, none
//! flyout <name> main, downloads, shield, vpn, media, siteinfo, profiles, apps, qr, tabmenu, back,
//! bookmark (edit the current page's bookmark), none
//! type <text> put text in the address bar with its suggestions open
//! do <action> a shortcut action by its settings key, e.g. `do new_tab`
//! cmd <name> [arg] back, forward, reload, bookmark, install_app, pip, exitpip, free_memory,
//! update_lists, check_updates, close_tab, select <n>, zoom <step>,
@ -173,6 +175,8 @@ impl App {
},
"flyout" => {
let url = self.windows.get(&window).and_then(|w| w.tab()).map(|t| t.url.clone()).unwrap_or_default();
let tab = self.windows.get(&window).and_then(|w| w.tab()).map(|t| t.id).unwrap_or(0);
let at = egui::pos2(80.0, 40.0);
let flyout = match rest {
"main" => Some(Flyout::Main),
"downloads" => Some(Flyout::Downloads),
@ -183,6 +187,9 @@ impl App {
"profiles" => Some(Flyout::Profiles),
"apps" => Some(Flyout::Apps),
"qr" => Some(Flyout::Qr(url)),
"tabmenu" => Some(Flyout::TabMenu(tab, at)),
"back" => Some(Flyout::BackHistory(at)),
"bookmark" => Some(Flyout::EditBookmark(url)),
_ => None,
};
if let Some(win) = self.windows.get_mut(&window) {
@ -259,6 +266,17 @@ impl App {
win.send_mouse_button(winit::event::ElementState::Released, winit::event::MouseButton::Left);
}
},
"type" => {
// Type into the address bar as if the user did: focus, text, suggestions.
if let Some(win) = self.windows.get_mut(&window) {
// Xvfb has no window manager, so the window never gets focus and egui would drop text focus.
let _ = win.egui.on_window_event(&win.window, &winit::event::WindowEvent::Focused(true));
win.ui.focus_omnibox = true;
win.ui.omnibox_edit = Some(rest.to_owned());
win.ui.omnibox_query.clear();
}
self.redraw(window);
},
"log" => self.selftest_log(rest),
"quit" => self.quit(),
_ => self.selftest_log(&format!("unknown line: {line}")),

View file

@ -465,6 +465,13 @@ pub fn spring(ctx: &Context, id: Id, target: f32, spring: Spring) -> f32 {
value
}
/// Puts a spring at `value`, at rest: for things that follow the pointer (a dragged tab) and spring from there once
/// let go, or that must not animate (a window resize).
pub fn spring_jump(ctx: &Context, id: Id, value: f32) {
let frame = ctx.cumulative_frame_nr();
ctx.data_mut(|d| d.insert_temp(id, SpringState { value, velocity: 0.0, frame }));
}
/// A 0..1 value for an on/off state with the `EFFECT` spring: hover and selection tints, fades.
pub fn effect(ctx: &Context, id: Id, on: bool) -> f32 {
spring(ctx, id, if on { 1.0 } else { 0.0 }, EFFECT).clamp(0.0, 1.0)

File diff suppressed because it is too large Load diff

View file

@ -140,6 +140,14 @@ pub const RAINY: &str = "\u{f176}";
pub const WEATHER_SNOWY: &str = "\u{e2cd}";
pub const THUNDERSTORM: &str = "\u{ebdb}";
pub const FOGGY: &str = "\u{e818}";
pub const SAVE: &str = "\u{e161}";
pub const FIND_IN_PAGE: &str = "\u{e880}";
pub const POWER_SETTINGS_NEW: &str = "\u{f8c7}";
pub const NEW_WINDOW: &str = "\u{f710}";
pub const WEB: &str = "\u{e051}";
pub const CONTENT_CUT: &str = "\u{e14e}";
pub const CONTENT_PASTE: &str = "\u{e14f}";
pub const SELECT_ALL: &str = "\u{e162}";
/// Every icon with its name, for the gallery.
pub const ALL: &[(&str, &str)] = &[
@ -282,4 +290,12 @@ pub const ALL: &[(&str, &str)] = &[
("weather_snowy", WEATHER_SNOWY),
("thunderstorm", THUNDERSTORM),
("foggy", FOGGY),
("save", SAVE),
("find_in_page", FIND_IN_PAGE),
("power_settings_new", POWER_SETTINGS_NEW),
("new_window", NEW_WINDOW),
("web", WEB),
("content_cut", CONTENT_CUT),
("content_paste", CONTENT_PASTE),
("select_all", SELECT_ALL),
];

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
//! The browser interface, drawn with egui. Plain on purpose for now: everything works, the
//! designed look comes later. Drawing code reads the shared stores, may edit simple things
//! (settings, bookmarks, history) directly, and asks the app for everything else with `Command`s.
//! The browser interface, drawn with egui from the theme tokens (docs/DESIGN.md "UI system"). Drawing code reads
//! the shared stores, may edit simple things (settings, bookmarks, history) directly, and asks the app for
//! everything else with `Command`s.
pub mod chrome;
pub mod dialogs;
@ -188,7 +188,10 @@ pub fn draw(root: &mut egui::Ui, f: &mut Frame) {
dialogs::find_bar(root, f);
}
let floating = f.shared.settings.borrow().ui.floating_card && !page_fullscreen && !app_window;
let frame = egui::Frame::NONE.inner_margin(if floating { egui::Margin::symmetric(8, 6) } else { egui::Margin::ZERO });
// The page floats as a rounded card with a margin, on the chrome's colour.
let gap = crate::theme::GAP_S as i8;
let margin = if floating { egui::Margin { left: gap, right: gap, top: 0, bottom: gap } } else { egui::Margin::ZERO };
let frame = egui::Frame::NONE.fill(chrome::chrome_fill(&f.palette())).inner_margin(margin);
egui::CentralPanel::no_frame().frame(frame).show(root, |ui| page_area(ui, f, floating));
dialogs::page_dialogs(&ctx, f);
menus::flyouts(&ctx, f);
@ -197,6 +200,22 @@ pub fn draw(root: &mut egui::Ui, f: &mut Frame) {
/// The page itself: a web page's framebuffer, or one of Nacre's pages.
fn page_area(ui: &mut egui::Ui, f: &mut Frame, floating: bool) {
let rect = ui.max_rect();
page_contents(ui, f);
if floating {
card_corners(ui, rect, f.palette());
}
}
/// Rounds the page card's corners. The web page is a framebuffer blitted as a rectangle, so the corners are masked
/// afterwards with a ring in the chrome colour whose inner edge is the card's rounded outline.
fn card_corners(ui: &egui::Ui, rect: egui::Rect, p: Palette) {
let radius = crate::theme::radius(ui.ctx(), crate::theme::L);
let painter = ui.painter().with_clip_rect(rect);
painter.rect_stroke(rect.expand(radius), egui::CornerRadius::same((radius * 2.0).round().min(255.0) as u8), egui::Stroke::new(radius, chrome::chrome_fill(&p)), egui::StrokeKind::Inside);
}
fn page_contents(ui: &mut egui::Ui, f: &mut Frame) {
let rect = ui.max_rect();
let Some(tab) = f.tabs.get(*f.active) else {
*f.page_rect = None;
@ -204,7 +223,7 @@ fn page_area(ui: &mut egui::Ui, f: &mut Frame, floating: bool) {
};
if let Some(page) = tab.page.clone() {
*f.page_rect = None;
egui::Frame::NONE.fill(f.palette().surface_low).corner_radius(if floating { crate::theme::corner(&f.shared.settings.borrow()) } else { 0 }).show(ui, |ui| {
egui::Frame::NONE.fill(f.palette().surface_low).show(ui, |ui| {
ui.set_min_size(rect.size());
pages::draw(ui, f, &page);
});

View file

@ -7,14 +7,14 @@ use super::icons;
use crate::theme::{self, Palette, Weight};
/// How a control looks while the pointer and keyboard work on it, each 0..1 and animated.
struct Interaction {
hover: f32,
press: f32,
focus: bool,
enabled: bool,
pub struct Interaction {
pub hover: f32,
pub press: f32,
pub focus: bool,
pub enabled: bool,
}
fn interaction(ui: &Ui, response: &Response) -> Interaction {
pub fn interaction(ui: &Ui, response: &Response) -> Interaction {
let ctx = ui.ctx();
let enabled = response.enabled();
let hover = theme::effect(ctx, response.id.with("hover"), enabled && response.hovered());
@ -24,17 +24,17 @@ fn interaction(ui: &Ui, response: &Response) -> Interaction {
impl Interaction {
/// The state layer: the content colour over the container.
fn layer(&self, container: Color32, content: Color32) -> Color32 {
pub fn layer(&self, container: Color32, content: Color32) -> Color32 {
theme::layer(container, content, self.amount())
}
/// State layer opacity.
fn amount(&self) -> f32 {
pub fn amount(&self) -> f32 {
theme::HOVER * self.hover + theme::PRESS * self.press.clamp(0.0, 1.0)
}
}
fn focus_ring(ui: &Ui, rect: Rect, radius: f32, p: &Palette) {
pub fn focus_ring(ui: &Ui, rect: Rect, radius: f32, p: &Palette) {
ui.painter().rect_stroke(rect.expand(2.0), theme::corner_radius(radius + 2.0), Stroke::new(2.0, p.secondary), StrokeKind::Outside);
}