mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibGUI: Move most of mouse event handling to GAbstractView
This deduplicates existing code, and also gives all the model-backed widgets selection manipulation and drag support for free :^)
This commit is contained in:
committed by
Andreas Kling
parent
fd11c96e8e
commit
d3ce7ae0e3
@@ -102,25 +102,6 @@ Point GListView::adjusted_position(const Point& position) const
|
||||
return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
}
|
||||
|
||||
void GListView::mousedown_event(GMouseEvent& event)
|
||||
{
|
||||
if (!model())
|
||||
return;
|
||||
|
||||
if (event.button() != GMouseButton::Left)
|
||||
return;
|
||||
|
||||
auto index = index_at_event_position(event.position());
|
||||
if (index.is_valid()) {
|
||||
if (event.modifiers() & Mod_Ctrl)
|
||||
selection().toggle(index);
|
||||
else
|
||||
selection().set(index);
|
||||
} else {
|
||||
selection().clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GListView::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GFrame::paint_event(event);
|
||||
|
||||
Reference in New Issue
Block a user