feat: add system widgets and a persistent native Console with bare assignments
Verify Tessera GUI / verify (push) Failing after 7m17s

This commit is contained in:
2026-10-20 18:36:48 +08:00
parent 1d4b1d3c86
commit 53e8d7b287
15 changed files with 1549 additions and 245 deletions
+310 -182
View File
@@ -6,6 +6,10 @@ use crate::{
document::{CodeNode, RenderDocument},
geometry::{Point, Rect},
sources::SourceWorkspace,
system_ui::{
Axis, Button, Cursor, Interaction, Role, Target, Ui, WidgetId,
theme::{BAR, BG, BORDER, ERROR, MUTED, OK, PALETTE, TEXT, Theme, readable_accent},
},
text::{self, TextStyle},
};
use std::{
@@ -16,24 +20,9 @@ use std::{
};
use unicode_segmentation::UnicodeSegmentation;
const BG: Color = Color::rgb(255, 255, 255);
const BAR: Color = Color::rgb(243, 245, 248);
const BORDER: Color = Color::rgb(214, 220, 229);
const TEXT: Color = Color::rgb(35, 42, 53);
const MUTED: Color = Color::rgb(103, 114, 130);
const ERROR: Color = Color::rgb(175, 42, 49);
const OK: Color = Color::rgb(31, 121, 80);
const ROW: f32 = 19.0;
const PALETTE: [Color; 6] = [
Color::rgb(22, 113, 213),
Color::rgb(0, 132, 143),
Color::rgb(115, 76, 189),
Color::rgb(180, 68, 115),
Color::rgb(168, 94, 24),
Color::rgb(52, 123, 78),
];
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Tab {
#[default]
Console,
@@ -41,7 +30,7 @@ pub enum Tab {
Network,
Settings,
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Region {
Transcript = 0,
Input,
@@ -55,20 +44,20 @@ struct Scroll {
x: f32,
y: f32,
}
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Focus {
Input,
Filter,
Custom,
}
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Action {
Tab(Tab),
Close,
ClearConsole,
ClearNetwork,
Follow,
Mode,
ResetSession,
Submit,
Focus(Focus),
Snapshot,
@@ -79,7 +68,7 @@ pub enum Action {
Request(u64),
Theme(usize),
}
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Split {
Dock,
Editor,
@@ -95,6 +84,8 @@ enum Drag {
#[derive(Debug)]
pub struct DeveloperToolsState {
pub open: bool,
pub interaction: Interaction,
pub repaint: bool,
pub proxy: Option<winit::event_loop::EventLoopProxy<AppEvent>>,
pub cloud_sources: SourceWorkspace,
pub tab: Tab,
@@ -115,7 +106,6 @@ pub struct DeveloperToolsState {
scroll: [Scroll; 6],
widths: [Option<(u64, f32)>; 6],
drag: Option<Drag>,
script: bool,
cloud: bool,
follow: bool,
selected_request: Option<u64>,
@@ -129,6 +119,8 @@ impl Default for DeveloperToolsState {
fn default() -> Self {
Self {
open: false,
interaction: Interaction::default(),
repaint: false,
proxy: None,
cloud_sources: SourceWorkspace::default(),
tab: Tab::Console,
@@ -149,7 +141,6 @@ impl Default for DeveloperToolsState {
scroll: [Scroll::default(); 6],
widths: [None; 6],
drag: None,
script: false,
cloud: false,
follow: true,
selected_request: None,
@@ -164,7 +155,7 @@ impl Default for DeveloperToolsState {
#[derive(Clone, Debug, Default)]
pub struct DeveloperToolsLayout {
pub panel: Rect,
pub actions: Vec<(Rect, Action)>,
pub widgets: Vec<Target<Action>>,
splits: Vec<(Rect, Split)>,
regions: Vec<(Rect, Region, f32, f32)>,
thumbs: Vec<(Rect, Region, bool, f32)>,
@@ -172,6 +163,7 @@ pub struct DeveloperToolsLayout {
impl DeveloperToolsState {
pub fn toggle(&mut self, doc: &RenderDocument) {
self.open = !self.open;
self.interaction.blur();
self.focus = None;
self.drag = None;
self.document_updated(doc);
@@ -185,50 +177,64 @@ impl DeveloperToolsState {
self.selected_node_id = doc.root.as_ref().map(|n| n.id.clone());
}
}
pub fn cursor_kind(
&self,
layout: &DeveloperToolsLayout,
point: Point,
) -> winit::window::CursorIcon {
pub fn cursor_kind(&self, layout: &DeveloperToolsLayout) -> winit::window::CursorIcon {
use winit::window::CursorIcon;
if let Some((_, split)) = layout.splits.iter().find(|(r, _)| r.contains(point)) {
return match split {
Split::Dock | Split::Tree => CursorIcon::ColResize,
_ => CursorIcon::RowResize,
};
if !self.open {
return CursorIcon::Default;
}
if layout
.actions
.iter()
.any(|(r, a)| r.contains(point) && matches!(a, Action::Focus(_)))
{
CursorIcon::Text
} else {
CursorIcon::Default
match self.interaction.cursor(&layout.widgets) {
Cursor::Default => CursorIcon::Default,
Cursor::Pointer => CursorIcon::Pointer,
Cursor::Text => CursorIcon::Text,
Cursor::ResizeHorizontal => CursorIcon::ColResize,
Cursor::ResizeVertical => CursorIcon::RowResize,
Cursor::Grab => CursorIcon::Grab,
Cursor::Disabled => CursorIcon::NotAllowed,
}
}
pub fn pointer_left(&mut self) {
self.interaction.pointer_left();
}
pub fn blur(&mut self) {
self.interaction.blur();
self.drag = None;
self.focus = None;
self.preedit.clear();
}
pub fn press(&mut self, layout: &DeveloperToolsLayout, p: Point, activity: &Activity) {
if !self.open {
return;
}
self.preedit.clear();
if let Some((_, split)) = layout.splits.iter().find(|(r, _)| r.contains(p)) {
self.drag = Some(Drag::Split(*split));
self.focus = None;
return;
self.interaction.pointer_moved(p, &layout.widgets);
let target = self.interaction.press(&layout.widgets);
self.focus = None;
if let Some(target) = target {
match target.role {
Role::Splitter(_) => {
if let Some((_, split)) = layout.splits.iter().find(|(r, _)| r.contains(p)) {
self.drag = Some(Drag::Split(*split));
}
}
Role::Scrollbar(_) => {
if let Some((_, region, h, ratio)) =
layout.thumbs.iter().find(|(r, _, _, _)| r.contains(p))
{
self.drag = Some(Drag::Scroll(*region, *h, *ratio));
}
}
Role::TextField => self.activate(target.action, layout, p, activity),
_ => {}
}
}
if let Some((_, region, horizontal, ratio)) =
layout.thumbs.iter().find(|(r, _, _, _)| r.contains(p))
{
self.drag = Some(Drag::Scroll(*region, *horizontal, *ratio));
return;
}
let action = layout
.actions
.iter()
.rev()
.find(|(r, _)| r.contains(p))
.map(|(_, a)| a.clone());
}
fn activate(
&mut self,
action: Option<Action>,
layout: &DeveloperToolsLayout,
p: Point,
activity: &Activity,
) {
self.focus = None;
match action {
Some(Action::Tab(t)) => {
@@ -285,9 +291,7 @@ impl DeveloperToolsState {
Some(Action::Follow) => {
self.follow = !self.follow;
}
Some(Action::Mode) => {
self.script = !self.script;
}
Some(Action::ResetSession) => self.submit_console(true),
Some(Action::Submit) => self.submit(),
Some(Action::Snapshot) => self.cloud = false,
Some(Action::Cloud) => self.cloud = true,
@@ -320,8 +324,70 @@ impl DeveloperToolsState {
None => {}
}
}
pub fn release(&mut self) {
pub fn release(&mut self, layout: &DeveloperToolsLayout, p: Point, activity: &Activity) {
self.interaction.pointer_moved(p, &layout.widgets);
let action = self.interaction.release(&layout.widgets);
self.drag = None;
if action.is_some() {
self.activate(action, layout, p, activity);
}
}
pub fn keyboard_control(
&mut self,
event: &winit::event::KeyEvent,
shift: bool,
layout: &DeveloperToolsLayout,
activity: &Activity,
) -> bool {
use winit::{
event::ElementState,
keyboard::{Key, NamedKey},
};
if !self.open || !self.preedit.is_empty() {
return false;
}
if event.logical_key == Key::Named(NamedKey::Escape) && self.focus.is_none() {
if event.state == ElementState::Pressed {
self.interaction.blur();
}
return true;
}
if event.logical_key == Key::Named(NamedKey::Tab)
&& (self.focus != Some(Focus::Input) || shift)
{
if event.state == ElementState::Pressed && !event.repeat {
let target = self.interaction.focus_next(&layout.widgets, shift);
self.focus = target.and_then(|t| match t.action {
Some(Action::Focus(f)) => Some(f),
_ => None,
});
if self.focus == Some(Focus::Input) {
self.cursor = self.input.len();
}
}
return true;
}
let control = self
.interaction
.focused(&layout.widgets)
.is_some_and(|t| t.role != Role::TextField);
if control
&& matches!(
event.logical_key,
Key::Named(NamedKey::Enter | NamedKey::Space)
)
{
if event.state == ElementState::Pressed {
if !event.repeat {
self.interaction.key_press(&layout.widgets);
}
} else {
let action = self.interaction.key_release(&layout.widgets);
self.activate(action, layout, Point::default(), activity);
}
return true;
}
false
}
pub fn move_pointer(
&mut self,
@@ -330,6 +396,7 @@ impl DeveloperToolsState {
layout: &DeveloperToolsLayout,
window_width: f32,
) {
self.interaction.pointer_moved(p, &layout.widgets);
match self.drag {
Some(Drag::Split(Split::Dock)) => {
self.panel_width =
@@ -468,6 +535,12 @@ impl DeveloperToolsState {
}
pub fn key(&mut self, key: &winit::keyboard::NamedKey, shift: bool, command: bool) {
use winit::keyboard::NamedKey::*;
if *key == Escape {
self.focus = None;
self.preedit.clear();
self.interaction.blur();
return;
}
if self.focus == Some(Focus::Custom) && *key == Enter {
let hex = self.custom.trim_start_matches('#');
if hex.len() == 6
@@ -623,66 +696,83 @@ impl DeveloperToolsState {
self.reveal_cursor();
}
fn submit(&mut self) {
if self.input.trim().is_empty() {
self.submit_console(false);
}
fn submit_console(&mut self, reset: bool) {
if !reset && self.input.trim().is_empty() {
return;
}
let source = self.input.clone();
let script = self.script;
let source = if reset {
String::new()
} else {
self.input.clone()
};
let proxy = self.proxy.clone();
// A real loopback request keeps Console and external integrations on the same API path.
match thread::Builder::new().name("tessera-console-client".into()).spawn(move || {
let send=|| -> std::io::Result<()> {
let spawned=thread::Builder::new().name("tessera-console-client".into()).spawn(move||{
let send=||->std::io::Result<()> {
let mut stream=TcpStream::connect_timeout(&"127.0.0.1:4737".parse().unwrap(),Duration::from_secs(2))?;
stream.set_read_timeout(Some(Duration::from_secs(120)))?;stream.set_write_timeout(Some(Duration::from_secs(10)))?;
let (method,path)=if script {("PUT","code")}else{("POST","evaluate")};
write!(stream,"{method} /v1/namespaces/app.main/{path} HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\nContent-Type: text/plain; charset=utf-8\r\nX-Tessera-Origin: console\r\nContent-Length: {}\r\n\r\n{}",source.len(),source)?;
let method=if reset{"DELETE"}else{"POST"};
write!(stream,"{method} /v1/namespaces/app.main/repl HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\nContent-Type: text/plain; charset=utf-8\r\nX-Tessera-Origin: console\r\nContent-Length: {}\r\n\r\n{}",source.len(),source)?;
let mut response=String::new();stream.read_to_string(&mut response)?;Ok(())
};
if let Err(error)=send() && let Some(proxy)=proxy {let _=proxy.send_event(AppEvent::ConsoleFailed {message:error.to_string(),source});}
}) { Ok(_)=> {self.history.push(self.input.clone()); if self.history.len()>80{self.history.remove(0);}self.input.clear();self.cursor=0;self.history_index=None;self.scroll[Region::Input as usize]=Scroll::default();self.follow=true;self.input_error.clear();},Err(e)=>self.input_error=e.to_string() }
if let Err(error)=send()&&let Some(proxy)=proxy{let _=proxy.send_event(AppEvent::ConsoleFailed{message:error.to_string(),source});}
});
match spawned {
Ok(_) => {
if !reset {
self.history.push(self.input.clone());
if self.history.len() > 80 {
self.history.remove(0);
}
self.input.clear();
self.cursor = 0;
self.history_index = None;
self.scroll[Region::Input as usize] = Scroll::default();
}
self.follow = true;
self.input_error.clear();
}
Err(error) => self.input_error = error.to_string(),
}
}
}
struct Painter {
list: DisplayList,
ui: Ui<Action>,
layout: DeveloperToolsLayout,
accent: Color,
}
impl Painter {
fn fill(&mut self, r: Rect, c: Color) {
self.list.push(DrawCommand::FillRoundedRect {
rect: r,
radius: 0.0,
color: c,
});
self.ui.fill(r, c);
}
fn label(&mut self, x: f32, y: f32, value: &str, c: Color, code: bool) {
self.list.push(DrawCommand::Text {
origin: Point::new(x, y),
value: value.into(),
style: if code {
TextStyle::code()
} else {
TextStyle {
font_size: 12.0,
line_height: 18.0,
..TextStyle::ui(1)
}
},
color: c,
});
self.ui.label(x, y, value, c, code);
}
fn button(&mut self, r: Rect, label: &str, action: Action, active: bool) {
if active {
self.fill(r, tint(self.accent));
}
self.label(r.x + 10.0, r.y + 6.0, label, TEXT, false);
self.layout.actions.push((r, action));
let role = match action {
Action::Tab(_) => Role::Tab,
Action::Follow | Action::Snapshot | Action::Cloud => Role::Toggle,
_ => Role::Button,
};
self.ui
.button(r, action, Button::new(label).selected(active).role(role));
}
fn enabled_button(&mut self, r: Rect, label: &str, action: Action, enabled: bool) {
self.ui
.button(r, action, Button::new(label).enabled(enabled));
}
fn split(&mut self, r: Rect, kind: Split) {
self.fill(r, BORDER);
self.ui.splitter(
r,
WidgetId::new(("split", kind)),
match kind {
Split::Dock | Split::Tree => Axis::Horizontal,
_ => Axis::Vertical,
},
);
self.layout.splits.push((
Rect::new(r.x - 2.0, r.y - 2.0, r.width + 4.0, r.height + 4.0),
Rect::new(r.x - 3.0, r.y - 3.0, r.width + 6.0, r.height + 6.0),
kind,
));
}
@@ -720,7 +810,7 @@ impl Painter {
s.y.clamp(0.0, (content_h - area.height + 12.0).max(0.0))
};
s.x = s.x.clamp(0.0, (content_w - area.width + 12.0).max(0.0));
self.list.push(DrawCommand::PushClip(Rect::new(
self.ui.list.push(DrawCommand::PushClip(Rect::new(
area.x,
area.y,
(area.width - 9.0).max(0.0),
@@ -731,24 +821,26 @@ impl Painter {
for (i, line) in lines.iter().enumerate().skip(first).take(count) {
let y = area.y + 5.0 + i as f32 * ROW - s.y;
if line.divider {
self.fill(Rect::new(area.x, y, area.width, 1.0), self.accent);
self.fill(Rect::new(area.x, y, area.width, 1.0), self.ui.theme.accent);
}
if line.selected {
self.fill(Rect::new(area.x, y, area.width, ROW), tint(self.accent));
}
self.label(area.x + 8.0 - s.x, y, &line.value, line.color, true);
let paint = Rect::new(area.x, y, area.width, ROW);
if let Some(action) = &line.action {
let top = y.max(area.y);
let bottom = (y + ROW).min(area.y + area.height - 9.0);
if bottom > top {
self.layout.actions.push((
self.ui.row(
paint,
Rect::new(area.x, top, area.width - 9.0, bottom - top),
action.clone(),
));
line.selected,
);
}
} else if line.selected {
self.fill(paint, self.ui.theme.soft());
}
self.label(area.x + 8.0 - s.x, y, &line.value, line.color, true);
}
self.list.push(DrawCommand::PopClip);
self.ui.list.push(DrawCommand::PopClip);
self.layout
.regions
.push((area, region, content_w, content_h));
@@ -775,7 +867,11 @@ impl Painter {
} else {
Rect::new(track.x + 1.0, track.y + position, 6.0, length)
};
self.fill(thumb, Color::rgb(161, 173, 190));
self.ui.scrollbar(
thumb,
WidgetId::new(("scroll", region, h)),
if h { Axis::Horizontal } else { Axis::Vertical },
);
self.layout
.thumbs
.push((thumb, region, h, maximum / travel));
@@ -800,19 +896,8 @@ impl Line {
}
}
}
fn readable_accent(mut c: Color) -> Color {
// Keep an accent visible on white while retaining the chosen hue.
while (c.red as u32 * 299 + c.green as u32 * 587 + c.blue as u32 * 114) / 1000 > 155 {
c = Color::rgb(
(c.red as f32 * 0.94) as u8,
(c.green as f32 * 0.94) as u8,
(c.blue as f32 * 0.94) as u8,
);
}
c
}
fn tint(c: Color) -> Color {
Color::rgb(232 + c.red / 12, 232 + c.green / 12, 232 + c.blue / 12)
Theme::new(c).soft()
}
fn multiline(out: &mut Vec<Line>, value: &str, color: Color) {
out.extend(
@@ -824,6 +909,33 @@ fn multiline(out: &mut Vec<Line>, value: &str, color: Color) {
}
fn console_result(out: &mut Vec<Line>, body: &str, color: Color) {
if let Ok(value) = serde_json::from_str::<serde_json::Value>(body) {
if value["execution"] == "repl" {
out.push(Line::new(
if value["rendered"] == true {
format!(
"Rendered revision {} · session {}",
value["revision"], value["session"]
)
} else {
format!(
"Session {} · retained in memory; page unchanged",
value["session"]
)
},
MUTED,
));
}
if value["session_reset"] == true {
multiline(
out,
value["message"]
.as_str()
.or(value["error"].as_str())
.unwrap_or("Session reset"),
color,
);
return;
}
if let Some(result) = value["value"].as_str() {
multiline(out, result, color);
return;
@@ -884,15 +996,14 @@ pub fn build(
let x = width - w;
let panel = Rect::new(x, 0.0, w, height);
let mut p = Painter {
list: DisplayList::default(),
ui: Ui::new(Theme::new(state.accent), state.interaction.clone()),
layout: DeveloperToolsLayout {
panel,
..Default::default()
},
accent: state.accent,
};
p.fill(panel, BG);
p.list.push(DrawCommand::PushClip(panel));
p.ui.list.push(DrawCommand::PushClip(panel));
p.fill(Rect::new(x, 0.0, w, 31.0), BAR);
p.split(Rect::new(x, 0.0, 1.0, height), Split::Dock);
for (i, (label, tab)) in [
@@ -906,9 +1017,6 @@ pub fn build(
{
let r = Rect::new(x + 5.0 + i as f32 * 75.0, 0.0, 75.0, 30.0);
p.button(r, label, Action::Tab(*tab), state.tab == *tab);
if state.tab == *tab {
p.fill(Rect::new(r.x, 29.0, r.width, 2.0), state.accent);
}
}
p.button(
Rect::new(width - 32.0, 0.0, 31.0, 30.0),
@@ -927,11 +1035,14 @@ pub fn build(
match state.tab {
Tab::Console => {
p.fill(Rect::new(x, 32.0, w, 30.0), BAR);
p.button(
p.enabled_button(
Rect::new(x + 3.0, 32.0, 62.0, 29.0),
"Clear",
Action::ClearConsole,
false,
records.iter().any(|r| {
r.id > state.console_after
&& matches!(r.method.as_str(), "PUT" | "POST" | "DELETE")
}),
);
p.button(
Rect::new(x + 68.0, 32.0, 106.0, 29.0),
@@ -943,13 +1054,15 @@ pub fn build(
Action::Follow,
state.follow,
);
p.label(
x + 184.0,
39.0,
"app.main · execution transcript",
MUTED,
p.button(
Rect::new(x + 181.0, 32.0, 119.0, 29.0),
"Reset session",
Action::ResetSession,
false,
);
if w > 520.0 {
p.label(x + 309.0, 39.0, "app.main · live objects", MUTED, false);
}
let editor = state
.editor_height
.clamp(100.0, (height - 170.0).max(100.0));
@@ -959,10 +1072,16 @@ pub fn build(
r.id > state.console_after
&& (r.method == "PUT" || r.method == "POST" || r.method == "DELETE")
}) {
let kind = if r.path.ends_with("/evaluate") {
"EXPRESSION · fresh VM"
let kind = if r.path.ends_with("/repl") {
if r.method == "DELETE" {
"RESET SESSION"
} else {
"REPL · live objects"
}
} else if r.path.ends_with("/evaluate") {
"ISOLATED API EVALUATION"
} else if r.method == "PUT" {
"SCRIPT · replace snapshot"
"FULL SOURCE · new run"
} else {
"CLEAR DOCUMENT"
};
@@ -993,7 +1112,7 @@ pub fn build(
if lines.is_empty() {
multiline(
&mut lines,
"Console\n\nEvaluate an expression, or submit a complete UI script.\nExternal HTTP executions appear here as they happen.\n\nEach request starts a fresh VM. Bindings do not persist.\nPersistent REPL sessions are not connected.\nNo history is replayed.",
"Console\n\nStatements, definitions and expressions share one live session.\nCreate objects now; call page.render(...) when ready to display.\nUse title = ui.text(\"你好,Tessera\") or let title = ...\nThe last value is also available as _.\n\nReset session clears objects and bindings, preserving the page.\nRuntime errors may retain earlier successful statements.\nExternal HTTP activity appears here too. History is never replayed.",
MUTED,
);
}
@@ -1007,26 +1126,25 @@ pub fn build(
);
p.split(Rect::new(x + 1.0, split_y, w - 2.0, 1.0), Split::Editor);
p.fill(Rect::new(x + 1.0, split_y + 1.0, w - 2.0, 32.0), BAR);
p.button(
Rect::new(x + 5.0, split_y + 2.0, 190.0, 30.0),
if state.script {
"Script · replace page ⇄"
} else {
"Expression · fresh VM ⇄"
},
Action::Mode,
true,
p.label(
x + 12.0,
split_y + 8.0,
"Console · live session · render to display",
TEXT,
false,
);
p.button(
p.enabled_button(
Rect::new(width - 95.0, split_y + 2.0, 89.0, 30.0),
"Run ↵",
Action::Submit,
false,
!state.input.trim().is_empty(),
);
let input_area = Rect::new(x + 3.0, split_y + 35.0, w - 6.0, (editor - 62.0).max(24.0));
p.layout
.actions
.push((input_area, Action::Focus(Focus::Input)));
p.ui.text_field(
input_area,
Action::Focus(Focus::Input),
state.focus == Some(Focus::Input),
);
if state.selection && state.focus == Some(Focus::Input) {
p.fill(input_area, tint(state.accent));
}
@@ -1041,12 +1159,7 @@ pub fn build(
input.insert_str(state.cursor, &format!("{}│", state.preedit));
}
if input.is_empty() {
input = if state.script {
"// Complete script; must render a page"
} else {
"// Try \"Hello Endor\""
}
.into();
input = "// title = ui.text(\"你好,Tessera\")".into();
}
let mut input_lines = Vec::new();
multiline(&mut input_lines, &input, TEXT);
@@ -1140,7 +1253,16 @@ pub fn build(
code_x + 10.0,
69.0,
&format!(
"app.main.endor · {} lines · read only",
"{} · {} lines · read only",
if doc
.root
.as_ref()
.is_some_and(|root| root.kind == "repl-session")
{
"Console transcript"
} else {
"app.main.endor"
},
doc.source.split('\n').count()
),
MUTED,
@@ -1196,20 +1318,17 @@ pub fn build(
}
Tab::Network => {
p.fill(Rect::new(x, 32.0, w, 30.0), BAR);
p.button(
p.enabled_button(
Rect::new(x + 3.0, 32.0, 62.0, 29.0),
"Clear",
Action::ClearNetwork,
false,
records.iter().any(|r| r.id > state.network_after),
);
let filter_area = Rect::new(x + 72.0, 35.0, (w - 85.0).max(100.0), 24.0);
p.fill(
p.ui.text_field(
filter_area,
if state.focus == Some(Focus::Filter) {
tint(state.accent)
} else {
BG
},
Action::Focus(Focus::Filter),
state.focus == Some(Focus::Filter),
);
p.label(
filter_area.x + 7.0,
@@ -1226,9 +1345,7 @@ pub fn build(
MUTED,
false,
);
p.layout
.actions
.push((filter_area, Action::Focus(Focus::Filter)));
p.label(
x + 10.0,
69.0,
@@ -1318,11 +1435,7 @@ pub fn build(
);
for (i, color) in PALETTE.iter().enumerate() {
let r = Rect::new(x + 24.0 + i as f32 * 44.0, 122.0, 32.0, 32.0);
p.fill(r, *color);
if *color == state.accent {
p.label(r.x + 10.0, r.y + 6.0, "✓", BG, false);
}
p.layout.actions.push((r, Action::Theme(i)));
p.ui.swatch(r, Action::Theme(i), *color, *color == state.accent);
}
p.label(
x + 24.0,
@@ -1332,7 +1445,11 @@ pub fn build(
false,
);
let custom = Rect::new(x + 24.0, 204.0, 200.0, 32.0);
p.fill(custom, BAR);
p.ui.text_field(
custom,
Action::Focus(Focus::Custom),
state.focus == Some(Focus::Custom),
);
p.label(
custom.x + 10.0,
custom.y + 6.0,
@@ -1348,9 +1465,7 @@ pub fn build(
TEXT,
true,
);
p.layout
.actions
.push((custom, Action::Focus(Focus::Custom)));
if !state.input_error.is_empty() {
p.label(x + 24.0, 245.0, &state.input_error, ERROR, false);
}
@@ -1386,9 +1501,9 @@ pub fn build(
MUTED,
false,
);
p.list.push(DrawCommand::PopClip);
p.ui.list.push(DrawCommand::PopClip);
let mut scaled = DisplayList::default();
for cmd in p.list.commands() {
for cmd in p.ui.list.commands() {
let rect =
|r: &Rect| Rect::new(r.x * scale, r.y * scale, r.width * scale, r.height * scale);
scaled.push(match cmd {
@@ -1413,9 +1528,22 @@ pub fn build(
color: *color,
},
DrawCommand::PushClip(r) => DrawCommand::PushClip(rect(r)),
DrawCommand::StrokeRoundedRect {
rect: r,
radius,
width,
color,
} => DrawCommand::StrokeRoundedRect {
rect: rect(r),
radius: radius * scale,
width: width * scale,
color: *color,
},
other => other.clone(),
});
}
p.layout.widgets = p.ui.targets;
state.repaint = state.interaction.reconcile(&p.layout.widgets);
(scaled, p.layout)
}
fn request_details(out: &mut Vec<Line>, r: &Exchange) {