2020-05-01 00:08:01 +00:00
// #![allow(dead_code, unused_variables)] // should be commented out
2020-05-10 17:04:10 +00:00
use std ::sync ::Arc ;
use serde_derive ::{ Deserialize , Serialize } ;
2020-05-01 00:08:01 +00:00
2020-05-11 18:21:24 +00:00
use crate ::{ color ::* , containers ::* , examples ::FractalClock , widgets ::* , * } ;
2018-12-26 09:46:23 +00:00
2020-05-10 17:04:10 +00:00
// ----------------------------------------------------------------------------
#[ derive(Default, Deserialize, Serialize) ]
2020-05-12 15:09:54 +00:00
#[ serde(default) ]
2020-05-10 17:04:10 +00:00
pub struct ExampleApp {
example_window : ExampleWindow ,
open_windows : OpenWindows ,
2020-05-11 18:21:24 +00:00
fractal_clock : FractalClock ,
2020-05-10 17:04:10 +00:00
}
impl ExampleApp {
2020-05-12 05:27:14 +00:00
pub fn ui ( & mut self , ui : & mut Ui ) {
show_menu_bar ( ui , & mut self . open_windows ) ;
self . windows ( ui . ctx ( ) ) ;
}
pub fn windows ( & mut self , ctx : & Arc < Context > ) {
2020-05-10 17:04:10 +00:00
// TODO: Make it even simpler to show a window
2020-05-11 18:21:24 +00:00
// TODO: window manager for automatic positioning?
let ExampleApp {
example_window ,
open_windows ,
fractal_clock ,
} = self ;
2020-05-12 15:09:54 +00:00
if ctx . previus_input ( ) . web ! = ctx . input ( ) . web {
2020-05-11 18:21:24 +00:00
let location_hash = ctx
. input ( )
. web
. as_ref ( )
. map ( | web | web . location_hash . as_str ( ) ) ;
2020-05-12 15:09:54 +00:00
// #fragment end of URL:
2020-05-11 18:21:24 +00:00
if location_hash = = Some ( " #clock " ) {
2020-05-12 15:09:54 +00:00
* open_windows = OpenWindows {
fractal_clock : true ,
.. OpenWindows ::none ( )
} ;
2020-05-11 18:21:24 +00:00
}
}
2020-05-10 17:04:10 +00:00
Window ::new ( " Examples " )
2020-05-12 05:27:14 +00:00
. open ( & mut open_windows . examples )
2020-05-10 17:04:10 +00:00
. default_pos ( pos2 ( 32.0 , 100.0 ) )
. default_size ( vec2 ( 430.0 , 600.0 ) )
. show ( ctx , | ui | {
2020-05-11 18:21:24 +00:00
example_window . ui ( ui ) ;
2020-05-10 17:04:10 +00:00
} ) ;
Window ::new ( " Settings " )
2020-05-11 18:21:24 +00:00
. open ( & mut open_windows . settings )
2020-05-10 17:04:10 +00:00
. default_pos ( pos2 ( 500.0 , 100.0 ) )
2020-05-11 18:21:24 +00:00
. default_size ( vec2 ( 350.0 , 400.0 ) )
2020-05-10 17:04:10 +00:00
. show ( ctx , | ui | {
ctx . settings_ui ( ui ) ;
} ) ;
Window ::new ( " Inspection " )
2020-05-11 18:21:24 +00:00
. open ( & mut open_windows . inspection )
2020-05-10 17:04:10 +00:00
. default_pos ( pos2 ( 500.0 , 400.0 ) )
. default_size ( vec2 ( 400.0 , 300.0 ) )
. show ( ctx , | ui | {
ctx . inspection_ui ( ui ) ;
} ) ;
Window ::new ( " Memory " )
2020-05-11 18:21:24 +00:00
. open ( & mut open_windows . memory )
2020-05-10 17:04:10 +00:00
. default_pos ( pos2 ( 700.0 , 350.0 ) )
. auto_sized ( )
. show ( ctx , | ui | {
ctx . memory_ui ( ui ) ;
} ) ;
2020-05-11 18:21:24 +00:00
fractal_clock . window ( ctx , & mut open_windows . fractal_clock ) ;
2020-05-10 17:04:10 +00:00
}
}
2020-05-12 21:00:20 +00:00
// ----------------------------------------------------------------------------
2020-05-10 17:04:10 +00:00
#[ derive(Deserialize, Serialize) ]
struct OpenWindows {
2020-05-12 05:27:14 +00:00
examples : bool ,
2020-05-10 17:04:10 +00:00
settings : bool ,
inspection : bool ,
memory : bool ,
2020-05-11 18:21:24 +00:00
fractal_clock : bool ,
2020-05-10 17:04:10 +00:00
}
impl Default for OpenWindows {
fn default ( ) -> Self {
Self {
2020-05-12 05:27:14 +00:00
examples : true ,
2020-05-12 15:09:54 +00:00
.. OpenWindows ::none ( )
}
}
}
impl OpenWindows {
fn none ( ) -> Self {
Self {
examples : false ,
2020-05-10 17:04:10 +00:00
settings : false ,
2020-05-12 05:27:14 +00:00
inspection : false ,
2020-05-10 17:04:10 +00:00
memory : false ,
2020-05-11 18:21:24 +00:00
fractal_clock : false ,
2020-05-10 17:04:10 +00:00
}
}
}
fn show_menu_bar ( ui : & mut Ui , windows : & mut OpenWindows ) {
menu ::bar ( ui , | ui | {
menu ::menu ( ui , " File " , | ui | {
2020-05-16 15:28:15 +00:00
if ui . add ( Button ::new ( " Clear memory " ) ) . clicked {
* ui . ctx ( ) . memory ( ) = Default ::default ( ) ;
}
2020-05-10 17:04:10 +00:00
} ) ;
menu ::menu ( ui , " Windows " , | ui | {
2020-05-12 05:27:14 +00:00
ui . add ( Checkbox ::new ( & mut windows . examples , " Examples " ) ) ;
2020-05-10 17:04:10 +00:00
ui . add ( Checkbox ::new ( & mut windows . settings , " Settings " ) ) ;
ui . add ( Checkbox ::new ( & mut windows . inspection , " Inspection " ) ) ;
ui . add ( Checkbox ::new ( & mut windows . memory , " Memory " ) ) ;
2020-05-11 18:21:24 +00:00
ui . add ( Checkbox ::new ( & mut windows . fractal_clock , " Fractal Clock " ) ) ;
2020-05-10 17:04:10 +00:00
} ) ;
menu ::menu ( ui , " About " , | ui | {
2020-05-12 05:27:14 +00:00
ui . add ( label! ( " This is Emigui " ) ) ;
ui . add ( Hyperlink ::new ( " https://github.com/emilk/emigui/ " ) . text ( " Emigui home page " ) ) ;
2020-05-10 17:04:10 +00:00
} ) ;
2020-05-13 20:56:37 +00:00
if let Some ( time ) = ui . input ( ) . seconds_since_midnight {
let time = format! (
" {:02}:{:02}:{:02}.{:02} " ,
( time . rem_euclid ( 24.0 * 60.0 * 60.0 ) / 3600.0 ) . floor ( ) ,
( time . rem_euclid ( 60.0 * 60.0 ) / 60.0 ) . floor ( ) ,
( time . rem_euclid ( 60.0 ) ) . floor ( ) ,
( time . rem_euclid ( 1.0 ) * 100.0 ) . floor ( )
) ;
ui . inner_layout ( Layout ::horizontal ( Align ::Max ) . reverse ( ) , | ui | {
if ui
. add ( Button ::new ( time ) . text_style ( TextStyle ::Monospace ) )
. clicked
{
windows . fractal_clock = ! windows . fractal_clock ;
}
} ) ;
}
2020-05-10 17:04:10 +00:00
} ) ;
}
// ----------------------------------------------------------------------------
2020-05-08 20:42:31 +00:00
/// Showcase some ui code
2020-05-10 17:04:10 +00:00
#[ derive(Deserialize, Serialize) ]
2020-05-01 00:08:01 +00:00
pub struct ExampleWindow {
2019-03-11 12:32:44 +00:00
num_columns : usize ,
2019-03-11 12:32:54 +00:00
2020-05-12 21:00:20 +00:00
widgets : Widgets ,
layout : LayoutExample ,
box_painting : BoxPainting ,
2020-04-24 16:32:27 +00:00
painting : Painting ,
2018-12-26 09:46:23 +00:00
}
2020-05-01 00:08:01 +00:00
impl Default for ExampleWindow {
fn default ( ) -> ExampleWindow {
ExampleWindow {
2019-03-11 12:32:44 +00:00
num_columns : 2 ,
2019-03-11 12:32:54 +00:00
2020-05-12 21:00:20 +00:00
widgets : Default ::default ( ) ,
layout : Default ::default ( ) ,
box_painting : Default ::default ( ) ,
2020-04-24 16:32:27 +00:00
painting : Default ::default ( ) ,
2018-12-26 16:32:58 +00:00
}
}
2018-12-26 21:17:33 +00:00
}
2018-12-26 16:32:58 +00:00
2020-05-01 00:08:01 +00:00
impl ExampleWindow {
2020-05-08 20:42:31 +00:00
pub fn ui ( & mut self , ui : & mut Ui ) {
ui . collapsing ( " About Emigui " , | ui | {
ui . add ( label! (
2020-04-21 18:48:31 +00:00
" Emigui is an experimental immediate mode GUI written in Rust. "
) ) ;
2020-04-23 17:15:17 +00:00
2020-05-08 20:42:31 +00:00
ui . horizontal ( | ui | {
ui . add_label ( " Project home page: " ) ;
ui . add_hyperlink ( " https://github.com/emilk/emigui/ " ) ;
2020-04-23 17:15:17 +00:00
} ) ;
2020-04-12 10:07:51 +00:00
} ) ;
2020-04-23 07:50:03 +00:00
CollapsingHeader ::new ( " Widgets " )
2020-05-19 21:57:48 +00:00
. default_open ( true )
2020-05-08 20:42:31 +00:00
. show ( ui , | ui | {
2020-05-12 21:00:20 +00:00
self . widgets . ui ( ui ) ;
2019-01-21 07:48:32 +00:00
} ) ;
2020-04-21 18:52:17 +00:00
2020-05-12 21:00:20 +00:00
CollapsingHeader ::new ( " Layout " )
2020-05-19 21:57:48 +00:00
. default_open ( false )
2020-05-12 21:00:20 +00:00
. show ( ui , | ui | self . layout . ui ( ui ) ) ;
2018-12-26 21:26:15 +00:00
2020-05-19 21:57:48 +00:00
CollapsingHeader ::new ( " Tree " )
. default_open ( true )
. show ( ui , | ui | self . tree . ui ( ui ) ) ;
2020-05-12 21:00:20 +00:00
ui . collapsing ( " Columns " , | ui | {
2020-05-08 20:42:31 +00:00
ui . add ( Slider ::usize ( & mut self . num_columns , 1 ..= 10 ) . text ( " Columns " ) ) ;
ui . columns ( self . num_columns , | cols | {
2019-03-11 12:32:44 +00:00
for ( i , col ) in cols . iter_mut ( ) . enumerate ( ) {
col . add ( label! ( " Column {} out of {} " , i + 1 , self . num_columns ) ) ;
2020-04-24 16:47:14 +00:00
if i + 1 = = self . num_columns & & col . add ( Button ::new ( " Delete this " ) ) . clicked {
self . num_columns - = 1 ;
2019-03-11 12:32:44 +00:00
}
}
} ) ;
} ) ;
2020-05-12 21:00:20 +00:00
ui . collapsing ( " Test box rendering " , | ui | self . box_painting . ui ( ui ) ) ;
2019-03-11 12:32:54 +00:00
2020-04-22 16:15:27 +00:00
CollapsingHeader ::new ( " Scroll area " )
2020-05-19 21:57:48 +00:00
. default_open ( false )
2020-05-08 20:42:31 +00:00
. show ( ui , | ui | {
ScrollArea ::default ( ) . show ( ui , | ui | {
ui . add_label ( LOREM_IPSUM ) ;
2020-04-22 16:15:27 +00:00
} ) ;
2020-04-21 18:52:17 +00:00
} ) ;
2020-04-19 09:13:24 +00:00
2020-04-24 16:32:27 +00:00
CollapsingHeader ::new ( " Painting " )
2020-05-19 21:57:48 +00:00
. default_open ( false )
2020-05-08 20:42:31 +00:00
. show ( ui , | ui | self . painting . ui ( ui ) ) ;
2020-04-24 16:32:27 +00:00
2020-04-25 12:37:39 +00:00
CollapsingHeader ::new ( " Resize " )
2020-05-19 21:57:48 +00:00
. default_open ( false )
2020-05-08 20:42:31 +00:00
. show ( ui , | ui | {
2020-04-25 12:37:39 +00:00
Resize ::default ( )
. default_height ( 200.0 )
// .as_wide_as_possible()
2020-04-26 20:30:24 +00:00
. auto_shrink_height ( false )
2020-05-08 20:42:31 +00:00
. show ( ui , | ui | {
ui . add ( label! ( " This ui can be resized! " ) ) ;
ui . add ( label! ( " Just pull the handle on the bottom right " ) ) ;
2020-04-25 12:37:39 +00:00
} ) ;
} ) ;
2020-05-08 20:42:31 +00:00
ui . collapsing ( " Name clash example " , | ui | {
ui . add_label ( " \
Widgets that store state require unique identifiers so we can track their state between frames . \
2020-04-20 21:42:11 +00:00
Identifiers are normally derived from the titles of the widget . " );
2020-04-19 09:13:24 +00:00
2020-05-08 20:42:31 +00:00
ui . add_label ( " \
For instance , collapsable headers needs to store wether or not they are open . \
2020-04-19 09:13:24 +00:00
If you fail to give them unique names then clicking one will open both . \
2020-04-21 18:48:31 +00:00
To help you debug this , an error message is printed on screen :" );
2020-04-19 09:13:24 +00:00
2020-05-08 20:42:31 +00:00
ui . collapsing ( " Collapsing header " , | ui | {
ui . add_label ( " Contents of first folddable ui " ) ;
2020-04-19 09:13:24 +00:00
} ) ;
2020-05-08 20:42:31 +00:00
ui . collapsing ( " Collapsing header " , | ui | {
ui . add_label ( " Contents of second folddable ui " ) ;
2020-04-19 09:13:24 +00:00
} ) ;
2020-05-08 20:42:31 +00:00
ui . add_label ( " \
2020-04-20 21:42:11 +00:00
Most widgets don ' t need unique names , but are tracked \
based on their position on screen . For instance , buttons :" );
2020-05-08 20:42:31 +00:00
ui . add ( Button ::new ( " Button " ) ) ;
ui . add ( Button ::new ( " Button " ) ) ;
2020-04-19 09:13:24 +00:00
} ) ;
2018-12-26 22:08:50 +00:00
}
}
2020-04-12 10:07:51 +00:00
2020-05-10 17:04:10 +00:00
// ----------------------------------------------------------------------------
2020-05-12 21:00:20 +00:00
#[ derive(Deserialize, Serialize) ]
#[ serde(default) ]
struct Widgets {
checked : bool ,
count : usize ,
radio : usize ,
slider_value : usize ,
2020-05-17 07:44:09 +00:00
single_line_text_input : String ,
multiline_text_input : String ,
2020-05-12 21:00:20 +00:00
}
impl Default for Widgets {
fn default ( ) -> Self {
Self {
checked : true ,
radio : 0 ,
count : 0 ,
slider_value : 100 ,
2020-05-17 07:44:09 +00:00
single_line_text_input : " Hello World! " . to_owned ( ) ,
multiline_text_input : " Text can both be so wide that it needs a linebreak, but you can also add manual linebreak by pressing enter, creating new paragraphs. \n This is the start of the next paragraph. \n \n Click me to edit me! " . to_owned ( ) ,
2020-05-12 21:00:20 +00:00
}
}
}
impl Widgets {
pub fn ui ( & mut self , ui : & mut Ui ) {
ui . horizontal ( | ui | {
ui . add ( label! ( " Text can have " ) . text_color ( srgba ( 110 , 255 , 110 , 255 ) ) ) ;
ui . add ( label! ( " color " ) . text_color ( srgba ( 128 , 140 , 255 , 255 ) ) ) ;
ui . add ( label! ( " and tooltips (hover me) " ) ) . tooltip_text (
" This is a multiline tooltip that demonstrates that you can easily add tooltips to any element. \n This is the second line. \n This is the third. " ,
) ;
} ) ;
ui . add ( Checkbox ::new ( & mut self . checked , " checkbox " ) ) ;
ui . horizontal ( | ui | {
if ui . add ( radio ( self . radio = = 0 , " First " ) ) . clicked {
self . radio = 0 ;
}
if ui . add ( radio ( self . radio = = 1 , " Second " ) ) . clicked {
self . radio = 1 ;
}
if ui . add ( radio ( self . radio = = 2 , " Final " ) ) . clicked {
self . radio = 2 ;
}
} ) ;
2020-05-17 07:44:09 +00:00
ui . inner_layout ( Layout ::horizontal ( Align ::Center ) , | ui | {
2020-05-12 21:00:20 +00:00
if ui
. add ( Button ::new ( " Click me " ) )
. tooltip_text ( " This will just increase a counter. " )
. clicked
{
self . count + = 1 ;
}
ui . add ( label! ( " The button has been clicked {} times " , self . count ) ) ;
} ) ;
ui . add ( Slider ::usize ( & mut self . slider_value , 1 ..= 1000 ) . text ( " value " ) ) ;
if ui . add ( Button ::new ( " Double it " ) ) . clicked {
self . slider_value * = 2 ;
}
2020-05-17 07:44:09 +00:00
ui . horizontal ( | ui | {
ui . add ( label! ( " Single line text input: " ) ) ;
ui . add (
TextEdit ::new ( & mut self . single_line_text_input )
. multiline ( false )
. id ( " single line " ) ,
) ;
} ) ; // TODO: .tooltip_text("Enter text to edit me")
ui . add ( label! ( " Multiline text input: " ) ) ;
ui . add ( TextEdit ::new ( & mut self . multiline_text_input ) . id ( " multiline " ) ) ;
2020-05-12 21:00:20 +00:00
}
}
// ----------------------------------------------------------------------------
#[ derive(Deserialize, Serialize) ]
#[ serde(default) ]
struct BoxPainting {
size : Vec2 ,
corner_radius : f32 ,
stroke_width : f32 ,
num_boxes : usize ,
}
impl Default for BoxPainting {
fn default ( ) -> Self {
Self {
size : vec2 ( 100.0 , 50.0 ) ,
corner_radius : 5.0 ,
stroke_width : 2.0 ,
num_boxes : 1 ,
}
}
}
impl BoxPainting {
pub fn ui ( & mut self , ui : & mut Ui ) {
ui . add ( Slider ::f32 ( & mut self . size . x , 0. 0 ..= 500.0 ) . text ( " width " ) ) ;
ui . add ( Slider ::f32 ( & mut self . size . y , 0. 0 ..= 500.0 ) . text ( " height " ) ) ;
ui . add ( Slider ::f32 ( & mut self . corner_radius , 0. 0 ..= 50.0 ) . text ( " corner_radius " ) ) ;
ui . add ( Slider ::f32 ( & mut self . stroke_width , 0. 0 ..= 10.0 ) . text ( " stroke_width " ) ) ;
ui . add ( Slider ::usize ( & mut self . num_boxes , 0 ..= 5 ) . text ( " num_boxes " ) ) ;
let pos = ui
. reserve_space (
vec2 ( self . size . x * ( self . num_boxes as f32 ) , self . size . y ) ,
None ,
)
. rect
. min ;
let mut cmds = vec! [ ] ;
for i in 0 .. self . num_boxes {
cmds . push ( PaintCmd ::Rect {
corner_radius : self . corner_radius ,
fill_color : Some ( gray ( 136 , 255 ) ) ,
rect : Rect ::from_min_size (
pos2 ( 10.0 + pos . x + ( i as f32 ) * ( self . size . x * 1.1 ) , pos . y ) ,
self . size ,
) ,
outline : Some ( Outline ::new ( self . stroke_width , gray ( 255 , 255 ) ) ) ,
} ) ;
}
ui . add_paint_cmds ( cmds ) ;
}
}
// ----------------------------------------------------------------------------
2020-05-10 17:04:10 +00:00
#[ derive(Default, Deserialize, Serialize) ]
2020-05-12 21:00:20 +00:00
#[ serde(default) ]
2020-04-24 16:32:27 +00:00
struct Painting {
2020-04-26 20:25:23 +00:00
lines : Vec < Vec < Vec2 > > ,
2020-04-24 16:32:27 +00:00
}
impl Painting {
2020-05-08 20:42:31 +00:00
pub fn ui ( & mut self , ui : & mut Ui ) {
ui . add_label ( " Draw with your mouse to paint " ) ;
if ui . add ( Button ::new ( " Clear " ) ) . clicked {
2020-04-24 16:32:27 +00:00
self . lines . clear ( ) ;
}
2020-05-17 07:44:09 +00:00
Resize ::default ( )
. default_height ( 200.0 )
. show ( ui , | ui | self . content ( ui ) ) ;
}
2020-04-26 20:25:23 +00:00
2020-05-17 07:44:09 +00:00
fn content ( & mut self , ui : & mut Ui ) {
let interact = ui . reserve_space ( ui . available_finite ( ) . size ( ) , Some ( ui . id ( ) ) ) ;
let rect = interact . rect ;
ui . set_clip_rect ( ui . clip_rect ( ) . intersect ( rect ) ) ; // Make sure we don't paint out of bounds
2020-04-26 20:25:23 +00:00
2020-05-17 07:44:09 +00:00
if self . lines . is_empty ( ) {
self . lines . push ( vec! [ ] ) ;
}
2020-04-24 16:32:27 +00:00
2020-05-17 07:44:09 +00:00
let current_line = self . lines . last_mut ( ) . unwrap ( ) ;
2020-04-24 16:32:27 +00:00
2020-05-17 07:44:09 +00:00
if interact . active {
if let Some ( mouse_pos ) = ui . input ( ) . mouse_pos {
let canvas_pos = mouse_pos - rect . min ;
if current_line . last ( ) ! = Some ( & canvas_pos ) {
current_line . push ( canvas_pos ) ;
2020-04-24 16:32:27 +00:00
}
}
2020-05-17 07:44:09 +00:00
} else if ! current_line . is_empty ( ) {
self . lines . push ( vec! [ ] ) ;
}
2020-04-24 16:32:27 +00:00
2020-05-17 07:44:09 +00:00
for line in & self . lines {
if line . len ( ) > = 2 {
ui . add_paint_cmd ( PaintCmd ::LinePath {
points : line . iter ( ) . map ( | p | rect . min + * p ) . collect ( ) ,
color : LIGHT_GRAY ,
width : 2.0 ,
} ) ;
}
}
2020-04-24 16:32:27 +00:00
}
}
2020-05-10 17:04:10 +00:00
// ----------------------------------------------------------------------------
2020-05-12 21:00:20 +00:00
use crate ::layout ::* ;
#[ derive(Deserialize, Serialize) ]
#[ serde(default) ]
struct LayoutExample {
dir : Direction ,
2020-05-13 19:36:15 +00:00
align : Option < Align > , // None == jusitifed
2020-05-13 20:24:32 +00:00
reversed : bool ,
2020-05-12 21:00:20 +00:00
}
impl Default for LayoutExample {
fn default ( ) -> Self {
Self {
dir : Direction ::Vertical ,
2020-05-13 19:36:15 +00:00
align : Some ( Align ::Center ) ,
2020-05-13 20:24:32 +00:00
reversed : false ,
2020-05-12 21:00:20 +00:00
}
}
}
impl LayoutExample {
pub fn ui ( & mut self , ui : & mut Ui ) {
2020-05-13 19:36:15 +00:00
Resize ::default ( )
. default_size ( vec2 ( 200.0 , 200.0 ) )
. show ( ui , | ui | self . contents_ui ( ui ) ) ;
}
pub fn contents_ui ( & mut self , ui : & mut Ui ) {
2020-05-13 20:24:32 +00:00
let layout = Layout ::from_dir_align ( self . dir , self . align ) ;
if self . reversed {
ui . set_layout ( layout . reverse ( ) ) ;
} else {
ui . set_layout ( layout ) ;
}
2020-05-12 21:00:20 +00:00
2020-05-13 20:56:37 +00:00
// ui.add(label!("Available space: {:?}", ui.available().size()));
2020-05-12 21:00:20 +00:00
if ui . add ( Button ::new ( " Reset " ) ) . clicked {
* self = Default ::default ( ) ;
}
ui . add ( Separator ::new ( ) ) ;
ui . add ( label! ( " Direction: " ) ) ;
// TODO: enum iter
for & dir in & [ Direction ::Horizontal , Direction ::Vertical ] {
if ui
. add ( RadioButton ::new ( self . dir = = dir , format! ( " {:?} " , dir ) ) )
. clicked
{
self . dir = dir ;
}
}
2020-05-13 20:24:32 +00:00
ui . add ( Checkbox ::new ( & mut self . reversed , " Reversed " ) ) ;
2020-05-12 21:00:20 +00:00
ui . add ( Separator ::new ( ) ) ;
2020-05-13 19:36:15 +00:00
2020-05-12 21:00:20 +00:00
ui . add ( label! ( " Align: " ) ) ;
2020-05-13 19:36:15 +00:00
for & align in & [ Align ::Min , Align ::Center , Align ::Max ] {
2020-05-12 21:00:20 +00:00
if ui
. add ( RadioButton ::new (
2020-05-13 19:36:15 +00:00
self . align = = Some ( align ) ,
2020-05-12 21:00:20 +00:00
format! ( " {:?} " , align ) ,
) )
. clicked
{
2020-05-13 19:36:15 +00:00
self . align = Some ( align ) ;
2020-05-12 21:00:20 +00:00
}
}
2020-05-13 19:36:15 +00:00
if ui
. add ( RadioButton ::new ( self . align = = None , " Justified " ) )
. tooltip_text ( " Try to fill full width/heigth (e.g. buttons) " )
. clicked
{
self . align = None ;
}
2020-05-12 21:00:20 +00:00
}
}
// ----------------------------------------------------------------------------
2020-04-21 18:52:17 +00:00
const LOREM_IPSUM : & str = " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Curabitur pretium tincidunt lacus . Nulla gravida orci a odio . Nullam varius , turpis et commodo pharetra , est eros bibendum elit , nec luctus magna felis sollicitudin mauris . Integer in mauris eu nibh euismod gravida . Duis ac tellus et risus vulputate vehicula . Donec lobortis risus a elit . Etiam tempor . Ut ullamcorper , ligula eu tempor congue , eros est euismod turpis , id tincidunt sapien risus a quam . Maecenas fermentum consequat mi . Donec fermentum . Pellentesque malesuada nulla a mi . Duis sapien sem , aliquet nec , commodo eget , consequat quis , neque . Aliquam faucibus , elit ut dictum aliquet , felis nisl adipiscing sapien , sed malesuada diam lacus eget erat . Cras mollis scelerisque nunc . Nullam arcu . Aliquam consequat . Curabitur augue lorem , dapibus quis , laoreet et , pretium ac , nisi . Aenean magna nisl , mollis quis , molestie eu , feugiat in , orci . In hac habitasse platea dictumst . " ;