1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibGUI+FontEditor: Restore normalized selections on Undo/Redo

Selections are always normalized when saving undo commands.
The restore_selection() function reverses this process so
negatively sized selections (created right-to-left) continue
to resize correctly with the keyboard when restored.
This commit is contained in:
thankyouverycool 2022-12-17 15:36:02 -05:00 committed by Andreas Kling
parent 02212f373b
commit 40e94a315a
3 changed files with 16 additions and 2 deletions

View file

@ -97,6 +97,17 @@ void GlyphMapWidget::set_selection(int start, int size, Optional<u32> active_gly
set_active_glyph(active_glyph.value(), ShouldResetSelection::No);
}
void GlyphMapWidget::restore_selection(int start, int size, int active_glyph)
{
if (start == active_glyph && size > 1) {
start = active_glyph + size - 1;
size = -size + 1;
}
m_selection.set_start(start);
m_selection.set_size(size);
set_active_glyph(active_glyph, ShouldResetSelection::No);
}
Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const
{
glyph -= m_active_range.first;