1
1
use cursive:: {
2
2
theme:: { BorderStyle , ColorStyle , Palette , Theme } ,
3
- view:: IntoBoxedView ,
4
- views:: { Layer , Panel , TextView } ,
5
- Cursive , CursiveExt ,
3
+ view:: { IntoBoxedView , Resizable , Nameable } ,
4
+ views:: { Layer , Panel , TextView , EditView , TextArea , Button } ,
5
+ Cursive , CursiveExt , With ,
6
6
} ;
7
7
8
8
use cursive_flexbox:: prelude:: * ;
@@ -27,8 +27,8 @@ fn main() {
27
27
) )
28
28
. into_boxed_view( ) ,
29
29
Panel :: new( Layer :: with_color(
30
- TextView :: new( "I doubt I will be wrapped..." ) ,
31
- ColorStyle :: back( cursive:: theme:: BaseColor :: Green . dark( ) ) ,
30
+ EditView :: new( ) . with ( |v| { v . set_content ( "I doubt I will be wrapped..." ) ; } ) . min_width ( 28 ) ,
31
+ ColorStyle :: back( cursive:: theme:: BaseColor :: Blue . dark( ) ) ,
32
32
) )
33
33
. into_boxed_view( ) ,
34
34
Panel :: new( Layer :: with_color(
@@ -37,16 +37,25 @@ fn main() {
37
37
) )
38
38
. into_boxed_view( ) ,
39
39
Panel :: new( Layer :: with_color(
40
- TextView :: new(
40
+ TextArea :: new( ) . with ( |v| { v . set_content (
41
41
"And a bigger container\n to test out the alignment\n of items in the main \
42
- axis\n a bit better.",
43
- ) ,
44
- ColorStyle :: back( cursive:: theme:: BaseColor :: Green . dark( ) ) ,
42
+ axis\n a bit better.\n \n Edit me. ",
43
+ ) ; } ) . min_width ( 20 ) ,
44
+ ColorStyle :: back( cursive:: theme:: BaseColor :: Blue . dark( ) ) ,
45
45
) )
46
46
. into_boxed_view( ) ,
47
47
Panel :: new( Layer :: with_color(
48
- TextView :: new( "And a final item for good luck." ) ,
49
- ColorStyle :: back( cursive:: theme:: BaseColor :: Green . dark( ) ) ,
48
+ Button :: new( "And a final button for good luck." , |c| {
49
+ let mut flexbox = c. find_name:: <Flexbox >( "flexbox" ) . unwrap( ) ;
50
+ let new_align = match flexbox. align_items( ) {
51
+ AlignItems :: FlexStart => AlignItems :: Center ,
52
+ AlignItems :: Center => AlignItems :: FlexEnd ,
53
+ AlignItems :: FlexEnd => AlignItems :: Stretch ,
54
+ AlignItems :: Stretch => AlignItems :: FlexStart ,
55
+ } ;
56
+ flexbox. set_align_items( new_align) ;
57
+ } ) ,
58
+ ColorStyle :: back( cursive:: theme:: BaseColor :: Red . dark( ) ) ,
50
59
) )
51
60
. into_boxed_view( ) ,
52
61
] ) ;
@@ -77,7 +86,7 @@ fn main() {
77
86
flexbox. set_flex_direction ( FlexDirection :: Row ) ;
78
87
79
88
// Add the flexbox to the ui.
80
- cursive. add_fullscreen_layer ( flexbox) ;
89
+ cursive. add_fullscreen_layer ( flexbox. with_name ( "flexbox" ) ) ;
81
90
82
91
// Start running the eventloop.
83
92
cursive. run ( ) ;
0 commit comments