This commit is contained in:
enx01
2025-11-26 17:59:48 +01:00
commit da0888b50f
5 changed files with 71 additions and 0 deletions

0
src/gui/elements.rs Normal file
View File

69
src/gui/mod.rs Normal file
View File

@@ -0,0 +1,69 @@
use fltk::{
app, prelude::*, window::Window, frame::Frame, group::{Pack, Flex},
menu::MenuBar, button::Button, tree::Tree, enums::{FrameType, Align}
};
pub struct P2PClientGUI {
app: app::App,
win: Window,
}
impl P2PClientGUI {
pub fn new() -> Self {
let app = app::App::default();
let mut win = Window::default()
.with_size(900, 600)
.with_label("P2P Merkle Client");
// 1. Main Layout: Flex (Vertical)
let mut main_flex = Flex::default_fill().column();
// 2. Menu Bar (Top)
let mut menu_bar = MenuBar::default().with_size(win.width(), 30);
menu_bar.add_emit("File/Connect", fltk::enums::Shortcut::None, fltk::menu::MenuFlag::Invisible, app::channel().0, ());
menu_bar.add_emit("File/Exit", fltk::enums::Shortcut::None, fltk::menu::MenuFlag::Invisible, app::channel().0, ());
menu_bar.end();
// 3. Content Area: Flex (Horizontal)
let mut content_flex = Flex::default().row();
// --- Central Area (Filesystem Tree)
let mut fs_tree = Tree::default().with_label("Filesystem View");
fs_tree.set_frame(FrameType::FlatBox);
// Placeholder data for the tree
fs_tree.add("root/Folder A/File 1");
fs_tree.add("root/Folder B/File 2");
content_flex.fixed(&fs_tree, win.width() - 200); // 700px width
// --- Right-Sided Panel (Known Peers List)
let mut right_panel = Pack::default();
right_panel.set_frame(FrameType::EngravedBox);
right_panel.set_spacing(5);
Frame::default().with_label("Known Peers").set_align(Align::Top);
// List of Labels (placeholder)
Frame::default().with_label("Peer A (Online)").set_frame(FrameType::ThinUpBox);
Frame::default().with_label("Peer B (Offline)").set_frame(FrameType::ThinUpBox);
right_panel.end();
content_flex.fixed(&right_panel, 200); // 200px width
content_flex.end();
main_flex.end(); // End of main layout
win.end();
win.show();
Self { app, win }
}
pub fn run(&mut self) {
// Here you would connect signals from the GUI to the network thread.
// For now, it just runs the application loop.
while self.app.wait() {
// Handle GUI events
}
}
}

2
src/network/mod.rs Normal file
View File

@@ -0,0 +1,2 @@
mod protocol;
mod peers;

0
src/network/peers.rs Normal file
View File

0
src/network/protocol.rs Normal file
View File