@@ -2,6 +2,7 @@ use crate::common::{ComponentStore, Components, Simulator};
22use crate :: gui_egui:: editor:: EditorMode ;
33use crate :: gui_egui:: {
44 editor:: { Editor , Library } ,
5+ gui_options:: GuiOptions ,
56 keymap,
67 keymap:: Shortcuts ,
78 menu:: Menu ,
@@ -38,22 +39,6 @@ pub struct Gui {
3839 pub gui_options : GuiOptions ,
3940}
4041
41- #[ derive( Clone , Debug ) ]
42- pub struct GuiOptions {
43- // This is added/subtracted to/from the view scale when zoomed.
44- pub view_scaling_val : f32 ,
45- pub window_visible : bool ,
46- }
47-
48- impl Default for GuiOptions {
49- fn default ( ) -> GuiOptions {
50- GuiOptions {
51- view_scaling_val : 0.03 ,
52- window_visible : false ,
53- }
54- }
55- }
56-
5742#[ derive( Clone , Debug ) ]
5843pub struct EguiExtra {
5944 pub properties_window : bool ,
@@ -92,12 +77,16 @@ pub fn gui(cs: ComponentStore, path: &PathBuf, library: Library) -> Result<(), e
9277}
9378
9479impl Gui {
95- pub fn new ( cs : ComponentStore , path : & PathBuf , library : Library ) -> Result < Self , Box < dyn Error > > {
80+ pub fn new (
81+ cs : ComponentStore ,
82+ path : & PathBuf ,
83+ library : Library ,
84+ ) -> Result < Self , Box < dyn Error > > {
9685 let contexts = create_contexts ( & cs. store ) ;
9786 let simulator = Simulator :: new ( cs) ?;
9887 let path = path. to_owned ( ) ;
9988 // simulator.save_dot(&path);
100-
89+
10190 Ok ( Gui {
10291 path,
10392 simulator : Some ( simulator) ,
@@ -256,30 +245,3 @@ pub fn create_contexts(components: &Components) -> HashMap<crate::common::Id, Eg
256245 }
257246 contexts
258247}
259-
260-
261- use egui:: { ViewportBuilder , ViewportId } ;
262- /// This should be somewhere else but put it here for experiments
263- // It makes more sense to have a GuiOptionsWindow having render but let's see how this works
264- impl GuiOptions {
265- pub fn render ( & mut self , ctx : & egui:: Context ) {
266- ctx. show_viewport_immediate (
267- ViewportId :: from_hash_of ( "Preferences" ) ,
268- ViewportBuilder {
269- title : Some ( "Preferences" . to_string ( ) ) ,
270- position : Some ( Pos2 :: new ( ctx. screen_rect ( ) . max . x /2.0 , ctx. screen_rect ( ) . max . y /2.0 ) ) ,
271- inner_size : Some ( ( 500.0 , 200.0 ) . into ( ) ) ,
272- ..ViewportBuilder :: default ( )
273- } ,
274- |ctx, _class| {
275- if ctx. input ( |i| i. viewport ( ) . close_requested ( ) ) {
276- self . window_visible = false
277- }
278- egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
279- ui. label ( "Zoom Scaling" ) ;
280- let response = ui. add ( egui:: Slider :: new ( & mut self . view_scaling_val , 0.0 ..=0.1 ) ) ;
281- response. on_hover_text ( "Adjusts the step size by which zooming zooms." ) ;
282- } ) ;
283- } ) ;
284- }
285- }
0 commit comments