pub struct VerticalLayoutManager { /* private fields */ }

Implementations§

source§

impl VerticalLayoutManager

source

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

source§

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

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§

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> 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.
§

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> SetParameter for T

source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
source§

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

§

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>,

§

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.