mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
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:
parent
cdbc252190
commit
57fe4d19ac
2 changed files with 19 additions and 34 deletions
|
@ -90,18 +90,16 @@ 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;
|
||||
if (m_auto_repeat_interval) {
|
||||
if (!m_being_pressed)
|
||||
m_auto_repeat_timer->stop();
|
||||
else
|
||||
m_auto_repeat_timer->start(m_auto_repeat_interval);
|
||||
}
|
||||
update();
|
||||
bool being_pressed = is_over;
|
||||
if (being_pressed != m_being_pressed) {
|
||||
m_being_pressed = being_pressed;
|
||||
if (m_auto_repeat_interval) {
|
||||
if (!m_being_pressed)
|
||||
m_auto_repeat_timer->stop();
|
||||
else
|
||||
m_auto_repeat_timer->start(m_auto_repeat_interval);
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
Widget::mousemove_event(event);
|
||||
|
@ -113,14 +111,12 @@ 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();
|
||||
m_being_pressed = true;
|
||||
update();
|
||||
|
||||
if (m_auto_repeat_interval) {
|
||||
click();
|
||||
m_auto_repeat_timer->start(m_auto_repeat_interval);
|
||||
}
|
||||
if (m_auto_repeat_interval) {
|
||||
click();
|
||||
m_auto_repeat_timer->start(m_auto_repeat_interval);
|
||||
}
|
||||
}
|
||||
Widget::mousedown_event(event);
|
||||
|
@ -134,13 +130,11 @@ 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();
|
||||
}
|
||||
bool was_being_pressed = m_being_pressed;
|
||||
m_being_pressed = false;
|
||||
update();
|
||||
if (was_being_pressed && !was_auto_repeating)
|
||||
click();
|
||||
}
|
||||
Widget::mouseup_event(event);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue