URI: 
       Render widget is now focus aware. - icy_draw - icy_draw is the successor to mystic draw. fork / mirror
  HTML git clone https://git.drkhsh.at/icy_draw.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 86d3152697fa734be4bc78d28fd9d67020069a37
   DIR parent 145d1a2d12ea774976c316c1ea65c6a4a7255790
  HTML Author: Mike Krüger <mkrueger@posteo.de>
       Date:   Thu, 31 Aug 2023 15:17:04 +0200
       
       Render widget is now focus aware.
       
       Diffstat:
         M src/model/tools/draw_rectangle_fil… |       1 -
         M src/ui/dialogs/export_file_dialog/… |       1 -
         M src/ui/docking.rs                   |       1 -
         M src/ui/editor/mod.rs                |       9 ++++-----
         M src/ui/main_window.rs               |      92 +++++++++++++++++++------------
       
       5 files changed, 60 insertions(+), 44 deletions(-)
       ---
   DIR diff --git a/src/model/tools/draw_rectangle_filled_imp.rs b/src/model/tools/draw_rectangle_filled_imp.rs
       @@ -106,7 +106,6 @@ impl Tool for DrawRectangleFilledTool {
                lines.add_rectangle(Rectangle::from_pt(start, cur));
        
                let draw = move |rect: Rectangle| {
       -            println!("draw rect: {:?}", rect);
                    for y in 0..(rect.size.height as i32) {
                        for x in 0..(rect.size.width as i32) {
                            plot_point(
   DIR diff --git a/src/ui/dialogs/export_file_dialog/mod.rs b/src/ui/dialogs/export_file_dialog/mod.rs
       @@ -109,7 +109,6 @@ impl ModalDialog for ExportFileDialog {
                                        });
                                    });
                                if old_format != format_type {
       -                            println!("change extension to {}", format_type);
                                    self.file_name
                                        .set_extension(TYPE_DESCRIPTIONS[format_type].2);
                                }
   DIR diff --git a/src/ui/docking.rs b/src/ui/docking.rs
       @@ -15,7 +15,6 @@ pub struct TabBehavior {
        
        impl egui_tiles::Behavior<Tab> for TabBehavior {
            fn tab_title_for_pane(&mut self, pane: &Tab) -> egui::WidgetText {
       -        println!("get title for pane {}", pane.doc.get_title());
                let mut title = pane.doc.get_title();
                if pane.doc.is_dirty() {
                    title.push('*');
   DIR diff --git a/src/ui/editor/mod.rs b/src/ui/editor/mod.rs
       @@ -146,9 +146,8 @@ impl Document for AnsiEditor {
                            id: Some(Id::new(self.id + 10000)),
                            ..Default::default()
                        };
       -
                        let (response, calc) = show_terminal_area(ui, self.buffer_view.clone(), opt);
       -                self.handle_response(ui, response, calc, cur_tool);
       +                self.handle_response(ui, response, calc, cur_tool)
                    },
                );
                self.show_toolbar(ui);
       @@ -869,8 +868,8 @@ impl AnsiEditor {
                response: Response,
                calc: TerminalCalc,
                cur_tool: &mut Box<dyn Tool>,
       -    ) {
       -        if self.enabled {
       +    ) -> Response {
       +        if response.has_focus() {
                    let events = ui.input(|i| i.events.clone());
                    for e in &events {
                        match e {
       @@ -938,7 +937,6 @@ impl AnsiEditor {
                    if let Some(mouse_pos) = response.interact_pointer_pos() {
                        if calc.buffer_rect.contains(mouse_pos) {
                            let click_pos = calc.calc_click_pos(mouse_pos);
       -                    println!("click !");
                            /*
                            let b: i32 = match responsee.b {
                                             PointerButton::Primary => 1,
       @@ -1009,6 +1007,7 @@ impl AnsiEditor {
                        }
                    }
                }
       +        response
            }
        
            pub(crate) fn set_file_name(&self, file_name: impl Into<PathBuf>) {
   DIR diff --git a/src/ui/main_window.rs b/src/ui/main_window.rs
       @@ -183,11 +183,9 @@ impl MainWindow {
                if let Some(root) = self.tree.root {
                    stack.push(root);
                }
       -        while !stack.is_empty() {
       -            let id = stack.pop().unwrap();
       -
       +        while let Some(id) = stack.pop() {
                    match self.tree.tiles.get(id) {
       -                Some(egui_tiles::Tile::Pane(p)) => {
       +                Some(egui_tiles::Tile::Pane(_)) => {
                            if let Some(egui_tiles::Tile::Pane(p)) = self.tree.tiles.get_mut(id) {
                                return Some(p);
                            } else {
       @@ -218,6 +216,43 @@ impl MainWindow {
                None
            }
        
       +    pub fn enumerate_documents(&mut self, callback: fn(&mut Box<dyn Document>)) {
       +        let mut stack = vec![];
       +
       +        if let Some(root) = self.tree.root {
       +            stack.push(root);
       +        }
       +        while let Some(id) = stack.pop() {
       +            match self.tree.tiles.get(id) {
       +                Some(egui_tiles::Tile::Pane(_)) => {
       +                    if let Some(egui_tiles::Tile::Pane(p)) = self.tree.tiles.get_mut(id) {
       +                        callback(&mut p.doc);
       +                    }
       +                }
       +                Some(egui_tiles::Tile::Container(container)) => match container {
       +                    egui_tiles::Container::Tabs(tabs) => {
       +                        if let Some(active) = tabs.active {
       +                            stack.push(active);
       +                        }
       +                    }
       +                    egui_tiles::Container::Linear(l) => {
       +                        for child in l.children.iter() {
       +                            stack.push(*child);
       +                        }
       +                    }
       +                    egui_tiles::Container::Grid(g) => {
       +                        for child in g.children() {
       +                            stack.push(*child);
       +                        }
       +                    }
       +                },
       +                None => {}
       +            }
       +        }
       +    }
       +
       +
       +
            pub fn get_active_document_mut(&mut self) -> Option<&mut Box<dyn Document>> {
                if let Some(pane) = self.get_active_pane() {
                    return Some(&mut pane.doc);
       @@ -259,20 +294,7 @@ pub fn button_with_shortcut(
        
        impl eframe::App for MainWindow {
            fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
       -        use egui::FontFamily::Proportional;
       -        use egui::FontId;
       -        use egui::TextStyle::*;
       -
       -        let mut style: egui::Style = (*ctx.style()).clone();
       -        style.text_styles = [
       -            (Heading, FontId::new(30.0, Proportional)),
       -            (Body, FontId::new(14.0, Proportional)),
       -            (Monospace, FontId::new(20.0, Proportional)),
       -            (Button, FontId::new(20.0, Proportional)),
       -            (Small, FontId::new(16.0, Proportional)),
       -        ]
       -        .into();
       -        ctx.set_style(style);
       +    
        
                let msg = self.show_top_bar(ctx, frame);
                self.handle_message(msg);
       @@ -360,28 +382,26 @@ impl eframe::App for MainWindow {
                        }
                    }
        
       -            for (_, tile) in self.tree.tiles.iter_mut() {
       -                match tile {
       -                    egui_tiles::Tile::Pane(Tab { doc, .. }) => {
       -                        doc.set_enabled(!self.dialog_open);
       -                    }
       -                    _ => {}
       -                }
       +            let enabled = !self.dialog_open;
       +            if enabled {
       +                self.enumerate_documents( move |doc| {
       +                    doc.set_enabled(true);
       +                });
       +            } else {
       +                self.enumerate_documents( move |doc| {
       +                    doc.set_enabled(false);
       +                });
                    }
       +
                }
                ctx.request_repaint_after(Duration::from_millis(150));
            }
        
       -    fn on_exit(&mut self, gl: Option<&glow::Context>) {
       -        if let Some(gl) = gl {
       -            for (_, tile) in self.tree.tiles.iter() {
       -                match tile {
       -                    egui_tiles::Tile::Pane(Tab { doc, .. }) => {
       -                        doc.destroy(gl);
       -                    }
       -                    _ => {}
       -                }
       -            }
       -        }
       +    fn on_exit(&mut self, _gl: Option<&glow::Context>) {
       +        /* TODO
       +        
       +        self.enumerate_documents( move |doc| {
       +            doc.destroy(gl);
       +        });*/
            }
        }