Window

Struct Window 

Source
pub struct Window { /* private fields */ }

Implementations§

Source§

impl Window

Source

pub fn new(_label: &str) -> Window

Examples found in repository?
examples/demo.rs (line 4)
3fn main() {
4    imgui_miniquad_render::Window::new("Test").main_loop(|ui| {
5        let mut opened = true;
6        ui.show_demo_window(&mut opened);
7    });
8}
More examples
Hide additional examples
examples/test_window.rs (line 6)
3fn main() {
4    let mut input = ImString::with_capacity(128);
5
6    imgui_miniquad_render::Window::new("Test").main_loop(|ui| {
7        Window::new(im_str!("window_title"))
8            .size([300.0, 300.0], Condition::FirstUseEver)
9            .build(ui, || {
10                ui.text(im_str!("Hello world!"));
11                ui.text(im_str!("This...is...imgui-rs!"));
12                ui.separator();
13                let mouse_pos = ui.io().mouse_pos;
14                ui.text(format!(
15                    "Mouse Position: ({:.1},{:.1})",
16                    mouse_pos[0], mouse_pos[1]
17                ));
18                ui.input_text(im_str!("edit"), &mut input).build();
19            });
20    });
21}
examples/text_editor.rs (line 7)
4fn main() {
5    let mut text = ImString::with_capacity(10);
6
7    imgui_miniquad_render::Window::new("Test")
8        .on_init(|imgui| {
9            let style = imgui.style_mut();
10            style.window_rounding = 0.;
11            style.use_light_colors();
12        })
13        .main_loop(|ui| {
14            let [width, height] = ui.io().display_size;
15
16            Window::new(im_str!("Modbus Testing Tool"))
17                .position([0.0, 0.0], Condition::Always)
18                .size([width, height], Condition::Always)
19                .title_bar(false)
20                .resizable(false)
21                .menu_bar(true)
22                .build(ui, || {
23                    if let Some(menu_bar) = ui.begin_menu_bar() {
24                        if let Some(menu) = ui.begin_menu(im_str!("File"), true) {
25    
26                            if MenuItem::new(im_str!("Exit")).build(ui) {
27                                platform::request_quit();
28                            }
29                            menu.end(ui);
30                        }
31
32                        menu_bar.end(ui);
33                    };
34
35
36                    ui.input_text_multiline(&im_str!(""), &mut text, [-1., -1.])
37                        .resize_buffer(true)
38                        .build();
39                })
40        });
41}
Source

pub fn on_init(self, f: impl FnOnce(&mut Context)) -> Self

Examples found in repository?
examples/text_editor.rs (lines 8-12)
4fn main() {
5    let mut text = ImString::with_capacity(10);
6
7    imgui_miniquad_render::Window::new("Test")
8        .on_init(|imgui| {
9            let style = imgui.style_mut();
10            style.window_rounding = 0.;
11            style.use_light_colors();
12        })
13        .main_loop(|ui| {
14            let [width, height] = ui.io().display_size;
15
16            Window::new(im_str!("Modbus Testing Tool"))
17                .position([0.0, 0.0], Condition::Always)
18                .size([width, height], Condition::Always)
19                .title_bar(false)
20                .resizable(false)
21                .menu_bar(true)
22                .build(ui, || {
23                    if let Some(menu_bar) = ui.begin_menu_bar() {
24                        if let Some(menu) = ui.begin_menu(im_str!("File"), true) {
25    
26                            if MenuItem::new(im_str!("Exit")).build(ui) {
27                                platform::request_quit();
28                            }
29                            menu.end(ui);
30                        }
31
32                        menu_bar.end(ui);
33                    };
34
35
36                    ui.input_text_multiline(&im_str!(""), &mut text, [-1., -1.])
37                        .resize_buffer(true)
38                        .build();
39                })
40        });
41}
Source

pub fn on_quit(self, f: impl FnOnce()) -> Self

Source

pub fn main_loop(self, on_draw: impl FnMut(&mut Ui<'_>)) -> !

Examples found in repository?
examples/demo.rs (lines 4-7)
3fn main() {
4    imgui_miniquad_render::Window::new("Test").main_loop(|ui| {
5        let mut opened = true;
6        ui.show_demo_window(&mut opened);
7    });
8}
More examples
Hide additional examples
examples/test_window.rs (lines 6-20)
3fn main() {
4    let mut input = ImString::with_capacity(128);
5
6    imgui_miniquad_render::Window::new("Test").main_loop(|ui| {
7        Window::new(im_str!("window_title"))
8            .size([300.0, 300.0], Condition::FirstUseEver)
9            .build(ui, || {
10                ui.text(im_str!("Hello world!"));
11                ui.text(im_str!("This...is...imgui-rs!"));
12                ui.separator();
13                let mouse_pos = ui.io().mouse_pos;
14                ui.text(format!(
15                    "Mouse Position: ({:.1},{:.1})",
16                    mouse_pos[0], mouse_pos[1]
17                ));
18                ui.input_text(im_str!("edit"), &mut input).build();
19            });
20    });
21}
examples/text_editor.rs (lines 13-40)
4fn main() {
5    let mut text = ImString::with_capacity(10);
6
7    imgui_miniquad_render::Window::new("Test")
8        .on_init(|imgui| {
9            let style = imgui.style_mut();
10            style.window_rounding = 0.;
11            style.use_light_colors();
12        })
13        .main_loop(|ui| {
14            let [width, height] = ui.io().display_size;
15
16            Window::new(im_str!("Modbus Testing Tool"))
17                .position([0.0, 0.0], Condition::Always)
18                .size([width, height], Condition::Always)
19                .title_bar(false)
20                .resizable(false)
21                .menu_bar(true)
22                .build(ui, || {
23                    if let Some(menu_bar) = ui.begin_menu_bar() {
24                        if let Some(menu) = ui.begin_menu(im_str!("File"), true) {
25    
26                            if MenuItem::new(im_str!("Exit")).build(ui) {
27                                platform::request_quit();
28                            }
29                            menu.end(ui);
30                        }
31
32                        menu_bar.end(ui);
33                    };
34
35
36                    ui.input_text_multiline(&im_str!(""), &mut text, [-1., -1.])
37                        .resize_buffer(true)
38                        .build();
39                })
40        });
41}

Auto Trait Implementations§

§

impl Freeze for Window

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl !UnwindSafe for Window

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.