Layout

Struct Layout 

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

Implementations§

Source§

impl Layout

Source

pub fn new(axis: Axis) -> Self

Examples found in repository?
examples/widget_gallery.rs (line 141)
87    fn ui(&mut self, ui: &mut pierro::UI) {
88
89        pierro::margin(ui, |ui| {
90            pierro::dropdown_labeled(ui, "Axis: ", match self.axis {
91                pierro::Axis::X => "X",
92                pierro::Axis::Y => "Y",
93            }, |ui| {
94                if pierro::menu_button(ui, "X").mouse_clicked() {
95                    self.axis = pierro::Axis::X;
96                }
97                if pierro::menu_button(ui, "Y").mouse_clicked() {
98                    self.axis = pierro::Axis::Y;
99                }
100            });
101            pierro::v_spacing(ui, 5.0);
102
103            pierro::dropdown_labeled(ui, "Justify: ", match self.justify {
104                pierro::Justify::Min => "Min",
105                pierro::Justify::Center => "Center",
106                pierro::Justify::Max => "Max",
107            }, |ui| {
108                if pierro::menu_button(ui, "Min").mouse_clicked() {
109                    self.justify = pierro::Justify::Min;
110                }
111                if pierro::menu_button(ui, "Center").mouse_clicked() {
112                    self.justify = pierro::Justify::Center;
113                }
114                if pierro::menu_button(ui, "Max").mouse_clicked() {
115                    self.justify = pierro::Justify::Max;
116                }
117            });
118            pierro::v_spacing(ui, 5.0);
119
120            pierro::dropdown_labeled(ui, "Align: ", match self.align {
121                pierro::Align::Min => "Min",
122                pierro::Align::Center => "Center",
123                pierro::Align::Max => "Max",
124            }, |ui| {
125                if pierro::menu_button(ui, "Min").mouse_clicked() {
126                    self.align = pierro::Align::Min;
127                }
128                if pierro::menu_button(ui, "Center").mouse_clicked() {
129                    self.align = pierro::Align::Center;
130                }
131                if pierro::menu_button(ui, "Max").mouse_clicked() {
132                    self.align = pierro::Align::Max;
133                }
134            });
135        });
136
137        pierro::h_divider(ui);
138        pierro::container(ui,
139            pierro::Size::fr(1.0),
140            pierro::Size::fr(1.0),
141            pierro::Layout::new(self.axis).with_justify(self.justify).with_align(self.align),
142            |ui| {
143                self.node(ui, pierro::Color::RED);   
144                self.node(ui, pierro::Color::GREEN);   
145                self.node(ui, pierro::Color::BLUE);
146            });
147    }
Source

pub fn horizontal() -> Self

Source

pub fn vertical() -> Self

