From 027af2d36ec3f761ac37d7e99a01416b4320caf5 Mon Sep 17 00:00:00 2001 From: p6nj Date: Thu, 6 Jun 2024 21:51:01 +0200 Subject: [PATCH] =?UTF-8?q?vive=20la=20r=C3=A9volution=20!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 20 +------- bent.wsd | 17 +++++++ bent/Cargo.toml | 8 +++ bent/src/main.rs | 3 ++ bingus/Cargo.toml | 1 + bong/Cargo.toml | 8 +++ bong/src/main.rs | 3 ++ src/app.rs | 47 ------------------ src/app/tabs.rs | 123 ---------------------------------------------- src/main.rs | 19 ------- 10 files changed, 42 insertions(+), 207 deletions(-) create mode 100644 bent.wsd create mode 100644 bent/Cargo.toml create mode 100644 bent/src/main.rs create mode 100644 bong/Cargo.toml create mode 100644 bong/src/main.rs delete mode 100644 src/app.rs delete mode 100644 src/app/tabs.rs delete mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 7beec45..3eeef77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,3 @@ -[package] -name = "bent" -version = "0.1.0" -edition = "2021" -license = "Unlicense" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow = "1.0" -derive-new = "0.6.0" -eframe = "0.27" -egui_dock = "0.12" -egui_extras = "0.27.2" -rfd = "0.14" -strum = { version = "0.26", features = ["derive"] } - [workspace] -members = ["bingus"] +resolver = "2" +members = ["bent", "bingus", "bong"] diff --git a/bent.wsd b/bent.wsd new file mode 100644 index 0000000..fa653ab --- /dev/null +++ b/bent.wsd @@ -0,0 +1,17 @@ +@startuml "bingus" +title "Project organization" +package bong +note bottom + cli bin +endnote +package bingus +note bottom + core lib +endnote +package bent +note bottom + gui bin +endnote +bong -> bingus +bingus <- bent +@enduml \ No newline at end of file diff --git a/bent/Cargo.toml b/bent/Cargo.toml new file mode 100644 index 0000000..5cbbd47 --- /dev/null +++ b/bent/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bent" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/bent/src/main.rs b/bent/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/bent/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/bingus/Cargo.toml b/bingus/Cargo.toml index 37a0340..efd8c7e 100644 --- a/bingus/Cargo.toml +++ b/bingus/Cargo.toml @@ -2,6 +2,7 @@ name = "bingus" version = "0.1.0" edition = "2021" +license = "Unlicense" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bong/Cargo.toml b/bong/Cargo.toml new file mode 100644 index 0000000..1141f72 --- /dev/null +++ b/bong/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "bong" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/bong/src/main.rs b/bong/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/bong/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/app.rs b/src/app.rs deleted file mode 100644 index 6cfaca5..0000000 --- a/src/app.rs +++ /dev/null @@ -1,47 +0,0 @@ -use derive_new::new; -use eframe::egui::{self, menu, CentralPanel, Frame}; -use egui_dock::{DockArea, DockState}; - -mod tabs; -use tabs::{chefs_dish, Tab, TabViewer}; - -use self::tabs::TabKind; - -#[derive(new)] -pub(super) struct App { - tree: DockState, - tab_viewer: TabViewer, - open_summary: bool, -} - -impl eframe::App for App { - fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { - CentralPanel::default() - .frame(Frame::central_panel(&ctx.style())) - .show(ctx, |ui| { - menu::bar(ui, |ui| { - ui.menu_button("Tabs", |ui| { - if ui.checkbox(&mut self.open_summary, "Summary").changed() { - match self.open_summary { - true => self.tree.push_to_focused_leaf(Tab::new(TabKind::Summary)), - false => { - self.tree = self - .tree - .filter_tabs(|tab| !matches!(tab.kind, TabKind::Summary)) - } - } - } - }); - }); - DockArea::new(&mut self.tree).show_inside(ui, &mut self.tab_viewer); - }); - } -} - -impl Default for App { - fn default() -> Self { - let tree = DockState::new(chefs_dish()); - - Self::new(tree, TabViewer::default(), false) - } -} diff --git a/src/app/tabs.rs b/src/app/tabs.rs deleted file mode 100644 index e97eac2..0000000 --- a/src/app/tabs.rs +++ /dev/null @@ -1,123 +0,0 @@ -use std::path::PathBuf; - -use derive_new::new; -use eframe::egui::{ScrollArea, Sense, TextStyle, Ui, WidgetText}; -use egui_extras::{Column, Size, StripBuilder, TableBuilder}; -use rfd::FileDialog; -use strum::{AsRefStr, EnumIter, IntoEnumIterator}; - -#[derive(Clone, AsRefStr, PartialEq, EnumIter)] -pub(super) enum TabKind { - Input, - Decode, - Process, - Encode, - Output, - Summary, - Help, -} - -#[derive(new, Clone)] -pub(super) struct Tab { - #[allow(private_interfaces)] - pub(super) kind: TabKind, -} - -impl TabKind { - fn is_optional(&self) -> bool { - match self { - Self::Input | Self::Decode | Self::Process | Self::Encode | Self::Output => false, - _ => true, - } - } -} - -impl Tab { - fn is_optional(&self) -> bool { - self.kind.is_optional() - } -} - -pub(super) fn chefs_dish() -> Vec { - TabKind::iter().take(5).map(|kind| Tab::new(kind)).collect() -} - -#[derive(Default)] -pub(super) struct TabViewer { - input_files: Vec, -} - -impl egui_dock::TabViewer for TabViewer { - type Tab = Tab; - - fn title(&mut self, tab: &mut Self::Tab) -> WidgetText { - tab.kind.as_ref().into() - } - - fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab) { - ui.heading(tab.kind.as_ref()); - match tab.kind { - TabKind::Input => { - let button_size = TextStyle::Button.resolve(ui.style()).size; - StripBuilder::new(ui) - .size(Size::remainder().at_least(20.0)) // for the table - .size(Size::remainder().at_most(button_size * 4.0)) // for the add and clear buttons - .vertical(|mut strip| { - strip.cell(|ui| { - ScrollArea::horizontal().show(ui, |ui| { - TableBuilder::new(ui) - .striped(true) - .sense(Sense::click()) - .column(Column::remainder()) - .body(|body| { - body.rows(18.0, self.input_files.len(), |mut row| { - let index = row.index(); - row.col(|ui| { - ui.label( - &self - .input_files - .get(index) - .map(|buf| { - buf.to_str() - .unwrap_or("[invalid UTF-8]") - .to_string() - }) - .unwrap_or("???".to_string()), - ); - }); - }); - }) - }); - }); - strip.cell(|ui| { - ui.vertical_centered_justified(|ui| { - if ui.button("Clear").clicked() { - self.input_files.clear(); - } - if ui.button("Add").clicked() { - if let Some(mut paths) = FileDialog::new().pick_files() { - self.input_files.append(&mut paths); - } - } - }); - }); - }); - // https://github.com/emilk/egui/blob/master/examples/file_dialog/src/main.rs - } - TabKind::Decode => todo!(), - TabKind::Process => todo!(), - TabKind::Encode => todo!(), - TabKind::Output => todo!(), - TabKind::Summary => todo!(), - TabKind::Help => todo!(), - } - } - - fn allowed_in_windows(&self, tab: &mut Self::Tab) -> bool { - tab.is_optional() - } - - fn closeable(&mut self, tab: &mut Self::Tab) -> bool { - tab.is_optional() - } -} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index 2dcc362..0000000 --- a/src/main.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use eframe::egui; - -mod app; -use app::App; - -fn main() -> Result<(), eframe::Error> { - let options = eframe::NativeOptions { - viewport: egui::ViewportBuilder::default() - .with_inner_size([640.0, 240.0]) // wide enough for the drag-drop overlay text - .with_drag_and_drop(true), - ..Default::default() - }; - eframe::run_native( - "Native file dialogs and drag-and-drop files", - options, - Box::new(|_cc| Box::::default()), - ) -}