Struct pushrod::core::main::Pushrod

source ·
pub struct Pushrod {
    pub widget_store: RefCell<WidgetStore>,
    pub drawing_texture: DrawingTexture,
    /* private fields */
}
Expand description

This structure is returned when instantiating a new Pushrod main object.

Fields§

§widget_store: RefCell<WidgetStore>

This is the WidgetStore object that is used to store the Widget list in the current display stack.

§drawing_texture: DrawingTexture

Implementations§

source§

impl Pushrod

Pushrod implementation. Create a Pushrod::new( PistonWindow ) object to create a new main loop. Only one of these should be set for the entire application runtime.

source

pub fn new(window: GlfwWindow) -> Self

Pushrod Object Constructor. Takes in a single OpenGL configuration type.

Examples found in repository?
examples/simple.rs (line 977)
971
972
973
974
975
976
977
978
979
980
fn main() {
    let window: GlfwWindow = WindowSettings::new("Pushrod Window", [800, 640])
        .opengl(OpenGL::V3_2)
        .resizable(true)
        .build()
        .unwrap_or_else(|error| panic!("Failed to build PistonWindow: {}", error));
    let mut app_window = SimpleWindow::new(Pushrod::new(window));

    app_window.run();
}
source

pub fn add_widget(&mut self, name: &str, widget: Box<dyn Widget>) -> i32

Convenience method that adds a Widget to the GUI display stack.

source

pub fn add_layout_manager(&mut self, manager: Box<dyn LayoutManager>) -> i32

Convenience method that adds a LayoutManager to the layout management stack.

