diff options
| author | tslil clingman <> | 2021-01-09 22:42:12 -0500 |
|---|---|---|
| committer | tslil clingman <> | 2021-01-09 22:44:29 -0500 |
| commit | a0f3a7f8ba9036d1fcb18941a54077082f15cf3c (patch) | |
| tree | bb3943b7bc3cee704fbc7ad7c4e4c1ca0204d5f7 /src/gui/mod.rs | |
| parent | 1cb3c0ea50ce55278413dfd368285cb622130a30 (diff) | |
Added .rustfmt.toml, tabs for indentation, spaces for alignment
Diffstat (limited to 'src/gui/mod.rs')
| -rw-r--r-- | src/gui/mod.rs | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 47f56d5..1980fdb 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -1,18 +1,18 @@ /* - This file is part of Takwrap. + This file is part of Takwrap. - Takwrap is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + Takwrap is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - Takwrap is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + Takwrap is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with Takwrap. If not, see <https://www.gnu.org/licenses/>. + You should have received a copy of the GNU General Public License + along with Takwrap. If not, see <https://www.gnu.org/licenses/>. */ mod boardwidget; @@ -22,101 +22,101 @@ use fltk::{app::*, button::*, menu::*, text::*, window::*}; #[derive(Clone, Copy)] enum GUIMessage { - None, - Test, - BoardClick, + None, + Test, + BoardClick, } pub struct GUI { - app: App, - window: DoubleWindow, - board: BoardWidget, - log: TextDisplay, - sender: Sender<GUIMessage>, - receiver: Receiver<GUIMessage>, + app: App, + window: DoubleWindow, + board: BoardWidget, + log: TextDisplay, + sender: Sender<GUIMessage>, + receiver: Receiver<GUIMessage>, } impl GUI { - pub fn new() -> GUI { - let app = App::default(); + pub fn new() -> GUI { + let app = App::default(); - // TODO: Why is this not the same as - /* - let mut window = Window::default() - .with_size(800, 600) - .with_label("Takwrap") - .center_screen(); - */ - // Windows made that way are not resizable? + // TODO: Why is this not the same as + /* + let mut window = Window::default() + .with_size(800, 600) + .with_label("Takwrap") + .center_screen(); + */ + // Windows made that way are not resizable? - let mut window = DoubleWindow::new(0, 0, 800, 600, "Takwrap").center_screen(); + let mut window = DoubleWindow::new(0, 0, 800, 600, "Takwrap").center_screen(); - let (sender, receiver) = channel::<GUIMessage>(); + let (sender, receiver) = channel::<GUIMessage>(); - const MENU_HEIGHT: i32 = 24; - let mut menu = SysMenuBar::default().with_size(800, MENU_HEIGHT); - // menu.set_text_font(Font::Helvetica); - menu.set_color(Color::Light2); - menu.add_emit( - "&File/New...\t", - Shortcut::None, - MenuFlag::Normal, - sender, - GUIMessage::None, - ); - menu.add_emit( - "&File/Open...\t", - Shortcut::None, - MenuFlag::Normal, - sender, - GUIMessage::Test, - ); + const MENU_HEIGHT: i32 = 24; + let mut menu = SysMenuBar::default().with_size(800, MENU_HEIGHT); + // menu.set_text_font(Font::Helvetica); + menu.set_color(Color::Light2); + menu.add_emit( + "&File/New...\t", + Shortcut::None, + MenuFlag::Normal, + sender, + GUIMessage::None, + ); + menu.add_emit( + "&File/Open...\t", + Shortcut::None, + MenuFlag::Normal, + sender, + GUIMessage::Test, + ); - const LOG_WIDTH: i32 = 800 - 600 + MENU_HEIGHT; - let mut log = TextDisplay::default() - .with_size(LOG_WIDTH, 600 - menu.height()) - .with_pos(800 - LOG_WIDTH, menu.height()); - log.set_buffer(Some(TextBuffer::default())); - log.insert("test\n"); + const LOG_WIDTH: i32 = 800 - 600 + MENU_HEIGHT; + let mut log = TextDisplay::default() + .with_size(LOG_WIDTH, 600 - menu.height()) + .with_pos(800 - LOG_WIDTH, menu.height()); + log.set_buffer(Some(TextBuffer::default())); + log.insert("test\n"); - let mut board_button = Button::default() - .with_size(800 - LOG_WIDTH, 600 - menu.height()) - .below_of(&menu, 0); - board_button.set_frame(FrameType::EmbossedBox); - board_button.emit(sender, GUIMessage::BoardClick); + let mut board_button = Button::default() + .with_size(800 - LOG_WIDTH, 600 - menu.height()) + .below_of(&menu, 0); + board_button.set_frame(FrameType::EmbossedBox); + board_button.emit(sender, GUIMessage::BoardClick); - window.resizable(&mut board_button); - window.end(); - window.show(); + window.resizable(&mut board_button); + window.end(); + window.show(); - let board = BoardWidget::new(board_button, 5); + let board = BoardWidget::new(board_button, 5); - // button.emit(sender, GUIMessage::Foo); + // button.emit(sender, GUIMessage::Foo); - GUI { - app, - board, - window, - log, - sender, - receiver, - } - } + GUI { + app, + board, + window, + log, + sender, + receiver, + } + } - pub fn run(&mut self) -> Result<(), fltk::prelude::FltkError> { - while self.app.wait() { - if let Some(msg) = self.receiver.recv() { - match msg { - GUIMessage::BoardClick => { - let x = event_x(); - let y = event_y(); - let (x, y) = self.board.to_square(x, y); - self.log.insert(&format!("Board click ({},{})\n", x, y)); - } - _ => (), - } - } - } - Ok(()) - } + pub fn run(&mut self) -> Result<(), fltk::prelude::FltkError> { + while self.app.wait() { + if let Some(msg) = self.receiver.recv() { + match msg { + GUIMessage::BoardClick => { + let x = event_x(); + let y = event_y(); + let (x, y) = self.board.to_square(x, y); + self.log.insert(&format!("Board click ({},{})\n", x, y)); + } + _ => (), + } + } + } + Ok(()) + } } |
