Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev

- uses: dtolnay/rust-toolchain@98e1b82157cd469e843cb7f524c1313b4ad9492c # 1.88
- uses: dtolnay/rust-toolchain@87eb139fed4b08a67bd1fa429a21d1f5d523e03e # 1.92.0
with:
components: rustfmt, clippy

Expand Down
13 changes: 8 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## What this is

`tokito_ui` is a small **egui 0.29** component library — the shared design
`tokito_ui` is a small **egui 0.35** component library — the shared design
layer for the Tokito desktop schematic studio
([github.com/TokitoAI/tokito](https://github.com/TokitoAI/tokito)).

Expand Down Expand Up @@ -47,12 +47,15 @@ src/
`FontFamily::Name("phosphor")` so its Private-Use-Area codepoints never
collide with a text font (Inter Var occupies part of the PUA range).
- **Stable widget ids.** Anything with internal egui state (`text_input`,
`search_field`) takes an explicit `id_source: impl Hash`. Never derive a
widget id from layout position — it collides and breaks focus on reflow.
`search_field`) takes an explicit `id_source: impl Hash + std::fmt::Debug`
(egui 0.35's `Id::new` requires `AsId`, which needs both bounds). Never
derive a widget id from layout position — it collides and breaks focus on
reflow.
- **`Tokens` is `#[non_exhaustive]`.** Construct via `Tokens::dark()` /
`light()` and assign fields to customise; new fields won't be breaking.
- **Version coupling.** Pin `egui` 0.29 and `egui-phosphor` 0.7.x together
(≥ 0.8 targets egui ≥ 0.30). Bumping is a coordinated change.
- **Version coupling.** Pin `egui` 0.35 and `egui-phosphor` 0.13.x together —
check crates.io for the `egui-phosphor` release whose `egui` dependency
matches before bumping either. Bumping is a coordinated change.

## STRICT — this repo is the *only* place UI components are defined

Expand Down
29 changes: 24 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "tokito_ui"
version = "0.1.0"
edition = "2021"
rust-version = "1.81"
rust-version = "1.92"
description = "A small, opinionated egui component library — the design layer for Tokito."
license = "MIT"
repository = "https://github.com/TokitoAI/ui"
Expand All @@ -11,13 +11,32 @@ keywords = ["egui", "eframe", "gui", "components", "design-system"]
categories = ["gui", "rendering::gui"]

[dependencies]
egui = "0.29"
egui-phosphor = { version = "0.7", default-features = false, features = ["regular"] }
egui_extras = "0.29"
egui = "0.35"
egui-phosphor = { version = "0.13", default-features = false, features = ["regular"] }
egui_extras = "0.35"
image = { version = "0.25", default-features = false, features = ["png"] }

[dev-dependencies]
eframe = "0.29"
# default-features off: eframe 0.35 flipped its default renderer from glow to
# wgpu; the gallery example renders on glow, matching the consuming app.
eframe = { version = "0.35", default-features = false, features = [
"accesskit",
"default_fonts",
"glow",
"wayland",
"web_screen_reader",
"x11",
] }
# `winit/default` (Wayland CSD + dlopen) can't be requested through eframe's
# feature table — `dep/feature` syntax only reaches a *direct* dependency's
# features, and winit is eframe's dependency, not ours. Cargo unifies
# features per resolved package version, so declaring winit directly (same
# version eframe pins, unused in code) with just the two sub-features eframe
# drops when its own defaults are off restores them for the gallery example.
winit = { version = "0.30", default-features = false, features = [
"wayland-csd-adwaita",
"wayland-dlopen",
] }

[lints.clippy]
too_many_arguments = "allow"
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
buttons, inputs, menus, toggles — plus light/dark theming and Phosphor icons.
A small, opinionated UI component library and design system for Rust GUI apps.**

`tokito_ui` is an **egui 0.29 component library**: a flat colour-token palette,
`tokito_ui` is an **egui 0.35 component library**: a flat colour-token palette,
a theme applier, icon helpers, and a set of composable widget primitives. It is
the shared design layer of the
[Tokito](https://github.com/TokitoAI/tokito) desktop schematic studio, and
Expand Down Expand Up @@ -36,8 +36,9 @@ Browse it live: `cargo run --example gallery`.
tokito_ui = { git = "https://github.com/TokitoAI/ui" }
```

`tokito_ui` pins `egui` **0.29** and `egui-phosphor` **0.7.x**. Bump all three
together (egui-phosphor ≥ 0.8 targets egui ≥ 0.30).
`tokito_ui` pins `egui` **0.35** and `egui-phosphor` **0.13.x**. Bump all three
together — check crates.io for the `egui-phosphor` release that depends on
your target `egui` version before bumping either.

## Setup — once, at startup

Expand Down
19 changes: 10 additions & 9 deletions examples/gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,22 @@ impl Gallery {
}

impl eframe::App for Gallery {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();
let t = if self.dark {
Tokens::dark()
} else {
Tokens::light()
};
tokito_ui::theme::apply(ctx, &t);
tokito_ui::theme::apply(&ctx, &t);

egui::CentralPanel::default()
.frame(
egui::Frame::none()
egui::Frame::new()
.fill(t.bg)
.inner_margin(egui::Margin::same(28.0)),
.inner_margin(egui::Margin::same((28.0) as i8)),
)
.show(ctx, |ui| {
.show(ui, |ui| {
egui::ScrollArea::vertical()
.auto_shrink([false, false])
.show(ui, |ui| self.body(ui, &t));
Expand All @@ -93,7 +94,7 @@ impl eframe::App for Gallery {
self.frame += 1;
ctx.request_repaint();
if self.frame == 4 {
ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot);
ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(egui::UserData::default()));
}
let shot = ctx.input(|i| {
i.raw.events.iter().find_map(|e| match e {
Expand Down Expand Up @@ -341,9 +342,9 @@ impl Gallery {
egui::vec2(380.0, 260.0),
egui::Layout::top_down(egui::Align::Min).with_cross_justify(true),
|ui| {
egui::Frame::none()
egui::Frame::new()
.fill(t.bg)
.inner_margin(egui::Margin::same(8.0))
.inner_margin(egui::Margin::same((8.0) as i8))
.show(ui, |ui| {
egui::ScrollArea::vertical()
.id_salt("gallery_chat_history")
Expand Down Expand Up @@ -428,7 +429,7 @@ impl Gallery {
});

// Help button (floating bottom-right of the example window).
let area_pos = ui.ctx().screen_rect().right_bottom() - egui::vec2(24.0, 24.0);
let area_pos = ui.ctx().content_rect().right_bottom() - egui::vec2(24.0, 24.0);
egui::Area::new(egui::Id::new("gallery_help"))
.order(egui::Order::Foreground)
.fixed_pos(area_pos - egui::vec2(32.0, 32.0))
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]
2 changes: 1 addition & 1 deletion src/brand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn brand_tile(ui: &mut Ui, side: f32) -> Response {
let painter = ui.painter();
let tile_fill = Color32::from_rgb(0x07, 0x10, 0x1e);
let radius = side * 0.235; // matches the Figma's 36 / 150 corner ratio.
painter.rect_filled(rect, egui::Rounding::same(radius), tile_fill);
painter.rect_filled(rect, egui::CornerRadius::same(radius as u8), tile_fill);

// Inset the mark to ~70 % of the tile, centred. The mark's native
// aspect is slightly taller than square, so derive the rect from
Expand Down
Loading