Examples found in repository?
examples/simple.rs (lines 535-544)
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
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_horizontal_layout(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 70);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 200);
        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",
            "HorizontalManagerWidget1",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 4,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut box_widget = BoxWidget::new();

        box_widget.set_point(CONFIG_ORIGIN, 250, 80);
        box_widget.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_widget.set_color(CONFIG_MAIN_COLOR, [0.0, 1.0, 0.0, 1.0]);
        box_widget.set_numeric(CONFIG_BORDER_WIDTH, 4);
        box_widget.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 0.0, 1.0]);
        let box_widget_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget1",
            Box::new(box_widget),
            base_layout_id,
            make_origin_point(),
        );

        let mut text_widget2 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Left".to_string(),
            24,
            TextJustify::Left,
        );
        text_widget2.set_point(CONFIG_ORIGIN, 265, 100);
        text_widget2.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget2.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "LeftJustifiedText",
            Box::new(text_widget2),
            box_widget_id,
        );

        let mut text_widget3 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Center".to_string(),
            24,
            TextJustify::Center,
        );
        text_widget3.set_point(CONFIG_ORIGIN, 265, 166);
        text_widget3.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget3.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "CenterJustifiedText",
            Box::new(text_widget3),
            box_widget_id,
        );

        let mut text_widget4 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Right".to_string(),
            24,
            TextJustify::Right,
        );
        text_widget4.set_point(CONFIG_ORIGIN, 265, 230);
        text_widget4.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget4.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget4.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "RightJustifiedText",
            Box::new(text_widget4),
            box_widget_id,
        );

        let mut box_1 = BoxWidget::new();
        box_1.set_point(CONFIG_ORIGIN, 480, 80);
        box_1.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_1.set_color(CONFIG_MAIN_COLOR, [0.5, 0.5, 1.0, 1.0]);
        box_1.set_numeric(CONFIG_BORDER_WIDTH, 2);
        box_1.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 1.0, 1.0]);
        let box_1_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget2",
            Box::new(box_1),
            base_layout_id,
            make_origin_point(),
        );

        let mut inner_box_1 = BoxWidget::new();
        inner_box_1.set_point(CONFIG_ORIGIN, 505, 105);
        inner_box_1.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_1.set_color(CONFIG_MAIN_COLOR, [0.75, 0.75, 1.0, 1.0]);
        inner_box_1.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_1.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox1", Box::new(inner_box_1), box_1_id);

        let mut inner_box_2 = BoxWidget::new();
        inner_box_2.set_point(CONFIG_ORIGIN, 585, 105);
        inner_box_2.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_2.set_color(CONFIG_MAIN_COLOR, [0.75, 0.25, 1.0, 1.0]);
        inner_box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_2.set_color(CONFIG_BORDER_COLOR, [1.0, 1.0, 0.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox2", Box::new(inner_box_2), box_1_id);

        let mut inner_box_3 = BoxWidget::new();
        inner_box_3.set_point(CONFIG_ORIGIN, 505, 190);
        inner_box_3.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_3.set_color(CONFIG_MAIN_COLOR, [0.25, 0.50, 0.75, 1.0]);
        inner_box_3.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_3.set_color(CONFIG_BORDER_COLOR, [1.0, 0.50, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox3", Box::new(inner_box_3), box_1_id);

        let mut inner_box_4 = BoxWidget::new();
        inner_box_4.set_point(CONFIG_ORIGIN, 585, 190);
        inner_box_4.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_4.set_color(CONFIG_MAIN_COLOR, [0.75, 0.50, 0.0, 1.0]);
        inner_box_4.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_4.set_color(CONFIG_BORDER_COLOR, [0.50, 0.0, 0.25, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox4", Box::new(inner_box_4), box_1_id);

        let mut box_2 = BoxWidget::new();
        box_2.set_point(CONFIG_ORIGIN, 480, 80);
        box_2.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_2.set_color(
            CONFIG_MAIN_COLOR,
            [
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                1.0,
            ],
        );
        box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        box_2.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget3",
            Box::new(box_2),
            base_layout_id,
            make_origin_point(),
        );
    }

    fn add_horizontal_layout_buttons(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 270);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 36);
        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",
            "HorizontalManagerWidget2",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 0,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut button1 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Hide".to_string(),
            18,
            TextJustify::Center,
        );
        button1.set_point(CONFIG_ORIGIN, 30, 236);
        button1.set_size(CONFIG_BODY_SIZE, 180, 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]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton1",
            Box::new(button1),
            base_layout_id,
            make_origin_point(),
        );

        let mut button3 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Disable".to_string(),
            18,
            TextJustify::Center,
        );
        button3.set_point(CONFIG_ORIGIN, 30, 236);
        button3.set_size(CONFIG_BODY_SIZE, 180, 32);
        button3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button3.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button3.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton2",
            Box::new(button3),
            base_layout_id,
            make_origin_point(),
        );

        let mut button5 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Randomize".to_string(),
            18,
            TextJustify::Center,
        );
        button5.set_point(CONFIG_ORIGIN, 30, 236);
        button5.set_size(CONFIG_BODY_SIZE, 180, 32);
        button5.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button5.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button5.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton3",
            Box::new(button5),
            base_layout_id,
            make_origin_point(),
        );
    }

    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(),
        );
    }
source

pub fn add_widget_to_layout_manager( &mut self, name: &str, widget: Box<dyn Widget>, manager_id: i32, position: Point, ) -> i32

Convenience method that adds a Widget to a LayoutManager by the manager’s ID and the positioning of the Widget.

