From 4ac02cbd6edcdfeb74f8be644a38c9fa1f3e7aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Tue, 10 Oct 2023 17:11:24 +0200 Subject: [PATCH] Pipette tool has now shift/ctrl for selecting fg/bg color only. --- i18n/de/icy_draw.ftl | 10 ++++++++++ i18n/en/icy_draw.ftl | 6 ++++++ src/model/tools/pipette_imp.rs | 22 +++++++++++++++++++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/i18n/de/icy_draw.ftl b/i18n/de/icy_draw.ftl index 83b7606..4625e55 100644 --- a/i18n/de/icy_draw.ftl +++ b/i18n/de/icy_draw.ftl @@ -309,6 +309,16 @@ font_tool_no_fonts_label= Installiere Fonts in das Fontverzeichnis font_tool_open_directory_button=Fontverzeichnis öffnen +pipette_tool_char_code=Code { $code } +pipette_tool_foreground=Vordergrund { $fg } +pipette_tool_background=Hintergrund { $bg } +pipette_tool_keys= + Shift halten für + Vordergrund Farbe + + Strg halten für + Hintergrund Farbe + char_table_tool_title=Zeichentabelle minimap_tool_title=Übersicht diff --git a/i18n/en/icy_draw.ftl b/i18n/en/icy_draw.ftl index 4b475f2..0d97de2 100644 --- a/i18n/en/icy_draw.ftl +++ b/i18n/en/icy_draw.ftl @@ -304,6 +304,12 @@ font_tool_open_directory_button=Open font directory pipette_tool_char_code=Code { $code } pipette_tool_foreground=Foreground { $fg } pipette_tool_background=Background { $bg } +pipette_tool_keys= + Hold shift to pick up + foreground color + + Hold control to pick up + background color char_table_tool_title=Char table minimap_tool_title=Preview diff --git a/src/model/tools/pipette_imp.rs b/src/model/tools/pipette_imp.rs index 1990af2..155f704 100644 --- a/src/model/tools/pipette_imp.rs +++ b/src/model/tools/pipette_imp.rs @@ -73,6 +73,11 @@ impl Tool for PipetteTool { ui.label(fl!(crate::LANGUAGE_LOADER, "pipette_tool_background", bg = ch.attribute.get_background())); paint_color(ui, &editor.buffer_view.lock().get_buffer().palette.get_color(ch.attribute.get_background())); }); + ui.add_space(4.0); + ui.horizontal(|ui| { + ui.add_space(8.0); + ui.label(fl!(crate::LANGUAGE_LOADER, "pipette_tool_keys")); + }); } None } @@ -115,10 +120,21 @@ impl Tool for PipetteTool { } } - fn handle_click(&mut self, editor: &mut AnsiEditor, button: i32, pos: Position, _pos_abs: Position, _response: &egui::Response) -> Option { + fn handle_click(&mut self, editor: &mut AnsiEditor, button: i32, _pos: Position, _pos_abs: Position, response: &egui::Response) -> Option { if button == 1 { - let ch = editor.get_char(pos); - editor.set_caret_attribute(ch.attribute); + unsafe { + if let Some(ch) = CUR_CHAR { + let mut attr = editor.buffer_view.lock().get_caret_mut().get_attribute(); + if response.ctx.input(|i| i.modifiers.shift) { + attr.set_foreground(ch.attribute.get_foreground()); + } else if response.ctx.input(|i| i.modifiers.ctrl) { + attr.set_background(ch.attribute.get_background()); + } else { + attr = ch.attribute; + } + editor.set_caret_attribute(attr); + } + } return Some(Message::SelectPreviousTool); } None