URI: 
       Implemented basic layer functionality. - 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 d0435ec74f08ded8d01c4e9b53eea9c714cbe563
   DIR parent ff0834f3e6148988119b375579059dd2bc574459
  HTML Author: Mike Krüger <mkrueger@posteo.de>
       Date:   Wed,  9 Aug 2023 12:10:02 +0200
       
       Implemented basic layer functionality.
       
       Diffstat:
         M src/ui/ansi_editor/mod.rs           |      14 ++++++++++----
         M src/ui/dialogs/about_dialog.rs      |       8 +++-----
         M src/ui/layer_view.rs                |      74 +++++++++++++++++++++++++++----
       
       3 files changed, 79 insertions(+), 17 deletions(-)
       ---
   DIR diff --git a/src/ui/ansi_editor/mod.rs b/src/ui/ansi_editor/mod.rs
       @@ -395,7 +395,7 @@ impl Document for AnsiEditor {
        
                ui.horizontal(|ui| {
                    let pos = self.buffer_view.lock().unwrap().editor.caret.get_position();
       -            
       +
                    let label_font_size = 20.0;
        
                    ui.vertical(|ui| {
       @@ -426,7 +426,10 @@ impl Document for AnsiEditor {
                            self.buffer_view.lock().unwrap().editor.cur_outline =
                                (cur_outline + 1) % DEFAULT_OUTLINE_TABLE.len();
                        }
       -                ui.label(RichText::new((cur_outline + 1).to_string()).font(FontId::proportional(label_font_size)));
       +                ui.label(
       +                    RichText::new((cur_outline + 1).to_string())
       +                        .font(FontId::proportional(label_font_size)),
       +                );
        
                        if ui
                            .selectable_label(
       @@ -454,9 +457,12 @@ impl Document for AnsiEditor {
                                cur_font_page,
                            ));
        
       -                    ui.label(RichText::new(format!("F{}", i + 1)).font(FontId::proportional(label_font_size)));
       +                    ui.label(
       +                        RichText::new(format!("F{}", i + 1))
       +                            .font(FontId::proportional(label_font_size)),
       +                    );
                        }
       -/* 
       +                /*
                        ui.label(fl!(
                            crate::LANGUAGE_LOADER,
                            "toolbar-size",
   DIR diff --git a/src/ui/dialogs/about_dialog.rs b/src/ui/dialogs/about_dialog.rs
       @@ -4,11 +4,9 @@ use i18n_embed_fl::fl;
        
        #[derive(Default)]
        pub struct AboutDialog {
       -
            pub create: bool,
        }
        
       -
        impl crate::ModalDialog for AboutDialog {
            fn show(&mut self, ctx: &egui::Context) -> bool {
                let mut result = false;
       @@ -21,7 +19,7 @@ impl crate::ModalDialog for AboutDialog {
                        ui.vertical_centered(|ui| {
                            ui.heading(fl!(crate::LANGUAGE_LOADER, "about-dialog-heading"));
                        });
       -    
       +
                        ui.label(fl!(crate::LANGUAGE_LOADER, "about-dialog-description"));
                        ui.add_space(12.0); // ui.separator();
                        ui.label(fl!(
       @@ -29,9 +27,9 @@ impl crate::ModalDialog for AboutDialog {
                            "about-dialog-created_by",
                            authors = env!("CARGO_PKG_AUTHORS")
                        ));
       -    
       +
                        ui.add_space(8.0); // ui.separator();
       -                });
       +            });
        
                    modal.buttons(ui, |ui| {
                        if ui
   DIR diff --git a/src/ui/layer_view.rs b/src/ui/layer_view.rs
       @@ -15,6 +15,9 @@ pub fn show_layer_view(
            if buffer_opt.is_none() {
                return;
            }
       +    let buffer_opt = buffer_opt.unwrap();
       +    let max = buffer_opt.lock().unwrap().editor.buf.layers.len();
       +    let cur_layer = buffer_opt.lock().unwrap().editor.cur_layer;
        
            let table = TableBuilder::new(ui)
                .striped(false)
       @@ -34,12 +37,17 @@ pub fn show_layer_view(
                    });
                })
                .body(|mut body| {
       -            for layer in &mut buffer_opt.unwrap().lock().unwrap().editor.buf.layers {
       +            for i in 0..max {
       +                let (is_visible, title) = {
       +                    let layer = &buffer_opt.lock().unwrap().editor.buf.layers[i];
       +                    (layer.is_visible, layer.title.clone())
       +                };
       +
                        body.row(20.0, |mut row| {
                            row.col(|ui| {
                                let r = ui
                                    .add(egui::ImageButton::new(
       -                                if layer.is_visible {
       +                                if is_visible {
                                            super::VISIBLE_SVG.texture_id(ctx)
                                        } else {
                                            super::INVISIBLE_SVG.texture_id(ctx)
       @@ -57,11 +65,15 @@ pub fn show_layer_view(
                                    });
        
                                if r.clicked() {
       -                            layer.is_visible = !layer.is_visible;
       +                            buffer_opt.lock().unwrap().editor.buf.layers[i].is_visible =
       +                                !is_visible;
                                }
                            });
                            row.col(|ui| {
       -                        ui.label(&layer.title);
       +                        let r = ui.selectable_label((i as i32) == cur_layer, &title);
       +                        if r.clicked() {
       +                            buffer_opt.lock().unwrap().editor.cur_layer = i as i32;
       +                        }
                            });
                        });
                    }
       @@ -69,7 +81,7 @@ pub fn show_layer_view(
        
            let img_size = Vec2::new(24., 24.);
            ui.horizontal(|ui| {
       -        let _r = ui
       +        let r = ui
                    .add(egui::ImageButton::new(
                        super::ADD_LAYER_SVG.texture_id(ctx),
                        img_size,
       @@ -78,7 +90,19 @@ pub fn show_layer_view(
                        ui.label(RichText::new(fl!(crate::LANGUAGE_LOADER, "add_layer_tooltip")).small());
                    });
        
       -        let _r = ui
       +        if r.clicked() {
       +            let mut new_layer = icy_engine::Layer::new();
       +            new_layer.title = "New layer".to_string();
       +            buffer_opt
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .layers
       +                .insert(0, new_layer);
       +        }
       +
       +        let r = ui
                    .add(egui::ImageButton::new(
                        super::MOVE_UP_SVG.texture_id(ctx),
                        img_size,
       @@ -89,7 +113,18 @@ pub fn show_layer_view(
                        );
                    });
        
       -        let _r = ui
       +        if r.clicked() && cur_layer > 0 {
       +            buffer_opt
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .layers
       +                .swap(cur_layer as usize, cur_layer as usize - 1);
       +            buffer_opt.lock().unwrap().editor.cur_layer -= 1;
       +        }
       +
       +        let r = ui
                    .add(egui::ImageButton::new(
                        super::MOVE_DOWN_SVG.texture_id(ctx),
                        img_size,
       @@ -100,7 +135,18 @@ pub fn show_layer_view(
                        );
                    });
        
       -        let _r = ui
       +        if r.clicked() && (1 + cur_layer as usize) < max {
       +            buffer_opt
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .layers
       +                .swap(cur_layer as usize, cur_layer as usize + 1);
       +            buffer_opt.lock().unwrap().editor.cur_layer += 1;
       +        }
       +
       +        let r = ui
                    .add(egui::ImageButton::new(
                        super::DELETE_SVG.texture_id(ctx),
                        img_size,
       @@ -110,5 +156,17 @@ pub fn show_layer_view(
                            RichText::new(fl!(crate::LANGUAGE_LOADER, "delete_layer_tooltip")).small(),
                        );
                    });
       +
       +        if r.clicked() && cur_layer >= 0 && cur_layer < max as i32 {
       +            buffer_opt
       +                .lock()
       +                .unwrap()
       +                .editor
       +                .buf
       +                .layers
       +                .remove(cur_layer as usize);
       +            buffer_opt.lock().unwrap().editor.cur_layer =
       +                std::cmp::min(cur_layer, (max as i32) - 1);
       +        }
            });
        }