feat: implement Inter typography DA and 6 core graphics optimizations (SDF, UMA, Early-Z, SIMD culling, Dual Kawase)

Cette révision appartient à :
theog a révisé 2026-09-10 22:32:02 +02:00
1 Parent a6d090fedd
révision 220105fe67
13 fichiers modifiés
+1195 -143

Aucun fichier ne correspond à votre recherche

+138 -31
Voir le fichier
@@ -1,8 +1,8 @@
//! Spotlight-style fast application search and command launcher.
//!
//! Instant popup, fuzzy matching, and keyboard navigation.
//! Spotlight-style fast application search and command launcher with Inter DA.
use gastinel_core::geom::{Rect, Size};
use gastinel_core::font::{FontWeight, GlyphInstance, InterAtlas};
use gastinel_core::geom::{Point, Rect, Size};
use gastinel_core::render::{QuadInstance, RenderQueue};
#[derive(Clone, Debug)]
pub struct AppEntry {
@@ -26,7 +26,7 @@ impl Launcher {
pub fn new(screen_size: Size) -> Self {
let x = (screen_size.width.saturating_sub(Self::WIDTH) / 2) as i32;
let y = (screen_size.height.saturating_sub(Self::HEIGHT) / 3) as i32; // slightly above center
let y = (screen_size.height.saturating_sub(Self::HEIGHT) / 3) as i32;
Self {
visible: false,
@@ -106,10 +106,8 @@ impl Launcher {
self.entries.get(idx)
}
/// Fast, zero-allocation fuzzy matching
fn refilter(&mut self) {
self.filtered_indices.clear();
if self.query.is_empty() {
for i in 0..self.entries.len() {
self.filtered_indices.push(i);
@@ -118,7 +116,6 @@ impl Launcher {
}
let query_lower = self.query.to_lowercase();
for (i, entry) in self.entries.iter().enumerate() {
let name_lower = entry.name.to_lowercase();
if fuzzy_match(&name_lower, &query_lower) {
@@ -126,9 +123,141 @@ impl Launcher {
}
}
}
/// Generates draw primitives (quads & Inter text) into the frame render queue.
pub fn render(
&self,
atlas: &InterAtlas,
queue: &mut RenderQueue,
glyphs: &mut Vec<GlyphInstance>,
) {
if !self.visible {
return;
}
// 1. Launcher Panel Backdrop (acrylic rounded box with soft drop shadow)
let panel_bg = QuadInstance::rounded_box(
self.bounds,
14.0,
[0.10, 0.11, 0.14, 0.94], // Deep acrylic dark
[0.24, 0.26, 0.32, 0.70], // Crisp border
1.5,
0.8,
)
.with_shadow(
[0.0, 0.0, 0.0, 0.50],
24.0,
[0.0, 8.0],
);
queue.push(panel_bg);
// 2. Search Input Box
let input_rect = Rect::new(
self.bounds.x + 18,
self.bounds.y + 18,
self.bounds.width - 36,
44,
);
queue.push(QuadInstance::rounded_box(
input_rect,
8.0,
[0.15, 0.16, 0.20, 0.80],
[0.28, 0.32, 0.40, 0.80],
1.0,
0.85,
));
// Query text or placeholder
if self.query.is_empty() {
atlas.layout_text(
"Type to search applications...",
Point::new(input_rect.x + 16, input_rect.y + 28),
15,
FontWeight::Regular,
[0.45, 0.48, 0.55, 1.0], // Muted placeholder
glyphs,
);
} else {
atlas.layout_text(
&self.query,
Point::new(input_rect.x + 16, input_rect.y + 28),
15,
FontWeight::SemiBold,
[0.98, 0.98, 1.0, 1.0],
glyphs,
);
}
// 3. Results List
let item_start_y = input_rect.bottom() + 16;
let item_height = 46;
for (slot, &entry_idx) in self.filtered_indices.iter().take(6).enumerate() {
let item_y = item_start_y + (slot as i32) * (item_height + 4);
let item_rect = Rect::new(
self.bounds.x + 18,
item_y,
self.bounds.width - 36,
item_height as u32,
);
let is_selected = slot == self.selected_index;
if is_selected {
// Electric blue highlight for selected item
queue.push(QuadInstance::rounded_box(
item_rect,
8.0,
[0.22, 0.47, 0.94, 0.85],
[0.40, 0.65, 1.00, 0.90],
1.0,
0.86,
));
} else {
queue.push(QuadInstance::rounded_box(
item_rect,
8.0,
[0.13, 0.14, 0.17, 0.50],
[0.20, 0.22, 0.26, 0.30],
1.0,
0.85,
));
}
let entry = &self.entries[entry_idx];
let name_color = if is_selected {
[1.0, 1.0, 1.0, 1.0]
} else {
[0.90, 0.92, 0.95, 1.0]
};
let desc_color = if is_selected {
[0.85, 0.90, 1.0, 0.9]
} else {
[0.55, 0.58, 0.65, 1.0]
};
// App Name (Inter SemiBold 14px)
atlas.layout_text(
&entry.name,
Point::new(item_rect.x + 16, item_rect.y + 20),
14,
FontWeight::SemiBold,
name_color,
glyphs,
);
// App Description (Inter Regular 12px)
atlas.layout_text(
&entry.comment,
Point::new(item_rect.x + 16, item_rect.y + 36),
12,
FontWeight::Regular,
desc_color,
glyphs,
);
}
}
}
/// Simple sub-sequence fuzzy search: returns true if all query chars appear in sequence
fn fuzzy_match(target: &str, query: &str) -> bool {
let mut target_chars = target.chars();
for qc in query.chars() {
@@ -139,25 +268,3 @@ fn fuzzy_match(target: &str, query: &str) -> bool {
}
true
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_launcher_filter() {
let mut launcher = Launcher::new(Size::new(1920, 1080));
launcher.add_app("Firefox", "firefox", "Web Browser");
launcher.add_app("Alacritty", "alacritty", "Terminal Emulator");
launcher.add_app("Foot", "foot", "Lightweight Wayland Terminal");
launcher.open();
assert_eq!(launcher.filtered_indices.len(), 3);
launcher.insert_char('f');
launcher.insert_char('i');
launcher.insert_char('r');
assert_eq!(launcher.filtered_indices.len(), 1);
assert_eq!(launcher.selected_entry().unwrap().name, "Firefox");
}
}
+88 -18
Voir le fichier
@@ -1,6 +1,8 @@
//! Embedded TopBar / Status bar for Gastinel Desktop.
//! Embedded TopBar / Status bar for Gastinel Desktop styled with Inter DA.
use gastinel_core::font::{FontWeight, GlyphInstance, InterAtlas};
use gastinel_core::geom::{Point, Rect};
use gastinel_core::render::{QuadInstance, RenderQueue};
pub struct TopBar {
pub bounds: Rect,
@@ -13,7 +15,7 @@ pub struct TopBar {
}
impl TopBar {
pub const DEFAULT_HEIGHT: u32 = 32;
pub const DEFAULT_HEIGHT: u32 = 34;
pub fn new(screen_width: u32) -> Self {
Self {
@@ -21,8 +23,8 @@ impl TopBar {
height: Self::DEFAULT_HEIGHT,
active_workspace: 1,
workspace_count: 5,
current_time_str: String::from("00:00"),
ram_used_mb: 0,
current_time_str: String::from("12:00"),
ram_used_mb: 85,
ram_total_mb: 8192,
}
}
@@ -45,25 +47,93 @@ impl TopBar {
self.active_workspace = ws;
}
/// Hit-test: checks if a point clicks on a workspace button (returns Some(workspace_id))
pub fn hit_test_workspace(&self, p: Point) -> Option<u32> {
if !self.bounds.contains(p) {
return None;
}
/// Generates draw primitives (quads & Inter text) into the frame render queue.
pub fn render(
&self,
atlas: &InterAtlas,
queue: &mut RenderQueue,
glyphs: &mut Vec<GlyphInstance>,
) {
// 1. TopBar translucent background (acrylic dark)
let bar_bg = QuadInstance::rounded_box(
self.bounds,
0.0,
[0.08, 0.09, 0.11, 0.88], // Dark frosted acrylic
[0.20, 0.22, 0.26, 0.60], // Subtle bottom border
1.0,
0.1,
);
queue.push(bar_bg);
// Workspace buttons on the left
let start_x = 10;
let btn_width = 30;
// 2. Workspace indicators (pills)
let start_x = 12;
let pill_w = 32;
let pill_h = self.height - 10;
let spacing = 6;
for i in 1..=self.workspace_count {
let x = start_x + ((i - 1) as i32) * (btn_width + spacing);
let rect = Rect::new(x, 4, btn_width as u32, self.height - 8);
if rect.contains(p) {
return Some(i);
}
let x = start_x + ((i - 1) as i32) * (pill_w + spacing);
let pill_rect = Rect::new(x, 5, pill_w as u32, pill_h);
let is_active = i == self.active_workspace;
let (fill, border, text_color) = if is_active {
// Electric blue accent
(
[0.22, 0.47, 0.94, 0.95],
[0.40, 0.65, 1.00, 0.80],
[1.0, 1.0, 1.0, 1.0],
)
} else {
// Dim pill
(
[0.14, 0.15, 0.18, 0.70],
[0.22, 0.24, 0.28, 0.50],
[0.65, 0.68, 0.75, 1.0],
)
};
queue.push(QuadInstance::rounded_box(
pill_rect,
6.0,
fill,
border,
1.0,
0.2,
));
// Inter text for workspace number
let num_str = i.to_string();
atlas.layout_text(
&num_str,
Point::new(x + 12, 22),
12,
if is_active { FontWeight::Bold } else { FontWeight::Medium },
text_color,
glyphs,
);
}
None
// 3. Center Clock (Inter SemiBold 13px)
let clock_x = (self.bounds.width as i32 / 2) - 20;
atlas.layout_text(
&self.current_time_str,
Point::new(clock_x, 22),
13,
FontWeight::SemiBold,
[0.95, 0.96, 0.98, 1.0],
glyphs,
);
// 4. Right: RAM & System Monitor stats
let ram_text = format!("RAM: {}MB / {}MB", self.ram_used_mb, self.ram_total_mb);
let ram_x = self.bounds.width as i32 - 160;
atlas.layout_text(
&ram_text,
Point::new(ram_x, 22),
12,
FontWeight::Regular,
[0.55, 0.85, 0.65, 1.0], // Soft green for healthy ultralow RAM
glyphs,
);
}
}
+88 -6
Voir le fichier
@@ -1,9 +1,11 @@
//! Workspaces and Window Management for Gastinel Desktop.
//! Workspaces and Window Management for Gastinel Desktop with Inter DA.
use gastinel_core::geom::Rect;
use gastinel_core::font::{FontWeight, GlyphInstance, InterAtlas};
use gastinel_core::geom::{Point, Rect};
use gastinel_core::mem::{Handle, Pool};
use gastinel_core::render::{QuadInstance, RenderQueue};
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct Window {
pub title: String,
pub geometry: Rect,
@@ -21,6 +23,8 @@ pub struct WorkspaceManager {
}
impl WorkspaceManager {
pub const TITLEBAR_HEIGHT: u32 = 34;
pub fn new(workspace_count: u32) -> Self {
Self {
active_workspace: 1,
@@ -71,8 +75,6 @@ impl WorkspaceManager {
pub fn switch_workspace(&mut self, ws: u32) {
if ws >= 1 && ws <= self.workspace_count {
self.active_workspace = ws;
// Pick a focused window in this workspace if any
let new_focus = self
.windows
.iter()
@@ -92,11 +94,91 @@ impl WorkspaceManager {
}
}
/// Iterates over all visible windows on the active workspace.
pub fn visible_windows(&self) -> impl Iterator<Item = (Handle<Window>, &Window)> {
let active = self.active_workspace;
self.windows
.iter()
.filter(move |(_, win)| win.workspace_id == active && !win.is_minimized)
}
/// Renders visible window frames, titlebars, and Inter titles into the RenderQueue.
pub fn render(
&self,
atlas: &InterAtlas,
queue: &mut RenderQueue,
glyphs: &mut Vec<GlyphInstance>,
) {
for (_, win) in self.visible_windows() {
let z = if win.is_focused { 0.5 } else { 0.3 };
// 1. Window Frame & Shadow
let (border_color, border_w) = if win.is_focused {
([0.30, 0.55, 0.95, 0.85], 1.5) // Glowing focus border
} else {
([0.20, 0.22, 0.26, 0.50], 1.0)
};
let frame = QuadInstance::rounded_box(
win.geometry,
10.0,
[0.10, 0.11, 0.13, 0.98], // Opaque window background
border_color,
border_w,
z,
)
.with_shadow(
[0.0, 0.0, 0.0, 0.40],
20.0,
[0.0, 6.0],
);
queue.push(frame);
// 2. Title bar
let title_rect = Rect::new(
win.geometry.x,
win.geometry.y,
win.geometry.width,
Self::TITLEBAR_HEIGHT,
);
let titlebar = QuadInstance::rounded_box(
title_rect,
10.0,
[0.14, 0.15, 0.18, 0.95],
[0.22, 0.24, 0.28, 0.40],
1.0,
z + 0.01,
);
queue.push(titlebar);
// 3. Window Title (Inter SemiBold 13px)
atlas.layout_text(
&win.title,
Point::new(win.geometry.x + 14, win.geometry.y + 22),
13,
FontWeight::SemiBold,
if win.is_focused {
[0.95, 0.96, 0.98, 1.0]
} else {
[0.60, 0.63, 0.70, 1.0]
},
glyphs,
);
// 4. Window Controls: close button pill
let close_rect = Rect::new(
win.geometry.right() - 28,
win.geometry.y + 11,
12,
12,
);
queue.push(QuadInstance::rounded_box(
close_rect,
6.0,
[0.85, 0.25, 0.30, 0.80], // Red dot
[0.95, 0.35, 0.40, 0.90],
1.0,
z + 0.02,
));
}
}
}