Examples found in repository?
examples/simple.rs (lines 553-558)
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
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_horizontal_layout(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 70);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 200);
        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",
            "HorizontalManagerWidget1",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 4,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut box_widget = BoxWidget::new();

        box_widget.set_point(CONFIG_ORIGIN, 250, 80);
        box_widget.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_widget.set_color(CONFIG_MAIN_COLOR, [0.0, 1.0, 0.0, 1.0]);
        box_widget.set_numeric(CONFIG_BORDER_WIDTH, 4);
        box_widget.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 0.0, 1.0]);
        let box_widget_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget1",
            Box::new(box_widget),
            base_layout_id,
            make_origin_point(),
        );

        let mut text_widget2 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Left".to_string(),
            24,
            TextJustify::Left,
        );
        text_widget2.set_point(CONFIG_ORIGIN, 265, 100);
        text_widget2.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget2.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "LeftJustifiedText",
            Box::new(text_widget2),
            box_widget_id,
        );

        let mut text_widget3 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Center".to_string(),
            24,
            TextJustify::Center,
        );
        text_widget3.set_point(CONFIG_ORIGIN, 265, 166);
        text_widget3.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget3.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "CenterJustifiedText",
            Box::new(text_widget3),
            box_widget_id,
        );

        let mut text_widget4 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Right".to_string(),
            24,
            TextJustify::Right,
        );
        text_widget4.set_point(CONFIG_ORIGIN, 265, 230);
        text_widget4.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget4.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget4.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "RightJustifiedText",
            Box::new(text_widget4),
            box_widget_id,
        );

        let mut box_1 = BoxWidget::new();
        box_1.set_point(CONFIG_ORIGIN, 480, 80);
        box_1.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_1.set_color(CONFIG_MAIN_COLOR, [0.5, 0.5, 1.0, 1.0]);
        box_1.set_numeric(CONFIG_BORDER_WIDTH, 2);
        box_1.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 1.0, 1.0]);
        let box_1_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget2",
            Box::new(box_1),
            base_layout_id,
            make_origin_point(),
        );

        let mut inner_box_1 = BoxWidget::new();
        inner_box_1.set_point(CONFIG_ORIGIN, 505, 105);
        inner_box_1.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_1.set_color(CONFIG_MAIN_COLOR, [0.75, 0.75, 1.0, 1.0]);
        inner_box_1.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_1.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox1", Box::new(inner_box_1), box_1_id);

        let mut inner_box_2 = BoxWidget::new();
        inner_box_2.set_point(CONFIG_ORIGIN, 585, 105);
        inner_box_2.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_2.set_color(CONFIG_MAIN_COLOR, [0.75, 0.25, 1.0, 1.0]);
        inner_box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_2.set_color(CONFIG_BORDER_COLOR, [1.0, 1.0, 0.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox2", Box::new(inner_box_2), box_1_id);

        let mut inner_box_3 = BoxWidget::new();
        inner_box_3.set_point(CONFIG_ORIGIN, 505, 190);
        inner_box_3.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_3.set_color(CONFIG_MAIN_COLOR, [0.25, 0.50, 0.75, 1.0]);
        inner_box_3.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_3.set_color(CONFIG_BORDER_COLOR, [1.0, 0.50, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox3", Box::new(inner_box_3), box_1_id);

        let mut inner_box_4 = BoxWidget::new();
        inner_box_4.set_point(CONFIG_ORIGIN, 585, 190);
        inner_box_4.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_4.set_color(CONFIG_MAIN_COLOR, [0.75, 0.50, 0.0, 1.0]);
        inner_box_4.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_4.set_color(CONFIG_BORDER_COLOR, [0.50, 0.0, 0.25, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox4", Box::new(inner_box_4), box_1_id);

        let mut box_2 = BoxWidget::new();
        box_2.set_point(CONFIG_ORIGIN, 480, 80);
        box_2.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_2.set_color(
            CONFIG_MAIN_COLOR,
            [
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                1.0,
            ],
        );
        box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        box_2.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget3",
            Box::new(box_2),
            base_layout_id,
            make_origin_point(),
        );
    }

    fn add_horizontal_layout_buttons(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 270);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 36);
        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",
            "HorizontalManagerWidget2",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 0,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut button1 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Hide".to_string(),
            18,
            TextJustify::Center,
        );
        button1.set_point(CONFIG_ORIGIN, 30, 236);
        button1.set_size(CONFIG_BODY_SIZE, 180, 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]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton1",
            Box::new(button1),
            base_layout_id,
            make_origin_point(),
        );

        let mut button3 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Disable".to_string(),
            18,
            TextJustify::Center,
        );
        button3.set_point(CONFIG_ORIGIN, 30, 236);
        button3.set_size(CONFIG_BODY_SIZE, 180, 32);
        button3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button3.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button3.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton2",
            Box::new(button3),
            base_layout_id,
            make_origin_point(),
        );

        let mut button5 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Randomize".to_string(),
            18,
            TextJustify::Center,
        );
        button5.set_point(CONFIG_ORIGIN, 30, 236);
        button5.set_size(CONFIG_BODY_SIZE, 180, 32);
        button5.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button5.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button5.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton3",
            Box::new(button5),
            base_layout_id,
            make_origin_point(),
        );
    }

    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(),
        );
    }
