ladybird/DevTools/HackStudio/CursorTool.cpp
Andreas Kling f6576c4b7c 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.
2019-11-10 22:03:39 +01:00

31 lines
922 B
C++

#include "CursorTool.h"
#include "FormEditorWidget.h"
#include "FormWidget.h"
#include <AK/LogStream.h>
void CursorTool::on_mousedown(GMouseEvent& 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)
{
(void)event;
dbg() << "CursorTool::on_mouseup";
}
void CursorTool::on_mousemove(GMouseEvent& event)
{
(void)event;
dbg() << "CursorTool::on_mousemove";
}