Function fltk::app::background

source ·
pub fn background(r: u8, g: u8, b: u8)
Expand description

Set the background color

Examples found in repository?
examples/tabs.rs (line 43)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    app::background(221, 221, 221);

    let mut wind = Window::default()
        .with_size(500, 450)
        .with_label("Tabs")
        .center_screen();

    draw_gallery();

    wind.make_resizable(true);
    wind.end();
    wind.show();

    app.run().unwrap();
}
More examples
Hide additional examples
examples/custom_dial.rs (line 66)
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
fn main() {
    let app = app::App::default();
    app::background(255, 255, 255);
    let mut win = window::Window::default().with_size(400, 300);
    let mut dial = MyDial::new(100, 100, 200, 200, "CPU Load %");
    dial.set_label_size(22);
    dial.set_label_color(Color::from_u32(0x797979));
    win.end();
    win.show();

    // get the cpu load value from somewhere, then call dial.set_value() in a callback or event loop
    dial.set_value(10);

    app.run().unwrap();
}
examples/rounded_images.rs (line 48)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gleam);
    app::background(0, 0, 0);
    let image = image::SharedImage::load("screenshots/calc2.jpg")
        .unwrap()
        .to_rgb()
        .unwrap();

    let mut wind = window::Window::new(100, 100, 800, 400, "Hello from rust");
    let row = group::Flex::default()
        .row()
        .with_size(800, 200)
        .center_of_parent();
    for i in 1..=4 {
        let color_depth = enums::ColorDepth::from_u8(i).unwrap();
        let image = image.convert(color_depth).unwrap();
        RoundImageBox::new(100, image);
    }
    row.end();
    wind.end();
    wind.show();

    app.run().unwrap();
}
examples/defaults.rs (line 9)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fn main() {
    let (r, g, b) = utils::hex2rgb(0xfafdf3);

    let app = app::App::default();

    // global theming
    app::background(r, g, b); // background color. For input/output and text widgets, use app::background2
    app::foreground(20, 20, 20); // labels
    app::set_font(enums::Font::Courier);
    app::set_font_size(16);
    app::set_frame_type(enums::FrameType::RFlatBox);
    app::set_visible_focus(false);

    // regular widget code
    let mut win = window::Window::default().with_size(400, 300);
    let frame = frame::Frame::new(0, 0, 400, 200, "Defaults");
    let flex = group::Flex::default()
        .with_size(400, 50)
        .below_of(&frame, 50);
    let mut but1 = button::Button::default().with_label("Button1");
    but1.set_color(enums::Color::Yellow);
    but1.set_down_frame(enums::FrameType::RFlatBox);
    frame::Frame::default();
    let mut but2 = button::Button::default().with_label("Button2");
    but2.set_color(enums::Color::Yellow);
    but2.set_down_frame(enums::FrameType::RFlatBox);
    flex.end();

    win.end();
    win.show();

    app.run().unwrap();
}
examples/counter.rs (line 14)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    app::background(0x62, 0x00, 0xee);
    app::set_visible_focus(false);

    let count = Rc::new(RefCell::new(0));

    let mut wind = Window::default().with_size(160, 200).with_label("Counter");
    let mut flex = Flex::default_fill().column();
    flex.set_margins(30, 40, 30, 40);
    flex.set_pad(10);
    let mut but_inc = Button::default().with_label("+");
    let mut frame = Frame::default().with_label(&count.borrow().to_string());
    let mut but_dec = Button::default().with_label("-");
    flex.end();
    // wind.make_resizable(true);
    wind.end();
    wind.show();

    but_inc.set_callback({
        let count = count.clone();
        let mut frame = frame.clone();
        move |_| {
            *count.borrow_mut() += 1;
            frame.set_label(&count.borrow().to_string());
        }
    });

    but_dec.set_callback(move |_| {
        *count.borrow_mut() -= 1;
        frame.set_label(&count.borrow().to_string());
    });

    // Theming
    wind.set_color(Color::White);
    but_inc.set_color(Color::from_u32(0x304FFE));
    but_inc.set_selection_color(Color::Green);
    but_inc.set_label_size(20);
    but_inc.set_frame(FrameType::FlatBox);
    but_inc.set_label_color(Color::White);
    but_dec.set_color(Color::from_u32(0x2962FF));
    but_dec.set_selection_color(Color::Red);
    but_dec.set_frame(FrameType::FlatBox);
    but_dec.set_label_size(20);
    but_dec.set_label_color(Color::White);
    // End theming

    app.run().unwrap();
}
examples/popup_browser.rs (line 7)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
fn main() {
    let app = app::App::default().with_scheme(app::Scheme::Gtk);
    app::background(211, 211, 211);

    let mut win = window::Window::default().with_size(900, 300);
    let mut b = browser::HoldBrowser::default()
        .with_size(900 - 10, 300 - 10)
        .center_of(&win);
    let widths = &[50, 50, 50, 70, 70, 40, 40, 70, 70, 50];

    b.set_column_widths(widths);
    b.set_column_char('\t');
    b.add("USER\tPID\t%CPU\t%MEM\tVSZ\tRSS\tTTY\tSTAT\tSTART\tTIME\tCOMMAND");
    b.add("root\t2888\t0.0\t0.0\t1352\t0\ttty3\tSW\tAug15\t0:00\t@b@f/sbin/mingetty tty3");
    b.add("erco\t2889\t0.0\t13.0\t221352\t0\ttty3\tR\tAug15\t1:34\t@b@f/usr/local/bin/render a35 0004");
    b.add("uucp\t2892\t0.0\t0.0\t1352\t0\tttyS0\tSW\tAug15\t0:00\t@b@f/sbin/agetty -h 19200 ttyS0 vt100");
    b.add("root\t13115\t0.0\t0.0\t1352\t0\ttty2\tSW\tAug30\t0:00\t@b@f/sbin/mingetty tty2");
    b.add(
        "root\t13464\t0.0\t0.0\t1352\t0\ttty1\tSW\tAug30\t0:00\t@b@f/sbin/mingetty tty1 --noclear",
    );

    let menu = menu::MenuItem::new(&["1st menu item\t", "2nd menu item\t", "3rd menu item\t"]);

    b.set_callback(move |_| {
        if app::event_mouse_button() == app::MouseButton::Right {
            // or app::event_button() == 3
            let coords = app::event_coords();
            match menu.popup(coords.0, coords.1) {
                None => println!("No value was chosen!"),
                Some(val) => println!("{}", val.label().unwrap()),
            }
        }
    });

    win.make_resizable(true);
    win.end();
    win.show();
    app.run().unwrap();
}