bingus, tabs
This commit is contained in:
parent
9103cd1e8b
commit
409ee2f121
5 changed files with 4051 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/target
|
||||
*.lock
|
3956
Cargo.lock
generated
3956
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,7 @@
|
|||
[package]
|
||||
name = "bent"
|
||||
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
|
||||
|
14
bingus/src/lib.rs
Normal file
14
bingus/src/lib.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
81
src/main.rs
81
src/main.rs
|
@ -1,3 +1,80 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
use derive_new::new;
|
||||
use eframe::egui;
|
||||
use egui_dock::{DockArea, DockState, Style};
|
||||
|
||||
struct Main {
|
||||
tree: DockState<Tab>,
|
||||
}
|
||||
|
||||
impl eframe::App for Main {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
DockArea::new(&mut self.tree)
|
||||
.style(Style::from_egui(ctx.style().as_ref()))
|
||||
.show(ctx, &mut TabViewer);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Main {
|
||||
fn default() -> Self {
|
||||
let tree = DockState::new(vec![Tab::new("dummy"), Tab::new("hi")]);
|
||||
|
||||
Self { tree }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(new)]
|
||||
struct Tab {
|
||||
name: &'static str,
|
||||
}
|
||||
|
||||
impl Display for Tab {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.name)
|
||||
}
|
||||
}
|
||||
|
||||
struct TabViewer;
|
||||
|
||||
impl egui_dock::TabViewer for TabViewer {
|
||||
type Tab = Tab;
|
||||
|
||||
fn title(&mut self, tab: &mut Self::Tab) -> egui::WidgetText {
|
||||
format!("{tab}").into()
|
||||
}
|
||||
fn ui(&mut self, ui: &mut egui::Ui, tab: &mut Self::Tab) {
|
||||
ui.label(format!("Content of {tab}"));
|
||||
}
|
||||
fn allowed_in_windows(&self, _tab: &mut Self::Tab) -> bool {
|
||||
false
|
||||
}
|
||||
fn closeable(&mut self, _tab: &mut Self::Tab) -> bool {
|
||||
false
|
||||
}
|
||||
fn context_menu(
|
||||
&mut self,
|
||||
_ui: &mut egui::Ui,
|
||||
_tab: &mut Self::Tab,
|
||||
_surface: egui_dock::SurfaceIndex,
|
||||
_node: egui_dock::NodeIndex,
|
||||
) {
|
||||
}
|
||||
fn on_add(&mut self, _surface: egui_dock::SurfaceIndex, _node: egui_dock::NodeIndex) {}
|
||||
}
|
||||
|
||||
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::<Main>::default()),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue