Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Pipette tool has now shift/ctrl for selecting fg/bg color only.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Oct 10, 2023
1 parent 659cf49 commit 4ac02cb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions i18n/de/icy_draw.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions i18n/en/icy_draw.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 19 additions & 3 deletions src/model/tools/pipette_imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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<Message> {
fn handle_click(&mut self, editor: &mut AnsiEditor, button: i32, _pos: Position, _pos_abs: Position, response: &egui::Response) -> Option<Message> {
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
Expand Down

0 comments on commit 4ac02cb

Please sign in to comment.