pub struct VerticalLayoutManager { /* private fields */ }Implementations§
source§impl VerticalLayoutManager
impl VerticalLayoutManager
sourcepub fn new(widget_id: i32, padding: LayoutManagerPadding) -> Self
pub fn new(widget_id: i32, padding: LayoutManagerPadding) -> Self
Examples found in repository?
examples/simple.rs (lines 784-793)
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
fn add_vertical_layout(&mut self) {
let mut base_widget: CanvasWidget = CanvasWidget::new();
base_widget.set_point(CONFIG_ORIGIN, 20, 330);
base_widget.set_size(CONFIG_BODY_SIZE, 200, 180);
base_widget.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 1.0]);
let base_widget_id = self.pushrod.borrow_mut().add_widget_to_parent_by_name(
"MainContainerWidget",
"VerticalManagerWidget1",
Box::new(base_widget),
);
let base_layout_id =
self.pushrod
.borrow_mut()
.add_layout_manager(Box::new(VerticalLayoutManager::new(
base_widget_id,
LayoutManagerPadding {
top: 4,
left: 4,
right: 4,
bottom: 4,
spacing: 2,
},
)));
let mut progress_widget = ProgressWidget::new();
progress_widget.set_point(CONFIG_ORIGIN, 20, 360);
progress_widget.set_size(CONFIG_BODY_SIZE, 230, 32);
progress_widget.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 1.0]);
progress_widget.set_color(CONFIG_SECONDARY_COLOR, [0.5, 0.5, 0.5, 1.0]);
progress_widget.set_numeric(CONFIG_PROGRESS, 50);
self.pushrod.borrow_mut().add_widget_to_layout_manager(
"ProgressWidget",
Box::new(progress_widget),
base_layout_id,
make_origin_point(),
);
let mut progress_text = TextWidget::new(
"assets/OpenSans-Regular.ttf".to_string(),
"50%".to_string(),
18,
TextJustify::Center,
);
progress_text.set_point(CONFIG_ORIGIN, 260, 360);
progress_text.set_size(CONFIG_BODY_SIZE, 50, 32);
progress_text.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
self.pushrod.borrow_mut().add_widget_to_layout_manager(
"ProgressText1",
Box::new(progress_text),
base_layout_id,
make_origin_point(),
);
let mut button1 = ToggleButtonWidget::new(
"assets/OpenSans-Regular.ttf".to_string(),
"Animate".to_string(),
18,
TextJustify::Center,
);
button1.set_point(CONFIG_ORIGIN, 340, 360);
button1.set_size(CONFIG_BODY_SIZE, 160, 32);
button1.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
button1.set_numeric(CONFIG_BORDER_WIDTH, 2);
button1.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
button1.set_toggle(CONFIG_SELECTED, true);
self.pushrod.borrow_mut().add_widget_to_layout_manager(
"AnimateButton1",
Box::new(button1),
base_layout_id,
make_origin_point(),
);
let mut button2 = PushButtonWidget::new(
"assets/OpenSans-Regular.ttf".to_string(),
"Randomize".to_string(),
18,
TextJustify::Center,
);
button2.set_point(CONFIG_ORIGIN, 520, 360);
button2.set_size(CONFIG_BODY_SIZE, 160, 32);
button2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
button2.set_numeric(CONFIG_BORDER_WIDTH, 2);
button2.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
self.pushrod.borrow_mut().add_widget_to_layout_manager(
"RandomColorButton2",
Box::new(button2),
base_layout_id,
make_origin_point(),
);
}Trait Implementations§
source§impl LayoutManager for VerticalLayoutManager
impl LayoutManager for VerticalLayoutManager
source§fn do_layout(
&mut self,
origin: Point,
size: Size,
coordinates: LayoutManagerCoordinates,
) -> LayoutManagerCoordinates
fn do_layout( &mut self, origin: Point, size: Size, coordinates: LayoutManagerCoordinates, ) -> LayoutManagerCoordinates
This method is called when a new
Widget is added to the list, or the layout needs to
be re-computed (due to a resize). The origin passed is the origin of the layout
manager’s top-level Widget, as each LayoutManager requires a Widget against which
objects can be added. size indicates the Size of the Widget container, which is
the total allowed bounds of the objects within its layout area. coordinates are the
coordinates of the Widgets to be resized. Once the compute of all of the coordinates
of all of the objects is completed, a new LayoutManagerCoordinates object must be
returned, containing the new coordinates of all of the objects within its bounds.
See also HorizontalLayoutManager and VerticalLayoutManager for more info.source§fn get_widget_id(&self) -> i32
fn get_widget_id(&self) -> i32
This function must be overridden to return the ID of the
Widget that is stored within
the LayoutManager, since the system doesn’t have direct access to it.Auto Trait Implementations§
impl Freeze for VerticalLayoutManager
impl RefUnwindSafe for VerticalLayoutManager
impl Send for VerticalLayoutManager
impl Sync for VerticalLayoutManager
impl Unpin for VerticalLayoutManager
impl UnwindSafe for VerticalLayoutManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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