Examples found in repository?
examples/test.rs (line 20)
15    fn tick(&mut self, ui: &mut pierro::UI) {
16
17        let bg_color = ui.style::<pierro::Theme>().bg_dark;
18        let bg = ui.node(
19            pierro::UINodeParams::new(pierro::Size::fr(1.0), pierro::Size::fr(1.0))
20                .with_layout(pierro::Layout::vertical().with_vertical_overflow())
21                .with_fill(bg_color)
22                .with_transform(pierro::TSTransform::scale(self.zoom))
23        );
24        
25        ui.with_parent(bg.node_ref, |ui| {
26
27            pierro::menu_bar(ui, |ui| {
28                pierro::menu_bar_item(ui, "File", |ui| {
29                    if pierro::menu_button(ui, "New").mouse_clicked() {
30                        println!("New!!");
31                    }
32                    if pierro::menu_button(ui, "Open").mouse_clicked() {
33                        println!("Open!!");
34                    }
35                    pierro::menu_category(ui, "Recent", |ui| {
36                        pierro::menu_button(ui, "A.txt");
37                        pierro::menu_button(ui, "B.txt");
38                        pierro::menu_button(ui, "C.txt");
39                        pierro::menu_category(ui, "!!", |ui| {
40                            pierro::menu_button(ui, "A.txt");
41                            pierro::menu_button(ui, "B.txt");
42                            pierro::menu_button(ui, "C.txt");
43                        });
44                    });
45                    pierro::h_line(ui);
46                    pierro::menu_button(ui, "XYZ").mouse_clicked();
47                    pierro::menu_button(ui, "PQR").mouse_clicked();
48                });
49                pierro::menu_bar_item(ui, "Edit", |ui| {
50                    pierro::menu_button(ui, "Undo").mouse_clicked();
51                    pierro::menu_button(ui, "Redo").mouse_clicked();
52                });
53            });
54
55            pierro::v_spacing(ui, 15.0);
56            pierro::label(ui, "Above the scroll area");
57
58            pierro::dnd_source(ui, "Hello".to_string(), |ui| {
59                pierro::label(ui, "Drag me! (Hello)");
60            });
61            pierro::dnd_source(ui, "World".to_string(), |ui| {
62                pierro::label(ui, "Drag me! (World)");
63            });
64            if let Some(message) = pierro::dnd_drop_zone::<String, _>(ui, |ui| {
65                pierro::label(ui, "Drop here...");
66            }).1 {
67                println!("{}", message);
68            }
69
70            pierro::horizontal(ui, |ui| {
71                if pierro::button(ui, "+").mouse_clicked() {
72                    self.zoom *= 1.25;
73                }
74                if pierro::button(ui, "-").mouse_clicked() {
75                    self.zoom /= 1.25;
76                }
77                
78                let button_response = pierro::button(ui, "@");
79                pierro::context_menu(ui, &button_response, |ui| {
80                    pierro::label(ui, "Truly!!!");
81                });
82            });
83            pierro::v_spacing(ui, 15.0);
84            pierro::text_edit(ui, &mut self.text);
85            pierro::v_spacing(ui, 15.0);
86
87            pierro::scroll_area(ui, |ui| {
88
89                pierro::label(ui, "Button #1: 🍊");
90                if pierro::button(ui, "So long mom, I'm off to drop the bomb").mouse_clicked() {
91                    self.n += 1;
92                }
93
94                pierro::label(ui, "Button #2:");
95                if pierro::button(ui, "So long mom, I'm off to drop the bomb").mouse_clicked() {
96                    self.n -= 1;
97                }
98
99                pierro::label(ui, "The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.");
100
101                for i in 0..100 {
102                    pierro::label(ui, format!("{} {}", i, self.n));
103                }
104
105            });
106
107            pierro::v_spacing(ui, 15.0);
108            pierro::label(ui, "Below the scroll area");
109            pierro::label(ui, "Ниже области прокрутки");
110            pierro::label(ui, "أسفل منطقة التمرير");
111            pierro::v_spacing(ui, 15.0);
112
113        });
114
115    }
Source

pub fn with_justify(self, justify: Justify) -> Self

Examples found in repository?
examples/widget_gallery.rs (line 141)
87    fn ui(&mut self, ui: &mut pierro::UI) {
88
89        pierro::margin(ui, |ui| {
90            pierro::dropdown_labeled(ui, "Axis: ", match self.axis {
91                pierro::Axis::X => "X",
92                pierro::Axis::Y => "Y",
93            }, |ui| {
94                if pierro::menu_button(ui, "X").mouse_clicked() {
95                    self.axis = pierro::Axis::X;
96                }
97                if pierro::menu_button(ui, "Y").mouse_clicked() {
98                    self.axis = pierro::Axis::Y;
99                }
100            });
101            pierro::v_spacing(ui, 5.0);
102
103            pierro::dropdown_labeled(ui, "Justify: ", match self.justify {
104                pierro::Justify::Min => "Min",
105                pierro::Justify::Center => "Center",
106                pierro::Justify::Max => "Max",
107            }, |ui| {
108                if pierro::menu_button(ui, "Min").mouse_clicked() {
109                    self.justify = pierro::Justify::Min;
110                }
111                if pierro::menu_button(ui, "Center").mouse_clicked() {
112                    self.justify = pierro::Justify::Center;
113                }
114                if pierro::menu_button(ui, "Max").mouse_clicked() {
115                    self.justify = pierro::Justify::Max;
116                }
117            });
118            pierro::v_spacing(ui, 5.0);
119
120            pierro::dropdown_labeled(ui, "Align: ", match self.align {
121                pierro::Align::Min => "Min",
122                pierro::Align::Center => "Center",
123                pierro::Align::Max => "Max",
124            }, |ui| {
125                if pierro::menu_button(ui, "Min").mouse_clicked() {
126                    self.align = pierro::Align::Min;
127                }
128                if pierro::menu_button(ui, "Center").mouse_clicked() {
129                    self.align = pierro::Align::Center;
130                }
131                if pierro::menu_button(ui, "Max").mouse_clicked() {
132                    self.align = pierro::Align::Max;
133                }
134            });
135        });
136
137        pierro::h_divider(ui);
138        pierro::container(ui,
139            pierro::Size::fr(1.0),
140            pierro::Size::fr(1.0),
141            pierro::Layout::new(self.axis).with_justify(self.justify).with_align(self.align),
142            |ui| {
143                self.node(ui, pierro::Color::RED);   
144                self.node(ui, pierro::Color::GREEN);   
145                self.node(ui, pierro::Color::BLUE);
146            });
147    }
Source

pub fn justify_min(self) -> Self

Source

pub fn justify_center(self) -> Self

Source

pub fn justify_max(self) -> Self

Source

pub fn with_align(self, align: Align) -> Self

Examples found in repository?
examples/widget_gallery.rs (line 141)
87    fn ui(&mut self, ui: &mut pierro::UI) {
88
89        pierro::margin(ui, |ui| {
90            pierro::dropdown_labeled(ui, "Axis: ", match self.axis {
91                pierro::Axis::X => "X",
92                pierro::Axis::Y => "Y",
93            }, |ui| {
94                if pierro::menu_button(ui, "X").mouse_clicked() {
95                    self.axis = pierro::Axis::X;
96                }
97                if pierro::menu_button(ui, "Y").mouse_clicked() {
98                    self.axis = pierro::Axis::Y;
99                }
100            });
101            pierro::v_spacing(ui, 5.0);
102
103            pierro::dropdown_labeled(ui, "Justify: ", match self.justify {
104                pierro::Justify::Min => "Min",
105                pierro::Justify::Center => "Center",
106                pierro::Justify::Max => "Max",
107            }, |ui| {
108                if pierro::menu_button(ui, "Min").mouse_clicked() {
109                    self.justify = pierro::Justify::Min;
110                }
111                if pierro::menu_button(ui, "Center").mouse_clicked() {
112                    self.justify = pierro::Justify::Center;
113                }
114                if pierro::menu_button(ui, "Max").mouse_clicked() {
115                    self.justify = pierro::Justify::Max;
116                }
117            });
118            pierro::v_spacing(ui, 5.0);
119
120            pierro::dropdown_labeled(ui, "Align: ", match self.align {
121                pierro::Align::Min => "Min",
122                pierro::Align::Center => "Center",
123                pierro::Align::Max => "Max",
124            }, |ui| {
125                if pierro::menu_button(ui, "Min").mouse_clicked() {
126                    self.align = pierro::Align::Min;
127                }
128                if pierro::menu_button(ui, "Center").mouse_clicked() {
129                    self.align = pierro::Align::Center;
130                }
131                if pierro::menu_button(ui, "Max").mouse_clicked() {
132                    self.align = pierro::Align::Max;
133                }
134            });
135        });
136
137        pierro::h_divider(ui);
138        pierro::container(ui,
139            pierro::Size::fr(1.0),
140            pierro::Size::fr(1.0),
141            pierro::Layout::new(self.axis).with_justify(self.justify).with_align(self.align),
142            |ui| {
143                self.node(ui, pierro::Color::RED);   
144                self.node(ui, pierro::Color::GREEN);   
145                self.node(ui, pierro::Color::BLUE);
146            });
147    }
Source

pub fn align_min(self) -> Self

Source

pub fn align_center(self) -> Self

Source

pub fn align_max(self) -> Self

Source

pub fn with_horizontal_overflow(self) -> Self

Source

pub fn with_vertical_overflow(self) -> Self

