mirror of
https://github.com/RGBCube/serenity
synced 2025-07-07 12:57:35 +00:00
HackStudio: Start implementing basic widget selection in CursorTool
You can now select widgets by clicking on them with the CursorTool, and toggle the selection state of a widget by Ctrl+clicking it.
This commit is contained in:
parent
e87756424d
commit
f6576c4b7c
4 changed files with 78 additions and 2 deletions
|
@ -1,10 +1,21 @@
|
|||
#include "CursorTool.h"
|
||||
#include "FormEditorWidget.h"
|
||||
#include "FormWidget.h"
|
||||
#include <AK/LogStream.h>
|
||||
|
||||
void CursorTool::on_mousedown(GMouseEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
dbg() << "CursorTool::on_mousedown";
|
||||
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 (event.modifiers() & Mod_Ctrl)
|
||||
m_editor.selection().toggle(*result.widget);
|
||||
else
|
||||
m_editor.selection().set(*result.widget);
|
||||
// FIXME: Do we need to update any part of the FormEditorWidget outside the FormWidget?
|
||||
form_widget.update();
|
||||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_mouseup(GMouseEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue