mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 17:55:08 +00:00
HackStudio: Allow rubber-band selection of widgets
This patch implements basic rubber-banding. Perhaps this mechanism can be generalized somehow, but it's not clear to me how that would work at the moment.
This commit is contained in:
parent
196b64c0ae
commit
69dee20761
3 changed files with 91 additions and 10 deletions
|
@ -29,6 +29,8 @@ void CursorTool::on_mousedown(GMouseEvent& event)
|
|||
}
|
||||
} else {
|
||||
m_editor.selection().clear();
|
||||
form_widget.set_rubber_banding({}, true);
|
||||
form_widget.set_rubber_band_origin({}, event.position());
|
||||
}
|
||||
// FIXME: Do we need to update any part of the FormEditorWidget outside the FormWidget?
|
||||
form_widget.update();
|
||||
|
@ -49,15 +51,21 @@ void CursorTool::on_mouseup(GMouseEvent& event)
|
|||
}
|
||||
}
|
||||
m_dragging = false;
|
||||
form_widget.set_rubber_banding({}, false);
|
||||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_mousemove(GMouseEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_mousemove";
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
|
||||
if (form_widget.is_rubber_banding({})) {
|
||||
form_widget.set_rubber_band_position({}, event.position());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_dragging && event.buttons() & GMouseButton::Left && event.position() != m_drag_origin) {
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No);
|
||||
if (result.widget && result.widget != &form_widget) {
|
||||
if (!m_editor.selection().contains(*result.widget)) {
|
||||
|
@ -82,6 +90,7 @@ void CursorTool::on_mousemove(GMouseEvent& event)
|
|||
m_editor.model().update();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CursorTool::on_keydown(GKeyEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue