Update examples to ui.window(...)

This commit is contained in:
dbr 2021-09-25 11:51:11 +10:00
parent 0f7cb49865
commit cc7ffbe351
17 changed files with 71 additions and 69 deletions

View File

@ -10,9 +10,9 @@
![Hello world](hello_world.png) ![Hello world](hello_world.png)
```rust ```rust
Window::new("Hello world") ui.window("Hello world")
.size([300.0, 100.0], Condition::FirstUseEver) .size([300.0, 100.0], Condition::FirstUseEver)
.build(&ui, || { .build(|| {
ui.text("Hello world!"); ui.text("Hello world!");
ui.text("こんにちは世界!"); ui.text("こんにちは世界!");
ui.text("This...is...imgui-rs!"); ui.text("This...is...imgui-rs!");

View File

@ -8,11 +8,11 @@ fn main() {
}; };
let system = support::init(file!()); let system = support::init(file!());
system.main_loop(move |run, ui| { system.main_loop(move |run, ui| {
let w = Window::new("Collapsing header") let w = ui.window("Collapsing header")
.opened(run) .opened(run)
.position([20.0, 20.0], Condition::Appearing) .position([20.0, 20.0], Condition::Appearing)
.size([700.0, 500.0], Condition::Appearing); .size([700.0, 500.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
if CollapsingHeader::new("I'm a collapsing header. Click me!").build(ui) { if CollapsingHeader::new("I'm a collapsing header. Click me!").build(ui) {
ui.text( ui.text(
"A collapsing header can be used to toggle rendering of a group of widgets", "A collapsing header can be used to toggle rendering of a group of widgets",

View File

@ -17,12 +17,12 @@ fn main() {
} }
fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) { fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
let w = Window::new("Color button examples") let w = ui.window("Color button examples")
.opened(run) .opened(run)
.position([20.0, 20.0], Condition::Appearing) .position([20.0, 20.0], Condition::Appearing)
.size([700.0, 100.0], Condition::Appearing) .size([700.0, 100.0], Condition::Appearing)
.resizable(false); .resizable(false);
w.build(ui, || { w.build(|| {
let ex1 = ui.radio_button("Example 1: Basics", &mut state.example, 1); let ex1 = ui.radio_button("Example 1: Basics", &mut state.example, 1);
let ex2 = ui.radio_button("Example 2: Alpha component", &mut state.example, 2); let ex2 = ui.radio_button("Example 2: Alpha component", &mut state.example, 2);
let ex3 = ui.radio_button("Example 3: Input format", &mut state.example, 3); let ex3 = ui.radio_button("Example 3: Input format", &mut state.example, 3);
@ -33,10 +33,10 @@ fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
} }
fn example_1(ui: &Ui, state: &mut State) { fn example_1(ui: &Ui, state: &mut State) {
let w = Window::new("Example 1: Basics") let w = ui.window("Example 1: Basics")
.size([700.0, 300.0], Condition::Appearing) .size([700.0, 300.0], Condition::Appearing)
.position([20.0, 140.0], Condition::Appearing); .position([20.0, 140.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text_wrapped( ui.text_wrapped(
"Color button is a widget that displays a color value as a clickable rectangle. \ "Color button is a widget that displays a color value as a clickable rectangle. \
It also supports a tooltip with detailed information about the color value. \ It also supports a tooltip with detailed information about the color value. \
@ -73,10 +73,10 @@ fn example_1(ui: &Ui, state: &mut State) {
} }
fn example_2(ui: &Ui) { fn example_2(ui: &Ui) {
let w = Window::new("Example 2: Alpha component") let w = ui.window("Example 2: Alpha component")
.size([700.0, 320.0], Condition::Appearing) .size([700.0, 320.0], Condition::Appearing)
.position([20.0, 140.0], Condition::Appearing); .position([20.0, 140.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text_wrapped( ui.text_wrapped(
"The displayed color is passed to the button as four float values between \ "The displayed color is passed to the button as four float values between \
0.0 - 1.0 (RGBA). If you don't care about the alpha component, it can be \ 0.0 - 1.0 (RGBA). If you don't care about the alpha component, it can be \
@ -123,10 +123,10 @@ fn example_2(ui: &Ui) {
} }
fn example_3(ui: &Ui) { fn example_3(ui: &Ui) {
let w = Window::new("Example 3: Input format") let w = ui.window("Example 3: Input format")
.size([700.0, 320.0], Condition::Appearing) .size([700.0, 320.0], Condition::Appearing)
.position([20.0, 140.0], Condition::Appearing); .position([20.0, 140.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text("This button interprets the input value [1.0, 0.0, 0.0, 1.0] as RGB(A) (default):"); ui.text("This button interprets the input value [1.0, 0.0, 0.0, 1.0] as RGB(A) (default):");
ColorButton::new("RGBA red", [1.0, 0.0, 0.0, 1.0]).build(ui); ColorButton::new("RGBA red", [1.0, 0.0, 0.0, 1.0]).build(ui);

View File

@ -78,9 +78,9 @@ impl CustomTexturesApp {
} }
fn show_textures(&self, ui: &Ui) { fn show_textures(&self, ui: &Ui) {
Window::new("Hello textures") ui.window("Hello textures")
.size([400.0, 400.0], Condition::FirstUseEver) .size([400.0, 400.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text("Hello textures!"); ui.text("Hello textures!");
if let Some(my_texture_id) = self.my_texture_id { if let Some(my_texture_id) = self.my_texture_id {
ui.text("Some generated texture"); ui.text("Some generated texture");

View File

@ -1,3 +1,5 @@
//! Demonstrates disabling widgets. Prevents mouse interaction and greys out widgets
use imgui::*; use imgui::*;
mod support; mod support;
@ -11,9 +13,9 @@ fn main() {
let mut click_count = 0; let mut click_count = 0;
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Disabling widgets") ui.window("Disabling widgets")
.size([300.0, 200.0], Condition::FirstUseEver) .size([300.0, 200.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.checkbox("Edit mode", &mut edit_mode); ui.checkbox("Edit mode", &mut edit_mode);
ui.checkbox("Safe mode", &mut safe_mode); ui.checkbox("Safe mode", &mut safe_mode);

View File

@ -57,10 +57,10 @@ fn main() {
); );
} }
Window::new("Draw list") ui.window("Draw list")
.size([300.0, 110.0], Condition::FirstUseEver) .size([300.0, 110.0], Condition::FirstUseEver)
.scroll_bar(false) .scroll_bar(false)
.build(ui, || { .build(|| {
ui.button("random button"); ui.button("random button");
let draw_list = ui.get_window_draw_list(); let draw_list = ui.get_window_draw_list();
let o = ui.cursor_screen_pos(); let o = ui.cursor_screen_pos();

View File

@ -7,9 +7,9 @@ fn main() {
let mut value = 0; let mut value = 0;
let choices = ["test test this is 1", "test test this is 2"]; let choices = ["test test this is 1", "test test this is 2"];
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Hello world") ui.window("Hello world")
.size([300.0, 110.0], Condition::FirstUseEver) .size([300.0, 110.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text_wrapped("Hello world!"); ui.text_wrapped("Hello world!");
ui.text_wrapped("こんにちは世界!"); ui.text_wrapped("こんにちは世界!");
if ui.button(choices[value]) { if ui.button(choices[value]) {

View File

@ -14,9 +14,9 @@ fn main() {
let mut text_buffer = String::new(); let mut text_buffer = String::new();
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Means of accessing key state") ui.window("Means of accessing key state")
.size([500.0, 300.0], Condition::FirstUseEver) .size([500.0, 300.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
// You can check if a key is currently held down // You can check if a key is currently held down
if ui.is_key_down(Key::A) { if ui.is_key_down(Key::A) {
ui.text("The A key is down!"); ui.text("The A key is down!");

View File

@ -15,9 +15,9 @@ fn main() {
let system = support::init(file!()); let system = support::init(file!());
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Hello long world") ui.window("Hello long world")
.size([300.0, 110.0], Condition::FirstUseEver) .size([300.0, 110.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
let mut clipper = imgui::ListClipper::new(lots_of_words.len() as i32) let mut clipper = imgui::ListClipper::new(lots_of_words.len() as i32)
.items_height(ui.current_font_size()) .items_height(ui.current_font_size())
.begin(ui); .begin(ui);

View File

@ -19,7 +19,7 @@ fn main() {
.reload_font_texture(&mut system.imgui) .reload_font_texture(&mut system.imgui)
.expect("Failed to reload fonts"); .expect("Failed to reload fonts");
system.main_loop(move |run, ui| { system.main_loop(move |run, ui| {
Window::new("Hello world").opened(run).build(ui, || { ui.window("Hello world").opened(run).build(|| {
ui.text("Hello, I'm the default font!"); ui.text("Hello, I'm the default font!");
let _roboto = ui.push_font(roboto); let _roboto = ui.push_font(roboto);
ui.text("Hello, I'm Roboto Regular!"); ui.text("Hello, I'm Roboto Regular!");

View File

@ -5,11 +5,11 @@ mod support;
fn main() { fn main() {
let system = support::init(file!()); let system = support::init(file!());
system.main_loop(move |run, ui| { system.main_loop(move |run, ui| {
let w = Window::new("Progress bar") let w = ui.window("Progress bar")
.opened(run) .opened(run)
.position([20.0, 20.0], Condition::Appearing) .position([20.0, 20.0], Condition::Appearing)
.size([700.0, 200.0], Condition::Appearing); .size([700.0, 200.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text("This is a simple progress bar:"); ui.text("This is a simple progress bar:");
ProgressBar::new(0.5).build(ui); ProgressBar::new(0.5).build(ui);

View File

@ -16,12 +16,12 @@ fn main() {
} }
fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) { fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
let w = Window::new("Radio button examples") let w = ui.window("Radio button examples")
.opened(run) .opened(run)
.position([20.0, 20.0], Condition::Appearing) .position([20.0, 20.0], Condition::Appearing)
.size([700.0, 80.0], Condition::Appearing) .size([700.0, 80.0], Condition::Appearing)
.resizable(false); .resizable(false);
w.build(ui, || { w.build(|| {
let mut clicked = false; let mut clicked = false;
clicked |= ui.radio_button("Example 1: Boolean radio buttons", &mut state.example, 1); clicked |= ui.radio_button("Example 1: Boolean radio buttons", &mut state.example, 1);
clicked |= ui.radio_button("Example 2: Radio buttons", &mut state.example, 2); clicked |= ui.radio_button("Example 2: Radio buttons", &mut state.example, 2);
@ -32,10 +32,10 @@ fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
} }
fn example_1(ui: &Ui, state: &mut State) { fn example_1(ui: &Ui, state: &mut State) {
let w = Window::new("Example 1: Boolean radio buttons") let w = ui.window("Example 1: Boolean radio buttons")
.size([700.0, 200.0], Condition::Appearing) .size([700.0, 200.0], Condition::Appearing)
.position([20.0, 120.0], Condition::Appearing); .position([20.0, 120.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text_wrapped( ui.text_wrapped(
"Boolean radio buttons accept a boolean active state, which is passed as a value and \ "Boolean radio buttons accept a boolean active state, which is passed as a value and \
not as a mutable reference. This means that it's not updated automatically, so you \ not as a mutable reference. This means that it's not updated automatically, so you \
@ -58,10 +58,10 @@ fn example_1(ui: &Ui, state: &mut State) {
} }
fn example_2(ui: &Ui, state: &mut State) { fn example_2(ui: &Ui, state: &mut State) {
let w = Window::new("Example 2: Radio buttons") let w = ui.window("Example 2: Radio buttons")
.size([700.0, 300.0], Condition::Appearing) .size([700.0, 300.0], Condition::Appearing)
.position([20.0, 120.0], Condition::Appearing); .position([20.0, 120.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text_wrapped( ui.text_wrapped(
"Normal radio buttons accept a mutable reference to state, and the value \ "Normal radio buttons accept a mutable reference to state, and the value \
corresponding to this button. They are very flexible, because the value can be any \ corresponding to this button. They are very flexible, because the value can be any \

View File

@ -16,12 +16,12 @@ fn main() {
} }
fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) { fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
let w = Window::new("Slider examples") let w = ui.window("Slider examples")
.opened(run) .opened(run)
.position([20.0, 20.0], Condition::Appearing) .position([20.0, 20.0], Condition::Appearing)
.size([700.0, 80.0], Condition::Appearing) .size([700.0, 80.0], Condition::Appearing)
.resizable(false); .resizable(false);
w.build(ui, || { w.build(|| {
let mut clicked = false; let mut clicked = false;
clicked |= ui.radio_button("Example 1: Basic sliders", &mut state.example, 1); clicked |= ui.radio_button("Example 1: Basic sliders", &mut state.example, 1);
clicked |= ui.radio_button("Example 2: Slider arrays", &mut state.example, 2); clicked |= ui.radio_button("Example 2: Slider arrays", &mut state.example, 2);
@ -32,10 +32,10 @@ fn example_selector(run: &mut bool, ui: &mut Ui, state: &mut State) {
} }
fn example_1(ui: &Ui, state: &mut State) { fn example_1(ui: &Ui, state: &mut State) {
let w = Window::new("Example 1: Basic sliders") let w = ui.window("Example 1: Basic sliders")
.size([700.0, 340.0], Condition::Appearing) .size([700.0, 340.0], Condition::Appearing)
.position([20.0, 120.0], Condition::Appearing); .position([20.0, 120.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text("All of the following data types are supported:"); ui.text("All of the following data types are supported:");
ui.text("Signed: i8 i16 i32 i64"); ui.text("Signed: i8 i16 i32 i64");
ui.text("Unsigned: u8 u16 u32 u64"); ui.text("Unsigned: u8 u16 u32 u64");
@ -67,10 +67,10 @@ fn example_1(ui: &Ui, state: &mut State) {
} }
fn example_2(ui: &Ui, state: &mut State) { fn example_2(ui: &Ui, state: &mut State) {
let w = Window::new("Example 2: Slider arrays") let w = ui.window("Example 2: Slider arrays")
.size([700.0, 260.0], Condition::Appearing) .size([700.0, 260.0], Condition::Appearing)
.position([20.0, 120.0], Condition::Appearing); .position([20.0, 120.0], Condition::Appearing);
w.build(ui, || { w.build(|| {
ui.text("You can easily build a slider group from an array of values:"); ui.text("You can easily build a slider group from an array of values:");
Slider::new("[u8; 4]", 0, u8::MAX).build_array(ui, &mut state.array); Slider::new("[u8; 4]", 0, u8::MAX).build_array(ui, &mut state.array);

View File

@ -29,9 +29,9 @@ fn main() {
| TableFlags::NO_BORDERS_IN_BODY; | TableFlags::NO_BORDERS_IN_BODY;
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Input text callbacks") ui.window("Input text callbacks")
.size([800.0, 400.0], Condition::FirstUseEver) .size([800.0, 400.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
if let Some(_t) = ui.begin_table("Basic-Table", 3) { if let Some(_t) = ui.begin_table("Basic-Table", 3) {
// we must also call `next_row` here, because we declined // we must also call `next_row` here, because we declined
// to set up header rows. If we set up header rows ourselves, // to set up header rows. If we set up header rows ourselves,

View File

@ -286,15 +286,15 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
ui.show_metrics_window(&mut state.show_app_metrics); ui.show_metrics_window(&mut state.show_app_metrics);
} }
if state.show_app_style_editor { if state.show_app_style_editor {
Window::new("Style Editor") ui.window("Style Editor")
.opened(&mut state.show_app_style_editor) .opened(&mut state.show_app_style_editor)
.build(ui, || ui.show_default_style_editor()); .build(|| ui.show_default_style_editor());
} }
if state.show_app_about { if state.show_app_about {
Window::new("About ImGui") ui.window("About ImGui")
.always_auto_resize(true) .always_auto_resize(true)
.opened(&mut state.show_app_about) .opened(&mut state.show_app_about)
.build(ui, || { .build(|| {
ui.text(format!("dear imgui, {}", imgui::dear_imgui_version())); ui.text(format!("dear imgui, {}", imgui::dear_imgui_version()));
ui.separator(); ui.separator();
ui.text("By Omar Cornut and all github contributors."); ui.text("By Omar Cornut and all github contributors.");
@ -317,7 +317,7 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
show_app_log(ui, &mut state.app_log); show_app_log(ui, &mut state.app_log);
} }
let mut window = Window::new("ImGui Demo") let mut window = ui.window("ImGui Demo")
.title_bar(!state.no_titlebar) .title_bar(!state.no_titlebar)
.resizable(!state.no_resize) .resizable(!state.no_resize)
.movable(!state.no_move) .movable(!state.no_move)
@ -328,7 +328,7 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
if !state.no_close { if !state.no_close {
window = window.opened(opened) window = window.opened(opened)
} }
window.build(ui, || { window.build(|| {
ui.push_item_width(-140.0); ui.push_item_width(-140.0);
ui.text(format!("dear imgui says hello. ({})", imgui::dear_imgui_version())); ui.text(format!("dear imgui says hello. ({})", imgui::dear_imgui_version()));
if let Some(menu_bar) = ui.begin_menu_bar() { if let Some(menu_bar) = ui.begin_menu_bar() {
@ -872,10 +872,10 @@ fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) {
ui.separator(); ui.separator();
if let Some(menu) = ui.begin_menu("Options") { if let Some(menu) = ui.begin_menu("Options") {
MenuItem::new("Enabled").build_with_ref(ui, &mut state.enabled); MenuItem::new("Enabled").build_with_ref(ui, &mut state.enabled);
ChildWindow::new("child") ui.child_window("child")
.size([0.0, 60.0]) .size([0.0, 60.0])
.border(true) .border(true)
.build(ui, || { .build(|| {
for i in 0..10 { for i in 0..10 {
ui.text(format!("Scrolling Text {}", i)); ui.text(format!("Scrolling Text {}", i));
} }
@ -900,10 +900,10 @@ fn show_example_menu_file<'a>(ui: &Ui<'a>, state: &mut FileMenuState) {
} }
fn show_example_app_auto_resize(ui: &Ui, state: &mut AutoResizeState, opened: &mut bool) { fn show_example_app_auto_resize(ui: &Ui, state: &mut AutoResizeState, opened: &mut bool) {
Window::new("Example: Auto-resizing window") ui.window("Example: Auto-resizing window")
.opened(opened) .opened(opened)
.always_auto_resize(true) .always_auto_resize(true)
.build(ui, || { .build(|| {
ui.text( ui.text(
"Window will resize every-ui to the size of its content. "Window will resize every-ui to the size of its content.
Note that you probably don't want to query the window size to Note that you probably don't want to query the window size to
@ -920,7 +920,7 @@ fn show_example_app_fixed_overlay(ui: &Ui, opened: &mut bool) {
const DISTANCE: f32 = 10.0; const DISTANCE: f32 = 10.0;
let window_pos = [DISTANCE, DISTANCE]; let window_pos = [DISTANCE, DISTANCE];
let style = ui.push_style_color(StyleColor::WindowBg, [0.0, 0.0, 0.0, 0.3]); let style = ui.push_style_color(StyleColor::WindowBg, [0.0, 0.0, 0.0, 0.3]);
Window::new("Example: Fixed Overlay") ui.window("Example: Fixed Overlay")
.opened(opened) .opened(opened)
.position(window_pos, Condition::Always) .position(window_pos, Condition::Always)
.title_bar(false) .title_bar(false)
@ -928,7 +928,7 @@ fn show_example_app_fixed_overlay(ui: &Ui, opened: &mut bool) {
.always_auto_resize(true) .always_auto_resize(true)
.movable(false) .movable(false)
.save_settings(false) .save_settings(false)
.build(ui, || { .build(|| {
ui.text( ui.text(
"Simple overlay\nin the corner of the screen.\n(right-click to change position)", "Simple overlay\nin the corner of the screen.\n(right-click to change position)",
); );
@ -943,17 +943,17 @@ fn show_example_app_fixed_overlay(ui: &Ui, opened: &mut bool) {
} }
fn show_example_app_manipulating_window_title(ui: &Ui) { fn show_example_app_manipulating_window_title(ui: &Ui) {
Window::new("Same title as another window##1") ui.window("Same title as another window##1")
.position([100.0, 100.0], Condition::FirstUseEver) .position([100.0, 100.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text( ui.text(
"This is window 1. "This is window 1.
My title is the same as window 2, but my identifier is unique.", My title is the same as window 2, but my identifier is unique.",
); );
}); });
Window::new("Same title as another window##2") ui.window("Same title as another window##2")
.position([100.0, 200.0], Condition::FirstUseEver) .position([100.0, 200.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text( ui.text(
"This is window 2. "This is window 2.
My title is the same as window 1, but my identifier is unique.", My title is the same as window 1, but my identifier is unique.",
@ -963,16 +963,16 @@ My title is the same as window 1, but my identifier is unique.",
let ch_idx = (ui.time() / 0.25) as usize & 3; let ch_idx = (ui.time() / 0.25) as usize & 3;
let num = ui.frame_count(); // The C++ version uses rand() here let num = ui.frame_count(); // The C++ version uses rand() here
let title = format!("Animated title {} {}###AnimatedTitle", chars[ch_idx], num); let title = format!("Animated title {} {}###AnimatedTitle", chars[ch_idx], num);
Window::new(title) ui.window(title)
.position([100.0, 300.0], Condition::FirstUseEver) .position([100.0, 300.0], Condition::FirstUseEver)
.build(ui, || ui.text("This window has a changing title")); .build(|| ui.text("This window has a changing title"));
} }
fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, opened: &mut bool) { fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState, opened: &mut bool) {
Window::new("Example: Custom rendering") ui.window("Example: Custom rendering")
.size([350.0, 560.0], Condition::FirstUseEver) .size([350.0, 560.0], Condition::FirstUseEver)
.opened(opened) .opened(opened)
.build(ui, || { .build(|| {
ui.text("Primitives"); ui.text("Primitives");
// TODO: Add DragFloat to change value of sz // TODO: Add DragFloat to change value of sz
ColorEdit::new("Color", &mut state.col).build(ui); ColorEdit::new("Color", &mut state.col).build(ui);
@ -1217,9 +1217,9 @@ fn show_example_app_custom_rendering(ui: &Ui, state: &mut CustomRenderingState,
} }
fn show_app_log(ui: &Ui, app_log: &mut Vec<String>) { fn show_app_log(ui: &Ui, app_log: &mut Vec<String>) {
Window::new("Example: Log") ui.window("Example: Log")
.size([500.0, 400.0], Condition::FirstUseEver) .size([500.0, 400.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
if ui.small_button("[Debug] Add 5 entries") { if ui.small_button("[Debug] Add 5 entries") {
let categories = ["info", "warn", "error"]; let categories = ["info", "warn", "error"];
let words = [ let words = [
@ -1251,9 +1251,9 @@ fn show_app_log(ui: &Ui, app_log: &mut Vec<String>) {
ui.set_clipboard_text(&ImString::from(app_log.join("\n"))); ui.set_clipboard_text(&ImString::from(app_log.join("\n")));
} }
ui.separator(); ui.separator();
ChildWindow::new("logwindow") ui.child_window("logwindow")
.flags(WindowFlags::HORIZONTAL_SCROLLBAR) .flags(WindowFlags::HORIZONTAL_SCROLLBAR)
.build(ui, || { .build(|| {
if !app_log.is_empty() { if !app_log.is_empty() {
let mut clipper = ListClipper::new(app_log.len() as i32).begin(ui); let mut clipper = ListClipper::new(app_log.len() as i32).begin(ui);
while clipper.step() { while clipper.step() {

View File

@ -7,9 +7,9 @@ fn main() {
let mut buffers = vec![String::default(), String::default(), String::default()]; let mut buffers = vec![String::default(), String::default(), String::default()];
system.main_loop(move |_, ui| { system.main_loop(move |_, ui| {
Window::new("Input text callbacks") ui.window("Input text callbacks")
.size([500.0, 300.0], Condition::FirstUseEver) .size([500.0, 300.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text("You can make a variety of buffer callbacks on an Input Text"); ui.text("You can make a variety of buffer callbacks on an Input Text");
ui.text( ui.text(
"or on an InputTextMultiline. In this example, we'll use \ "or on an InputTextMultiline. In this example, we'll use \

View File

@ -144,9 +144,9 @@ impl TexturesUi {
} }
fn show(&self, ui: &imgui::Ui) { fn show(&self, ui: &imgui::Ui) {
imgui::Window::new("Hello textures") ui.window("Hello textures")
.size([400.0, 400.0], Condition::FirstUseEver) .size([400.0, 400.0], Condition::FirstUseEver)
.build(ui, || { .build(|| {
ui.text("Hello textures!"); ui.text("Hello textures!");
ui.text("Some generated texture"); ui.text("Some generated texture");
imgui::Image::new(self.generated_texture, [100.0, 100.0]).build(ui); imgui::Image::new(self.generated_texture, [100.0, 100.0]).build(ui);