外觀: the bot is the lead — its face over the input says what it is doing, its colour runs through the chat, requests dock above the input
- 思源黑體 (Noto Sans TC Regular, OFL, bundled) is the default font; 粉圓體 and the system font stay as choices - the chat takes the bot's colour by default: the person's bubble, the send button, the chosen tile (a little of it) - the bot's words sit on the page without a bubble; the person's bubble has its small corner toward them - above the input: the bot's face, looking at the input when idle, up while it thinks, across at 「正在…」 while a step runs, at the person (yellow dot) when it needs them, smiling for 2 s when done, flat-eyed after an error - 需要你允許 is a yellow card docked above the input instead of a pop-up over the window; Enter allows and Esc refuses while the input is empty, after the card has been up 0.6 s; yellow is the one colour for 「需要你」 - header: the name at the left, plain buttons without rings; icons drawn a little heavier (2.25) - an empty chat: the face large, a line on what the bot is for, three things to start with - screenshot hook ANYBOT_SHOT_CALM Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3QxSfoydRPM9mjj6d
This commit is contained in:
parent
deec40fd02
commit
6a84abcaeb
Binary file not shown.
|
|
@ -99,3 +99,8 @@ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
NotoSansTC-Regular.otf (Noto Sans CJK TC, © 2014–2021 Adobe (http://www.adobe.com/), with
|
||||
Reserved Font Name 'Source') is also licensed under the SIL Open Font License, Version 1.1,
|
||||
the license text above. Source: https://github.com/notofonts/noto-cjk
|
||||
|
|
|
|||
218
src/app.rs
218
src/app.rs
|
|
@ -261,6 +261,10 @@ pub struct App {
|
|||
menu_for: Option<(u64, usize)>,
|
||||
/// Each face's motion (gaze, blink, pokes).
|
||||
faces: HashMap<u64, sidebar_ui::Face>,
|
||||
/// When each bot last finished a turn well (its face above the input smiles for a moment).
|
||||
cheer: HashMap<u64, Instant>,
|
||||
/// When each bot's request card was first shown (Enter answers it only after a moment).
|
||||
ask_shown: HashMap<u64, Instant>,
|
||||
search_open: bool,
|
||||
confirm_section_delete: Option<String>,
|
||||
/// A group being renamed: (old name, what is typed).
|
||||
|
|
@ -419,6 +423,8 @@ impl App {
|
|||
started_ms: crate::model::now_ms(),
|
||||
menu_for: None,
|
||||
faces: HashMap::new(),
|
||||
cheer: HashMap::new(),
|
||||
ask_shown: HashMap::new(),
|
||||
search_open: false,
|
||||
confirm_section_delete: None,
|
||||
renaming: None,
|
||||
|
|
@ -804,7 +810,11 @@ impl App {
|
|||
if std::env::var("ANYBOT_SHOT_DARK").is_ok() {
|
||||
app.state.theme = Theme::Dark;
|
||||
}
|
||||
// For checking each screen without the demo's waiting pop-up on top.
|
||||
// ANYBOT_SHOT_CALM=1: each screen without the demo's waiting pop-up and running turn on top.
|
||||
if std::env::var("ANYBOT_SHOT_CALM").is_ok() {
|
||||
app.approvals.clear();
|
||||
app.streams.clear();
|
||||
}
|
||||
// ANYBOT_SHOT_NEWER=<hours ago>: a newer build is waiting (重新啟動以更新), built that
|
||||
// long ago (0: just now).
|
||||
if let Ok(h) = std::env::var("ANYBOT_SHOT_NEWER") {
|
||||
|
|
@ -1423,6 +1433,7 @@ impl App {
|
|||
}
|
||||
if outcome == TurnOutcome::Success {
|
||||
self.read_reply(bot_id);
|
||||
self.cheer.insert(bot_id, Instant::now());
|
||||
}
|
||||
if outcome == TurnOutcome::Success {
|
||||
let now = self.faces.get(&bot_id).map(|f| f.now()).unwrap_or(0.0);
|
||||
|
|
@ -2448,8 +2459,8 @@ impl App {
|
|||
self.msg_index = i;
|
||||
self.chat_message(ui, ctx, &bot, m, last);
|
||||
}
|
||||
// While it works: the ring and the shimmering phrase.
|
||||
self.working_row(ui, &bot);
|
||||
// (What it is doing, and a request, sit above the input: see composer.
|
||||
// A hand-off keeps its card here, with the live screen.)
|
||||
self.approval_card(ui, ctx, &bot);
|
||||
ui.add_space(16.0);
|
||||
// Last in the content, so no code block's own scroll area takes it.
|
||||
|
|
@ -2509,64 +2520,69 @@ impl App {
|
|||
self.voice_toggle(&ctx, bot.id);
|
||||
}
|
||||
}
|
||||
if let Some(kind) = self.approvals.get(&bot.id).map(|a| a.kind) {
|
||||
let label = if kind == ApprovalKind::Handoff { t("等你處理") } else { t("需要你允許") };
|
||||
if crate::icons::pill(&mut right, crate::icons::Icon::Shield, &label, p.accent, Color32::WHITE, 36.0).on_hover_text(t("打開請求視窗")).clicked() {
|
||||
self.popup_hidden.remove(&bot.id);
|
||||
self.stick_bottom = true;
|
||||
}
|
||||
}
|
||||
let right_w = bar.right() - right.min_rect().left();
|
||||
// Middle: the name pill (face + name), centred, never under the buttons on the right.
|
||||
let font = egui::FontId::proportional(14.0);
|
||||
let name_w = ui.painter().layout_no_wrap(bot.name.clone(), font.clone(), p.text).size().x;
|
||||
let max_pill = (bar.width() - 2.0 * right_w - 24.0).max(120.0);
|
||||
let pill_w = (name_w + 52.0).min(max_pill);
|
||||
let mut cx = bar.center().x;
|
||||
if cx + pill_w / 2.0 > bar.right() - right_w - 8.0 {
|
||||
cx = bar.right() - right_w - 8.0 - pill_w / 2.0;
|
||||
}
|
||||
let rect = egui::Rect::from_center_size(egui::pos2(cx.max(bar.left() + pill_w / 2.0 + 8.0), bar.center().y), vec2(pill_w, 40.0));
|
||||
// Left: the bot's name, plain; a press opens the conversation's details.
|
||||
let font = egui::FontId::proportional(FONT_XL);
|
||||
let name = sidebar_ui::shorten_width(ui, &bot.name, (bar.width() - right_w - 48.0).max(60.0), FONT_XL);
|
||||
let galley = ui.painter().layout_no_wrap(name, font, p.text);
|
||||
let rect = egui::Rect::from_min_size(egui::pos2(bar.left() + 14.0, bar.center().y - 18.0), vec2(galley.size().x + 20.0, 36.0));
|
||||
let r = ui.interact(rect, egui::Id::unique(("name-pill", bot.id)), egui::Sense::click());
|
||||
ui.painter().rect_filled(rect, 20, if r.hovered() { p.hover } else { p.elevated });
|
||||
ui.painter().rect_stroke(rect, 20, Stroke::new(1.0, p.border), egui::StrokeKind::Inside);
|
||||
let mut inner = ui.new_child(egui::UiBuilder::new().max_rect(rect.shrink2(vec2(8.0, 0.0))).layout(Layout::left_to_right(Align::Center)));
|
||||
inner.spacing_mut().item_spacing.x = 8.0;
|
||||
let (face, _) = inner.allocate_exact_size(vec2(26.0, 26.0), egui::Sense::hover());
|
||||
if r.hovered() {
|
||||
ui.painter().rect_filled(rect, 10, p.hover);
|
||||
}
|
||||
ui.painter().galley(egui::pos2(rect.left() + 10.0, rect.center().y - galley.size().y / 2.0), galley, p.text);
|
||||
let _ = color;
|
||||
self.live_face(&mut inner, bot.id, face, true);
|
||||
inner.add(egui::Label::new(RichText::new(&bot.name).size(14.0).color(p.text)).truncate().selectable(false));
|
||||
let open = self.panel.is_some();
|
||||
if r.on_hover_text(t(if open { "關閉對話詳細資訊" } else { "查看對話詳細資訊" })).on_hover_cursor(egui::CursorIcon::PointingHand).clicked() {
|
||||
self.panel = if open { None } else { Some(PanelTab::Activity) };
|
||||
}
|
||||
}
|
||||
|
||||
/// A chat with nothing in it yet: the bot's face, large, a line on what it is for, and a
|
||||
/// few things to start with (a press puts the words in the input, to send or change).
|
||||
fn empty_state(&mut self, ui: &mut egui::Ui, bot: &Bot) {
|
||||
let p = self.pal;
|
||||
ui.add_space(70.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
avatar::avatar(ui, 72.0, &bot.shape, self.bot_color(bot));
|
||||
ui.add_space(10.0);
|
||||
ui.label(RichText::new(&bot.name).size(22.0).strong());
|
||||
if !bot.description.is_empty() {
|
||||
ui.label(RichText::new(&bot.description).color(p.text2));
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
ui.label(RichText::new(format!("使用 {}·{}", bot.provider.label(), bot.model)).size(12.0).color(p.text3));
|
||||
if bot.tools_enabled {
|
||||
ui.label(RichText::new(format!("可以在「{}」裡查看、修改檔案和執行指令,動手前會先問你", bot.workdir)).size(12.0).color(p.text3));
|
||||
}
|
||||
let ps = self.state.provider(bot.provider);
|
||||
if bot.provider.needs_key() && providers::resolve_key(bot.provider, &ps.api_key).is_empty() {
|
||||
ui.add_space(10.0);
|
||||
if ui.button(format!("設定 {} 的 API 金鑰", bot.provider.label())).clicked() {
|
||||
self.show_settings = true;
|
||||
self.settings_tab = SettingsTab::Providers;
|
||||
self.settings_provider = bot.provider;
|
||||
}
|
||||
}
|
||||
let col = self.bot_color(bot);
|
||||
let tinted = self.state.accent == Accent::BotColor && bot.color != "black";
|
||||
ui.add_space((ui.available_height() * 0.16).clamp(24.0, 110.0));
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 20.0;
|
||||
let (face, _) = ui.allocate_exact_size(vec2(104.0, 104.0), egui::Sense::hover());
|
||||
self.live_face(ui, bot.id, face, true);
|
||||
ui.vertical(|ui| {
|
||||
ui.add_space(22.0);
|
||||
ui.label(RichText::new(t("嗨,我是 {name}").replace("{name}", &bot.name)).size(28.0).strong().color(p.text));
|
||||
let about = if bot.description.is_empty() { t("想做什麼?直接說,或從下面挑一個開始。") } else { bot.description.clone() };
|
||||
ui.add(egui::Label::new(RichText::new(about).size(FONT_LG).color(p.text2)).wrap());
|
||||
});
|
||||
});
|
||||
ui.add_space(22.0);
|
||||
let fill = if tinted { crate::theme::mist(col, p) } else { p.hover };
|
||||
for words in EMPTY_STARTS {
|
||||
let words = t(words);
|
||||
let (rect, r) = ui.allocate_exact_size(vec2(ui.available_width().min(560.0), 48.0), egui::Sense::click());
|
||||
ui.painter().rect_filled(rect, 16, if r.hovered() { fill.gamma_multiply(0.92).to_opaque().lerp_to_gamma(p.text, 0.04) } else { fill });
|
||||
ui.painter().text(rect.left_center() + vec2(18.0, 0.0), egui::Align2::LEFT_CENTER, &words, egui::FontId::proportional(FONT_LG), p.text);
|
||||
if r.on_hover_cursor(egui::CursorIcon::PointingHand).clicked() {
|
||||
self.drafts.insert(bot.id, words);
|
||||
ui.memory_mut(|m| m.request_focus(egui::Id::unique(("composer", bot.id))));
|
||||
}
|
||||
ui.add_space(8.0);
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
ui.label(RichText::new(format!("{} · {}", bot.provider.label(), bot.model)).size(12.0).color(p.text3));
|
||||
if bot.tools_enabled {
|
||||
ui.add(egui::Label::new(RichText::new(format!("可以在「{}」裡查看、修改檔案和執行指令,動手前會先問你", bot.workdir)).size(12.0).color(p.text3)).wrap());
|
||||
}
|
||||
let ps = self.state.provider(bot.provider);
|
||||
if bot.provider.needs_key() && providers::resolve_key(bot.provider, &ps.api_key).is_empty() {
|
||||
ui.add_space(10.0);
|
||||
if ui.button(format!("設定 {} 的 API 金鑰", bot.provider.label())).clicked() {
|
||||
self.show_settings = true;
|
||||
self.settings_tab = SettingsTab::Providers;
|
||||
self.settings_provider = bot.provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// "The bot wants to …": allow once, always allow this kind, or say no.
|
||||
|
|
@ -2603,7 +2619,7 @@ impl App {
|
|||
None if !head.is_empty() => ui.label(RichText::new(head).size(12.0).color(p.text3)),
|
||||
None => ui.label(""),
|
||||
};
|
||||
Frame::new().fill(p.hover).corner_radius(8).inner_margin(Margin::symmetric(10, 6)).show(ui, |ui| {
|
||||
Frame::new().fill(p.elevated).corner_radius(10).inner_margin(Margin::symmetric(12, 8)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.add(egui::Label::new(RichText::new(detail).monospace().size(12.5).color(p.text)).wrap());
|
||||
});
|
||||
|
|
@ -2613,7 +2629,8 @@ impl App {
|
|||
ui.add_space(6.0);
|
||||
ui.horizontal(|ui| {
|
||||
let once = if kind == ApprovalKind::Action { "允許" } else { "允許這一次" };
|
||||
if ui.add(egui::Button::new(RichText::new(once).color(p.on_primary)).fill(p.primary).corner_radius(8).min_size(vec2(0.0, if big { 30.0 } else { 0.0 }))).clicked() {
|
||||
ui.spacing_mut().button_padding = vec2(14.0, 7.0);
|
||||
if ui.add(egui::Button::new(RichText::new(once).strong().color(p.on_primary)).fill(p.primary).corner_radius(12).min_size(vec2(0.0, if big { 34.0 } else { 0.0 }))).clicked() {
|
||||
answer = Some(ApprovalAnswer::Once);
|
||||
}
|
||||
let always = match kind {
|
||||
|
|
@ -2645,28 +2662,74 @@ impl App {
|
|||
|
||||
fn approval_card(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
|
||||
let p = self.pal;
|
||||
let Some(kind) = self.approvals.get(&bot.id).map(|a| a.kind) else { return };
|
||||
if kind == ApprovalKind::Handoff {
|
||||
let _ = p;
|
||||
if self.approvals.get(&bot.id).map(|a| a.kind) == Some(ApprovalKind::Handoff) {
|
||||
self.handoff_card(ui, ctx, bot);
|
||||
}
|
||||
}
|
||||
|
||||
/// 需要你允許, docked above the input (it used to be a pop-up over the whole window, hiding
|
||||
/// what the bot had just said): the question on the yellow that means 「需要你」, with the
|
||||
/// chat still readable above and the input still there to say it differently. Enter allows
|
||||
/// and Esc refuses while the input is empty — once the card has been up for a moment, so an
|
||||
/// Enter meant for something else can't answer a request that just appeared.
|
||||
fn approval_dock(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot, draft_empty: bool, typing: bool) {
|
||||
let p = self.pal;
|
||||
let asking = self.approvals.get(&bot.id).is_some_and(|a| a.kind != ApprovalKind::Handoff);
|
||||
if !asking {
|
||||
self.ask_shown.remove(&bot.id);
|
||||
return;
|
||||
}
|
||||
let shown = self.ask_shown.entry(bot.id).or_insert_with(Instant::now).elapsed().as_secs_f32();
|
||||
let mut answer = None;
|
||||
let width = ui.available_width() - 32.0 - 28.0;
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.add_space(32.0);
|
||||
Frame::new().fill(p.elevated).stroke(Stroke::new(2.0, p.accent)).corner_radius(14).inner_margin(Margin::symmetric(14, 12)).show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(width);
|
||||
answer = self.approval_body(ui, bot, false);
|
||||
});
|
||||
});
|
||||
Frame::new().fill(p.attention_bg).stroke(Stroke::new(2.0, p.attention)).corner_radius(20).inner_margin(Margin::symmetric(16, 14)).show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
answer = self.approval_body(ui, bot, true);
|
||||
ui.add_space(2.0);
|
||||
ui.label(RichText::new(t("輸入框空著時:Enter 允許,Esc 拒絕")).size(11.5).color(p.text2));
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
ui.add_space(6.0);
|
||||
if answer.is_none() && draft_empty && !typing && shown > 0.6 && !egui::Popup::is_any_open(ctx) {
|
||||
let (enter, _) = ui.input_mut(chat_ui::take_enter);
|
||||
if enter {
|
||||
answer = Some(ApprovalAnswer::Once);
|
||||
} else if ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, Key::Escape)) {
|
||||
answer = Some(ApprovalAnswer::Reject);
|
||||
}
|
||||
}
|
||||
if let Some(ans) = answer {
|
||||
self.ask_shown.remove(&bot.id);
|
||||
self.answer(ctx, bot.id, ans);
|
||||
}
|
||||
}
|
||||
|
||||
/// The bot's face peeking over the input, and beside it what it is doing (see dock_face).
|
||||
/// Not in an empty chat, where the face is the big one in the middle.
|
||||
fn face_dock(&mut self, ui: &mut egui::Ui, bot: &Bot) {
|
||||
if bot.messages.is_empty() {
|
||||
return;
|
||||
}
|
||||
let p = self.pal;
|
||||
let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 40.0), egui::Sense::hover());
|
||||
// (Its chin goes behind the input, which is drawn after it; the eyes stay clear.)
|
||||
let face = egui::Rect::from_min_size(row.left_top() + vec2(14.0, -10.0), vec2(64.0, 64.0));
|
||||
self.dock_face(ui, bot, face);
|
||||
let now = ui.input(|i| i.time);
|
||||
let waiting = self.approvals.contains_key(&bot.id);
|
||||
let words = if waiting { Some(t("等你決定")) } else { self.working_phrase(now, bot) };
|
||||
if let Some(words) = words {
|
||||
let col = self.bot_color(bot);
|
||||
let col = if bot.color == "black" || self.state.accent != Accent::BotColor || waiting { p.text } else { col };
|
||||
let mut at = ui.new_child(egui::UiBuilder::new().max_rect(egui::Rect::from_min_max(egui::pos2(face.right() + 10.0, row.top()), row.right_bottom())).layout(Layout::left_to_right(Align::Center)));
|
||||
let words = sidebar_ui::shorten_width(&at, &words, at.available_width() - 8.0, 13.5);
|
||||
if waiting {
|
||||
at.label(RichText::new(words).size(13.5).strong().color(col));
|
||||
} else {
|
||||
chat_ui::shimmer(&mut at, &words, col.gamma_multiply(0.75), col, 13.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 需要處理 (the original's box hand-off card): what the bot needs the person to do, the
|
||||
/// computer's live screen with 「接管」 on it, and 跳過 / 我完成了 / 接管.
|
||||
fn handoff_card(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
|
||||
|
|
@ -2798,6 +2861,7 @@ impl App {
|
|||
}
|
||||
|
||||
/// The pop-up: a dimmed window with the request in the middle, so it can't be missed.
|
||||
#[allow(dead_code)]
|
||||
fn approval_popup(&mut self, ctx: &egui::Context) {
|
||||
let selected = self.state.selected;
|
||||
// (A hand-off is the card in the chat, with the live screen, like the original's.)
|
||||
|
|
@ -2937,12 +3001,15 @@ impl App {
|
|||
s.store(ctx, composer_id);
|
||||
ui.memory_mut(|m| m.request_focus(composer_id));
|
||||
}
|
||||
// The original's input: one 44 px pill — +, the words, the mic, and a round button in the
|
||||
// 需要你允許, then the bot's face peeking over the input with what it is doing.
|
||||
self.approval_dock(ui, ctx, bot, draft.trim().is_empty(), composing);
|
||||
self.face_dock(ui, bot);
|
||||
// The input: one box with an ink edge — +, the words, the mic, and a button in the
|
||||
// bot's colour (voice chat while empty, send ↑ once there is something to send).
|
||||
Frame::new()
|
||||
.fill(p.elevated)
|
||||
.stroke(Stroke::new(1.0, if had_focus { p.border.gamma_multiply(1.8) } else { p.border }))
|
||||
.corner_radius(22)
|
||||
.stroke(Stroke::new(1.5, if had_focus { p.text } else { p.text.gamma_multiply(0.45) }))
|
||||
.corner_radius(20)
|
||||
.inner_margin(Margin { left: 8, right: 8, top: 8, bottom: 8 })
|
||||
.show(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
|
|
@ -3704,7 +3771,7 @@ impl App {
|
|||
});
|
||||
setting_row(ui, p, "字型", "AnyBot 畫面使用的字型", |ui| {
|
||||
let cur = crate::font_choice();
|
||||
for (v, n) in [("system", "系統字型"), ("huninn", "粉圓體")] {
|
||||
for (v, n) in [("noto", "思源黑體"), ("system", "系統字型"), ("huninn", "粉圓體")] {
|
||||
if ui.selectable_label(cur == v, t(n)).clicked() && cur != v {
|
||||
if let Some(d) = State::path().parent() {
|
||||
let _ = std::fs::create_dir_all(d);
|
||||
|
|
@ -4515,7 +4582,6 @@ impl eframe::App for App {
|
|||
self.rebuild_dialog(ctx);
|
||||
self.local_control_bar(ctx);
|
||||
self.teach_bar(ctx);
|
||||
self.approval_popup(ctx);
|
||||
self.file_viewer(ctx);
|
||||
self.splash(ctx);
|
||||
self.drop_overlay(ctx);
|
||||
|
|
@ -4956,25 +5022,29 @@ fn composer_box_h(text_h: f32, max_h: f32) -> f32 {
|
|||
(text_h + COMPOSER_TOP + 3.0).clamp(28.0, max_h.max(28.0))
|
||||
}
|
||||
|
||||
/// The input's 28 px round buttons (+, mic, voice chat / send).
|
||||
/// What an empty chat offers to start with.
|
||||
const EMPTY_STARTS: [&str; 3] = ["幫我規劃這個週末的行程", "把這段文字改得更清楚好讀", "查一件事,整理成三個重點"];
|
||||
|
||||
/// The input's 28 px buttons (+, mic, voice chat / send).
|
||||
fn round_tool(ui: &mut egui::Ui, icon: crate::icons::Icon, fill: Color32, ink: Color32) -> egui::Response {
|
||||
let (rect, r) = ui.allocate_exact_size(vec2(28.0, 28.0), egui::Sense::click());
|
||||
let f = if r.hovered() { fill.gamma_multiply(0.82).to_opaque().lerp_to_gamma(fill, 0.3) } else { fill };
|
||||
ui.painter().circle_filled(rect.center(), 14.0, f);
|
||||
ui.painter().rect_filled(rect, 10, f);
|
||||
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(rect.center(), vec2(15.0, 15.0)), icon, ink);
|
||||
r.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
}
|
||||
|
||||
/// A 36 px rounded button with a hairline border (the original's 分享 / ⋯).
|
||||
fn pill_text(ui: &mut egui::Ui, text: &str, p: Palette) -> egui::Response {
|
||||
ui.add(egui::Button::new(RichText::new(text).size(14.0).color(p.text)).fill(p.elevated).stroke(Stroke::new(1.0, p.border)).corner_radius(18).min_size(vec2(0.0, 36.0)))
|
||||
ui.add(egui::Button::new(RichText::new(text).size(14.0).color(p.text)).fill(Color32::TRANSPARENT).stroke(Stroke::NONE).corner_radius(10).min_size(vec2(0.0, 36.0)))
|
||||
}
|
||||
|
||||
fn pill_icon(ui: &mut egui::Ui, icon: crate::icons::Icon, p: Palette) -> egui::Response {
|
||||
let (rect, r) = ui.allocate_exact_size(vec2(36.0, 36.0), egui::Sense::click());
|
||||
ui.painter().circle_filled(rect.center(), 18.0, if r.hovered() { p.hover } else { p.elevated });
|
||||
ui.painter().circle_stroke(rect.center(), 17.5, Stroke::new(1.0, p.border));
|
||||
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(rect.center(), vec2(16.0, 16.0)), icon, p.text2);
|
||||
if r.hovered() {
|
||||
ui.painter().rect_filled(rect, 10, p.hover);
|
||||
}
|
||||
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(rect.center(), vec2(18.0, 18.0)), icon, p.text);
|
||||
r.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -507,7 +507,8 @@ impl App {
|
|||
let rich = RichText::new(&shown_text).size(TRANSCRIPT_FONT).line_height(Some(TRANSCRIPT_LINE_HEIGHT)).color(text_col);
|
||||
let text_w = egui::WidgetText::from(rich.clone()).into_galley(ui, Some(egui::TextWrapMode::Extend), f32::INFINITY, egui::FontSelection::Default).size().x;
|
||||
let inner_w = text_w.min(max_w - 24.0).max(8.0);
|
||||
Frame::new().fill(fill).corner_radius(BUBBLE_RADIUS).inner_margin(bubble_margin()).show(ui, |ui| {
|
||||
// (Its corner toward the person is the small one.)
|
||||
Frame::new().fill(fill).corner_radius(CornerRadius { nw: 20, ne: 20, sw: 20, se: 6 }).inner_margin(bubble_margin()).show(ui, |ui| {
|
||||
ui.set_width(inner_w);
|
||||
ui.with_layout(Layout::top_down(Align::Min), |ui| {
|
||||
ui.add(egui::Label::new(rich).wrap());
|
||||
|
|
@ -587,7 +588,9 @@ impl App {
|
|||
let max_w = message_max_width(ui.available_width());
|
||||
let fill = if m.error { p.danger.gamma_multiply(0.12) } else { files_ui::agent_fill(p) };
|
||||
let col = if m.error { p.danger } else { p.text };
|
||||
Frame::new().fill(fill).corner_radius(BUBBLE_RADIUS).inner_margin(bubble_margin()).show(ui, |ui| {
|
||||
// The bot's words sit on the page like a document; only an error gets a bubble.
|
||||
let (fill, margin) = if m.error { (fill, bubble_margin()) } else { (Color32::TRANSPARENT, Margin::symmetric(2, 2)) };
|
||||
Frame::new().fill(fill).corner_radius(BUBBLE_RADIUS).inner_margin(margin).show(ui, |ui| {
|
||||
ui.set_max_width(max_w);
|
||||
ui.with_layout(Layout::top_down(Align::Min), |ui| self.markdown(ui, &m.text, col, streaming));
|
||||
});
|
||||
|
|
@ -761,12 +764,12 @@ impl App {
|
|||
ui.add_space(4.0);
|
||||
}
|
||||
|
||||
/// The working row at the end of the chat: ring + shimmering phrase.
|
||||
pub(super) fn working_row(&mut self, ui: &mut egui::Ui, bot: &Bot) {
|
||||
let p = self.pal;
|
||||
let Some(live) = self.streams.get(&bot.id) else { return };
|
||||
/// What the bot is doing now, in a few words (None when it isn't working): shown beside its
|
||||
/// face above the input. `now`: the window's clock, which turns the idle phrases.
|
||||
pub(super) fn working_phrase(&self, now: f64, bot: &Bot) -> Option<String> {
|
||||
let live = self.streams.get(&bot.id)?;
|
||||
let waiting = self.approvals.contains_key(&bot.id);
|
||||
let last = bot.messages.iter().rev().find(|m| m.role == Role::Assistant);
|
||||
let last = bot.messages.iter().rev().find(|m| m.role == Role::Assistant && !m.note);
|
||||
let running = last.and_then(|m| m.tool_calls.iter().rev().find(|c| matches!(c.status, ToolStatus::Running | ToolStatus::Waiting)));
|
||||
// Where it works, by the computer's name (its own computer is 「<name> 的電腦」).
|
||||
let named = running.and_then(|c| tools::args_of(&c.args)["computer"].as_str().map(String::from));
|
||||
|
|
@ -777,19 +780,9 @@ impl App {
|
|||
let from = bot.messages.iter().rposition(|m| m.role == Role::User && !m.steer).unwrap_or(0);
|
||||
let did_steps = bot.messages[from..].iter().any(|m| m.role == Role::Tool);
|
||||
let seed = live.turn_id.bytes().fold(0u64, |a, b| a.wrapping_mul(31).wrapping_add(b as u64));
|
||||
// The words change every few seconds while nothing new is running (the ring keeps the
|
||||
// window drawing, so no extra repaint is needed).
|
||||
let tick = seed.wrapping_add((ui.input(|i| i.time) / PHRASE_SECS) as u64);
|
||||
let tick = seed.wrapping_add((now / PHRASE_SECS) as u64);
|
||||
let place = named.as_deref().filter(|_| !on_box);
|
||||
let phrase = live.status.clone().unwrap_or_else(|| t(&status_phrase(running.map(|c| (c.name.as_str(), c.args.as_str())), place, waiting, has_text, did_steps, tick)));
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(6.0);
|
||||
ui.spacing_mut().item_spacing.x = 8.0;
|
||||
spinner(ui, 16.0, if waiting { p.accent } else { p.text2 });
|
||||
shimmer(ui, &phrase, p.text3, p.text, 14.0);
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
Some(live.status.clone().unwrap_or_else(|| t(&status_phrase(running.map(|c| (c.name.as_str(), c.args.as_str())), place, waiting, has_text, did_steps, tick))))
|
||||
}
|
||||
|
||||
pub(super) fn toggle_reaction(&mut self, bot_id: u64, idx: usize, e: &str) {
|
||||
|
|
|
|||
|
|
@ -73,9 +73,6 @@ impl App {
|
|||
pub(super) fn face_pose(&mut self, ctx: &egui::Context, id: u64, rect: egui::Rect, follow: bool) -> avatar::Pose {
|
||||
let now = ctx.input(|i| i.time);
|
||||
let pointer = ctx.input(|i| i.pointer.hover_pos());
|
||||
let f = self.faces.entry(id).or_insert_with(|| Face { gaze: egui::Vec2::ZERO, last: now, next_blink: now + 1.0 + 4.0 * rand01(id), blink_at: -10.0, poke: None });
|
||||
let dt = (now - f.last).clamp(0.0, 0.1) as f32;
|
||||
f.last = now;
|
||||
// Gaze: toward the pointer when it is near (within 2 face widths, like `fa`).
|
||||
let working = self.streams.contains_key(&id);
|
||||
let waiting = self.approvals.contains_key(&id);
|
||||
|
|
@ -101,7 +98,18 @@ impl App {
|
|||
} else {
|
||||
pointer_target
|
||||
};
|
||||
let f = self.faces.get_mut(&id).expect("face");
|
||||
self.settle_face(ctx, id, target, working)
|
||||
}
|
||||
|
||||
/// A face (kept under `key`) turning its eyes toward `target`, blinking now and then, and
|
||||
/// carrying out a poke; `busy` keeps the window drawing.
|
||||
fn settle_face(&mut self, ctx: &egui::Context, key: u64, target: egui::Vec2, busy: bool) -> avatar::Pose {
|
||||
let now = ctx.input(|i| i.time);
|
||||
let id = key;
|
||||
let working = busy;
|
||||
let f = self.faces.entry(key).or_insert_with(|| Face { gaze: egui::Vec2::ZERO, last: now, next_blink: now + 1.0 + 4.0 * rand01(key), blink_at: -10.0, poke: None });
|
||||
let dt = (now - f.last).clamp(0.0, 0.1) as f32;
|
||||
f.last = now;
|
||||
let k = 1.0 - 0.86f32.powf(dt * 60.0);
|
||||
f.gaze += (target - f.gaze) * k;
|
||||
// Blink every 2.5–6.5 s.
|
||||
|
|
@ -160,6 +168,43 @@ impl App {
|
|||
avatar::paint_posed(painter, rect, &b.shape, col, pose);
|
||||
}
|
||||
|
||||
/// The face above the input (the bot itself, looking at what it does): its eyes say how
|
||||
/// things stand — down at the input while it waits for words, up while it thinks, across at
|
||||
/// the line saying what it is doing, straight at the person (with a yellow dot) when it needs
|
||||
/// them, smiling for two seconds when it has finished, two flat lines after an error.
|
||||
pub(super) fn dock_face(&mut self, ui: &mut egui::Ui, bot: &Bot, rect: egui::Rect) {
|
||||
let ctx = ui.ctx().clone();
|
||||
let now = ctx.input(|i| i.time) as f32;
|
||||
let waiting = self.approvals.contains_key(&bot.id);
|
||||
let working = self.streams.contains_key(&bot.id);
|
||||
let last = bot.messages.iter().rev().find(|m| m.role == Role::Assistant && !m.note);
|
||||
let running = working && last.is_some_and(|m| m.tool_calls.iter().any(|c| matches!(c.status, ToolStatus::Running | ToolStatus::Waiting)));
|
||||
let cheer = self.cheer.get(&bot.id).is_some_and(|t| t.elapsed().as_secs_f32() < 2.0);
|
||||
let failed = !working && bot.messages.last().is_some_and(|m| m.error);
|
||||
let target = if waiting {
|
||||
vec2(0.0, 0.1)
|
||||
} else if running {
|
||||
vec2(0.9, 0.45 + 0.06 * (now * 2.0).sin())
|
||||
} else if working {
|
||||
vec2(0.55 * (now * 0.9).sin(), 0.85)
|
||||
} else {
|
||||
vec2(0.15, -0.75)
|
||||
};
|
||||
// (Its own state, apart from the same bot's face in the sidebar, which looks elsewhere.)
|
||||
let mut pose = self.settle_face(&ctx, !bot.id, target, working);
|
||||
pose.eyes = if cheer { avatar::Eyes::Smile } else if failed { avatar::Eyes::Flat } else { avatar::Eyes::Open };
|
||||
if cheer {
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(200));
|
||||
}
|
||||
let col = self.bot_color(bot);
|
||||
avatar::paint_posed(ui.painter(), rect, &bot.shape, col, pose);
|
||||
if waiting {
|
||||
let at = rect.right_top() + vec2(-8.0, 8.0);
|
||||
ui.painter().circle_filled(at, 8.0, self.pal.pane);
|
||||
ui.painter().circle_filled(at, 6.0, self.pal.attention);
|
||||
}
|
||||
}
|
||||
|
||||
/// The sidebar's contents (the panel itself, its width and dragging live in sidebar()).
|
||||
/// The bottom row (you, 連結應用程式) has its own fixed strip so it is never cut off.
|
||||
pub(super) fn sidebar_body(&mut self, ui: &mut egui::Ui) {
|
||||
|
|
@ -679,7 +724,9 @@ impl App {
|
|||
}
|
||||
let selected = self.state.selected == id;
|
||||
if selected || r.hovered() {
|
||||
ui.painter().rect_filled(hit, 14, if selected { p.active } else { p.hover });
|
||||
// The chosen bot's tile in a little of its own colour.
|
||||
let fill = if selected && self.state.accent == Accent::BotColor && b.color != "black" { crate::theme::mist(self.bot_color(&b), Palette { pane: p.sidebar, ..p }) } else if selected { p.active } else { p.hover };
|
||||
ui.painter().rect_filled(hit, 18, fill);
|
||||
}
|
||||
let face = egui::Rect::from_center_size(rect.center_top() + vec2(0.0, 36.0), vec2(56.0, 56.0));
|
||||
self.live_face(ui, id, face, true);
|
||||
|
|
@ -699,7 +746,11 @@ impl App {
|
|||
}
|
||||
let name = shorten_width(ui, &b.name, hit.width() - 8.0, 13.0);
|
||||
ui.painter().text(rect.center_top() + vec2(0.0, 80.0), egui::Align2::CENTER_CENTER, name, egui::FontId::proportional(13.0), p.text);
|
||||
if b.unread || self.approvals.contains_key(&id) {
|
||||
// 需要你 is yellow; something new to read is the small blue dot.
|
||||
if self.approvals.contains_key(&id) {
|
||||
ui.painter().circle_filled(face.right_top() + vec2(3.0, 3.0), 8.0, p.sidebar);
|
||||
ui.painter().circle_filled(face.right_top() + vec2(3.0, 3.0), 6.0, p.attention);
|
||||
} else if b.unread {
|
||||
ui.painter().circle_filled(face.right_top() + vec2(4.0, 2.0), 4.5, p.accent);
|
||||
}
|
||||
let r = r.on_hover_text(if is_primary { t("主要 Bot") } else { b.name.clone() }).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
|
@ -757,11 +808,10 @@ impl App {
|
|||
} else {
|
||||
b.messages.iter().rev().find(|m| m.role != Role::Tool && !m.text.is_empty()).map(|m| first_line(&m.text, 80)).filter(|s| !s.is_empty()).unwrap_or_else(|| b.description.clone())
|
||||
};
|
||||
let sub_col = if waiting { p.accent } else { p.text3 };
|
||||
let sub_col = if waiting { p.text } else { p.text3 };
|
||||
painter.galley(egui::pos2(tx, rect.top() + 30.0), one_line(sub, 13.0, sub_col), sub_col);
|
||||
if waiting {
|
||||
ui.painter().circle_filled(egui::pos2(rect.right() - 12.0, rect.center().y), 5.0, p.accent);
|
||||
ui.painter().circle_stroke(egui::pos2(rect.right() - 12.0, rect.center().y), 7.5, Stroke::new(1.5, p.accent.gamma_multiply(0.4)));
|
||||
ui.painter().circle_filled(egui::pos2(rect.right() - 12.0, rect.center().y), 6.0, p.attention);
|
||||
} else if b.unread {
|
||||
ui.painter().circle_filled(egui::pos2(rect.right() - 12.0, rect.center().y), 4.0, Color32::from_rgb(0x16, 0x80, 0xf3));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,19 @@ fn rounded_poly(rect: Rect, r: f32) -> Vec<Pos2> {
|
|||
}
|
||||
|
||||
/// How a face is held at this moment (the original's mark: gaze, blink, squash, lift, spin).
|
||||
/// What the eyes are doing besides looking: open, smiling (it just finished), or two flat
|
||||
/// lines (something went wrong).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Default)]
|
||||
pub enum Eyes {
|
||||
#[default]
|
||||
Open,
|
||||
Smile,
|
||||
Flat,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Pose {
|
||||
pub eyes: Eyes,
|
||||
/// Where it looks, -1…1 on each axis (y up).
|
||||
pub gaze: egui::Vec2,
|
||||
/// 0 = open, 1 = shut.
|
||||
|
|
@ -92,7 +103,7 @@ pub struct Pose {
|
|||
|
||||
impl Default for Pose {
|
||||
fn default() -> Self {
|
||||
Pose { gaze: egui::Vec2::ZERO, blink: 0.0, squash: vec2(1.0, 1.0), lift: 0.0, yaw: 0.0, pitch: 0.0 }
|
||||
Pose { eyes: Eyes::Open, gaze: egui::Vec2::ZERO, blink: 0.0, squash: vec2(1.0, 1.0), lift: 0.0, yaw: 0.0, pitch: 0.0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +131,21 @@ pub fn paint_posed(painter: &egui::Painter, rect: Rect, shape: &str, col: Color3
|
|||
let look = vec2(pose.gaze.x * 0.16 * s * turn, -pose.gaze.y * 0.12 * s + pose.pitch * 0.01 * s);
|
||||
for dx in [-0.27, 0.27] {
|
||||
let center = pos2(c.x + dx * body.width() / 2.0, c.y + 0.02 * bs) + look;
|
||||
painter.add(Shape::convex_polygon(ellipse_points(center, s * 0.11 * sx, s * 0.22 * open * sy, -0.35, 20), eye, Stroke::NONE));
|
||||
match pose.eyes {
|
||||
Eyes::Open => {
|
||||
painter.add(Shape::convex_polygon(ellipse_points(center, s * 0.11 * sx, s * 0.22 * open * sy, -0.35, 20), eye, Stroke::NONE));
|
||||
}
|
||||
// An arc, open downward (a smiling eye).
|
||||
Eyes::Smile => {
|
||||
let (w, h) = (s * 0.17 * sx, s * 0.17 * sy);
|
||||
let pts: Vec<Pos2> = (0..=12).map(|k| { let a = PI + k as f32 / 12.0 * PI; pos2(center.x + w * a.cos(), center.y + h * 0.5 + h * a.sin()) }).collect();
|
||||
painter.add(Shape::line(pts, Stroke::new((s * 0.1).max(1.5), eye)));
|
||||
}
|
||||
Eyes::Flat => {
|
||||
let w = s * 0.17 * sx;
|
||||
painter.add(Shape::line(vec![pos2(center.x - w, center.y), pos2(center.x + w, center.y)], Stroke::new((s * 0.1).max(1.5), eye)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,8 @@ fn cache() -> &'static Cache {
|
|||
|
||||
/// Render the SVG white at `px` × `px`.
|
||||
fn rasterize(icon: Icon, px: u32) -> Option<egui::ColorImage> {
|
||||
let mut svg = icon.svg().replace("currentColor", "#ffffff");
|
||||
// (A little heavier than Lucide draws them: 2.25 sits better next to the text.)
|
||||
let mut svg = icon.svg().replace("currentColor", "#ffffff").replace("stroke-width=\"2\"", "stroke-width=\"2.25\"");
|
||||
if icon.filled() {
|
||||
svg = svg.replace("fill=\"none\"", "fill=\"#ffffff\"");
|
||||
}
|
||||
|
|
|
|||
21
src/main.rs
21
src/main.rs
|
|
@ -108,9 +108,12 @@ fn shot_size() -> [f32; 2] {
|
|||
/// 粉圓體, bundled.
|
||||
pub const HUNINN: &[u8] = include_bytes!("../fonts/jf-openhuninn-2.1.ttf");
|
||||
|
||||
/// "huninn" (粉圓體, the default) or "system".
|
||||
/// 思源黑體 (Noto Sans TC Regular, SIL OFL 1.1), bundled: plain, clear, the same on every computer.
|
||||
pub const NOTO_TC: &[u8] = include_bytes!("../fonts/NotoSansTC-Regular.otf");
|
||||
|
||||
/// "noto" (思源黑體, the default), "huninn" (粉圓體) or "system".
|
||||
pub fn font_choice() -> String {
|
||||
model::State::path().parent().and_then(|d| std::fs::read_to_string(d.join("font.txt")).ok()).map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).unwrap_or_else(|| "huninn".into())
|
||||
model::State::path().parent().and_then(|d| std::fs::read_to_string(d.join("font.txt")).ok()).map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).unwrap_or_else(|| "noto".into())
|
||||
}
|
||||
|
||||
pub fn load_fonts(ctx: &egui::Context) {
|
||||
|
|
@ -157,12 +160,18 @@ pub fn load_fonts(ctx: &egui::Context) {
|
|||
}
|
||||
// 粉圓體 (jf open 粉圓, SIL OFL 1.1, fonts/OFL.txt) goes first everywhere it has the letter;
|
||||
// the system font above fills in what it lacks (some simplified characters, symbols).
|
||||
if font_choice() == "huninn" {
|
||||
fonts.font_data.insert("huninn".into(), egui::FontData::from_static(HUNINN).into());
|
||||
fonts.families.entry(egui::FontFamily::Proportional).or_default().insert(0, "huninn".into());
|
||||
// 思源黑體 the same way (the default).
|
||||
let bundled: Option<(&str, &'static [u8])> = match font_choice().as_str() {
|
||||
"huninn" => Some(("huninn", HUNINN)),
|
||||
"noto" => Some(("noto", NOTO_TC)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((name, bytes)) = bundled {
|
||||
fonts.font_data.insert(name.into(), egui::FontData::from_static(bytes).into());
|
||||
fonts.families.entry(egui::FontFamily::Proportional).or_default().insert(0, name.into());
|
||||
let mono = fonts.families.entry(egui::FontFamily::Monospace).or_default();
|
||||
let at = mono.iter().position(|f| f == "cjk").unwrap_or(mono.len());
|
||||
mono.insert(at, "huninn".into());
|
||||
mono.insert(at, name.into());
|
||||
}
|
||||
ctx.set_fonts(fonts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -829,7 +829,7 @@ impl State {
|
|||
selected: 0,
|
||||
next_id: 1,
|
||||
theme: Theme::Light,
|
||||
accent: Accent::Black,
|
||||
accent: Accent::BotColor,
|
||||
providers: Default::default(),
|
||||
sidebar_collapsed: false,
|
||||
embed_model: String::new(),
|
||||
|
|
|
|||
18
src/theme.rs
18
src/theme.rs
|
|
@ -20,6 +20,10 @@ pub struct Palette {
|
|||
pub focus: Color32,
|
||||
pub accent: Color32,
|
||||
pub danger: Color32,
|
||||
/// 需要你: the one colour for what waits for the person (a request, a newer build).
|
||||
pub attention: Color32,
|
||||
/// Behind a request's card.
|
||||
pub attention_bg: Color32,
|
||||
}
|
||||
|
||||
const fn hexa(r: u8, g: u8, b: u8, a: u8) -> Color32 {
|
||||
|
|
@ -28,7 +32,7 @@ const fn hexa(r: u8, g: u8, b: u8, a: u8) -> Color32 {
|
|||
|
||||
pub const LIGHT: Palette = Palette {
|
||||
pane: hexa(0xff, 0xff, 0xff, 0xff),
|
||||
sidebar: hexa(0xf5, 0xf5, 0xf5, 0xff),
|
||||
sidebar: hexa(0xf5, 0xf5, 0xf3, 0xff),
|
||||
elevated: hexa(0xff, 0xff, 0xff, 0xff),
|
||||
hover: hexa(0x1c, 0x1c, 0x1c, 0x0f),
|
||||
active: hexa(0x1c, 0x1c, 0x1c, 0x14),
|
||||
|
|
@ -42,6 +46,8 @@ pub const LIGHT: Palette = Palette {
|
|||
focus: hexa(0x1e, 0x86, 0xfc, 0xff),
|
||||
accent: hexa(0x16, 0x80, 0xf3, 0xff),
|
||||
danger: hexa(0xcd, 0x28, 0x34, 0xff),
|
||||
attention: hexa(0xff, 0xc8, 0x3d, 0xff),
|
||||
attention_bg: hexa(0xff, 0xf6, 0xd6, 0xff),
|
||||
};
|
||||
|
||||
// From the original's renderer (index.eager-common: appearance primitives dark neutral/0..6 and the
|
||||
|
|
@ -65,4 +71,14 @@ pub const DARK: Palette = Palette {
|
|||
focus: hexa(0x18, 0x84, 0xfc, 0xff),
|
||||
accent: hexa(0x18, 0x84, 0xfc, 0xff),
|
||||
danger: hexa(0xfc, 0x2c, 0x3e, 0xff),
|
||||
attention: hexa(0xff, 0xc8, 0x3d, 0xff),
|
||||
attention_bg: hexa(0x3a, 0x32, 0x12, 0xff),
|
||||
};
|
||||
|
||||
/// A bot's colour as a quiet background (its selected tile, its cards): a little of it over the
|
||||
/// page — more on a dark page, where a tenth would not show.
|
||||
pub fn mist(col: Color32, p: Palette) -> Color32 {
|
||||
let k = if p.pane.r() < 128 { 0.24 } else { 0.10 };
|
||||
let mix = |a: u8, b: u8| (a as f32 + (b as f32 - a as f32) * k).round() as u8;
|
||||
Color32::from_rgb(mix(p.pane.r(), col.r()), mix(p.pane.g(), col.g()), mix(p.pane.b(), col.b()))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue