1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:07:34 +00:00

VBForm: Set mouse type relative to how we resize the VBWidget

This commit is contained in:
rhin123 2019-08-29 22:41:41 -05:00 committed by Andreas Kling
parent 6fe0fa30f2
commit e7d15ccca4
2 changed files with 38 additions and 0 deletions

View file

@ -288,6 +288,12 @@ void VBForm::mousemove_event(GMouseEvent& event)
new_rect.set_height(new_rect.height() - (new_rect.height() % m_grid_size) + 1);
widget.set_rect(new_rect);
});
set_cursor_type_from_grabber(m_resize_direction);
} else {
for_each_selected_widget([&](auto& widget) {
set_cursor_type_from_grabber(widget.grabber_at(event.position()));
});
}
}
@ -394,6 +400,36 @@ void VBForm::for_each_selected_widget(Callback callback)
callback(*widget);
}
void VBForm::set_cursor_type_from_grabber(Direction grabber)
{
if (grabber == m_mouse_direction_type)
return;
switch (grabber) {
case Direction::Up:
case Direction::Down:
window()->set_override_cursor(GStandardCursor::ResizeVertical);
break;
case Direction::Left:
case Direction::Right:
window()->set_override_cursor(GStandardCursor::ResizeHorizontal);
break;
case Direction::UpLeft:
case Direction::DownRight:
window()->set_override_cursor(GStandardCursor::ResizeDiagonalTLBR);
break;
case Direction::UpRight:
case Direction::DownLeft:
window()->set_override_cursor(GStandardCursor::ResizeDiagonalBLTR);
break;
case Direction::None:
window()->set_override_cursor(GStandardCursor::None);
break;
}
m_mouse_direction_type = grabber;
}
VBWidget* VBForm::single_selected_widget()
{
if (m_selected_widgets.size() != 1)