2026-11-09 08:37:33 +00:00
|
|
|
|
// Menus like the original's (captured from the reference assistant itself): 200 px wide, 16 px corners, rows
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
// 32 px tall with a 16 px icon on the left and 14 px text, a soft rounded highlight, hairline
|
|
|
|
|
|
// separators between groups, a red 刪除 with a bin, and "›" on rows that open a submenu.
|
|
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
pub const MENU_W: f32 = 200.0;
|
|
|
|
|
|
const ROW_H: f32 = 32.0;
|
|
|
|
|
|
|
|
|
|
|
|
fn row(ui: &mut egui::Ui, p: Palette, icon: Option<crate::icons::Icon>, label: &str, col: Color32, chevron: bool) -> egui::Response {
|
|
|
|
|
|
// Rows touch (no gap between them) and the menu stays its own width, not the screen's.
|
|
|
|
|
|
ui.spacing_mut().item_spacing.y = 0.0;
|
2026-11-16 13:51:30 +00:00
|
|
|
|
let galley_w = ui.painter().layout_no_wrap(label.to_string(), egui::FontId::proportional(FONT_BASE), col).size().x;
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
let w = ui.min_rect().width().max(MENU_W - 12.0).max(galley_w + if icon.is_some() { 64.0 } else { 36.0 });
|
|
|
|
|
|
let (rect, r) = ui.allocate_exact_size(vec2(w, ROW_H), egui::Sense::click());
|
|
|
|
|
|
if r.hovered() {
|
2026-11-16 13:51:30 +00:00
|
|
|
|
ui.painter().rect_filled(rect, R_M, p.hover);
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
let x = rect.left() + 10.0;
|
|
|
|
|
|
if let Some(ic) = icon {
|
|
|
|
|
|
let icol = if col == p.danger { p.danger } else { p.text2 };
|
|
|
|
|
|
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(egui::pos2(x + 8.0, rect.center().y), vec2(16.0, 16.0)), ic, icol);
|
|
|
|
|
|
}
|
|
|
|
|
|
let tx = if icon.is_some() { x + 28.0 } else { x + 2.0 };
|
2026-11-16 13:51:30 +00:00
|
|
|
|
ui.painter().text(egui::pos2(tx, rect.center().y), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(FONT_BASE), col);
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
if chevron {
|
|
|
|
|
|
let c = egui::pos2(rect.right() - 14.0, rect.center().y);
|
|
|
|
|
|
let st = Stroke::new(1.4, p.text3);
|
|
|
|
|
|
ui.painter().line_segment([c + vec2(-2.5, -4.5), c + vec2(2.0, 0.0)], st);
|
|
|
|
|
|
ui.painter().line_segment([c + vec2(-2.5, 4.5), c + vec2(2.0, 0.0)], st);
|
|
|
|
|
|
}
|
|
|
|
|
|
r.on_hover_cursor(egui::CursorIcon::PointingHand)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// One menu row with an icon.
|
|
|
|
|
|
pub fn item(ui: &mut egui::Ui, p: Palette, icon: crate::icons::Icon, label: &str) -> egui::Response {
|
|
|
|
|
|
row(ui, p, Some(icon), &t(label), p.text, false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A row whose words are already translated / built.
|
|
|
|
|
|
pub fn item_text(ui: &mut egui::Ui, p: Palette, icon: Option<crate::icons::Icon>, label: &str) -> egui::Response {
|
|
|
|
|
|
row(ui, p, icon, label, p.text, false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// The red one (刪除…).
|
|
|
|
|
|
pub fn danger(ui: &mut egui::Ui, p: Palette, icon: crate::icons::Icon, label: &str) -> egui::Response {
|
|
|
|
|
|
row(ui, p, Some(icon), &t(label), p.danger, false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A row that opens a submenu on hover ("›").
|
|
|
|
|
|
pub fn sub<R>(ui: &mut egui::Ui, p: Palette, icon: crate::icons::Icon, label: &str, content: impl FnOnce(&mut egui::Ui) -> R) {
|
|
|
|
|
|
let r = row(ui, p, Some(icon), &t(label), p.text, true);
|
|
|
|
|
|
egui::containers::menu::SubMenu::new().show(ui, &r, |ui| {
|
|
|
|
|
|
ui.set_min_width(MENU_W - 12.0);
|
|
|
|
|
|
content(ui)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A hairline between groups.
|
|
|
|
|
|
pub fn sep(ui: &mut egui::Ui, p: Palette) {
|
|
|
|
|
|
ui.spacing_mut().item_spacing.y = 0.0;
|
|
|
|
|
|
ui.add_space(4.0);
|
|
|
|
|
|
let (rect, _) = ui.allocate_exact_size(vec2(ui.min_rect().width().max(MENU_W - 12.0), 1.0), egui::Sense::hover());
|
|
|
|
|
|
ui.painter().hline(rect.x_range().shrink(8.0), rect.center().y, Stroke::new(1.0, p.border));
|
|
|
|
|
|
ui.add_space(4.0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Small grey words above a group of rows.
|
|
|
|
|
|
pub fn caption(ui: &mut egui::Ui, p: Palette, text: &str) {
|
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
|
ui.add_space(10.0);
|
2026-11-16 13:51:30 +00:00
|
|
|
|
ui.label(RichText::new(t(text)).size(FONT_XS).color(p.text3));
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
}
|