LibGUI: Remove unnecessary is_enabled() checks in mouse event handlers

We never deliver mouse events to disabled widgets, so there's no need
to check is_enabled() in these event handlers.
This commit is contained in:
Andreas Kling 2020-04-29 19:05:30 +02:00
parent cdbc252190
commit 57fe4d19ac
2 changed files with 19 additions and 34 deletions

View file

@ -90,7 +90,6 @@ void AbstractButton::mousemove_event(MouseEvent& event)
bool is_over = rect().contains(event.position());
m_hovered = is_over;
if (event.buttons() & MouseButton::Left) {
if (is_enabled()) {
bool being_pressed = is_over;
if (being_pressed != m_being_pressed) {
m_being_pressed = being_pressed;
@ -103,7 +102,6 @@ void AbstractButton::mousemove_event(MouseEvent& event)
update();
}
}
}
Widget::mousemove_event(event);
}
@ -113,7 +111,6 @@ void AbstractButton::mousedown_event(MouseEvent& event)
dbgprintf("AbstractButton::mouse_down_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button());
#endif
if (event.button() == MouseButton::Left) {
if (is_enabled()) {
m_being_pressed = true;
update();
@ -122,7 +119,6 @@ void AbstractButton::mousedown_event(MouseEvent& event)
m_auto_repeat_timer->start(m_auto_repeat_interval);
}
}
}
Widget::mousedown_event(event);
}
@ -134,14 +130,12 @@ void AbstractButton::mouseup_event(MouseEvent& event)
if (event.button() == MouseButton::Left) {
bool was_auto_repeating = m_auto_repeat_timer->is_active();
m_auto_repeat_timer->stop();
if (is_enabled()) {
bool was_being_pressed = m_being_pressed;
m_being_pressed = false;
update();
if (was_being_pressed && !was_auto_repeating)
click();
}
}
Widget::mouseup_event(event);
}

View file

@ -115,8 +115,6 @@ Gfx::Rect Slider::knob_rect() const
void Slider::mousedown_event(MouseEvent& event)
{
if (!is_enabled())
return;
if (event.button() == MouseButton::Left) {
if (knob_rect().contains(event.position())) {
m_dragging = true;
@ -135,8 +133,6 @@ void Slider::mousedown_event(MouseEvent& event)
void Slider::mousemove_event(MouseEvent& event)
{
if (!is_enabled())
return;
set_knob_hovered(knob_rect().contains(event.position()));
if (m_dragging) {
float delta = event.position().primary_offset_for_orientation(orientation()) - m_drag_origin.primary_offset_for_orientation(orientation());
@ -151,8 +147,6 @@ void Slider::mousemove_event(MouseEvent& event)
void Slider::mouseup_event(MouseEvent& event)
{
if (!is_enabled())
return;
if (event.button() == MouseButton::Left) {
m_dragging = false;
return;
@ -163,9 +157,6 @@ void Slider::mouseup_event(MouseEvent& event)
void Slider::mousewheel_event(MouseEvent& event)
{
if (!is_enabled())
return;
if (orientation() == Orientation::Horizontal)
set_value(value() - event.wheel_delta() * m_step);
else