Examples found in repository?
examples/test.rs (line 20)
15    fn tick(&mut self, ui: &mut pierro::UI) {
16
17        let bg_color = ui.style::<pierro::Theme>().bg_dark;
18        let bg = ui.node(
19            pierro::UINodeParams::new(pierro::Size::fr(1.0), pierro::Size::fr(1.0))
20                .with_layout(pierro::Layout::vertical().with_vertical_overflow())
21                .with_fill(bg_color)
22                .with_transform(pierro::TSTransform::scale(self.zoom))
23        );
24        
25        ui.with_parent(bg.node_ref, |ui| {
26
27            pierro::menu_bar(ui, |ui| {
28                pierro::menu_bar_item(ui, "File", |ui| {
29                    if pierro::menu_button(ui, "New").mouse_clicked() {
30                        println!("New!!");
31                    }
32                    if pierro::menu_button(ui, "Open").mouse_clicked() {
33                        println!("Open!!");
34                    }
35                    pierro::menu_category(ui, "Recent", |ui| {
36                        pierro::menu_button(ui, "A.txt");
37                        pierro::menu_button(ui, "B.txt");
38                        pierro::menu_button(ui, "C.txt");
39                        pierro::menu_category(ui, "!!", |ui| {
40                            pierro::menu_button(ui, "A.txt");
41                            pierro::menu_button(ui, "B.txt");
42                            pierro::menu_button(ui, "C.txt");
43                        });
44                    });
45                    pierro::h_line(ui);
46                    pierro::menu_button(ui, "XYZ").mouse_clicked();
47                    pierro::menu_button(ui, "PQR").mouse_clicked();
48                });
49                pierro::menu_bar_item(ui, "Edit", |ui| {
50                    pierro::menu_button(ui, "Undo").mouse_clicked();
51                    pierro::menu_button(ui, "Redo").mouse_clicked();
52                });
53            });
54
55            pierro::v_spacing(ui, 15.0);
56            pierro::label(ui, "Above the scroll area");
57
58            pierro::dnd_source(ui, "Hello".to_string(), |ui| {
59                pierro::label(ui, "Drag me! (Hello)");
60            });
61            pierro::dnd_source(ui, "World".to_string(), |ui| {
62                pierro::label(ui, "Drag me! (World)");
63            });
64            if let Some(message) = pierro::dnd_drop_zone::<String, _>(ui, |ui| {
65                pierro::label(ui, "Drop here...");
66            }).1 {
67                println!("{}", message);
68            }
69
70            pierro::horizontal(ui, |ui| {
71                if pierro::button(ui, "+").mouse_clicked() {
72                    self.zoom *= 1.25;
73                }
74                if pierro::button(ui, "-").mouse_clicked() {
75                    self.zoom /= 1.25;
76                }
77                
78                let button_response = pierro::button(ui, "@");
79                pierro::context_menu(ui, &button_response, |ui| {
80                    pierro::label(ui, "Truly!!!");
81                });
82            });
83            pierro::v_spacing(ui, 15.0);
84            pierro::text_edit(ui, &mut self.text);
85            pierro::v_spacing(ui, 15.0);
86
87            pierro::scroll_area(ui, |ui| {
88
89                pierro::label(ui, "Button #1: 🍊");
90                if pierro::button(ui, "So long mom, I'm off to drop the bomb").mouse_clicked() {
91                    self.n += 1;
92                }
93
94                pierro::label(ui, "Button #2:");
95                if pierro::button(ui, "So long mom, I'm off to drop the bomb").mouse_clicked() {
96                    self.n -= 1;
97                }
98
99                pierro::label(ui, "The quick brown fox jumped over the lazy dog. The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.The quick brown fox jumped over the lazy dog.");
100
101                for i in 0..100 {
102                    pierro::label(ui, format!("{} {}", i, self.n));
103                }
104
105            });
106
107            pierro::v_spacing(ui, 15.0);
108            pierro::label(ui, "Below the scroll area");
109            pierro::label(ui, "Ниже области прокрутки");
110            pierro::label(ui, "أسفل منطقة التمرير");
111            pierro::v_spacing(ui, 15.0);
112
113        });
114
115    }

Trait Implementations§

Source§

impl Clone for Layout

Source§

fn clone(&self) -> Layout

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Layout

Auto Trait Implementations§

§

impl Freeze for Layout

§

impl RefUnwindSafe for Layout

§

impl Send for Layout

§

impl Sync for Layout

§

impl Unpin for Layout

§

impl UnwindSafe for Layout

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,