mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibGUI: Splitter should only override cursor if within grabbable area
Fixes #3284
This commit is contained in:
parent
d876c49ec7
commit
4463fed398
2 changed files with 19 additions and 5 deletions
|
@ -58,15 +58,25 @@ void Splitter::resize_event(ResizeEvent& event)
|
||||||
m_grabbable_rect = {};
|
m_grabbable_rect = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Splitter::enter_event(Core::Event&)
|
void Splitter::override_cursor(bool do_override)
|
||||||
{
|
{
|
||||||
window()->set_override_cursor(m_orientation == Orientation::Horizontal ? StandardCursor::ResizeColumn : StandardCursor::ResizeRow);
|
if (do_override) {
|
||||||
|
if (!m_overriding_cursor) {
|
||||||
|
window()->set_override_cursor(m_orientation == Orientation::Horizontal ? StandardCursor::ResizeColumn : StandardCursor::ResizeRow);
|
||||||
|
m_overriding_cursor = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_overriding_cursor) {
|
||||||
|
window()->set_override_cursor(StandardCursor::None);
|
||||||
|
m_overriding_cursor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Splitter::leave_event(Core::Event&)
|
void Splitter::leave_event(Core::Event&)
|
||||||
{
|
{
|
||||||
if (!m_resizing)
|
if (!m_resizing)
|
||||||
window()->set_override_cursor(StandardCursor::None);
|
override_cursor(false);
|
||||||
if (!m_grabbable_rect.is_empty()) {
|
if (!m_grabbable_rect.is_empty()) {
|
||||||
m_grabbable_rect = {};
|
m_grabbable_rect = {};
|
||||||
update();
|
update();
|
||||||
|
@ -134,9 +144,12 @@ void Splitter::mousemove_event(MouseEvent& event)
|
||||||
if (!m_resizing) {
|
if (!m_resizing) {
|
||||||
Widget* first { nullptr };
|
Widget* first { nullptr };
|
||||||
Widget* second { nullptr };
|
Widget* second { nullptr };
|
||||||
if (!get_resize_candidates_at(event.position(), first, second))
|
if (!get_resize_candidates_at(event.position(), first, second)) {
|
||||||
|
override_cursor(false);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
recompute_grabbable_rect(*first, *second);
|
recompute_grabbable_rect(*first, *second);
|
||||||
|
override_cursor(m_grabbable_rect.contains(event.position()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto delta = event.position() - m_resize_origin;
|
auto delta = event.position() - m_resize_origin;
|
||||||
|
|
|
@ -44,7 +44,6 @@ protected:
|
||||||
virtual void mousedown_event(MouseEvent&) override;
|
virtual void mousedown_event(MouseEvent&) override;
|
||||||
virtual void mousemove_event(MouseEvent&) override;
|
virtual void mousemove_event(MouseEvent&) override;
|
||||||
virtual void mouseup_event(MouseEvent&) override;
|
virtual void mouseup_event(MouseEvent&) override;
|
||||||
virtual void enter_event(Core::Event&) override;
|
|
||||||
virtual void leave_event(Core::Event&) override;
|
virtual void leave_event(Core::Event&) override;
|
||||||
|
|
||||||
virtual void did_layout() override;
|
virtual void did_layout() override;
|
||||||
|
@ -52,9 +51,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
void recompute_grabbable_rect(const Widget&, const Widget&);
|
void recompute_grabbable_rect(const Widget&, const Widget&);
|
||||||
bool get_resize_candidates_at(const Gfx::IntPoint&, Widget*&, Widget*&);
|
bool get_resize_candidates_at(const Gfx::IntPoint&, Widget*&, Widget*&);
|
||||||
|
void override_cursor(bool do_override);
|
||||||
|
|
||||||
Gfx::Orientation m_orientation;
|
Gfx::Orientation m_orientation;
|
||||||
bool m_resizing { false };
|
bool m_resizing { false };
|
||||||
|
bool m_overriding_cursor { false };
|
||||||
Gfx::IntPoint m_resize_origin;
|
Gfx::IntPoint m_resize_origin;
|
||||||
WeakPtr<Widget> m_first_resizee;
|
WeakPtr<Widget> m_first_resizee;
|
||||||
WeakPtr<Widget> m_second_resizee;
|
WeakPtr<Widget> m_second_resizee;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue