|
| 1 | +use fltk::app::Sender; |
| 2 | +use fltk::browser::*; |
| 3 | +use fltk::button::*; |
| 4 | +use fltk::enums::*; |
| 5 | +use fltk::frame::*; |
| 6 | +use fltk::input::*; |
| 7 | +use fltk::prelude::*; |
| 8 | +use fltk::valuator::*; |
| 9 | +use fltk::window::*; |
| 10 | + |
| 11 | +use crate::UIEvent; |
| 12 | + |
| 13 | +pub struct UserInterface { |
| 14 | + pub main_win: Window, |
| 15 | + pub seek_bar: HorNiceSlider, |
| 16 | + pub status_field: Frame, |
| 17 | + pub users: Browser, |
| 18 | + pub temp_input: Input, |
| 19 | + pub lbl_time: Frame, |
| 20 | +} |
| 21 | +impl UserInterface { |
| 22 | + pub fn make_window(sender: Sender<UIEvent>) -> Self { |
| 23 | + let mut main_win = Window::new(100, 100, 400, 180, "multiplayer :3"); |
| 24 | + |
| 25 | + let buttons_y = 120; |
| 26 | + let side_margin = 18; |
| 27 | + |
| 28 | + let mut temp_input = Input::new(150,buttons_y,120,20,""); |
| 29 | + main_win.add(&temp_input); |
| 30 | + |
| 31 | + let mut btn_play = Button::new(side_margin, buttons_y, 36, 26, "@>"); |
| 32 | + btn_play.emit(sender, UIEvent::BtnPlay); |
| 33 | + main_win.add(&btn_play); |
| 34 | + |
| 35 | + let btn_stop = Button::new(42 + side_margin, buttons_y, 36, 26, "@-7square"); |
| 36 | + main_win.add(&btn_stop); |
| 37 | + |
| 38 | + let btn_pause = Button::new(84 + side_margin, buttons_y, 36, 26, "| |"); |
| 39 | + main_win.add(&btn_pause); |
| 40 | + |
| 41 | + let seek_bar = HorNiceSlider::new(side_margin, buttons_y - 35, 200, 24, ""); |
| 42 | + main_win.add(&seek_bar); |
| 43 | + |
| 44 | + let mut status_field = |
| 45 | + Frame::new(0, main_win.height() - 21, main_win.width(), 21, "status"); |
| 46 | + status_field.set_align(Align::Left | Align::Inside); |
| 47 | + status_field.set_frame(FrameType::DownBox); |
| 48 | + main_win.add(&status_field); |
| 49 | + |
| 50 | + let mut art_frame = Frame::new(side_margin, 16, 50, 50, ""); |
| 51 | + art_frame.set_frame(FrameType::DownBox); |
| 52 | + main_win.add(&art_frame); |
| 53 | + |
| 54 | + let mut lbl_title = Frame::new(side_margin + 54, 22, 50, 16, "Title, thing"); |
| 55 | + lbl_title.set_align(Align::Left | Align::Inside); |
| 56 | + main_win.add(&lbl_title); |
| 57 | + |
| 58 | + let mut lbl_data1 = Frame::new(side_margin + 54, 40, 50, 16, "data1"); |
| 59 | + lbl_data1.set_align(Align::Left | Align::Inside); |
| 60 | + main_win.add(&lbl_data1); |
| 61 | + |
| 62 | + let mut users = Browser::new(main_win.width() - 85 - side_margin, 16, 85, 120, "Users"); |
| 63 | + users.add("* you"); |
| 64 | + main_win.add(&users); |
| 65 | + |
| 66 | + let mut btn_connect = Button::new(main_win.width() - 85 - 46, 16, 24, 24, "Cn"); |
| 67 | + //btn_connect.emit(sender, crate::UIEvent::Test("wow".to_string())); |
| 68 | + main_win.add(&btn_connect); |
| 69 | + |
| 70 | + let mut btn_queue = Button::new(main_win.width() - 85 - 46, 16+24+2, 24, 24, "Qu"); |
| 71 | + main_win.add(&btn_queue); |
| 72 | + |
| 73 | + let mut lbl_time = Frame::new(180,70,80,16,"00:00/00:00"); |
| 74 | + lbl_time.set_label_font(Font::Courier); |
| 75 | + lbl_time.set_align(Align::Left | Align::Inside); |
| 76 | + |
| 77 | + main_win.add(&lbl_time); |
| 78 | + |
| 79 | + |
| 80 | + Self { main_win, seek_bar, status_field, users, temp_input, lbl_time } |
| 81 | + } |
| 82 | +} |
0 commit comments