More refactor.

This commit is contained in:
Samuel Guerra 2023-04-12 18:02:22 -03:00
parent 19a9bce9d1
commit 3efc28fb8c
41 changed files with 269 additions and 290 deletions

View File

@ -5,7 +5,7 @@
## Inline Align::FILL
* Support `Justify`, enabled by `Align::FILL`.
* Implement fill/justify in `wrap!`.
* Implement fill/justify in `Wrap!`.
- Use segments API to control spacing all from the parent?
- Remove `first_max_fill` and `last_max_fill`.

View File

@ -45,12 +45,12 @@ fn example() -> impl UiNode {
use easing::EasingModifierFn::*;
let easing_mod = var(EaseOut);
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 10;
children_align = Align::TOP;
children = ui_vec![
container! {
Container! {
id = "demo";
width = 301;
background = ruler();
@ -69,7 +69,7 @@ fn example() -> impl UiNode {
}
};
},
stack! {
Stack! {
id = "mod-menu";
direction = StackDirection::left_to_right();
spacing = 2;
@ -89,11 +89,11 @@ fn example() -> impl UiNode {
]
}
},
grid! {
Grid! {
id = "easing-menu";
spacing = 2;
columns = ui_vec![grid::column!(1.lft()); 7];
auto_grow_fn = wgt_fn!(|_| grid::row!(1.lft()));
columns = ui_vec![grid::Column!(1.lft()); 7];
auto_grow_fn = wgt_fn!(|_| grid::Row!(1.lft()));
button::vis::extend_style = style_fn!(|_| style! {
padding = 3;
});
@ -148,7 +148,7 @@ fn ease_btn(
use easing::EasingModifierFn::*;
Button! {
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 2;
children_align = Align::TOP;
@ -231,7 +231,7 @@ fn plot(easing: impl Fn(EasingTime) -> EasingStep + Send + Sync + 'static) -> Im
}
.boxed(),
);
stack! {
Stack! {
children_align = Align::TOP_LEFT;
children;
size;
@ -243,7 +243,7 @@ fn plot(easing: impl Fn(EasingTime) -> EasingStep + Send + Sync + 'static) -> Im
}
fn ruler() -> impl UiNode {
stack! {
Stack! {
children_align = Align::LEFT;
children = (0..=300).step_by(10)
.map(|x| rule_line! {

View File

@ -26,7 +26,7 @@ fn app_main() {
color_scheme = ColorScheme::Dark;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
align = Align::CENTER;
spacing = 20;
@ -66,7 +66,7 @@ fn app_main() {
fn clip_to_bounds_demo() -> impl UiNode {
let clip = var(true);
container! {
Container! {
child_align = Align::FILL;
corner_radius = 10;
border = 0.5, colors::RED.darken(20.pct());

View File

@ -19,12 +19,12 @@ fn app_main() {
App::default().run_window(async {
Window! {
title = "Button Example";
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
spacing = 20;
align = Align::CENTER;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
sticky_width = true;
@ -77,7 +77,7 @@ fn image_button() -> impl UiNode {
id = "img-btn";
tooltip = tip!(Text!("image button"));
on_click = hn!(|_| println!("Clicked image button"));
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
children_align = Align::CENTER;
children = ui_vec![
@ -106,7 +106,7 @@ fn dyn_buttons() -> impl UiNode {
let children_ref = dyn_children.reference();
let mut btn = 'A';
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = dyn_children.chain(ui_vec![
@ -140,7 +140,7 @@ fn separator() -> impl UiNode {
}
fn toggle_buttons() -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![
@ -173,7 +173,7 @@ fn toggle_buttons() -> impl UiNode {
tristate = true;
style_fn = style_fn!(|_| toggle::vis::check_style!());
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
toggle::selector = toggle::Selector::single(var("Paris"));

View File

@ -27,7 +27,7 @@ fn app_main() {
resizable = false;
auto_size = true;
padding = 5;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![
@ -55,10 +55,10 @@ fn controls(calc: ArcVar<Calculator>) -> impl UiNode {
let b_back = btn_backspace(calc.clone());
let b_equal = btn_eval(calc.clone());
grid! {
Grid! {
spacing = 2;
columns = ui_vec![grid::column!(1.lft()); 4];
auto_grow_fn = wgt_fn!(|_| grid::row!(1.lft()));
columns = ui_vec![grid::Column!(1.lft()); 4];
auto_grow_fn = wgt_fn!(|_| grid::Row!(1.lft()));
font_size = 14.pt();
cells = ui_vec![
b_squre, b_sroot, b_clear, b_back,

View File

@ -44,7 +44,7 @@ fn app_main() {
txt_color = colors::RED;
}
};
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
align = Align::CENTER;
spacing = 5;

View File

@ -45,7 +45,7 @@ fn app_main() {
r
}));
icon = WindowIcon::render(move || container! {
icon = WindowIcon::render(move || Container! {
zero_ui::core::image::render_retain = true;
size = (36, 36);

View File

@ -25,9 +25,9 @@ fn app_main() {
auto_size = true;
padding = 20;
child = v_stack(ui_vec![
grid! {
columns = ui_vec![grid::column!(1.lft()); 5];
auto_grow_fn = wgt_fn!(|_| grid::row!(1.lft()));
Grid! {
columns = ui_vec![grid::Column!(1.lft()); 5];
auto_grow_fn = wgt_fn!(|_| grid::Row!(1.lft()));
cells = demos;
},
cursor_demo(None),
@ -37,7 +37,7 @@ fn app_main() {
}
fn cursor_demo(icon: Option<(CursorIcon, &'static [u8])>) -> impl UiNode {
container! {
Container! {
cursor = icon.map(|i| i.0);
size = (150, 80);

View File

@ -28,11 +28,11 @@ fn app_main() {
title = "Focus Example";
enabled = window_enabled.clone();
background = commands();
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children = ui_vec![
alt_scope(),
stack! {
Stack! {
direction = StackDirection::left_to_right();
margin = (50, 0, 0, 0);
align = Align::CENTER;
@ -54,7 +54,7 @@ fn app_main() {
}
fn alt_scope() -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::left_to_right();
alt_focus_scope = true;
button::vis::extend_style = style_fn!(|_| style! {
@ -69,7 +69,7 @@ fn alt_scope() -> impl UiNode {
}
fn tab_index() -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
focus_shortcut = shortcut!(T);
@ -85,7 +85,7 @@ fn tab_index() -> impl UiNode {
}
fn functions(window_enabled: ArcVar<bool>) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
focus_shortcut = shortcut!(F);
@ -100,7 +100,7 @@ fn functions(window_enabled: ArcVar<bool>) -> impl UiNode {
Window! {
title = "Other Window";
focus_shortcut = shortcut!(W);
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
align = Align::CENTER;
spacing = 5;
@ -163,18 +163,18 @@ fn disable_window(window_enabled: ArcVar<bool>) -> impl UiNode {
}
}
fn overlay(window_enabled: ArcVar<bool>) -> impl UiNode {
container! {
Container! {
id = "overlay";
modal = true;
child_align = Align::CENTER;
child = container! {
child = Container! {
focus_scope = true;
tab_nav = TabNav::Cycle;
directional_nav = DirectionalNav::Cycle;
background_color = color_scheme_map(colors::BLACK.with_alpha(90.pct()), colors::WHITE.with_alpha(90.pct()));
drop_shadow = (0, 0), 4, colors::BLACK;
padding = 2;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children_align = Align::RIGHT;
children = ui_vec![
@ -182,7 +182,7 @@ fn overlay(window_enabled: ArcVar<bool>) -> impl UiNode {
txt = "Window scope is disabled so the overlay scope is the root scope.";
margin = 15;
},
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 2;
children = ui_vec![
@ -202,7 +202,7 @@ fn overlay(window_enabled: ArcVar<bool>) -> impl UiNode {
}
fn delayed_focus() -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
focus_shortcut = shortcut!(D);
@ -302,7 +302,7 @@ fn commands() -> impl UiNode {
FOCUS_EXIT_CMD,
];
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
align = Align::BOTTOM_RIGHT;
padding = 10;
@ -355,7 +355,7 @@ fn nested_focusables() -> impl UiNode {
// zero_ui::properties::inspector::show_center_points = true;
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 10;
children = ui_vec![
@ -369,7 +369,7 @@ fn nested_focusables() -> impl UiNode {
}
}
fn nested_focusables_group(g: char) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::left_to_right();
align = Align::TOP;
spacing = 10;
@ -381,7 +381,7 @@ fn nested_focusable(g: char, column: u8, row: u8) -> impl UiNode {
txt = format!("Focusable {column}, {row}");
margin = 5;
};
stack! {
Stack! {
id = formatx!("focusable-{g}-{column}-{row}");
padding = 2;
direction = StackDirection::top_to_bottom();

View File

@ -19,7 +19,7 @@ fn app_main() {
icon = WindowIcon::render(icon);
child = scroll! {
padding = 20;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -166,12 +166,12 @@ fn stack_linear() -> impl UiNode {
fn sample(name: impl ToText, gradient: impl UiNode) -> impl UiNode {
let name = name.to_text();
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![
Text!(name),
container! {
Container! {
size = (180, 180);
child = gradient;
}
@ -180,7 +180,7 @@ fn sample(name: impl ToText, gradient: impl UiNode) -> impl UiNode {
}
fn sample_line(children: impl UiNodeList) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 5;
children;
@ -188,7 +188,7 @@ fn sample_line(children: impl UiNodeList) -> impl UiNode {
}
fn icon() -> impl UiNode {
container! {
Container! {
size = (36, 36);
background_gradient = Line::to_bottom_right(), stops![colors::MIDNIGHT_BLUE, 70.pct(), colors::CRIMSON];
corner_radius = 6;

View File

@ -55,7 +55,7 @@ fn headless_example() {
// A 800x600 "Hello World!" with a fancy background.
fn image() -> impl UiNode {
container! {
Container! {
size = (800, 600);
background = stack_nodes({

View File

@ -10,7 +10,7 @@ fn main() {
title = "Hit-Test Example";
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
spacing = 14;
children = ui_vec![
@ -24,7 +24,7 @@ fn main() {
}
fn example(mode: HitTestMode) -> impl UiNode {
container! {
Container! {
hit_test_mode = mode;
on_click = hn!(mode, |_| {

View File

@ -45,14 +45,14 @@ fn icons() -> impl UiNode {
}
fn show_font(icons: Vec<MaterialIcon>) -> impl UiNode {
let _scope = tracing::error_span!("show_font").entered();
wrap! {
Wrap! {
spacing = 5;
icon::vis::ico_size = 48;
children = {
let mut r = vec![];
icons
.par_chunks(100)
.map(|c| wrap! { // segment into multiple inlined lazy inited `wrap!` for better performance.
.map(|c| Wrap! { // segment into multiple inlined lazy inited `Wrap!` for better performance.
spacing = 5;
lazy = {
let len = c.len();
@ -73,13 +73,13 @@ fn icons() -> impl UiNode {
},
}
}
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
padding = (20, 5, 5, 5);
spacing = 20;
children_align = Align::TOP;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::left_to_right();
toggle::selector = toggle::Selector::single(selected_font.clone());
spacing = 5;
@ -110,7 +110,7 @@ fn icon_btn(ico: icons::MaterialIcon) -> impl UiNode {
Button! {
padding = 2;
size = (80, 80);
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 2;
children_align = Align::CENTER;
@ -134,7 +134,7 @@ fn icon_btn(ico: icons::MaterialIcon) -> impl UiNode {
fn expanded_icon(ico: icons::MaterialIcon) -> impl UiNode {
let opacity = var(0.fct());
opacity.ease(1.fct(), 200.ms(), easing::linear).perm();
container! {
Container! {
opacity = opacity.clone();
id = "expanded-icon";
@ -147,15 +147,15 @@ fn expanded_icon(ico: icons::MaterialIcon) -> impl UiNode {
args.propagation().stop();
}
});
child = container! {
child = Container! {
id = "panel";
background_color = color_scheme_map(colors::BLACK.with_alpha(90.pct()), colors::WHITE.with_alpha(90.pct()));
focus_scope = true;
tab_nav = TabNav::Cycle;
directional_nav = DirectionalNav::Cycle;
drop_shadow = (0, 0), 4, colors::BLACK;
child = stack!(children = ui_vec![
stack! {
child = Stack!(children = ui_vec![
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
padding = 10;
@ -168,12 +168,12 @@ fn expanded_icon(ico: icons::MaterialIcon) -> impl UiNode {
font_size = 18;
},
sub_title("Using `icon!`:"),
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 5;
children_align = Align::TOP_LEFT;
children = [64, 48, 32, 24, 16].into_iter().map(clmv!(ico, |size| {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 3;
children = ui_vec![
@ -195,12 +195,12 @@ fn expanded_icon(ico: icons::MaterialIcon) -> impl UiNode {
},
sub_title("Using `Text!`:"),
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 5;
children_align = Align::TOP_LEFT;
children = [64, 48, 32, 24, 16].into_iter().map(clmv!(ico, |size| {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 3;
children = ui_vec![

View File

@ -39,7 +39,7 @@ fn app_main() {
img_window(
"Image Example",
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 30;
children = ui_vec![
@ -47,9 +47,9 @@ fn app_main() {
"Sources",
ui_vec![
sub_title("File"),
grid! {
columns = ui_vec![grid::column!(1.lft()); 4];
auto_grow_fn = wgt_fn!(|_| grid::row!(1.lft()));
Grid! {
columns = ui_vec![grid::Column!(1.lft()); 4];
auto_grow_fn = wgt_fn!(|_| grid::Row!(1.lft()));
spacing = 2;
align = Align::CENTER;
cells= ui_vec![
@ -78,7 +78,7 @@ fn app_main() {
sub_title("Render"),
Image! {
img_scale_ppi = true;
source = ImageSource::render_node(RenderMode::Software, |_| container! {
source = ImageSource::render_node(RenderMode::Software, |_| Container! {
size = (180, 120);
background_gradient = Line::to_bottom_left(), stops![hex!(#34753a), 40.pct(), hex!(#597d81)];
font_size = 24;
@ -122,7 +122,7 @@ fn app_main() {
]
),
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 30;
children = ui_vec![
@ -160,7 +160,7 @@ fn app_main() {
fn img_fit(fit: impl IntoVar<ImageFit>) -> impl UiNode {
let fit = fit.into_var();
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children_align = Align::TOP_LEFT;
spacing = 5;
@ -183,7 +183,7 @@ fn img_fit(fit: impl IntoVar<ImageFit>) -> impl UiNode {
fn img_filter(filter: impl IntoVar<filters::Filter>) -> impl UiNode {
let filter = filter.into_var();
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children_align = Align::TOP_LEFT;
spacing = 2;
@ -210,7 +210,7 @@ fn sprite() -> impl UiNode {
let timer = TIMERS.interval((1.0 / 24.0).secs(), true);
let label = var_from("play");
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
align = Align::CENTER;
children = ui_vec![
@ -267,7 +267,7 @@ fn large_image() -> impl UiNode {
img_loading_fn = wgt_fn!(|_| {
// thumbnail
stack! {
Stack! {
children = ui_vec![
Image! {
source = "https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/757px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg";
@ -356,7 +356,7 @@ fn img_cache_mode(req: &task::http::Request) -> http::CacheMode {
}
fn center_viewport(msg: impl UiNode) -> impl UiNode {
container! {
Container! {
// center the message on the scroll viewport:
//
// the large images can take a moment to decode in debug builds, but the size
@ -456,14 +456,14 @@ fn img_window(title: impl IntoVar<Txt>, child: impl UiNode) -> WindowCfg {
}
fn section(title: impl IntoVar<Txt>, children: impl UiNodeList) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children_align = Align::TOP_LEFT;
children = ui_vec![
self::title(title),
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children_align = Align::TOP_LEFT;

View File

@ -45,7 +45,7 @@ fn app_main() {
});
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![
@ -69,12 +69,12 @@ fn overlay_example() -> impl UiNode {
}
fn overlay(id: impl Into<WidgetId>, offset: i32) -> impl UiNode {
let id = id.into();
container! {
Container! {
id;
modal = true;
background_color = color_scheme_map(colors::WHITE.with_alpha(10.pct()), colors::BLACK.with_alpha(10.pct()));
child_align = Align::CENTER;
child = container! {
child = Container! {
offset = (offset, offset);
focus_scope = true;
tab_nav = TabNav::Cycle;
@ -87,7 +87,7 @@ fn overlay(id: impl Into<WidgetId>, offset: i32) -> impl UiNode {
corner_radius = unset!;
});
padding = 2;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children_align = Align::RIGHT;
children = ui_vec![
@ -95,7 +95,7 @@ fn overlay(id: impl Into<WidgetId>, offset: i32) -> impl UiNode {
txt = "Overlay inserted in the TOP_MOST layer.";
margin = 15;
},
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 2;
children = ui_vec![
@ -122,7 +122,7 @@ fn overlay(id: impl Into<WidgetId>, offset: i32) -> impl UiNode {
fn layer_index_example() -> impl UiNode {
// demonstrates that the z-order is not affected by the order of insertion.
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 5;
children = ui_vec![
@ -138,7 +138,7 @@ fn layer_n_btn(n: u32, color: Rgba) -> impl UiNode {
child = Text!(label.clone());
on_click = async_hn!(label, |_| {
let id = WidgetId::new_unique();
LAYERS.insert(n, container! {
LAYERS.insert(n, Container! {
id;
child = Text! {
txt = label.clone();
@ -231,7 +231,7 @@ fn transform_anchor_example() -> impl UiNode {
on_click = hn!(|_| {
if insert {
LAYERS.insert_anchored(LayerIndex::ADORNER, "t-anchor", AnchorMode::foreground(), container! {
LAYERS.insert_anchored(LayerIndex::ADORNER, "t-anchor", AnchorMode::foreground(), Container! {
id = "t-anchored";
child_align = Align::TOP_LEFT;
border = 1, colors::GREEN.lighten(30.pct());

View File

@ -19,7 +19,7 @@ fn main() {
});
foreground = window_status();
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children_align = Align::TOP;
@ -76,7 +76,7 @@ fn click_counter() -> impl UiNode {
}
fn image() -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 3;
children = ui_vec![
@ -95,7 +95,7 @@ fn window_status() -> impl UiNode {
};
}
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
margin = 10;
@ -113,7 +113,7 @@ fn window_status() -> impl UiNode {
}
fn icon() -> impl UiNode {
container! {
Container! {
size = (36, 36);
background_gradient = Line::to_bottom_right(), stops![colors::ORANGE_RED, 70.pct(), colors::DARK_RED];
corner_radius = 6;

View File

@ -28,7 +28,7 @@ fn app_main() {
colors::WHITE.with_alpha(80.pct()).mix_normal(hex!(#245E81))
);
// smooth_scrolling = false;
child = stack!{
child = Stack!{
direction = StackDirection::top_to_bottom();
children_align = Align::LEFT;
children = ui_vec![
@ -58,7 +58,7 @@ fn commands() -> impl UiNode {
let show = var(false);
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
align = Align::TOP;
padding = 5;
@ -67,7 +67,7 @@ fn commands() -> impl UiNode {
alt_focus_scope = true;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
visibility = show.map_into();
spacing = 3;

View File

@ -67,7 +67,7 @@ fn app_main() {
start_position = StartPosition::CenterMonitor;
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children = ui_vec![
Text!{

View File

@ -24,13 +24,13 @@ fn app_main() {
zero_ui::core::widget_base::parallel = false;
title = fs.map(|s| formatx!("Text Example - font_size: {s}"));
child = z_stack(ui_vec![
stack! {
Stack! {
font_size = fs.easing(150.ms(), easing::linear);
direction = StackDirection::left_to_right();
align = Align::CENTER;
spacing = 40;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -38,7 +38,7 @@ fn app_main() {
defaults(),
];
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -48,7 +48,7 @@ fn app_main() {
letter_spacing(),
];
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -57,7 +57,7 @@ fn app_main() {
}
];
},
container! {
Container! {
align = Align::TOP;
margin = 10;
child = font_size(fs);
@ -73,7 +73,7 @@ fn font_size(font_size: ArcVar<Length>) -> impl UiNode {
*s.to_mut() += Length::Pt(change);
});
}
stack! {
Stack! {
button::vis::extend_style = style_fn!(|_| style! {
padding = (0, 5);
});
@ -149,7 +149,7 @@ fn line_height() -> impl UiNode {
fn line_spacing() -> impl UiNode {
section(
"line_spacing",
ui_vec![container! {
ui_vec![Container! {
child = Text! {
txt = "Hello line 1!\nHello line 2!\nHover to change `line_spacing`";
background_color = rgba(0.5, 0.5, 0.5, 0.3);
@ -274,7 +274,7 @@ fn defaults() -> impl UiNode {
None => Txt::empty(),
});
stack! {
Stack! {
direction = StackDirection::left_to_right();
children_align = Align::BASELINE_LEFT;
children = ui_vec![
@ -307,7 +307,7 @@ fn defaults() -> impl UiNode {
}
fn section(header: &'static str, items: impl UiNodeList) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![Text! {

View File

@ -20,11 +20,11 @@ fn app_main() {
Window! {
title = "Transform Example";
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
spacing = 40;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 25;
children_align = Align::TOP;
@ -37,7 +37,7 @@ fn app_main() {
transformed("Identity", Transform::identity()),
];
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 40;
children = ui_vec![
@ -52,8 +52,8 @@ fn app_main() {
}
fn transformed(label: impl Into<Txt>, transform: Transform) -> impl UiNode {
container! {
child = container! {
Container! {
child = Container! {
transform;
child = Text!(label.into());
background_color = color_scheme_map(colors::BROWN.with_alpha(80.pct()), hex!(#EF6950).with_alpha(80.pct()));
@ -63,8 +63,8 @@ fn transformed(label: impl Into<Txt>, transform: Transform) -> impl UiNode {
}
}
fn transformed_at(label: impl Into<Txt>, transform: Transform, origin: impl Into<Point>) -> impl UiNode {
container! {
child = container! {
Container! {
child = Container! {
transform;
transform_origin = origin.into();
child = Text!(label.into());
@ -78,16 +78,16 @@ fn transformed_at(label: impl Into<Txt>, transform: Transform, origin: impl Into
fn transform_stack() -> impl UiNode {
// the panel widget uses its child transform to position the widget for performance reasons,
// the widget transform does not affect.
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![
container! {
Container! {
child = Text!("Identity");
background_color = colors::DARK_GRAY.with_alpha(80.pct());
padding = 10;
},
container! {
Container! {
id = "in-stack";
transform = rotate(45.deg());
child = Text!("Rotated 45º");
@ -98,7 +98,7 @@ fn transform_stack() -> impl UiNode {
z_index = ZIndex::DEFAULT + 1;
}
},
container! {
Container! {
child = Text!("Identity");
background_color = colors::DARK_GRAY.with_alpha(80.pct());
padding = 10;

View File

@ -43,11 +43,11 @@ async fn main_window() -> WindowCfg {
});
on_close_requested = confirm_close();
child_align = Align::CENTER;
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
spacing = 40;
children = ui_vec![
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -55,7 +55,7 @@ async fn main_window() -> WindowCfg {
focus_control(),
]
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -64,7 +64,7 @@ async fn main_window() -> WindowCfg {
chrome(),
];
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -72,7 +72,7 @@ async fn main_window() -> WindowCfg {
background_color(background),
];
},
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 20;
children = ui_vec![
@ -90,7 +90,7 @@ fn background_color(color: impl Var<Rgba>) -> impl UiNode {
toggle! {
value::<Rgba> = c.clone();
select_on_init;
child = stack! {
child = Stack! {
direction = StackDirection::left_to_right();
spacing = 4;
children_align = Align::LEFT;
@ -476,14 +476,14 @@ fn confirm_close() -> impl WidgetHandler<WindowCloseRequestedArgs> {
fn close_dialog(windows: Vec<WindowId>, state: ArcVar<CloseState>) -> impl UiNode {
let opacity = var(0.fct());
opacity.ease(1.fct(), 300.ms(), easing::linear).perm();
container! {
Container! {
opacity = opacity.clone();
id = "close-dialog";
modal = true;
background_color = color_scheme_map(colors::WHITE.with_alpha(10.pct()), colors::BLACK.with_alpha(10.pct()));
child_align = Align::CENTER;
child = container! {
child = Container! {
background_color = color_scheme_map(colors::BLACK.with_alpha(90.pct()), colors::WHITE.with_alpha(90.pct()));
focus_scope = true;
tab_nav = TabNav::Cycle;
@ -498,7 +498,7 @@ fn close_dialog(windows: Vec<WindowId>, state: ArcVar<CloseState>) -> impl UiNod
}
});
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children_align = Align::RIGHT;
children = ui_vec![
@ -509,7 +509,7 @@ fn close_dialog(windows: Vec<WindowId>, state: ArcVar<CloseState>) -> impl UiNod
};
margin = 15;
},
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 4;
children = ui_vec![
@ -551,7 +551,7 @@ fn cmd_btn(cmd: Command) -> impl UiNode {
}
fn section(header: &'static str, items: impl UiNodeList) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
children = ui_vec![Text! {
@ -563,7 +563,7 @@ fn section(header: &'static str, items: impl UiNodeList) -> impl UiNode {
}
fn select<T: VarValue + PartialEq>(header: &'static str, selection: impl Var<T>, items: impl UiNodeList) -> impl UiNode {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = 5;
toggle::selector = toggle::Selector::single(selection);

View File

@ -127,15 +127,15 @@ async fn listener_window(focused_wgt: bool) -> WindowCfg {
Window! {
zero_ui::core::widget_base::parallel = false;
child = stack! {
child = Stack! {
direction = StackDirection::top_to_bottom();
children = ui_vec![
container! {
Container! {
id = "test-widget";
size = (100, 100);
child = FooHandlerNode { handle: None, handle_scoped: None, handle_scoped_wgt: None };
},
container! {
Container! {
id = "other-widget";
size = (100, 100);
focusable = focused_wgt;

View File

@ -21,7 +21,7 @@ pub fn first_and_last_window_events() {
let button_0_id = buttons.item_id(0);
let mut app = app.run_window(Window! {
child = stack!(id = stack_id; direction = StackDirection::top_to_bottom(); children = buttons);
child = Stack!(id = stack_id; direction = StackDirection::top_to_bottom(); children = buttons);
id = root_id;
});
let root_path = InteractionPath::new_enabled(app.window_id, vec![root_id].into());
@ -156,7 +156,7 @@ pub fn window_tab_cycle_and_alt_scope() {
let alt_ids: Vec<_> = alt_ids.into_iter().map(|(id, _)| id).collect();
let mut app = app.run(v_stack(ui_vec![
stack! {
Stack! {
direction = StackDirection::left_to_right();
alt_focus_scope = true;
children = alt_buttons;
@ -354,13 +354,13 @@ fn two_continue_scopes_or_containers_in_tab_cycle_window(focus_scope: bool) {
];
let ids_b: Vec<_> = (0..3).map(|i| buttons_b.item_id(i)).collect();
let a = stack! {
let a = Stack! {
direction = StackDirection::top_to_bottom();
children = buttons_a;
focus_scope;
tab_nav = TabNav::Continue;
};
let b = stack! {
let b = Stack! {
direction = StackDirection::top_to_bottom();
children = buttons_b;
focus_scope;
@ -437,13 +437,13 @@ pub fn two_continue_scopes_with_mixed_indexes() {
];
let ids_b: Vec<_> = (0..3).map(|i| buttons_b.item_id(i)).collect();
let a = stack! {
let a = Stack! {
direction = StackDirection::top_to_bottom();
children = buttons_a;
focus_scope = true;
tab_nav = TabNav::Continue;
};
let b = stack! {
let b = Stack! {
direction = StackDirection::top_to_bottom();
children = buttons_b;
focus_scope = true;
@ -627,7 +627,7 @@ pub fn tab_skip_inner_container() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children = inner_buttons;
tab_index = TabIndex::SKIP;
@ -681,7 +681,7 @@ pub fn tab_inner_scope_continue() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { id = "Button 0"; child = Text!("Button 0") },
stack! {
Stack! {
id = "Scope Continue";
direction = StackDirection::top_to_bottom();
children = inner_buttons;
@ -725,7 +725,7 @@ pub fn tab_skip_inner_scope_continue() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { id = "Button 0"; child = Text!("Button 0") },
stack! {
Stack! {
id = "v_stack";
direction = StackDirection::top_to_bottom();
children = inner_buttons;
@ -779,7 +779,7 @@ pub fn tab_inner_scope_cycle() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children = inner_buttons;
focus_scope = true;
@ -824,7 +824,7 @@ pub fn tab_inner_scope_contained() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children = inner_buttons;
focus_scope = true;
@ -869,7 +869,7 @@ pub fn tab_inner_scope_once() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children = inner_buttons;
focus_scope = true;
@ -911,7 +911,7 @@ pub fn tab_inner_scope_none() {
let inner_ids: Vec<_> = (0..2).map(|i| inner_buttons.item_id(i)).collect();
let children = ui_vec![
Button! { id = "btn-0"; child = Text!("Button 0") },
stack! {
Stack! {
id = "v-stack";
direction = StackDirection::top_to_bottom();
children = inner_buttons;
@ -954,7 +954,7 @@ pub fn tab_inner_scope_continue_to_non_focusable_siblings_focusable_child() {
let btn1 = WidgetId::named("btn-1");
let btn2 = WidgetId::named("btn-2");
let mut app = app.run(h_stack(ui_vec![
stack! {
Stack! {
id = "initial-scope";
direction = StackDirection::top_to_bottom();
focus_scope = true;
@ -981,7 +981,7 @@ pub fn dont_focus_alt_when_alt_pressed_before_focusing_window() {
let alt_buttons = ui_vec![Button! { child = Text!("Alt 0"); }, Button! { child = Text!("Alt 1"); },];
let mut app = app.run(v_stack(ui_vec![
stack! {
Stack! {
direction = StackDirection::left_to_right();
alt_focus_scope = true;
children = alt_buttons;
@ -1011,7 +1011,7 @@ pub fn window_blur_focus() {
let alt_buttons = ui_vec![Button! { child = Text!("Alt 0"); }, Button! { child = Text!("Alt 1"); },];
let mut app = app.run(v_stack(ui_vec![
stack! {
Stack! {
alt_focus_scope = true;
children = alt_buttons;
},
@ -1123,7 +1123,7 @@ pub fn focus_widget_or_parent_goes_to_parent() {
id = first_focus_id;
child = Text!("initial focus")
},
container! {
Container! {
id = parent_id;
focusable = true;
child = Text! {
@ -1155,7 +1155,7 @@ pub fn focus_widget_or_child_goes_to_child() {
id = first_focus_id;
child = Text!("initial focus")
},
container! {
Container! {
id = parent_id;
focusable = false;
child = Text! {
@ -1189,7 +1189,7 @@ pub fn focus_continued_after_widget_id_move() {
move |do_move_id| {
if do_move_id.get() {
View::Update({
container! {
Container! {
id = "some_other_place";
child = Button! { id; child = Text!("Button 1") };
}
@ -1224,10 +1224,10 @@ pub fn focus_continued_after_widget_move_same_window() {
let do_move = var(false);
let mut app = app.run(v_stack(ui_vec![
container! {
Container! {
child = button.take_when(true)
},
container! {
Container! {
child = button.take_when(do_move.clone())
}
]));
@ -1279,7 +1279,7 @@ pub fn focus_goes_to_parent_after_remove() {
let interactive = var(true);
let mut app = app.run(v_stack(ui_vec![container! {
let mut app = app.run(v_stack(ui_vec![Container! {
id = parent_id;
focusable = true;
child = Button! {
@ -1525,7 +1525,7 @@ pub fn directional_continue_up() {
let start_id = WidgetId::new_unique();
let buttons = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
focus_scope = true;
directional_nav = DirectionalNav::Continue;
@ -1553,7 +1553,7 @@ pub fn directional_continue_down() {
let start_id = WidgetId::new_unique();
let buttons = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
focus_scope = true;
directional_nav = DirectionalNav::Continue;
@ -1581,7 +1581,7 @@ pub fn directional_continue_left() {
let start_id = WidgetId::new_unique();
let buttons = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
focus_scope = true;
directional_nav = DirectionalNav::Continue;
@ -1609,7 +1609,7 @@ pub fn directional_continue_right() {
let start_id = WidgetId::new_unique();
let buttons = ui_vec![
Button! { child = Text!("Button 0") },
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
focus_scope = true;
directional_nav = DirectionalNav::Continue;

View File

@ -546,7 +546,7 @@ impl ImageSource {
/// # let _ =
/// ImageSource::render_node(
/// RenderMode::Software,
/// |_args| container! {
/// |_args| Container! {
/// size = (500, 400);
/// background_color = colors::GREEN;
/// child = Text!("Rendered!");

View File

@ -62,7 +62,7 @@ pub fn state_var() -> ArcVar<bool> {
/// # let _scope = zero_ui_core::app::App::minimal();
/// let probe = getter_var::<usize>();
/// # let _ =
/// row! {
/// Row! {
/// background_color = probe.map(|&i| {
/// let g = (i % 255) as u8;
/// rgb(g, g, g)

View File

@ -1246,7 +1246,7 @@ pub fn is_hit_testable(child: impl UiNode, state: impl IntoVar<bool>) -> impl Ui
/// # macro_rules! container { ($($tt:tt)*) => { NilUiNode }}
/// # use zero_ui_core::widget_instance::*;
/// fn center_viewport(content: impl UiNode) -> impl UiNode {
/// container! {
/// Container! {
/// zero_ui::core::widget_base::can_auto_hide = false;
///
/// x = zero_ui::widgets::scroll::SCROLL_HORIZONTAL_OFFSET_VAR.map(|&fct| Length::Relative(fct) - 1.vw() * fct);

View File

@ -27,7 +27,7 @@ macro_rules! source_location {
$crate::widget_builder::SourceLocation {
file: std::file!(),
line: std::line!(),
column: std::column!(),
column: std::Column!(),
}
};
}
@ -43,7 +43,7 @@ pub struct SourceLocation {
pub file: &'static str,
/// [`line!`]
pub line: u32,
/// [`column!`]
/// [`Column!`]
pub column: u32,
}
impl fmt::Display for SourceLocation {

View File

@ -473,7 +473,7 @@ impl WindowIcon {
/// # macro_rules! container { ($($tt:tt)*) => { zero_ui_core::widget_instance::NilUiNode } }
/// # let _ =
/// WindowIcon::render(
/// || container! {
/// || Container! {
/// size = (36, 36);
/// background_gradient = Line::to_bottom_right(), stops![colors::MIDNIGHT_BLUE, 70.pct(), colors::CRIMSON];
/// corner_radius = 6;

View File

@ -29,7 +29,7 @@ use zero_ui::prelude::new_property::*;
/// ```
/// # use zero_ui::prelude::*;
/// # let _scope = App::minimal();
/// container! {
/// Container! {
/// child = Button! {
/// margin = (10, 5.pct());
/// child = Text!("Click Me!")
@ -93,7 +93,7 @@ pub fn padding(child: impl UiNode, padding: impl IntoVar<SideOffsets>) -> impl U
/// # use zero_ui::prelude::*;
/// # let _scope = App::minimal();
/// #
/// container! {
/// Container! {
/// child = Button! {
/// align = Align::TOP;
/// child = Text!("Click Me!")
@ -1446,7 +1446,7 @@ pub fn child_insert_end(child: impl UiNode, insert: impl UiNode, spacing: impl I
pub enum WidgetLength {
/// Evaluates to [`PxConstraints2d::fill_size`] when measured, can serve as a request for *size-to-fit*.
///
/// The `grid!` widget uses this to fit the column and row widgets to *their* cells, as they don't
/// The `Grid!` widget uses this to fit the column and row widgets to *their* cells, as they don't
/// logically own the cells, this fit needs to be computed by the parent panel.
#[default]
Default,

View File

@ -10,7 +10,7 @@ use crate::prelude::new_property::*;
///
/// ```
/// # use zero_ui::prelude::*;
/// container! {
/// Container! {
/// cursor = CursorIcon::Hand;
/// child = Text!("Mouse over this text shows the hand cursor");
/// }

View File

@ -20,7 +20,7 @@ use super::hit_test_mode;
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// background = Text! {
/// txt = "CUSTOM BACKGROUND";
@ -84,7 +84,7 @@ pub fn background_fn(child: impl UiNode, wgt_fn: impl IntoVar<WidgetFn<()>>) ->
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// background_color = hex!(#ADF0B0);
/// }
@ -108,7 +108,7 @@ pub fn background_color(child: impl UiNode, color: impl IntoVar<Rgba>) -> impl U
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// background_gradient = {
/// axis: 90.deg(),
@ -138,7 +138,7 @@ pub fn background_gradient(child: impl UiNode, axis: impl IntoVar<LinearGradient
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// background_radial = {
/// center: (50.pct(), 80.pct()),
@ -174,7 +174,7 @@ pub fn background_radial(
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// background_conic = {
/// center: (50.pct(), 80.pct()),
@ -212,7 +212,7 @@ pub fn background_conic(
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// foreground = Text! {
/// txt = "TRIAL";
@ -276,7 +276,7 @@ pub fn foreground_fn(child: impl UiNode, wgt_fn: impl IntoVar<WidgetFn<()>>) ->
/// # use zero_ui::prelude::*;
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// container! {
/// Container! {
/// child = foo();
/// foreground_highlight = {
/// offsets: 3,
@ -381,7 +381,7 @@ pub fn foreground_highlight(
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// foreground_color = rgba(0, 240, 0, 10.pct())
/// }
@ -407,7 +407,7 @@ pub fn foreground_color(child: impl UiNode, color: impl IntoVar<Rgba>) -> impl U
/// # let _scope = App::minimal();
/// # fn foo() -> impl UiNode { wgt!() }
/// #
/// container! {
/// Container! {
/// child = foo();
/// foreground_gradient = {
/// axis: (0, 0).to(0, 10),
@ -441,12 +441,12 @@ pub fn foreground_gradient(child: impl UiNode, axis: impl IntoVar<LinearGradient
/// # use zero_ui::prelude::*;
/// # let _scope = App::minimal();
/// #
/// container! {
/// Container! {
/// background_color = rgb(255, 0, 0);
/// size = (200, 300);
/// corner_radius = 5;
/// clip_to_bounds = true;
/// child = container! {
/// child = Container! {
/// background_color = rgb(0, 255, 0);
/// // fixed size ignores the layout available size.
/// size = (1000, 1000);

View File

@ -177,9 +177,9 @@ mod ansi_parse {
/// Iterator that parses ANSI escape codes.
///
/// This is the pull style parser used internally by the [`ansi_text!`] widget.
/// This is the pull style parser used internally by the [`AnsiText!`] widget.
///
/// [`ansi_text!`]: mod@crate::widgets::ansi_text
/// [`AnsiText!`]: mod@crate::widgets::ansi_text
pub struct AnsiTextParser<'a> {
source: &'a str,
/// Current style.
@ -392,9 +392,9 @@ mod ansi_fn {
/// Widget function for [`PanelFnArgs`].
///
/// The returned view is the [`ansi_text!`] child. The default is [`default_panel_fn`].
/// The returned view is the [`AnsiText!`] child. The default is [`default_panel_fn`].
///
/// [`ansi_text!`]: mod@super::ansi_text
/// [`AnsiText!`]: mod@super::ansi_text
pub static PANEL_GEN_VAR: WidgetFn<PanelFnArgs> = wgt_fn!(|args: PanelFnArgs| {
default_panel_fn(args)
});
@ -497,7 +497,7 @@ mod ansi_fn {
/// Default [`LINE_GEN_VAR`].
///
/// Returns a `wrap!` for text with multiple segments, or returns the single segment, or an empty text.
/// Returns a `Wrap!` for text with multiple segments, or returns the single segment, or an empty text.
pub fn default_line_fn(mut args: LineFnArgs) -> impl UiNode {
use crate::prelude::*;

View File

@ -45,7 +45,7 @@ pub fn cells(child: impl UiNode, cells: impl UiNodeList) -> impl UiNode {}
/// Column definitions.
///
/// You can define columns with any widget, but the [`column!`] widget is recommended. The column widget width defines
/// You can define columns with any widget, but the [`Column!`] widget is recommended. The column widget width defines
/// the width of the cells assigned to it, the [`column::width`] property can be used to enforce a width, otherwise the
/// column is sized by the widest cell.
///
@ -69,7 +69,7 @@ pub fn cells(child: impl UiNode, cells: impl UiNodeList) -> impl UiNode {}
/// Properties like `padding` and `align` only affect the column visual, not the cells, similarly contextual properties like `text_color`
/// don't affect the cells.
///
/// [`column!`]: mod@column
/// [`Column!`]: mod@column
/// [`column::width`]: fn@column::width
/// [`lft`]: LengthUnits::lft
#[property(CHILD, capture, impl(Grid))]
@ -107,7 +107,7 @@ pub fn spacing(child: impl UiNode, spacing: impl IntoVar<GridSpacing>) -> impl U
/// Grid node.
///
/// Can be used directly to layout widgets without declaring a grid widget info. This node is the child
/// of the `grid!` widget.
/// of the `Grid!` widget.
pub fn node(
cells: impl UiNodeList,
columns: impl UiNodeList,
@ -147,7 +147,7 @@ pub mod column {
///
/// # Shorthand
///
/// The `column!` macro provides a shorthand init that sets the width, `grid::column!(1.lft())` instantiates
/// The `Column!` macro provides a shorthand init that sets the width, `grid::Column!(1.lft())` instantiates
/// a column with width of *1 leftover*.
///
/// [`grid::columns`]: fn@grid::columns
@ -233,7 +233,7 @@ pub mod column {
/// # use zero_ui::{widgets::layouts::grid, properties::background_color, core::color::colors};
/// # let _scope = zero_ui::core::app::App::minimal();
/// # let _ =
/// grid::column! {
/// grid::Column! {
/// background_color = colors::GRAY;
///
/// when *#get_index % 3 == 0 {
@ -332,7 +332,7 @@ pub mod row {
///
/// # Shorthand
///
/// The `row!` macro provides a shorthand init that sets the height, `grid::row!(1.lft())` instantiates
/// The `Row!` macro provides a shorthand init that sets the height, `grid::Row!(1.lft())` instantiates
/// a row with height of *1 leftover*.
///
/// [`grid::rows`]: fn@grid::rows
@ -418,7 +418,7 @@ pub mod row {
/// # use zero_ui::{widgets::layouts::grid, properties::background_color, core::color::colors};
/// # let _scope = zero_ui::core::app::App::minimal();
/// # let _ =
/// grid::row! {
/// grid::Row! {
/// background_color = colors::GRAY;
///
/// when *#get_index % 3 == 0 {
@ -510,7 +510,7 @@ pub mod cell {
/// Grid cell container.
///
/// This widget defines properties that position and size widgets in a [`grid!`].
/// This widget defines properties that position and size widgets in a [`Grid!`].
///
/// See the [`grid::cells`] property for more details.
///

View File

@ -102,7 +102,7 @@ pub fn children_align(child: impl UiNode, align: impl IntoVar<Align>) -> impl Ui
/// Stack node.
///
/// Can be used directly to stack widgets without declaring a stack widget info. This node is the child
/// of the `stack!` widget.
/// of the `Stack!` widget.
pub fn node(
children: impl UiNodeList,
direction: impl IntoVar<StackDirection>,
@ -477,9 +477,9 @@ fn spacing_from_direction(direction_vector: euclid::Vector2D<i8, ()>, spacing: L
/// ]);
/// ```
///
/// # `stack!`
/// # `Stack!`
///
/// This function is just a shortcut for [`stack!`](mod@stack) with [`StackDirection::left_to_right`].
/// This function is just a shortcut for [`Stack!`](mod@stack) with [`StackDirection::left_to_right`].
pub fn h_stack(children: impl UiNodeList) -> impl UiNode {
Stack! {
direction = StackDirection::left_to_right();
@ -500,9 +500,9 @@ pub fn h_stack(children: impl UiNodeList) -> impl UiNode {
/// ]);
/// ```
///
/// # `stack!`
/// # `Stack!`
///
/// This function is just a shortcut for [`stack!`](mod@stack) with [`StackDirection::top_to_bottom`].
/// This function is just a shortcut for [`Stack!`](mod@stack) with [`StackDirection::top_to_bottom`].
pub fn v_stack(children: impl UiNodeList) -> impl UiNode {
Stack! {
direction = StackDirection::top_to_bottom();
@ -523,9 +523,9 @@ pub fn v_stack(children: impl UiNodeList) -> impl UiNode {
/// ]);
/// ```
///
/// # `stack!`
/// # `Stack!`
///
/// This function is just a shortcut for [`stack!`](mod@stack) with [`StackDirection::none`].
/// This function is just a shortcut for [`Stack!`](mod@stack) with [`StackDirection::none`].
pub fn z_stack(children: impl UiNodeList) -> impl UiNode {
Stack! {
children;
@ -538,9 +538,9 @@ pub fn z_stack(children: impl UiNodeList) -> impl UiNode {
///
/// This is the most simple *z-stack* implementation possible, it is a building block useful for quickly declaring
/// overlaying effects composed of multiple nodes, it does not do any alignment layout or z-sorting render,
/// for a complete stack panel widget see [`stack!`].
/// for a complete stack panel widget see [`Stack!`].
///
/// [`stack!`]: mod@stack
/// [`Stack!`]: mod@stack
pub fn stack_nodes(nodes: impl UiNodeList) -> impl UiNode {
#[ui_node(struct StackNodesNode {
children: impl UiNodeList,

View File

@ -17,15 +17,15 @@ use std::{fmt, mem, ops};
/// The direction type can express non-fill alignment and spacing by it self, but prefer using the [`stack::children_align`] and
/// [`stack::spacing`] properties as they are more readable and include fill alignment.
///
/// The [`stack!`] widget implements alignment along the axis that does not change, so if the computed layout vector
/// The [`Stack!`] widget implements alignment along the axis that does not change, so if the computed layout vector
/// is zero in a dimension the items can fill in that dimension.
///
/// The [`stack!`] widget adds the spacing along non-zero axis for each item offset after the first, so the spacing is not
/// The [`Stack!`] widget adds the spacing along non-zero axis for each item offset after the first, so the spacing is not
/// added for a perfect straight column or row, but it is added even for a single pixel shift *diagonal* stack.
///
/// [`stack::children_align`]: fn@crate::widgets::layouts::stack::children_align
/// [`stack::spacing`]: fn@crate::widgets::layouts::stack::spacing
/// [`stack!`]: mod@crate::widgets::layouts::stack
/// [`Stack!`]: mod@crate::widgets::layouts::stack
#[derive(Default, Clone)]
pub struct StackDirection {
/// Point on the previous item where the next item is placed.

View File

@ -80,7 +80,7 @@ pub fn children_align(child: impl UiNode, align: impl IntoVar<Align>) -> impl Ui
/// Wrap node.
///
/// Can be used directly to inline widgets without declaring a wrap widget info. This node is the child
/// of the `wrap!` widget.
/// of the `Wrap!` widget.
pub fn node(children: impl UiNodeList, spacing: impl IntoVar<GridSpacing>, children_align: impl IntoVar<Align>) -> impl UiNode {
WrapNode {
children: PanelList::new(children),
@ -876,11 +876,11 @@ impl InlineLayout {
if (sum_width - width) > Px(1) {
if metrics.inline_constraints().is_some() && (i == 0 || i == self.rows.len() - 1) {
tracing::error!("wrap! panel row {i} inline width is {width}, but sum of segs is {sum_width}");
tracing::error!("Wrap! panel row {i} inline width is {width}, but sum of segs is {sum_width}");
continue;
}
tracing::error!("wrap! panel row {i} computed width {width}, but sum of segs is {sum_width}");
tracing::error!("Wrap! panel row {i} computed width {width}, but sum of segs is {sum_width}");
}
}
}

View File

@ -74,7 +74,7 @@ pub fn markdown_node(md: impl IntoVar<Txt>) -> impl UiNode {
#[UiNode]
fn info(&self, info: &mut WidgetInfoBuilder) {
info.meta().set(&markdown::MARKDOWN_INFO_ID, ());
info.meta().set(&MARKDOWN_INFO_ID, ());
self.child.info(info);
}

View File

@ -301,7 +301,7 @@ pub fn try_open_link(args: &LinkArgs) -> bool {
focus_on_init = true;
child = Text!(url);
underline_skip = UnderlineSkip::SPACES;
text::underline_skip = UnderlineSkip::SPACES;
on_blur = async_hn_once!(status, |_| {
if status.get() != Status::Pending {

View File

@ -388,42 +388,31 @@ pub fn panel_fn(child: impl UiNode, wgt_fn: impl IntoVar<WidgetFn<PanelFnArgs>>)
with_context_var(child, PANEL_GEN_VAR, wgt_fn)
}
fn text_view_builder(txt: Txt, style: MarkdownStyle) -> WidgetBuilder {
use crate::widgets::Text as t;
fn text_view_builder(txt: Txt, style: MarkdownStyle) -> crate::widgets::Text {
let mut builder = crate::widgets::Text::start();
let mut builder = WidgetBuilder::new(t::widget_type()); // !!: use `Text` directly.
t::include(&mut builder);
builder.push_property(
Importance::INSTANCE,
property_args! {
t::txt = txt;
},
);
properties! {
&mut builder;
txt;
}
if style.strong {
builder.push_property(
Importance::INSTANCE,
property_args! {
t::font_weight = FontWeight::BOLD;
},
);
properties! {
&mut builder;
font_weight = FontWeight::BOLD;
}
}
if style.emphasis {
builder.push_property(
Importance::INSTANCE,
property_args! {
t::font_style = FontStyle::Italic;
},
);
properties! {
&mut builder;
font_style = FontStyle::Italic;
}
}
if style.strikethrough {
builder.push_property(
Importance::INSTANCE,
property_args! {
t::strikethrough = 1, LineStyle::Solid;
},
);
properties! {
&mut builder;
strikethrough = 1, LineStyle::Solid;
}
}
builder
@ -433,32 +422,23 @@ fn text_view_builder(txt: Txt, style: MarkdownStyle) -> WidgetBuilder {
///
/// See [`TEXT_GEN_VAR`] for more details.
pub fn default_text_fn(args: TextFnArgs) -> impl UiNode {
let builder = text_view_builder(args.txt, args.style);
crate::widgets::text::build(builder)
let mut builder = text_view_builder(args.txt, args.style);
builder.build()
}
/// Default inlined code text view.
///
/// See [`CODE_INLINE_GEN_VAR`] for more details.
pub fn default_code_inline_fn(args: CodeInlineFnArgs) -> impl UiNode {
use crate::widgets::text as t;
let mut builder = text_view_builder(args.txt, args.style);
builder.push_property(
Importance::INSTANCE,
property_args! {
t::font_family = ["JetBrains Mono", "Consolas", "monospace"];
},
);
builder.push_property(
Importance::INSTANCE,
property_args! {
background_color = color_scheme_map(rgb(0.05, 0.05, 0.05), rgb(0.95, 0.95, 0.95));
},
);
properties! {
&mut builder;
font_family = ["JetBrains Mono", "Consolas", "monospace"];
background_color = color_scheme_map(rgb(0.05, 0.05, 0.05), rgb(0.95, 0.95, 0.95));
}
crate::widgets::text::build(builder)
builder.build()
}
/// Default inlined link view.
@ -474,20 +454,20 @@ pub fn default_link_fn(args: LinkFnArgs) -> impl UiNode {
let items = if items.len() == 1 {
items.remove(0)
} else {
crate::widgets::layouts::wrap! {
crate::widgets::layouts::Wrap! {
children = items;
}
.boxed()
};
crate::widgets::link! {
crate::widgets::Link! {
child = items;
on_click = hn!(|args: &ClickArgs| {
args.propagation().stop();
let link = WINDOW.widget_tree().get(WIDGET.id()).unwrap().interaction_path();
markdown::LINK_EVENT.notify(markdown::LinkArgs::now(url.clone(), link));
LINK_EVENT.notify(LinkArgs::now(url.clone(), link));
});
}
.boxed()
@ -496,14 +476,14 @@ pub fn default_link_fn(args: LinkFnArgs) -> impl UiNode {
/// Default code block view.
///
/// Is [`ansi_text!`] for the `ansi` language, and only raw text for the rest.
/// Is [`AnsiText!`] for the `ansi` language, and only raw text for the rest.
///
/// See [`CODE_BLOCK_GEN_VAR`] for more details.
///
/// [`ansi_text!`]: mod@crate::widgets::ansi_text
/// [`AnsiText!`]: mod@crate::widgets::ansi_text
pub fn default_code_block_fn(args: CodeBlockFnArgs) -> impl UiNode {
if args.lang == "ansi" {
crate::widgets::ansi_text! {
crate::widgets::AnsiText! {
txt = args.txt;
padding = 6;
corner_radius = 4;
@ -531,7 +511,7 @@ pub fn default_paragraph_fn(mut args: ParagraphFnArgs) -> impl UiNode {
} else if args.items.len() == 1 {
args.items.remove(0)
} else {
crate::widgets::layouts::wrap! {
crate::widgets::layouts::Wrap! {
children = args.items;
}
.boxed()
@ -545,7 +525,7 @@ pub fn default_heading_fn(args: HeadingFnArgs) -> impl UiNode {
if args.items.is_empty() {
NilUiNode.boxed()
} else {
crate::widgets::layouts::wrap! {
crate::widgets::layouts::Wrap! {
font_size = match args.level {
HeadingLevel::H1 => 2.em(),
HeadingLevel::H2 => 1.5.em(),
@ -555,7 +535,7 @@ pub fn default_heading_fn(args: HeadingFnArgs) -> impl UiNode {
HeadingLevel::H6 => 1.1.em()
};
children = args.items;
super::markdown::anchor = args.anchor;
anchor = args.anchor;
}
.boxed()
}
@ -563,22 +543,22 @@ pub fn default_heading_fn(args: HeadingFnArgs) -> impl UiNode {
/// Default list view.
///
/// Uses a [`grid!`] with two columns, one default for the bullet or number, the other fills the leftover space.
/// Uses a [`Grid!`] with two columns, one default for the bullet or number, the other fills the leftover space.
///
/// See [`LIST_GEN_VAR`] for more details.
///
/// [`grid!`]: mod@crate::widgets::layouts::grid
/// [`Grid!`]: mod@crate::widgets::layouts::grid
pub fn default_list_fn(args: ListFnArgs) -> impl UiNode {
if args.items.is_empty() {
NilUiNode.boxed()
} else {
use crate::widgets::layouts::grid;
grid! {
use crate::widgets::layouts::{Grid, grid};
Grid! {
margin = (0, 0, 0, 1.em());
cells = args.items;
columns = ui_vec![
grid::column!(),
grid::column! { width = 1.lft() },
grid::Column!(),
grid::Column! { width = 1.lft() },
];
}
.boxed()
@ -654,14 +634,14 @@ pub fn default_list_item_fn(args: ListItemFnArgs) -> impl UiNode {
let mut r = if items.len() == 1 {
items.remove(0)
} else {
wrap! {
Wrap! {
children = items;
}
.boxed()
};
if let Some(inner) = args.nested_list {
r = stack! {
r = Stack! {
direction = StackDirection::top_to_bottom();
children = ui_vec![
r,
@ -690,7 +670,7 @@ pub fn default_image_fn(args: ImageFnArgs) -> impl UiNode {
let alt_items = if alt_items.len() == 1 {
alt_items.remove(0)
} else {
wrap! {
Wrap! {
children = alt_items;
}
.boxed()
@ -724,7 +704,7 @@ pub fn default_block_quote_fn(args: BlockQuoteFnArgs) -> impl UiNode {
if args.items.is_empty() {
NilUiNode.boxed()
} else {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = PARAGRAPH_SPACING_VAR;
children = args.items;
@ -750,12 +730,12 @@ pub fn default_block_quote_fn(args: BlockQuoteFnArgs) -> impl UiNode {
pub fn default_table_fn(args: TableFnArgs) -> impl UiNode {
use crate::widgets::layouts::grid;
grid! {
Grid! {
background_color = TEXT_COLOR_VAR.map(|c| c.with_alpha(5.pct()));
border = 1, TEXT_COLOR_VAR.map(|c| c.with_alpha(30.pct()).into());
align = Align::LEFT;
auto_grow_fn = wgt_fn!(|args: grid::AutoGrowFnArgs| {
grid::row! {
grid::Row! {
border = (0, 0, 1, 0), TEXT_COLOR_VAR.map(|c| c.with_alpha(10.pct()).into());
background_color = {
let alpha = if args.index % 2 == 0 {
@ -771,7 +751,7 @@ pub fn default_table_fn(args: TableFnArgs) -> impl UiNode {
}
}
});
columns = std::iter::repeat_with(|| grid::column!{}.boxed()).take(args.columns.len()).collect::<UiNodeVec>();
columns = std::iter::repeat_with(|| grid::Column!{}.boxed()).take(args.columns.len()).collect::<UiNodeVec>();
cells = args.cells;
}
}
@ -785,7 +765,7 @@ pub fn default_table_cell_fn(args: TableCellFnArgs) -> impl UiNode {
if args.items.is_empty() {
NilUiNode.boxed()
} else if args.is_heading {
wrap! {
Wrap! {
crate::widgets::text::font_weight = crate::core::text::FontWeight::BOLD;
padding = 6;
child_align = args.col_align;
@ -793,7 +773,7 @@ pub fn default_table_cell_fn(args: TableCellFnArgs) -> impl UiNode {
}
.boxed()
} else {
wrap! {
Wrap! {
padding = 6;
child_align = args.col_align;
children = args.items;
@ -811,7 +791,7 @@ pub fn default_panel_fn(args: PanelFnArgs) -> impl UiNode {
if args.items.is_empty() {
NilUiNode.boxed()
} else {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
spacing = PARAGRAPH_SPACING_VAR;
children = args.items;
@ -827,7 +807,7 @@ pub fn default_footnote_ref_fn(args: FootnoteRefFnArgs) -> impl UiNode {
use crate::widgets::*;
let url = formatx!("#footnote-{}", args.label);
link! {
Link! {
font_size = 0.7.em();
offset = (0, (-0.5).em());
markdown::anchor = formatx!("footnote-ref-{}", args.label);
@ -853,7 +833,7 @@ pub fn default_footnote_def_fn(args: FootnoteDefFnArgs) -> impl UiNode {
} else if items.len() == 1 {
items.remove(0)
} else {
stack! {
Stack! {
direction = StackDirection::top_to_bottom();
children = items;
}
@ -861,12 +841,12 @@ pub fn default_footnote_def_fn(args: FootnoteDefFnArgs) -> impl UiNode {
};
let url_back = formatx!("#footnote-ref-{}", args.label);
stack! {
Stack! {
direction = StackDirection::left_to_right();
spacing = 0.5.em();
markdown::anchor = formatx!("footnote-{}", args.label);
children = ui_vec![
link! {
Link! {
child = Text!("[^{}]", args.label);
on_click = hn!(|args: &ClickArgs| {
args.propagation().stop();

View File

@ -100,7 +100,7 @@ impl Text {
/// The text string.
///
/// Set to an empty string (`""`) by default.
#[property(CHILD, capture, default(""))]
#[property(CHILD, capture, default(""), impl(Text))]
pub fn txt(child: impl UiNode, txt: impl IntoVar<Txt>) -> impl UiNode {}
///<span data-del-macro-root></span> A simple text run with **bold** font weight.

View File

@ -8,6 +8,8 @@ use std::{
sync::{Arc, Mutex},
};
use crate::core::gesture::CLICK_EVENT;
use crate::prelude::new_widget::*;
/// A toggle button that flips a `bool` or `Option<bool>` variable on click, or selects a value.
@ -21,20 +23,17 @@ use crate::prelude::new_widget::*;
/// [`value`]: fn@toggle::value
/// [`selector`]: fn@toggle::selector
#[widget($crate::widgets::Toggle)]
pub struct Toggle(Button);
pub struct Toggle(crate::widgets::Button);
impl Toggle {
#[widget(on_start)]
fn on_start(&mut self) {
defaults! {
self;
style_fn = STYLE_VAR;
}
self.style_fn(STYLE_VAR);
self.builder().push_build_action(|wgt| {
if let Some(p) = wgt.property_mut(super::property_id!(checked_opt)) {
if let Some(p) = wgt.property_mut(property_id!(Self::checked_opt)) {
p.position.index = u16::MAX; // force property to be inside tristate.
}
if let Some(p) = wgt.property_mut(super::property_id!(value::<()>)) {
if let Some(p) = wgt.property_mut(property_id!(Self::value)) {
p.position.index = u16::MAX; // force property to be inside select_on_init and others.
}
});
@ -261,7 +260,7 @@ pub fn is_checked(child: impl UiNode, state: impl IntoVar<bool>) -> impl UiNode
/// # let _scope = App::minimal();
/// let foo = var(1_i32);
///
/// stack! {
/// Stack! {
/// toggle::selector = toggle::Selector::single(foo.clone());
///
/// spacing = 5;
@ -838,7 +837,7 @@ impl DefaultStyle {
/// Style a [`Toggle!`] widget to look like a *checkbox*.
///
/// [`Toggle!`]: struct@Toggle
#[widget($crate::widgets::toggle::vis::CheckStyle)]
#[widget($crate::widgets::toggle::CheckStyle)]
pub struct CheckStyle(Style);
impl CheckStyle {
#[widget(on_start)]