Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c72ffee
Add cargo xtask loc: code lines per source file (#19)
samitbasu Nov 8, 2026
f7999ef
Spike: owned Button and Checkbox built from bullseye nodes (#19)
samitbasu Nov 8, 2026
241792c
Core Style contract, paint translate and the owned widget set (#19)
samitbasu Nov 9, 2026
05d1658
Regenerate goldens for the owned widget set (#19)
samitbasu Nov 9, 2026
5299cac
Owned slider, select trigger and stepper (#19, #22)
samitbasu Nov 9, 2026
50f9f19
Radio group as one Tab stop; switch track eases and thumb stays put (…
samitbasu Nov 9, 2026
4693aba
Gallery and signup form use the new owned widgets; regenerate goldens…
samitbasu Nov 9, 2026
0d17f8f
Selectable text through egui's label selection (#39)
samitbasu Nov 9, 2026
09b2c44
Remove the wrapped egui widgets; examples and tests use the owned set…
samitbasu Nov 9, 2026
dd2ed2d
Fold the owned controls' shared wiring into helpers; drop the dead Li…
samitbasu Nov 9, 2026
98c52b1
Round the slider range and make disabled colours opaque blends (#19, …
samitbasu Nov 9, 2026
a2f05b7
Split the gallery's owned controls into sections; document the CSS di…
samitbasu Nov 9, 2026
ed7ec6c
Stepper: one bordered group so the focus ring no longer overlaps the …
samitbasu Nov 9, 2026
c3ba40a
controls_gallery: one-row Section control, cell controls only for the…
samitbasu Nov 9, 2026
0f0a3e8
Pair-level layout: on/off looks can no longer differ in size (#19)
samitbasu Nov 9, 2026
dd89718
Ease transitions along Tailwind's timing functions (#19)
samitbasu Nov 9, 2026
d84e775
Debug overlay: frame-timing readout (#25)
samitbasu Nov 9, 2026
4dc4a61
Time-based transitions with CSS reversal semantics
samitbasu Nov 9, 2026
dcd5c84
Switch transition tests: drive by real click at 16ms frames
samitbasu Nov 9, 2026
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/samitbasu/bullseye"
[dependencies]
taffy = "0.15.1"
egui = "0.37"
web-time = "1.1"

[features]
# Golden-image tests: kittest renders them with wgpu, so they need a Vulkan
Expand Down
1 change: 1 addition & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ egui supplies interaction (input, focus, text editing, IME, popups). taffy suppl
- Retained widget trees, diffing or reconciliation.
- A component trait or ID enums. Components are plain functions (D9).
- Backdrop blur (egui cannot blur what is behind a layer; see §13).
- Rounded clipping and group opacity (egui clips to rectangles and fades shape by shape; see "Differences from CSS" in the crate docs).

## 3. Settled decisions

Expand Down
15 changes: 4 additions & 11 deletions examples/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#[path = "common/mod.rs"]
mod common;

use bullseye::owned::Button;
use bullseye::style::Tokens;
use bullseye::widget::Button;
use bullseye::{Builder, Tw, tw};
use egui::Color32;

Expand Down Expand Up @@ -45,16 +45,9 @@ pub struct State {
/// <aside class="flex flex-col gap-3 p-3 w-[240px]"><button>Reset</button></aside>
/// ```
fn controls(b: &mut B<'_, '_, State>) {
b.widget(
"reset",
tw().self_start(),
Button::new("Reset"),
|state, ui, button| {
if button.show(ui).clicked() {
*state = State::default();
}
},
);
Button::new("Reset")
.classes(Tw::self_start)
.show(b, "reset", |state: &mut State| *state = State::default());
}

type Align = fn(Tw) -> Tw;
Expand Down
25 changes: 8 additions & 17 deletions examples/chat_shell/centre.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The middle pane: title bar, conversation and composer.

use bullseye::prim::segmented::{Cell, segmented};
use bullseye::prim::select::{self, Options};
use bullseye::owned::Select;
use bullseye::owned::{Cell, Segmented};
use bullseye::prim::text_field::{self, Field};
use bullseye::{Builder, NodeUi, Opacity, Tw, none, tw};
use egui::{Key, WidgetInfo};
Expand Down Expand Up @@ -43,18 +43,11 @@ fn top_bar(b: &mut B<'_, '_>, app: &App) {
none,
|b| {
b.text(tw().role(k[Role::Title].clone()).truncate(), title);
let models = Options::new(MODELS);
let measured = models.clone();
b.leaf(
let models: Vec<(usize, &str)> = MODELS.iter().copied().enumerate().collect();
Select::new(app.model, &models).named("Model").show(
b,
Part::Model,
tw().role(k[Role::Small].clone()),
move |m| select::measure(m, &measured),
move |app: &mut App, ui| {
let response = select::show(ui, &mut app.model, &models);
response.widget_info(|| {
WidgetInfo::labeled(egui::Role::ComboBox, ui.is_enabled(), "Model")
});
},
|app: &mut App, _, model| app.model = model,
);
},
);
Expand Down Expand Up @@ -192,15 +185,13 @@ fn field(b: &mut B<'_, '_>, app: &App) {
/// ```
fn mode(b: &mut B<'_, '_>, app: &App) {
let k = &Theme::of(b.ctx());
segmented(
Segmented::new(app.mode, &Mode::ALL).show_with(
b,
Part::Mode,
tw().flex()
.items_center()
.gap(0.5)
.role(k[Role::Small].clone()),
app.mode,
&Mode::ALL,
|cell| {
let look = tw()
.px(2.5)
Expand All @@ -212,7 +203,7 @@ fn mode(b: &mut B<'_, '_>, app: &App) {
Cell::Released => look.text(k[Tok::InkMid]).hover(|p| p.bg(k[Tok::Hover])),
}
},
|app| &mut app.mode,
|app, _, mode| app.mode = mode,
);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/chat_shell/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ fn stroke(color: Color32) -> Stroke {
}

/// A paint function for [`bullseye::Builder::paint`] that draws `glyph` in `color`.
pub fn glyph(glyph: Glyph, color: Color32) -> impl Fn(&Painter, Rect) + 'static {
move |painter, rect| {
pub fn glyph(glyph: Glyph, color: Color32) -> impl Fn(&Painter, Rect, Color32) + 'static {
move |painter, rect, _| {
let c = rect.center();
let r = rect.width().min(rect.height()) * 0.5 * 0.7;
let s = stroke(color);
Expand Down
2 changes: 1 addition & 1 deletion examples/chat_shell/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! with its text up to a cap, the model is a select, and the mode a segmented
//! control. Scrolling arrives with M5; for now overflow is clipped.
//!
//! F12 toggles the layout debug overlay.
//! F12 toggles the layout debug overlay and its frame-timing readout.

pub mod centre;
#[path = "../common/mod.rs"]
Expand Down
98 changes: 53 additions & 45 deletions examples/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//! controls panel the demos put beside their layout, built from bullseye
//! widgets inside the same tree.
//!
//! F12 toggles the layout debug overlay ([`bullseye::Debug`]) in every example
//! F12 toggles the layout debug overlay and its frame-timing readout
//! ([`bullseye::Debug`]) in every example
//! that shows a [`ThemeBar`] or calls [`toggle_debug`].
#![allow(
dead_code,
Expand All @@ -13,10 +14,9 @@ use std::fmt::Debug;
use std::hash::Hash;
use std::ops::RangeInclusive;

use bullseye::prim::segmented::{Cell, segmented, segmented_by};
use bullseye::owned::{Cell, Segmented, Slider};
use bullseye::prim::text_field::{self, Field};
use bullseye::style::{Accent, Shadcn, Tokens};
use bullseye::widget::Slider;
use bullseye::{Builder, LayoutState, NodeUi, TextSpec, TextStyle, Tw, none, tw};
use egui::{Color32, Context, FontFamily, Key, Role, Theme, ThemePreference, WidgetInfo};

Expand All @@ -43,7 +43,7 @@ pub const APPEARANCES: [(ThemePreference, &str); 3] = [
(ThemePreference::Dark, "Dark"),
];

/// F12 flips the layout debug overlay.
/// F12 flips the layout debug overlay and its frame-timing readout.
pub fn toggle_debug(ctx: &Context) {
bullseye::Debug::toggle_on(ctx, Key::F12);
}
Expand Down Expand Up @@ -111,6 +111,7 @@ pub type AppLayout<S> = for<'b, 'f> fn(&mut Builder<'b, 'f, S>, &S);
pub fn run<S: 'static>(title: &str, state: S, layout: Layout<S>) -> eframe::Result {
shell(
title,
None,
state,
|_, _| {},
move |state, built_in, area, ui| {
Expand All @@ -135,9 +136,31 @@ pub fn run_app_styled<S: 'static>(
state: S,
prepare: fn(&egui::Context, &S),
layout: AppLayout<S>,
) -> eframe::Result {
run_styled_in(title, None, state, prepare, layout)
}

/// [`run_app_styled`] in a native window of `inner_size`.
pub fn run_app_sized<S: 'static>(
title: &str,
inner_size: egui::Vec2,
state: S,
prepare: fn(&egui::Context, &S),
layout: AppLayout<S>,
) -> eframe::Result {
run_styled_in(title, Some(inner_size), state, prepare, layout)
}

fn run_styled_in<S: 'static>(
title: &str,
inner_size: Option<egui::Vec2>,
state: S,
prepare: fn(&egui::Context, &S),
layout: AppLayout<S>,
) -> eframe::Result {
shell(
title,
inner_size,
state,
prepare,
move |state, layout_state, area, ui| {
Expand All @@ -151,13 +174,14 @@ pub fn run_app_styled<S: 'static>(

fn shell<S: 'static>(
title: &str,
inner_size: Option<egui::Vec2>,
mut state: S,
prepare: fn(&egui::Context, &S),
mut frame: impl FnMut(&mut S, &mut LayoutState, egui::Rect, &mut egui::Ui) + 'static,
) -> eframe::Result {
let mut layout_state = LayoutState::new();
let mut theme_bar = ThemeBar::new();
launch(title, None, move |ui| {
launch(title, inner_size, move |ui| {
let ctx = ui.ctx().clone();
use_preset(&ctx);
prepare(&ctx, &state);
Expand Down Expand Up @@ -255,17 +279,10 @@ where
A: 'static,
K: Hash + Debug + 'static,
{
let classes = segmented_classes(b.ctx());
let current = b.ctx().options(|options| options.theme_preference);
segmented_by(
b,
key,
classes.container(),
current,
&APPEARANCES,
|cell| classes.cell(cell),
|_: &mut A, ctx, preference| ctx.set_theme(preference),
);
Segmented::new(current, &APPEARANCES).show(b, key, |_: &mut A, ctx, preference| {
ctx.set_theme(preference)
});
}

/// The strip every example shows along its top edge, with the theme toggle
Expand Down Expand Up @@ -342,6 +359,16 @@ pub fn with_controls<'f, A>(
b: &mut Builder<'_, 'f, A>,
controls: impl FnOnce(&mut Builder<'_, 'f, A>),
demo: impl FnOnce(&mut Builder<'_, 'f, A>),
) {
with_panel(b, PANEL_WIDTH, controls, demo);
}

/// [`with_controls`] with a panel `width` points wide.
pub fn with_panel<'f, A>(
b: &mut Builder<'_, 'f, A>,
width: f32,
controls: impl FnOnce(&mut Builder<'_, 'f, A>),
demo: impl FnOnce(&mut Builder<'_, 'f, A>),
) {
let t = tokens(b.ctx());
b.div(tw().flex().size_full(), |b| {
Expand All @@ -350,7 +377,7 @@ pub fn with_controls<'f, A>(
.flex_col()
.gap(3.0)
.p(3.0)
.w_px(PANEL_WIDTH)
.w_px(width)
.shrink_0()
.bg(t.card)
.border_r(1.0)
Expand Down Expand Up @@ -403,18 +430,12 @@ pub fn slider_row<S: 'static>(
b.text(tw().text(muted), caption);
b.text(tw(), format!("{value:.0}"));
});
b.widget(
let bounds = f64::from(*range.start())..=f64::from(*range.end());
Slider::new(f64::from(value), bounds).named(name).show(
b,
key,
tw().w_full(),
Slider::new(),
move |state, ui, slider| {
let mut edited = f64::from(*lens(state));
let bounds = f64::from(*range.start())..=f64::from(*range.end());
let response = slider.show(ui, &mut edited, bounds);
if response.changed() {
*lens(state) = edited as f32;
}
response.widget_info(|| WidgetInfo::slider(ui.is_enabled(), edited, &name));
move |state: &mut S, edited| {
*lens(state) = edited as f32;
},
);
});
Expand All @@ -439,11 +460,6 @@ pub fn menu_item(t: &Tokens, cell: Cell) -> Tw {
}
}

/// The shadcn tab-list classes for the context's theme.
pub fn segmented_classes(ctx: &Context) -> bullseye::style::SegmentedClasses {
Shadcn::of(ctx).segmented()
}

/// A row of segments that sets the `T` at `lens`. A track of more than
/// [`MAX_ONE_ROW`] segments wraps.
///
Expand All @@ -464,21 +480,13 @@ pub fn choice<S, K, T>(
K: Hash + Debug + 'static,
T: Copy + PartialEq + Hash + Debug + 'static,
{
let classes = segmented_classes(b.ctx());
let classes = if options.len() > MAX_ONE_ROW {
classes.wrapping()
let group = Segmented::new(current, options);
let group = if options.len() > MAX_ONE_ROW {
group.wrapping()
} else {
classes
group
};
segmented(
b,
key,
classes.container(),
current,
options,
|cell| classes.cell(cell),
lens,
);
group.show(b, key, move |state, _, value| *lens(state) = value);
}

/// A frameless text field filling its row, in shadcn's input box: `h-9`,
Expand Down
Loading
Loading