Added char table. - icy_draw - icy_draw is the successor to mystic draw. fork / mirror
 (HTM) git clone https://git.drkhsh.at/icy_draw.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 40567bb2601d5059046a7bb5cb0d6d0dbc75488a
 (DIR) parent 0ff1e555b1e0b1e3dcf9e44abbc1ec830be461df
 (HTM) Author: Mike Krueger <mkrueger@posteo.de>
       Date:   Sun, 11 Dec 2022 20:17:08 +0100
       
       Added char table.
       
       Diffstat:
         M src/model/editor/mod.rs             |       2 ++
         A src/ui/char_table.rs                |      40 +++++++++++++++++++++++++++++++
         M src/ui/main_window.rs               |      10 +++++++++-
         M src/ui/mod.rs                       |       4 ++++
       
       4 files changed, 55 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/model/editor/mod.rs b/src/model/editor/mod.rs
       @@ -50,6 +50,7 @@ pub struct Editor {
        
            cur_outline: i32,
            pub is_inactive: bool,
       +    pub cur_font_page: usize,
        
            pub reference_image: Option<PathBuf>,
            pub cur_layer: i32,
       @@ -93,6 +94,7 @@ impl Editor
                   //outline_changed: Box::new(|_| {}),
                   // request_refresh: Box::new(|| {}),
                    cur_layer: 0,
       +            cur_font_page: 0,
                    atomic_undo_stack: Vec::new(),
                    //pos_changed: Box::new(|_, _| {}),
                    //attr_changed: Box::new(|_| {}),
 (DIR) diff --git a/src/ui/char_table.rs b/src/ui/char_table.rs
       @@ -0,0 +1,39 @@
       +use std::cmp::min;
       +use std::sync::{Arc, Mutex};
       +use eframe::epaint::{Vec2, Rect, Pos2, Rounding, Color32, Stroke};
       +use eframe::egui::{self, Sense};
       +use icy_engine::{AsciiParser, BufferParser};
       +use crate::ansi_editor::BufferView;
       +use crate::model::brush_imp::draw_glyph;
       +
       +pub fn show_char_table(ctx: &egui::Context, buffer_opt: Option<Arc<Mutex<BufferView>>>) -> impl egui::Widget {
       +    move |ui: &mut egui::Ui| {
       +        let Some(buffer) = &buffer_opt else { 
       +            return ui.label("no selected editor");
       +        };
       +        let font_page = buffer.lock().unwrap().editor.cur_font_page;
       +        let font_length  = buffer.lock().unwrap().editor.buf.font_table[font_page].length;
       +
       +        egui::ScrollArea::vertical().show(ui, |ui| {
       +            ui.horizontal_wrapped(|ui| {
       +                for i in 0..font_length {
       +                    let ch = unsafe { char::from_u32_unchecked(i as u32) };
       +                    if ui.add(draw_glyph(buffer.clone(), ch, font_page)).clicked() {
       +
       +                        if let Ok(b) = &mut buffer.lock() {
       +                            let mut p = AsciiParser::new();
       +                            let editor = &mut b.editor;
       +                            BufferParser::print_char(
       +                                &mut p,
       +                                &mut editor.buf,
       +                                &mut editor.caret,
       +                                ch,
       +                            );
       +                            b.redraw_view();
       +                        }
       +                    }
       +                }
       +            })
       +        }).inner.response
       +    }
       +}
       +\ No newline at end of file
 (DIR) diff --git a/src/ui/main_window.rs b/src/ui/main_window.rs
       @@ -1,6 +1,6 @@
        use std::{path::PathBuf, fs, sync::Arc, time::Duration};
        
       -use eframe::{egui::{self, menu, TopBottomPanel, SidePanel}};
       +use eframe::{egui::{self, menu, TopBottomPanel, SidePanel, CentralPanel}};
        use egui_dock::{DockArea, Style,  Tree, Node};
        use glow::Context;
        use i18n_embed_fl::fl;
       @@ -205,6 +205,14 @@ impl eframe::App for MainWindow {
                    }
                });
        
       +        TopBottomPanel::bottom("bottom_panel").resizable(true).show(ctx, |ui| {
       +            let mut buffer_opt = None;
       +            if let Some((_, t)) = self.tree.find_active_focused() {
       +                buffer_opt = t.1.get_buffer_view();
       +            }
       +            ui.add(crate::show_char_table(ctx, buffer_opt.clone()));
       +        });
       +
                DockArea::new(&mut self.tree)
                    .style(Style::from_egui(ctx.style().as_ref()))
                    .show(ctx, &mut TabViewer {});
 (DIR) diff --git a/src/ui/mod.rs b/src/ui/mod.rs
       @@ -16,6 +16,10 @@ pub use palette_editor::*;
        
        mod tool_switcher;
        pub use tool_switcher::*;
       +
       +mod char_table;
       +pub use char_table::*;
       +
        mod icons;
        pub use icons::*;