mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
VBForm: Set mouse type relative to how we resize the VBWidget
This commit is contained in:
parent
6fe0fa30f2
commit
e7d15ccca4
2 changed files with 38 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
void delete_selected_widgets();
|
||||
template<typename Callback>
|
||||
void for_each_selected_widget(Callback);
|
||||
void set_cursor_type_from_grabber(Direction grabber);
|
||||
|
||||
VBWidget* single_selected_widget();
|
||||
|
||||
|
@ -59,5 +60,6 @@ private:
|
|||
Point m_transform_event_origin;
|
||||
Point m_next_insertion_position;
|
||||
Direction m_resize_direction { Direction::None };
|
||||
Direction m_mouse_direction_type { Direction::None };
|
||||
OwnPtr<GMenu> m_context_menu;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue