From 414606b64aa6c6cf3209861b81a92a6af873937f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 8 Jan 2022 12:43:07 +0100 Subject: Make UI events const refs and celan up redundant use of virtual with override. --- dggui/scrollbar.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'dggui/scrollbar.cc') diff --git a/dggui/scrollbar.cc b/dggui/scrollbar.cc index e78aab3..00ed727 100644 --- a/dggui/scrollbar.cc +++ b/dggui/scrollbar.cc @@ -117,7 +117,7 @@ static void drawArrow(Painter &p, int x, int y, int w, int h) p.drawLine(x + (w / 2), y + h, x + w, y); } -void ScrollBar::repaintEvent(RepaintEvent* repaintEvent) +void ScrollBar::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); @@ -150,19 +150,19 @@ void ScrollBar::repaintEvent(RepaintEvent* repaintEvent) p.drawLine(0, height() - width(), width(), height() - width()); } -void ScrollBar::scrollEvent(ScrollEvent* scrollEvent) +void ScrollBar::scrollEvent(const ScrollEvent& scrollEvent) { - setValue(value() + scrollEvent->delta); + setValue(value() + scrollEvent.delta); } -void ScrollBar::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) +void ScrollBar::mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) { if(!dragging) { return; } - float delta = yOffset - mouseMoveEvent->y; + float delta = yOffset - mouseMoveEvent.y; int h = height() - 2 * width() - 3; delta /= (float)h / (float)maxValue; @@ -174,17 +174,17 @@ void ScrollBar::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) } } -void ScrollBar::buttonEvent(ButtonEvent* buttonEvent) +void ScrollBar::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if((buttonEvent->y < (int)width()) && buttonEvent->y > 0) + if((buttonEvent.y < (int)width()) && buttonEvent.y > 0) { - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { addValue(-1); } @@ -192,10 +192,10 @@ void ScrollBar::buttonEvent(ButtonEvent* buttonEvent) return; } - if((buttonEvent->y > ((int)height() - (int)width())) && - (buttonEvent->y < (int)height())) + if((buttonEvent.y > ((int)height() - (int)width())) && + (buttonEvent.y < (int)height())) { - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { addValue(1); } @@ -203,13 +203,13 @@ void ScrollBar::buttonEvent(ButtonEvent* buttonEvent) return; } - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { - yOffset = buttonEvent->y; + yOffset = buttonEvent.y; valueOffset = value(); } - dragging = (buttonEvent->direction == Direction::down); + dragging = (buttonEvent.direction == Direction::down); } } // dggui:: -- cgit v1.2.3