Skip to content

Commit

Permalink
expose less of the interals of the gui to the main app
Browse files Browse the repository at this point in the history
  • Loading branch information
Redhawk18 committed Jul 9, 2023
1 parent 36c4adf commit 96fd8a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/gui/elements.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use iced::widget::{button, row};
use iced::Element;
use iced_aw::menu::MenuTree;
use iced_aw::menu::{MenuBar, MenuTree};
use iced_aw::{TabBar, TabLabel};

pub fn file<'a>(_app: &super::State) -> MenuTree<'a, super::Message, iced::Renderer> {
pub fn menu_bar<'a>() -> MenuBar<'a, super::Message, iced::Renderer> {
MenuBar::new(vec![file()])
}

fn file<'a>() -> MenuTree<'a, super::Message, iced::Renderer> {
let new_file = MenuTree::new(button("New File").on_press(super::Message::TabNew(
super::FileTab {
text: std::string::String::default(),
Expand Down
7 changes: 2 additions & 5 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::path::PathBuf;
use iced::widget::text_input;
use iced::widget::Column;
use iced::{theme, Application, Command, Element, Subscription};
use iced_aw::menu::MenuBar;

mod elements;
mod file_dialog;

pub use elements::file;
pub use elements::menu_bar;

#[derive(Debug, Clone)]
pub enum Message {
Expand Down Expand Up @@ -148,9 +147,7 @@ impl Application for State {
}

fn view(&self) -> Element<Message> {
let menu_bar = MenuBar::new(vec![file(self)]);

let mut c = Column::new().push(menu_bar);
let mut c = Column::new().push(menu_bar());

if !self.tabs.is_empty() {
c = c.push(elements::tab_header(&self.tabs, self.active_tab.unwrap()));
Expand Down

0 comments on commit 96fd8a2

Please sign in to comment.