maps 1.10.1

Inspect, compare and align multiple grid maps in an intuitive & fast GUI
Documentation
use eframe::egui;

use crate::app::AppState;
use crate::app_impl::constants::SPACE;

const INFO_WINDOW_WIDTH: f32 = 500.0;
const KEYBINDING_TABLE_WIDTH: f32 = 400.0;

impl AppState {
    fn keybinding_table(ui: &mut egui::Ui) {
        // Collapsible table of keybindings.
        egui::CollapsingHeader::new("Keybindings")
            .default_open(false)
            .show(ui, |ui| {
                egui::Grid::new("keybindings")
                    .striped(true)
                    .max_col_width(KEYBINDING_TABLE_WIDTH)
                    .show(ui, |ui| {
                        ui.label(egui::RichText::new("Key").strong());
                        ui.label(egui::RichText::new("Action").strong());
                        ui.end_row();

                        // Movements
                        ui.label("+/-");
                        ui.label("Zoom grid in 'Aligned' view.");
                        ui.end_row();
                        ui.label("w/a/s/d");
                        ui.label(
                            "Move grid in 'Aligned' view, or move selected map \
                    when editing a pose and 'Move Map' is selected.",
                        );
                        ui.end_row();
                        ui.label("q/e");
                        ui.label(
                            "Rotate selected map in 'Aligned' view when editing \
                    a pose and 'Move Map' is selected.",
                        );
                        ui.end_row();
                        ui.label("1/2/3");
                        ui.label("Switch to fine, medium, or coarse movement sensitivity presets.");
                        ui.end_row();
                        ui.end_row();

                        // Mouse
                        ui.label("click + drag");
                        ui.label("Move grid in 'Aligned' view. Move tabs/panes in 'Tiles' view.");
                        ui.end_row();
                        ui.label("scroll");
                        ui.label(
                            "Zoom grid in 'Aligned' view or change lens size in \
                        'Tiles'/'Stacked' view, if active.",
                        );
                        ui.end_row();
                        ui.label("pinch gesture");
                        ui.label("Zoom grid in 'Aligned' view using a touchpad or touchscreen.");
                        ui.end_row();
                        ui.label("left click / l");
                        ui.label("Toggle hovering lens.");
                        ui.end_row();
                        ui.label("double click");
                        ui.label("Reset grid in 'Aligned' view.");
                        ui.end_row();
                        ui.label("g");
                        ui.label("Toggle grid lines in 'Aligned' view.");
                        ui.end_row();
                        ui.end_row();

                        // Screenshots, picking etc
                        ui.label("p");
                        ui.label("Take a picture of the full UI and save the screenshot.");
                        ui.end_row();
                        ui.label("shift + p");
                        ui.label("Take a screenshot containing only the central maps panel.");
                        ui.end_row();
                        ui.label("Ctrl c (Cmd c)");
                        ui.label(
                            "Copy the current hover position to the clipboard in 'Aligned' view.",
                        );
                        ui.end_row();
                        ui.end_row();

                        // General
                        ui.label("m");
                        ui.label("Toggle the menu sidebar.");
                        ui.end_row();
                        ui.label("o");
                        ui.label("Toggle the settings sidebar.");
                        ui.end_row();
                        ui.label("Esc");
                        ui.label(
                            "Close open sidebars or child windows. Deactivate lens if active.",
                        );
                        ui.end_row();
                        ui.label("Ctrl + (Cmd +)");
                        ui.label("Increase the global zoom level of the UI.");
                        ui.end_row();
                        ui.label("Ctrl - (Cmd -)");
                        ui.label("Decrease the global zoom level of the UI.");
                        ui.end_row();
                        ui.label("Ctrl 0 (Cmd 0)");
                        ui.label("Reset the global zoom level of the UI.");
                        ui.end_row();
                    });
            });
    }

    pub(crate) fn info_window(&mut self, ui: &mut egui::Ui) {
        if self.options.help_visible {
            egui::Window::new("Info")
                .open(&mut self.options.help_visible)
                .pivot(egui::Align2::CENTER_CENTER)
                .default_pos(ui.ctx().content_rect().center())
                .fixed_size(egui::Vec2::splat(INFO_WINDOW_WIDTH))
                .collapsible(false)
                .show(ui.ctx(), |ui| {
                    ui.vertical_centered(|ui| {
                        ui.heading("maps");
                        ui.add_space(SPACE);
                        ui.add(
                            egui::Hyperlink::from_label_and_url(
                                egui::RichText::new(egui::special_emojis::GITHUB).heading(),
                                "https://www.github.com/MichaelGrupp/maps",
                            )
                            .open_in_new_tab(true),
                        );
                        ui.add_space(SPACE);
                        ui.label("© Michael Grupp. Licensed under the Apache 2.0 license.");
                        ui.label(self.build_info.clone());
                        ui.separator();
                        Self::keybinding_table(ui);
                    });
                });
        }
    }
}