source

pub fn add_widget_to_parent( &mut self, name: &str, widget: Box<dyn Widget>, parent_id: i32, ) -> i32

Convenience method that adds a Widget to a parent by its ID. This guarantees a refresh if the top level parent becomes invalidated.

Examples found in repository?
examples/simple.rs (lines 570-574)
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
    fn add_horizontal_layout(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 70);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 200);
        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",
            "HorizontalManagerWidget1",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 4,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut box_widget = BoxWidget::new();

        box_widget.set_point(CONFIG_ORIGIN, 250, 80);
        box_widget.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_widget.set_color(CONFIG_MAIN_COLOR, [0.0, 1.0, 0.0, 1.0]);
        box_widget.set_numeric(CONFIG_BORDER_WIDTH, 4);
        box_widget.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 0.0, 1.0]);
        let box_widget_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget1",
            Box::new(box_widget),
            base_layout_id,
            make_origin_point(),
        );

        let mut text_widget2 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Left".to_string(),
            24,
            TextJustify::Left,
        );
        text_widget2.set_point(CONFIG_ORIGIN, 265, 100);
        text_widget2.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget2.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "LeftJustifiedText",
            Box::new(text_widget2),
            box_widget_id,
        );

        let mut text_widget3 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Center".to_string(),
            24,
            TextJustify::Center,
        );
        text_widget3.set_point(CONFIG_ORIGIN, 265, 166);
        text_widget3.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget3.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "CenterJustifiedText",
            Box::new(text_widget3),
            box_widget_id,
        );

        let mut text_widget4 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Right".to_string(),
            24,
            TextJustify::Right,
        );
        text_widget4.set_point(CONFIG_ORIGIN, 265, 230);
        text_widget4.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget4.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget4.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "RightJustifiedText",
            Box::new(text_widget4),
            box_widget_id,
        );

        let mut box_1 = BoxWidget::new();
        box_1.set_point(CONFIG_ORIGIN, 480, 80);
        box_1.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_1.set_color(CONFIG_MAIN_COLOR, [0.5, 0.5, 1.0, 1.0]);
        box_1.set_numeric(CONFIG_BORDER_WIDTH, 2);
        box_1.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 1.0, 1.0]);
        let box_1_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget2",
            Box::new(box_1),
            base_layout_id,
            make_origin_point(),
        );

        let mut inner_box_1 = BoxWidget::new();
        inner_box_1.set_point(CONFIG_ORIGIN, 505, 105);
        inner_box_1.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_1.set_color(CONFIG_MAIN_COLOR, [0.75, 0.75, 1.0, 1.0]);
        inner_box_1.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_1.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox1", Box::new(inner_box_1), box_1_id);

        let mut inner_box_2 = BoxWidget::new();
        inner_box_2.set_point(CONFIG_ORIGIN, 585, 105);
        inner_box_2.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_2.set_color(CONFIG_MAIN_COLOR, [0.75, 0.25, 1.0, 1.0]);
        inner_box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_2.set_color(CONFIG_BORDER_COLOR, [1.0, 1.0, 0.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox2", Box::new(inner_box_2), box_1_id);

        let mut inner_box_3 = BoxWidget::new();
        inner_box_3.set_point(CONFIG_ORIGIN, 505, 190);
        inner_box_3.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_3.set_color(CONFIG_MAIN_COLOR, [0.25, 0.50, 0.75, 1.0]);
        inner_box_3.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_3.set_color(CONFIG_BORDER_COLOR, [1.0, 0.50, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox3", Box::new(inner_box_3), box_1_id);

        let mut inner_box_4 = BoxWidget::new();
        inner_box_4.set_point(CONFIG_ORIGIN, 585, 190);
        inner_box_4.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_4.set_color(CONFIG_MAIN_COLOR, [0.75, 0.50, 0.0, 1.0]);
        inner_box_4.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_4.set_color(CONFIG_BORDER_COLOR, [0.50, 0.0, 0.25, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox4", Box::new(inner_box_4), box_1_id);

        let mut box_2 = BoxWidget::new();
        box_2.set_point(CONFIG_ORIGIN, 480, 80);
        box_2.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_2.set_color(
            CONFIG_MAIN_COLOR,
            [
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                1.0,
            ],
        );
        box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        box_2.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget3",
            Box::new(box_2),
            base_layout_id,
            make_origin_point(),
        );
    }
source

pub fn add_widget_to_parent_by_name( &mut self, parent_name: &str, name: &str, widget: Box<dyn Widget>, ) -> i32

Convenience method that adds a Widget to a parent by the parent’s name.

Examples found in repository?
examples/simple.rs (lines 502-506)
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
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
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
    fn add_hello_world(&mut self) {
        let mut text_widget = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Welcome to Pushrod".to_string(),
            36,
            TextJustify::Left,
        );

        text_widget.set_point(CONFIG_ORIGIN, 20, 10);
        text_widget.set_size(CONFIG_BODY_SIZE, 400, 50);
        text_widget.set_color(CONFIG_MAIN_COLOR, [1.0; 4]);
        text_widget.set_color(CONFIG_TEXT_COLOR, [0.75, 0.25, 1.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "TextWidget",
            Box::new(text_widget),
        );

        let mut timer = TimerWidget::new();

        timer.set_numeric(CONFIG_TIMER_TIMEOUT, 10);
        timer.set_toggle(CONFIG_TIMER_ENABLED, true);
        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "HelloWorldTimer",
            Box::new(timer),
        );
    }

    fn add_horizontal_layout(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 70);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 200);
        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",
            "HorizontalManagerWidget1",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 4,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut box_widget = BoxWidget::new();

        box_widget.set_point(CONFIG_ORIGIN, 250, 80);
        box_widget.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_widget.set_color(CONFIG_MAIN_COLOR, [0.0, 1.0, 0.0, 1.0]);
        box_widget.set_numeric(CONFIG_BORDER_WIDTH, 4);
        box_widget.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 0.0, 1.0]);
        let box_widget_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget1",
            Box::new(box_widget),
            base_layout_id,
            make_origin_point(),
        );

        let mut text_widget2 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Left".to_string(),
            24,
            TextJustify::Left,
        );
        text_widget2.set_point(CONFIG_ORIGIN, 265, 100);
        text_widget2.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget2.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "LeftJustifiedText",
            Box::new(text_widget2),
            box_widget_id,
        );

        let mut text_widget3 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Center".to_string(),
            24,
            TextJustify::Center,
        );
        text_widget3.set_point(CONFIG_ORIGIN, 265, 166);
        text_widget3.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget3.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "CenterJustifiedText",
            Box::new(text_widget3),
            box_widget_id,
        );

        let mut text_widget4 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Right".to_string(),
            24,
            TextJustify::Right,
        );
        text_widget4.set_point(CONFIG_ORIGIN, 265, 230);
        text_widget4.set_size(CONFIG_BODY_SIZE, 170, 32);
        text_widget4.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        text_widget4.set_color(CONFIG_MAIN_COLOR, [1.0, 1.0, 1.0, 0.0]);
        self.pushrod.borrow_mut().add_widget_to_parent(
            "RightJustifiedText",
            Box::new(text_widget4),
            box_widget_id,
        );

        let mut box_1 = BoxWidget::new();
        box_1.set_point(CONFIG_ORIGIN, 480, 80);
        box_1.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_1.set_color(CONFIG_MAIN_COLOR, [0.5, 0.5, 1.0, 1.0]);
        box_1.set_numeric(CONFIG_BORDER_WIDTH, 2);
        box_1.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 1.0, 1.0]);
        let box_1_id = self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget2",
            Box::new(box_1),
            base_layout_id,
            make_origin_point(),
        );

        let mut inner_box_1 = BoxWidget::new();
        inner_box_1.set_point(CONFIG_ORIGIN, 505, 105);
        inner_box_1.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_1.set_color(CONFIG_MAIN_COLOR, [0.75, 0.75, 1.0, 1.0]);
        inner_box_1.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_1.set_color(CONFIG_BORDER_COLOR, [1.0, 0.0, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox1", Box::new(inner_box_1), box_1_id);

        let mut inner_box_2 = BoxWidget::new();
        inner_box_2.set_point(CONFIG_ORIGIN, 585, 105);
        inner_box_2.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_2.set_color(CONFIG_MAIN_COLOR, [0.75, 0.25, 1.0, 1.0]);
        inner_box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_2.set_color(CONFIG_BORDER_COLOR, [1.0, 1.0, 0.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox2", Box::new(inner_box_2), box_1_id);

        let mut inner_box_3 = BoxWidget::new();
        inner_box_3.set_point(CONFIG_ORIGIN, 505, 190);
        inner_box_3.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_3.set_color(CONFIG_MAIN_COLOR, [0.25, 0.50, 0.75, 1.0]);
        inner_box_3.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_3.set_color(CONFIG_BORDER_COLOR, [1.0, 0.50, 1.0, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox3", Box::new(inner_box_3), box_1_id);

        let mut inner_box_4 = BoxWidget::new();
        inner_box_4.set_point(CONFIG_ORIGIN, 585, 190);
        inner_box_4.set_size(CONFIG_BODY_SIZE, 70, 60);
        inner_box_4.set_color(CONFIG_MAIN_COLOR, [0.75, 0.50, 0.0, 1.0]);
        inner_box_4.set_numeric(CONFIG_BORDER_WIDTH, 1);
        inner_box_4.set_color(CONFIG_BORDER_COLOR, [0.50, 0.0, 0.25, 1.0]);
        self.pushrod
            .borrow_mut()
            .add_widget_to_parent("MiniBox4", Box::new(inner_box_4), box_1_id);

        let mut box_2 = BoxWidget::new();
        box_2.set_point(CONFIG_ORIGIN, 480, 80);
        box_2.set_size(CONFIG_BODY_SIZE, 200, 200);
        box_2.set_color(
            CONFIG_MAIN_COLOR,
            [
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                (rand::random::<u8>() as f32 / 255.0),
                1.0,
            ],
        );
        box_2.set_numeric(CONFIG_BORDER_WIDTH, 1);
        box_2.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidget3",
            Box::new(box_2),
            base_layout_id,
            make_origin_point(),
        );
    }

    fn add_horizontal_layout_buttons(&mut self) {
        let mut base_widget: CanvasWidget = CanvasWidget::new();

        base_widget.set_point(CONFIG_ORIGIN, 20, 270);
        base_widget.set_size(CONFIG_BODY_SIZE, 760, 36);
        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",
            "HorizontalManagerWidget2",
            Box::new(base_widget),
        );

        let base_layout_id =
            self.pushrod
                .borrow_mut()
                .add_layout_manager(Box::new(HorizontalLayoutManager::new(
                    base_widget_id,
                    LayoutManagerPadding {
                        top: 0,
                        left: 4,
                        right: 4,
                        bottom: 4,
                        spacing: 4,
                    },
                )));

        let mut button1 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Hide".to_string(),
            18,
            TextJustify::Center,
        );
        button1.set_point(CONFIG_ORIGIN, 30, 236);
        button1.set_size(CONFIG_BODY_SIZE, 180, 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]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton1",
            Box::new(button1),
            base_layout_id,
            make_origin_point(),
        );

        let mut button3 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Disable".to_string(),
            18,
            TextJustify::Center,
        );
        button3.set_point(CONFIG_ORIGIN, 30, 236);
        button3.set_size(CONFIG_BODY_SIZE, 180, 32);
        button3.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button3.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button3.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton2",
            Box::new(button3),
            base_layout_id,
            make_origin_point(),
        );

        let mut button5 = PushButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Randomize".to_string(),
            18,
            TextJustify::Center,
        );
        button5.set_point(CONFIG_ORIGIN, 30, 236);
        button5.set_size(CONFIG_BODY_SIZE, 180, 32);
        button5.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        button5.set_numeric(CONFIG_BORDER_WIDTH, 2);
        button5.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_layout_manager(
            "BoxInLayoutWidgetButton3",
            Box::new(button5),
            base_layout_id,
            make_origin_point(),
        );
    }

    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(),
        );
    }
    fn add_timer(&mut self) {
        let mut timer = TimerWidget::new();

        timer.set_numeric(CONFIG_TIMER_TIMEOUT, 100);
        timer.set_toggle(CONFIG_TIMER_ENABLED, true);
        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "TimerWidget1",
            Box::new(timer),
        );
    }

    fn add_debugging(&mut self) {
        let mut check_widget = CheckboxWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Enable Debugging".to_string(),
            20,
            TextJustify::Left,
            true,
        );
        check_widget.set_point(CONFIG_ORIGIN, 20, 540);
        check_widget.set_size(CONFIG_BODY_SIZE, 500, 28);
        check_widget.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "DebugCheck1",
            Box::new(check_widget),
        );

        let mut text_widget1 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Current Widget: 0".to_string(),
            20,
            TextJustify::Left,
        );
        text_widget1.set_point(CONFIG_ORIGIN, 20, 570);
        text_widget1.set_size(CONFIG_BODY_SIZE, 500, 28);
        text_widget1.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "DebugText1",
            Box::new(text_widget1),
        );

        let mut text_widget2 = TextWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "".to_string(),
            20,
            TextJustify::Left,
        );
        text_widget2.set_point(CONFIG_ORIGIN, 20, 600);
        text_widget2.set_size(CONFIG_BODY_SIZE, 500, 28);
        text_widget2.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "DebugText2",
            Box::new(text_widget2),
        );
    }

    fn add_powered_by(&mut self) {
        let mut image_widget = ImageButtonWidget::new(
            "assets/OpenSans-Regular.ttf".to_string(),
            "Powered By Rust!".to_string(),
            "rust-512x512.jpg".to_string(),
            18,
            TextJustify::Left,
        );

        image_widget.set_point(CONFIG_ORIGIN, 570, 580);
        image_widget.set_size(CONFIG_BODY_SIZE, 220, 48);
        image_widget.set_color(CONFIG_TEXT_COLOR, [0.0, 0.0, 0.0, 1.0]);
        image_widget.set_numeric(CONFIG_BORDER_WIDTH, 1);
        image_widget.set_color(CONFIG_BORDER_COLOR, [0.0, 0.0, 0.0, 1.0]);

        self.pushrod.borrow_mut().add_widget_to_parent_by_name(
            "MainContainerWidget",
            "RustImageButton",
            Box::new(image_widget),
        );
    }
source

pub fn run(&mut self, event_handler: &mut dyn PushrodCallbackEvents)

This is the main run loop for Pushrod. A run loop requires the use of an assigned PushrodCallbackEvents event handler. This is how all communications take place when an action occurs within the GUI window.

Examples found in repository?
examples/simple.rs (line 967)
963
964
965
966
967
968
    pub fn run(&mut self) {
        let mut handler = SimpleWindowEventHandler::new();

        self.build();
        self.get_pushrod().run(&mut handler);
    }

Auto Trait Implementations§

§

impl !Freeze for Pushrod

§

impl !RefUnwindSafe for Pushrod

§

impl !Send for Pushrod

§

impl !Sync for Pushrod

§

impl Unpin for Pushrod

§

impl !UnwindSafe for Pushrod

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.