Skip to content

Commit

Permalink
Interactive demo ui improvements (#24)
Browse files Browse the repository at this point in the history
* repositioned ui interactive demo

* removed max size for side panel
  • Loading branch information
blitzarx1 authored Apr 29, 2023
1 parent 9f8fcda commit 966fcac
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions examples/interactive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ impl InteractiveApp {
// * update simulation
// * restore loop edges

// remove looped edges
let looped_nodes = {
// remove looped edges
let graph = self.simulation.get_graph_mut();
let mut looped_nodes = vec![];
let mut looped_edges = vec![];
Expand Down Expand Up @@ -308,6 +308,18 @@ impl InteractiveApp {
});
}

fn reset_graph(&mut self, ui: &mut Ui) {
self.settings_graph = SettingsGraph::default();
let (simulation, elements) = construct_simulation(
self.settings_graph.count_node,
self.settings_graph.count_edge,
);
self.simulation = simulation;
self.elements = elements;

GraphView::reset_metadata(ui);
}

fn draw_section_client(&mut self, ui: &mut Ui) {
CollapsingHeader::new("Client")
.default_open(true)
Expand All @@ -327,7 +339,9 @@ impl InteractiveApp {
{
self.simulation_stopped = !self.simulation_stopped;
};
ui.label("Stop/start the simulation.");
if ui.button("reset").clicked() {
self.reset_graph(ui);
}
});

ui.add_space(10.);
Expand All @@ -336,22 +350,10 @@ impl InteractiveApp {

ui.add_space(10.);

ui.horizontal(|ui| {
if ui.button("randomize").clicked() {
let (simulation, elements) = construct_simulation(
self.settings_graph.count_node,
self.settings_graph.count_edge,
);
self.simulation = simulation;
self.elements = elements;

GraphView::reset_metadata(ui);
}

ui.add_space(5.);
ui.label("Style");
ui.separator();

self.draw_dark_mode(ui);
});
self.draw_dark_mode(ui);
});
}

Expand Down Expand Up @@ -473,7 +475,6 @@ impl App for InteractiveApp {

egui::SidePanel::right("right_panel")
.min_width(250.)
.max_width(400.)
.show(ctx, |ui| {
ScrollArea::vertical().show(ui, |ui| {
self.draw_section_client(ui);
Expand Down

0 comments on commit 966fcac

Please sign in to comment.