mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:22:07 +00:00
LibGUI: Allow selecting glyphs by dragging in GlyphMapWidget
This commit is contained in:
parent
c094bb60bc
commit
66e72ed5e6
2 changed files with 34 additions and 0 deletions
|
@ -160,10 +160,41 @@ void GlyphMapWidget::mousedown_event(MouseEvent& event)
|
|||
m_selection.set_size(1);
|
||||
m_selection.set_start(glyph);
|
||||
}
|
||||
m_in_drag_select = true;
|
||||
set_active_glyph(glyph, ShouldResetSelection::No);
|
||||
}
|
||||
}
|
||||
|
||||
void GlyphMapWidget::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
Frame::mouseup_event(event);
|
||||
|
||||
if (!m_in_drag_select)
|
||||
return;
|
||||
|
||||
if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) {
|
||||
auto glyph = maybe_glyph.value();
|
||||
m_selection.extend_to(glyph);
|
||||
m_in_drag_select = false;
|
||||
set_active_glyph(glyph, ShouldResetSelection::No);
|
||||
}
|
||||
}
|
||||
|
||||
void GlyphMapWidget::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
Frame::mousemove_event(event);
|
||||
|
||||
if (!m_in_drag_select)
|
||||
return;
|
||||
|
||||
if (auto maybe_glyph = glyph_at_position(event.position()); maybe_glyph.has_value()) {
|
||||
auto glyph = maybe_glyph.value();
|
||||
m_selection.extend_to(glyph);
|
||||
scroll_to_glyph(glyph);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void GlyphMapWidget::doubleclick_event(MouseEvent& event)
|
||||
{
|
||||
Widget::doubleclick_event(event);
|
||||
|
|
|
@ -69,6 +69,8 @@ private:
|
|||
GlyphMapWidget();
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void doubleclick_event(MouseEvent&) override;
|
||||
virtual void keydown_event(KeyEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
@ -87,6 +89,7 @@ private:
|
|||
Selection m_selection;
|
||||
int m_active_glyph { 0 };
|
||||
int m_visible_glyphs { 0 };
|
||||
bool m_in_drag_select { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue