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/button.cc | 2 +- dggui/button.h | 2 +- dggui/button_base.cc | 8 +++---- dggui/button_base.h | 8 +++---- dggui/checkbox.cc | 2 +- dggui/checkbox.h | 2 +- dggui/combobox.cc | 18 ++++++++-------- dggui/combobox.h | 8 +++---- dggui/eventhandler.cc | 12 +++++------ dggui/frame.cc | 2 +- dggui/frame.h | 6 +++--- dggui/helpbutton.cc | 2 +- dggui/helpbutton.h | 2 +- dggui/knob.cc | 34 ++++++++++++++--------------- dggui/knob.h | 10 ++++----- dggui/label.cc | 2 +- dggui/label.h | 2 +- dggui/layout.h | 10 ++++----- dggui/led.cc | 2 +- dggui/led.h | 2 +- dggui/lineedit.cc | 18 ++++++++-------- dggui/lineedit.h | 6 +++--- dggui/listbox.cc | 2 +- dggui/listbox.h | 4 ++-- dggui/listboxbasic.cc | 40 +++++++++++++++++------------------ dggui/listboxbasic.h | 10 ++++----- dggui/listboxthin.cc | 2 +- dggui/listboxthin.h | 4 ++-- dggui/nativewindow_cocoa.h | 30 +++++++++++++------------- dggui/powerbutton.cc | 2 +- dggui/powerbutton.h | 2 +- dggui/progressbar.cc | 2 +- dggui/progressbar.h | 2 +- dggui/scrollbar.cc | 30 +++++++++++++------------- dggui/scrollbar.h | 8 +++---- dggui/slider.cc | 22 +++++++++---------- dggui/slider.h | 9 ++++---- dggui/tabbutton.cc | 6 +++--- dggui/tabbutton.h | 4 ++-- dggui/textedit.cc | 6 +++--- dggui/textedit.h | 4 ++-- dggui/toggle.cc | 6 +++--- dggui/toggle.h | 6 +++--- dggui/tooltip.cc | 6 +++--- dggui/tooltip.h | 10 ++++----- dggui/verticalline.cc | 2 +- dggui/verticalline.h | 2 +- dggui/widget.cc | 2 +- dggui/widget.h | 22 +++++++++---------- plugingui/bleedcontrolframecontent.h | 2 +- plugingui/diskstreamingframecontent.h | 2 +- plugingui/drumkitframecontent.h | 4 ++-- plugingui/drumkittab.cc | 28 ++++++++++++------------ plugingui/drumkittab.h | 6 +++--- plugingui/filebrowser.cc | 2 +- plugingui/filebrowser.h | 4 ++-- plugingui/humaniservisualiser.cc | 4 ++-- plugingui/humaniservisualiser.h | 6 +++--- plugingui/mainwindow.cc | 2 +- plugingui/mainwindow.h | 2 +- plugingui/powerwidget.cc | 30 +++++++++++++------------- plugingui/powerwidget.h | 14 ++++++------ plugingui/resamplingframecontent.h | 2 +- plugingui/statusframecontent.h | 2 +- plugingui/visualizerframecontent.h | 4 ++-- test/uitests/framewidgettest.cc | 2 +- test/uitests/powerwidgettest.cc | 2 +- test/uitests/tabwidgettest.cc | 2 +- 68 files changed, 263 insertions(+), 262 deletions(-) diff --git a/dggui/button.cc b/dggui/button.cc index 39e9eaa..c673ab1 100644 --- a/dggui/button.cc +++ b/dggui/button.cc @@ -43,7 +43,7 @@ Button::~Button() { } -void Button::repaintEvent(RepaintEvent* repaintEvent) +void Button::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); p.clear(); diff --git a/dggui/button.h b/dggui/button.h index f1b6584..56c7aaa 100644 --- a/dggui/button.h +++ b/dggui/button.h @@ -41,7 +41,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* e) override; + void repaintEvent(const RepaintEvent& event) override; private: TexturedBox box_up{getImageCache(), ":resources/pushbutton.png", diff --git a/dggui/button_base.cc b/dggui/button_base.cc index 4625b55..0cd7186 100644 --- a/dggui/button_base.cc +++ b/dggui/button_base.cc @@ -40,15 +40,15 @@ ButtonBase::~ButtonBase() { } -void ButtonBase::buttonEvent(ButtonEvent* buttonEvent) +void ButtonBase::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(!enabled || buttonEvent->button != MouseButton::left) + if(!enabled || buttonEvent.button != MouseButton::left) { return; } - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { draw_state = State::Down; button_state = State::Down; @@ -56,7 +56,7 @@ void ButtonBase::buttonEvent(ButtonEvent* buttonEvent) redraw(); } - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { draw_state = State::Up; button_state = State::Up; diff --git a/dggui/button_base.h b/dggui/button_base.h index 72f693b..08b3e32 100644 --- a/dggui/button_base.h +++ b/dggui/button_base.h @@ -57,10 +57,10 @@ protected: virtual void clicked() {} // From Widget: - virtual void repaintEvent(RepaintEvent* e) override {}; - virtual void buttonEvent(ButtonEvent* e) override; - virtual void mouseLeaveEvent() override; - virtual void mouseEnterEvent() override; + void repaintEvent(const RepaintEvent& e) override {}; + void buttonEvent(const ButtonEvent& e) override; + void mouseLeaveEvent() override; + void mouseEnterEvent() override; bool enabled{true}; bool in_button{false}; diff --git a/dggui/checkbox.cc b/dggui/checkbox.cc index 8911862..f28534b 100644 --- a/dggui/checkbox.cc +++ b/dggui/checkbox.cc @@ -39,7 +39,7 @@ CheckBox::CheckBox(Widget* parent) { } -void CheckBox::repaintEvent(RepaintEvent* repaintEvent) +void CheckBox::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); p.clear(); diff --git a/dggui/checkbox.h b/dggui/checkbox.h index 1a323b6..281280e 100644 --- a/dggui/checkbox.h +++ b/dggui/checkbox.h @@ -39,7 +39,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: Texture bg_on; diff --git a/dggui/combobox.cc b/dggui/combobox.cc index 33765e2..51e5868 100644 --- a/dggui/combobox.cc +++ b/dggui/combobox.cc @@ -40,7 +40,7 @@ void ComboBox::listboxSelectHandler() { ButtonEvent buttonEvent; buttonEvent.direction = Direction::down; - this->buttonEvent(&buttonEvent); + this->buttonEvent(buttonEvent); } ComboBox::ComboBox(Widget* parent) @@ -95,7 +95,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 ComboBox::repaintEvent(RepaintEvent* repaintEvent) +void ComboBox::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); @@ -129,7 +129,7 @@ void ComboBox::repaintEvent(RepaintEvent* repaintEvent) } } -void ComboBox::scrollEvent(ScrollEvent* scrollEvent) +void ComboBox::scrollEvent(const ScrollEvent& scrollEvent) { /* scroll_offset += e->delta; @@ -145,15 +145,15 @@ void ComboBox::scrollEvent(ScrollEvent* scrollEvent) */ } -void ComboBox::keyEvent(KeyEvent* keyEvent) +void ComboBox::keyEvent(const KeyEvent& keyEvent) { - if(keyEvent->direction != Direction::up) + if(keyEvent.direction != Direction::up) { return; } /* - switch(keyEvent->keycode) { + switch(keyEvent.keycode) { case Key::up: { selected--; @@ -205,15 +205,15 @@ void ComboBox::keyEvent(KeyEvent* keyEvent) */ } -void ComboBox::buttonEvent(ButtonEvent* buttonEvent) +void ComboBox::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if(buttonEvent->direction != Direction::down) + if(buttonEvent.direction != Direction::down) { return; } diff --git a/dggui/combobox.h b/dggui/combobox.h index a3ef8ac..5fe1909 100644 --- a/dggui/combobox.h +++ b/dggui/combobox.h @@ -54,10 +54,10 @@ public: // From Widget: bool isFocusable() override { return true; } - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void buttonEvent(ButtonEvent* buttonEvent) override; - virtual void scrollEvent(ScrollEvent* scrollEvent) override; - virtual void keyEvent(KeyEvent* keyEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; + void keyEvent(const KeyEvent& keyEvent) override; Notifier valueChangedNotifier; diff --git a/dggui/eventhandler.cc b/dggui/eventhandler.cc index b2cf616..24cc467 100644 --- a/dggui/eventhandler.cc +++ b/dggui/eventhandler.cc @@ -143,7 +143,7 @@ void EventHandler::processEvents() moveEvent->x -= widget->translateToWindowX(); moveEvent->y -= widget->translateToWindowY(); - window.buttonDownFocus()->mouseMoveEvent(moveEvent); + window.buttonDownFocus()->mouseMoveEvent(*moveEvent); break; } @@ -151,7 +151,7 @@ void EventHandler::processEvents() { moveEvent->x -= widget->translateToWindowX(); moveEvent->y -= widget->translateToWindowY(); - widget->mouseMoveEvent(moveEvent); + widget->mouseMoveEvent(*moveEvent); } } break; @@ -182,7 +182,7 @@ void EventHandler::processEvents() buttonEvent->x -= widget->translateToWindowX(); buttonEvent->y -= widget->translateToWindowY(); - widget->buttonEvent(buttonEvent); + widget->buttonEvent(*buttonEvent); window.setButtonDownFocus(nullptr); break; } @@ -193,7 +193,7 @@ void EventHandler::processEvents() buttonEvent->x -= widget->translateToWindowX(); buttonEvent->y -= widget->translateToWindowY(); - widget->buttonEvent(buttonEvent); + widget->buttonEvent(*buttonEvent); if((buttonEvent->direction == Direction::down) && widget->catchMouse()) @@ -224,7 +224,7 @@ void EventHandler::processEvents() scrollEvent->x -= widget->translateToWindowX(); scrollEvent->y -= widget->translateToWindowY(); - widget->scrollEvent(scrollEvent); + widget->scrollEvent(*scrollEvent); } } break; @@ -241,7 +241,7 @@ void EventHandler::processEvents() auto keyEvent = static_cast(event.get()); if(window.keyboardFocus()) { - window.keyboardFocus()->keyEvent(keyEvent); + window.keyboardFocus()->keyEvent(*keyEvent); } } break; diff --git a/dggui/frame.cc b/dggui/frame.cc index 3a163f1..d42a1df 100644 --- a/dggui/frame.cc +++ b/dggui/frame.cc @@ -60,7 +60,7 @@ FrameWidget::FrameWidget(Widget* parent, bool has_switch, bool has_help_text) CONNECT(this, sizeChangeNotifier, this, &FrameWidget::sizeChanged); } -void FrameWidget::repaintEvent(RepaintEvent* repaintEvent) +void FrameWidget::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/frame.h b/dggui/frame.h index dc8e17a..0e8cf5a 100644 --- a/dggui/frame.h +++ b/dggui/frame.h @@ -44,8 +44,8 @@ public: virtual ~FrameWidget() = default; // From Widget: - virtual bool isFocusable() override { return false; } - virtual bool catchMouse() override { return false; } + bool isFocusable() override { return false; } + bool catchMouse() override { return false; } bool isSwitchedOn() { return is_switched_on; } @@ -61,7 +61,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; //! Callback for Widget::sizeChangeNotifier void sizeChanged(int width, int height); diff --git a/dggui/helpbutton.cc b/dggui/helpbutton.cc index cc03112..a8c44d6 100644 --- a/dggui/helpbutton.cc +++ b/dggui/helpbutton.cc @@ -46,7 +46,7 @@ void HelpButton::setHelpText(const std::string& help_text) tip.setText(help_text); } -void HelpButton::repaintEvent(RepaintEvent* repaintEvent) +void HelpButton::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/helpbutton.h b/dggui/helpbutton.h index 639799a..b48c81b 100644 --- a/dggui/helpbutton.h +++ b/dggui/helpbutton.h @@ -44,7 +44,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: void showHelpText(); diff --git a/dggui/knob.cc b/dggui/knob.cc index 4f8ead0..148c736 100644 --- a/dggui/knob.cc +++ b/dggui/knob.cc @@ -82,40 +82,40 @@ void Knob::showValue(bool show_value) this->show_value = show_value; } -void Knob::scrollEvent(ScrollEvent* scrollEvent) +void Knob::scrollEvent(const ScrollEvent& scrollEvent) { - float value = (current_value - (scrollEvent->delta / 200.0)); + float value = (current_value - (scrollEvent.delta / 200.0)); internalSetValue(value); } -void Knob::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) +void Knob::mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) { if(state == down) { - if(mouse_offset_x == (mouseMoveEvent->x + (-1 * mouseMoveEvent->y))) + if(mouse_offset_x == (mouseMoveEvent.x + (-1 * mouseMoveEvent.y))) { return; } float dval = - mouse_offset_x - (mouseMoveEvent->x + (-1 * mouseMoveEvent->y)); + mouse_offset_x - (mouseMoveEvent.x + (-1 * mouseMoveEvent.y)); float value = current_value - (dval / 300.0); internalSetValue(value); - mouse_offset_x = mouseMoveEvent->x + (-1 * mouseMoveEvent->y); + mouse_offset_x = mouseMoveEvent.x + (-1 * mouseMoveEvent.y); } } -void Knob::keyEvent(KeyEvent* keyEvent) +void Knob::keyEvent(const KeyEvent& keyEvent) { - if(keyEvent->direction != Direction::up) + if(keyEvent.direction != Direction::up) { return; } float value = current_value; - switch(keyEvent->keycode) { + switch(keyEvent.keycode) { case Key::up: value += 0.01; break; @@ -141,15 +141,15 @@ void Knob::keyEvent(KeyEvent* keyEvent) internalSetValue(value); } -void Knob::buttonEvent(ButtonEvent* buttonEvent) +void Knob::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if(buttonEvent->doubleClick) + if(buttonEvent.doubleClick) { float value = default_value; value -= minimum; @@ -158,23 +158,23 @@ void Knob::buttonEvent(ButtonEvent* buttonEvent) return; } - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { state = down; - mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y); + mouse_offset_x = buttonEvent.x + (-1 * buttonEvent.y); return; } - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { state = up; - mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y); + mouse_offset_x = buttonEvent.x + (-1 * buttonEvent.y); clicked(); return; } } -void Knob::repaintEvent(RepaintEvent* repaintEvent) +void Knob::repaintEvent(const RepaintEvent& repaintEvent) { int diameter = (width()>height()?height():width()); int radius = diameter / 2; diff --git a/dggui/knob.h b/dggui/knob.h index 851c9c6..ed2525c 100644 --- a/dggui/knob.h +++ b/dggui/knob.h @@ -56,11 +56,11 @@ protected: virtual void clicked() {} // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void buttonEvent(ButtonEvent* buttonEvent) override; - virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override; - virtual void scrollEvent(ScrollEvent* scrollEvent) override; - virtual void keyEvent(KeyEvent* keyEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; + void keyEvent(const KeyEvent& keyEvent) override; private: //! Sets the internal value and sends out the changed notification. diff --git a/dggui/label.cc b/dggui/label.cc index fc3f60e..3ce6d89 100644 --- a/dggui/label.cc +++ b/dggui/label.cc @@ -67,7 +67,7 @@ void Label::resizeToText() resize(font.textWidth(_text) + border, font.textHeight()); } -void Label::repaintEvent(RepaintEvent* repaintEvent) +void Label::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); p.clear(); diff --git a/dggui/label.h b/dggui/label.h index 453bc4f..ec4896a 100644 --- a/dggui/label.h +++ b/dggui/label.h @@ -55,7 +55,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: std::string _text; diff --git a/dggui/layout.h b/dggui/layout.h index 860ecc2..e1b4092 100644 --- a/dggui/layout.h +++ b/dggui/layout.h @@ -91,7 +91,7 @@ public: void setSpacing(size_t spacing); // From Layout: - virtual void layout() override = 0; + void layout() override = 0; protected: bool resizeChildren{false}; @@ -114,7 +114,7 @@ public: void setHAlignment(HAlignment alignment); // From BoxLayout: - virtual void layout() override; + void layout() override; protected: HAlignment align; @@ -136,7 +136,7 @@ public: void setVAlignment(VAlignment alignment); // From BoxLayout: - virtual void layout() override; + void layout() override; protected: VAlignment align; @@ -188,8 +188,8 @@ private: }; CellSize calculateCellSize() const; - void moveAndResize( - LayoutItem& item, GridRange const& range, CellSize cell_size) const; + void moveAndResize(LayoutItem& item, GridRange const& range, + CellSize cell_size) const; }; } // dggui:: diff --git a/dggui/led.cc b/dggui/led.cc index 6e1059c..9729299 100644 --- a/dggui/led.cc +++ b/dggui/led.cc @@ -46,7 +46,7 @@ void LED::setState(state_t state) } } -void LED::repaintEvent(RepaintEvent* repaintEvent) +void LED::repaintEvent(const RepaintEvent& repaintEvent) { size_t h = height() - 1; size_t w = width() - 1; diff --git a/dggui/led.h b/dggui/led.h index 7a1f55f..8536967 100644 --- a/dggui/led.h +++ b/dggui/led.h @@ -46,7 +46,7 @@ public: protected: // From Widget: - void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: state_t state; diff --git a/dggui/lineedit.cc b/dggui/lineedit.cc index 7e8bf86..f7c4ec7 100644 --- a/dggui/lineedit.cc +++ b/dggui/lineedit.cc @@ -71,7 +71,7 @@ std::string LineEdit::getText() return _text; } -void LineEdit::buttonEvent(ButtonEvent *buttonEvent) +void LineEdit::buttonEvent(const ButtonEvent& buttonEvent) { if(readOnly()) { @@ -79,17 +79,17 @@ void LineEdit::buttonEvent(ButtonEvent *buttonEvent) } // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { for(int i = 0; i < (int)visibleText.length(); ++i) { int textWidth = font.textWidth(visibleText.substr(0, i)); - if(buttonEvent->x < (textWidth + BORDER)) + if(buttonEvent.x < (textWidth + BORDER)) { pos = i + offsetPos; break; @@ -99,7 +99,7 @@ void LineEdit::buttonEvent(ButtonEvent *buttonEvent) } } -void LineEdit::keyEvent(KeyEvent *keyEvent) +void LineEdit::keyEvent(const KeyEvent& keyEvent) { if(readOnly()) { @@ -108,9 +108,9 @@ void LineEdit::keyEvent(KeyEvent *keyEvent) bool change = false; - if(keyEvent->direction == Direction::down) + if(keyEvent.direction == Direction::down) { - switch(keyEvent->keycode) { + switch(keyEvent.keycode) { case Key::left: if(pos == 0) { @@ -176,7 +176,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent) { std::string pre = _text.substr(0, pos); std::string post = _text.substr(pos, std::string::npos); - _text = pre + keyEvent->text + post; + _text = pre + keyEvent.text + post; change = true; pos++; } @@ -199,7 +199,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent) } } -void LineEdit::repaintEvent(RepaintEvent *repaintEvent) +void LineEdit::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/lineedit.h b/dggui/lineedit.h index c702c47..c419da9 100644 --- a/dggui/lineedit.h +++ b/dggui/lineedit.h @@ -54,9 +54,9 @@ public: Notifier<> enterPressedNotifier; //protected: - virtual void keyEvent(KeyEvent *keyEvent) override; - virtual void repaintEvent(RepaintEvent *repaintEvent) override; - virtual void buttonEvent(ButtonEvent *buttonEvent) override; + void keyEvent(const KeyEvent& keyEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; protected: virtual void textChanged() {} diff --git a/dggui/listbox.cc b/dggui/listbox.cc index 4513895..3f29527 100644 --- a/dggui/listbox.cc +++ b/dggui/listbox.cc @@ -81,7 +81,7 @@ void ListBox::clearSelectedValue() basic.clearSelectedValue(); } -void ListBox::repaintEvent(RepaintEvent* repaintEvent) +void ListBox::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/listbox.h b/dggui/listbox.h index 75a4ea0..88795c7 100644 --- a/dggui/listbox.h +++ b/dggui/listbox.h @@ -54,8 +54,8 @@ public: void clearSelectedValue(); // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void resize(std::size_t width, std::size_t height) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void resize(std::size_t width, std::size_t height) override; // Forwarded notifiers from ListBoxBasic::basic Notifier<>& selectionNotifier; diff --git a/dggui/listboxbasic.cc b/dggui/listboxbasic.cc index dd58944..2dc02d0 100644 --- a/dggui/listboxbasic.cc +++ b/dggui/listboxbasic.cc @@ -140,7 +140,7 @@ void ListBoxBasic::onScrollBarValueChange(int value) redraw(); } -void ListBoxBasic::repaintEvent(RepaintEvent* repaintEvent) +void ListBoxBasic::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); @@ -190,20 +190,20 @@ void ListBoxBasic::repaintEvent(RepaintEvent* repaintEvent) scroll.setMaximum(items.size()); } -void ListBoxBasic::scrollEvent(ScrollEvent* scrollEvent) +void ListBoxBasic::scrollEvent(const ScrollEvent& scrollEvent) { // forward scroll event to scroll bar. scroll.scrollEvent(scrollEvent); } -void ListBoxBasic::keyEvent(KeyEvent* keyEvent) +void ListBoxBasic::keyEvent(const KeyEvent& keyEvent) { - if(keyEvent->direction != Direction::down) + if(keyEvent.direction != Direction::down) { return; } - switch(keyEvent->keycode) { + switch(keyEvent.keycode) { case Key::up: if(marked == 0) { @@ -259,7 +259,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent) break; case Key::character: - if(keyEvent->text == " ") + if(keyEvent.text == " ") { setSelection(marked); //selectionNotifier(); @@ -278,20 +278,20 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent) redraw(); } -void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent) +void ListBoxBasic::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if((buttonEvent->x > ((int)width() - btn_size)) && - (buttonEvent->y < ((int)width() - 1))) + if((buttonEvent.x > ((int)width() - btn_size)) && + (buttonEvent.y < ((int)width() - 1))) { - if(buttonEvent->y > 0 && buttonEvent->y < btn_size) + if(buttonEvent.y > 0 && buttonEvent.y < btn_size) { - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { return; } @@ -299,10 +299,10 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent) return; } - if(buttonEvent->y > ((int)height() - btn_size) && - buttonEvent->y < ((int)height() - 1)) + if(buttonEvent.y > ((int)height() - btn_size) && + buttonEvent.y < ((int)height() - 1)) { - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { return; } @@ -311,14 +311,14 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent) } } - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { int skip = scroll.value(); size_t yoffset = padding / 2; for(int idx = skip; idx < (int)items.size(); idx++) { yoffset += font.textHeight() + padding; - if(buttonEvent->y < (int)yoffset - (padding / 2)) + if(buttonEvent.y < (int)yoffset - (padding / 2)) { setSelection(idx); marked = selected; @@ -330,14 +330,14 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent) redraw(); } - if(buttonEvent->direction != Direction::up) + if(buttonEvent.direction != Direction::up) { int skip = scroll.value(); size_t yoffset = padding / 2; for(int idx = skip; idx < (int)items.size(); idx++) { yoffset += font.textHeight() + padding; - if(buttonEvent->y < ((int)yoffset - (padding / 2))) + if(buttonEvent.y < ((int)yoffset - (padding / 2))) { marked = idx; break; @@ -347,7 +347,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent) redraw(); } - if(buttonEvent->doubleClick) + if(buttonEvent.doubleClick) { selectionNotifier(); } diff --git a/dggui/listboxbasic.h b/dggui/listboxbasic.h index 3d6515d..93badac 100644 --- a/dggui/listboxbasic.h +++ b/dggui/listboxbasic.h @@ -67,17 +67,17 @@ public: Notifier<> valueChangedNotifier; // From Widget: - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; protected: void onScrollBarValueChange(int value); // From Widget: bool isFocusable() override { return true; } - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void buttonEvent(ButtonEvent* buttonEvent) override; - virtual void keyEvent(KeyEvent* keyEvent) override; - virtual void scrollEvent(ScrollEvent* scrollEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void keyEvent(const KeyEvent& keyEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; ScrollBar scroll; diff --git a/dggui/listboxthin.cc b/dggui/listboxthin.cc index b92def3..994d256 100644 --- a/dggui/listboxthin.cc +++ b/dggui/listboxthin.cc @@ -76,7 +76,7 @@ std::string ListBoxThin::selectedValue() return basic.selectedValue(); } -void ListBoxThin::repaintEvent(RepaintEvent* repaintEvent) +void ListBoxThin::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/listboxthin.h b/dggui/listboxthin.h index 0305a04..578e9d1 100644 --- a/dggui/listboxthin.h +++ b/dggui/listboxthin.h @@ -55,8 +55,8 @@ public: std::string selectedValue(); // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void resize(std::size_t height, std::size_t width) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void resize(std::size_t height, std::size_t width) override; // Forwarded notifier from ListBoxBasic::basic Notifier<>& selectionNotifier; diff --git a/dggui/nativewindow_cocoa.h b/dggui/nativewindow_cocoa.h index e17d4af..aa7e4b3 100644 --- a/dggui/nativewindow_cocoa.h +++ b/dggui/nativewindow_cocoa.h @@ -42,21 +42,21 @@ public: ~NativeWindowCocoa(); // From NativeWindow: - virtual void setFixedSize(std::size_t width, std::size_t height) override; - virtual void setAlwaysOnTop(bool always_on_top) override; - virtual void resize(std::size_t width, std::size_t height) override; - virtual std::pair getSize() const override; - virtual void move(int x, int y) override; - virtual std::pair getPosition() const override; - virtual void show() override; - virtual void hide() override; - virtual bool visible() const override; - virtual void setCaption(const std::string &caption) override; - virtual void redraw(const Rect& dirty_rect) override; - virtual void grabMouse(bool grab) override; - virtual EventQueue getEvents() override; - virtual void* getNativeWindowHandle() const override; - virtual Point translateToScreen(const Point& point) override; + void setFixedSize(std::size_t width, std::size_t height) override; + void setAlwaysOnTop(bool always_on_top) override; + void resize(std::size_t width, std::size_t height) override; + std::pair getSize() const override; + void move(int x, int y) override; + std::pair getPosition() const override; + void show() override; + void hide() override; + bool visible() const override; + void setCaption(const std::string &caption) override; + void redraw(const Rect& dirty_rect) override; + void grabMouse(bool grab) override; + EventQueue getEvents() override; + void* getNativeWindowHandle() const override; + Point translateToScreen(const Point& point) override; // Expose friend members of Window to ObjC++ implementation. class Window& getWindow(); diff --git a/dggui/powerbutton.cc b/dggui/powerbutton.cc index 8a204f2..7bffc43 100644 --- a/dggui/powerbutton.cc +++ b/dggui/powerbutton.cc @@ -42,7 +42,7 @@ void PowerButton::setEnabled(bool enabled) redraw(); } -void PowerButton::repaintEvent(RepaintEvent* repaintEvent) +void PowerButton::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/powerbutton.h b/dggui/powerbutton.h index a752c53..b0313f9 100644 --- a/dggui/powerbutton.h +++ b/dggui/powerbutton.h @@ -42,7 +42,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; bool enabled = true; diff --git a/dggui/progressbar.cc b/dggui/progressbar.cc index 1f833f9..c9e21e8 100644 --- a/dggui/progressbar.cc +++ b/dggui/progressbar.cc @@ -65,7 +65,7 @@ void ProgressBar::setValue(std::size_t value) } } -void ProgressBar::repaintEvent(RepaintEvent* repaintEvent) +void ProgressBar::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); diff --git a/dggui/progressbar.h b/dggui/progressbar.h index a67687b..10b073c 100644 --- a/dggui/progressbar.h +++ b/dggui/progressbar.h @@ -57,7 +57,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: ProgressBarState state{ProgressBarState::Blue}; 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:: diff --git a/dggui/scrollbar.h b/dggui/scrollbar.h index 9bc4de8..c300696 100644 --- a/dggui/scrollbar.h +++ b/dggui/scrollbar.h @@ -57,10 +57,10 @@ public: protected: // From Widget: bool catchMouse() override { return true; } - void scrollEvent(ScrollEvent* scrollEvent) override; - void repaintEvent(RepaintEvent* repaintEvent) override; - void buttonEvent(ButtonEvent* buttonEvent) override; - void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) override; private: int maxValue{100}; diff --git a/dggui/slider.cc b/dggui/slider.cc index bb42f34..1a6ffda 100644 --- a/dggui/slider.cc +++ b/dggui/slider.cc @@ -105,7 +105,7 @@ void Slider::setEnabled(bool enabled) redraw(); } -void Slider::repaintEvent(RepaintEvent* repaintEvent) +void Slider::repaintEvent(const RepaintEvent& repaintEvent) { Painter p(*this); @@ -125,28 +125,28 @@ void Slider::repaintEvent(RepaintEvent* repaintEvent) p.drawImage(button_x, button_y, button); } -void Slider::buttonEvent(ButtonEvent* buttonEvent) +void Slider::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(!enabled || buttonEvent->button != MouseButton::left) + if(!enabled || buttonEvent.button != MouseButton::left) { return; } - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { state = State::down; - recomputeCurrentValue(buttonEvent->x); + recomputeCurrentValue(buttonEvent.x); redraw(); clickNotifier(); valueChangedNotifier(current_value); } - if(buttonEvent->direction == Direction::up) + if(buttonEvent.direction == Direction::up) { state = State::up; - recomputeCurrentValue(buttonEvent->x); + recomputeCurrentValue(buttonEvent.x); redraw(); clickNotifier(); @@ -154,11 +154,11 @@ void Slider::buttonEvent(ButtonEvent* buttonEvent) } } -void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) +void Slider::mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) { if(state == State::down) { - recomputeCurrentValue(mouseMoveEvent->x); + recomputeCurrentValue(mouseMoveEvent.x); redraw(); clickNotifier(); @@ -166,11 +166,11 @@ void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) } } -void Slider::scrollEvent(ScrollEvent* scrollEvent) +void Slider::scrollEvent(const ScrollEvent& scrollEvent) { if (!enabled) { return; } - current_value -= scrollEvent->delta/(float)getControlWidth(); + current_value -= scrollEvent.delta/(float)getControlWidth(); if (current_value < 0.) { current_value = 0.; diff --git a/dggui/slider.h b/dggui/slider.h index b249c91..e93cb11 100644 --- a/dggui/slider.h +++ b/dggui/slider.h @@ -62,10 +62,11 @@ public: Notifier valueChangedNotifier; // (float value) protected: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - virtual void buttonEvent(ButtonEvent* buttonEvent) override; - virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override; - virtual void scrollEvent(ScrollEvent* scrollEvent) override; + // From Widget: + void repaintEvent(const RepaintEvent& repaintEvent) override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; bool enabled = true;; diff --git a/dggui/tabbutton.cc b/dggui/tabbutton.cc index a2b0549..c681131 100644 --- a/dggui/tabbutton.cc +++ b/dggui/tabbutton.cc @@ -90,7 +90,7 @@ TabID TabButton::getID() const return tab_id; } -void TabButton::repaintEvent(RepaintEvent* e) +void TabButton::repaintEvent(const RepaintEvent& e) { Painter p(*this); @@ -119,9 +119,9 @@ void TabButton::repaintEvent(RepaintEvent* e) p.drawText(x, y, font, text, true); } -void TabButton::scrollEvent(ScrollEvent* scroll_event) +void TabButton::scrollEvent(const ScrollEvent& scroll_event) { - scrollNotifier(scroll_event->delta); + scrollNotifier(scroll_event.delta); } void TabButton::clickHandler() diff --git a/dggui/tabbutton.h b/dggui/tabbutton.h index ac9a37c..7a51ad6 100644 --- a/dggui/tabbutton.h +++ b/dggui/tabbutton.h @@ -58,8 +58,8 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* e) override; - virtual void scrollEvent(ScrollEvent* scroll_event) override; + void repaintEvent(const RepaintEvent& e) override; + void scrollEvent(const ScrollEvent& scroll_event) override; private: TabID tab_id; diff --git a/dggui/textedit.cc b/dggui/textedit.cc index f8aeab7..52830b7 100644 --- a/dggui/textedit.cc +++ b/dggui/textedit.cc @@ -149,7 +149,7 @@ void TextEdit::preprocessText() } } -void TextEdit::repaintEvent(RepaintEvent* repaintEvent) +void TextEdit::repaintEvent(const RepaintEvent& repaintEvent) { if(needs_preprocessing) { @@ -187,9 +187,9 @@ void TextEdit::repaintEvent(RepaintEvent* repaintEvent) } } -void TextEdit::scrollEvent(ScrollEvent* scrollEvent) +void TextEdit::scrollEvent(const ScrollEvent& scrollEvent) { - scroll.setValue(scroll.value() + scrollEvent->delta); + scroll.setValue(scroll.value() + scrollEvent.delta); } void TextEdit::scrolled(int value) diff --git a/dggui/textedit.h b/dggui/textedit.h index c07774b..ffc280a 100644 --- a/dggui/textedit.h +++ b/dggui/textedit.h @@ -64,8 +64,8 @@ public: protected: // From Widget - virtual void repaintEvent(RepaintEvent* repaintEvent) override; - void scrollEvent(ScrollEvent* scrollEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; + void scrollEvent(const ScrollEvent& scrollEvent) override; private: void scrolled(int value); diff --git a/dggui/toggle.cc b/dggui/toggle.cc index e655a65..dc62784 100644 --- a/dggui/toggle.cc +++ b/dggui/toggle.cc @@ -33,15 +33,15 @@ Toggle::Toggle(Widget* parent) : Widget(parent) { } -void Toggle::buttonEvent(ButtonEvent* buttonEvent) +void Toggle::buttonEvent(const ButtonEvent& buttonEvent) { // Ignore everything except left clicks. - if(buttonEvent->button != MouseButton::left) + if(buttonEvent.button != MouseButton::left) { return; } - if((buttonEvent->direction == Direction::up) || buttonEvent->doubleClick) + if((buttonEvent.direction == Direction::up) || buttonEvent.doubleClick) { buttonDown = false; clicked = false; diff --git a/dggui/toggle.h b/dggui/toggle.h index 0fa844b..e308822 100644 --- a/dggui/toggle.h +++ b/dggui/toggle.h @@ -52,9 +52,9 @@ public: protected: // From Widget: - virtual void buttonEvent(ButtonEvent* buttonEvent) override; - virtual void mouseLeaveEvent() override; - virtual void mouseEnterEvent() override; + void buttonEvent(const ButtonEvent& buttonEvent) override; + void mouseLeaveEvent() override; + void mouseEnterEvent() override; bool state{false}; bool clicked{false}; diff --git a/dggui/tooltip.cc b/dggui/tooltip.cc index b55b45e..c143cbd 100644 --- a/dggui/tooltip.cc +++ b/dggui/tooltip.cc @@ -57,7 +57,7 @@ void Tooltip::resize(std::size_t width, std::size_t height) Widget::resize(width, height); } -void Tooltip::repaintEvent(RepaintEvent* repaintEvent) +void Tooltip::repaintEvent(const RepaintEvent& repaintEvent) { if(needs_preprocessing) { @@ -189,9 +189,9 @@ void Tooltip::show() window()->setMouseFocus(this); } -void Tooltip::buttonEvent(ButtonEvent* buttonEvent) +void Tooltip::buttonEvent(const ButtonEvent& buttonEvent) { - if(buttonEvent->direction == Direction::down) + if(buttonEvent.direction == Direction::down) { hide(); } diff --git a/dggui/tooltip.h b/dggui/tooltip.h index 1ba1cd8..63bd06c 100644 --- a/dggui/tooltip.h +++ b/dggui/tooltip.h @@ -49,11 +49,11 @@ public: void setText(const std::string& text); // From Widget: - virtual void repaintEvent(RepaintEvent* repaint_event) override; - virtual void resize(std::size_t height, std::size_t width) override; - virtual void mouseLeaveEvent() override; - virtual void show() override; - virtual void buttonEvent(ButtonEvent* buttonEvent) override; + void repaintEvent(const RepaintEvent& repaint_event) override; + void resize(std::size_t height, std::size_t width) override; + void mouseLeaveEvent() override; + void show() override; + void buttonEvent(const ButtonEvent& buttonEvent) override; private: void preprocessText(); diff --git a/dggui/verticalline.cc b/dggui/verticalline.cc index d068b82..1528ec7 100644 --- a/dggui/verticalline.cc +++ b/dggui/verticalline.cc @@ -37,7 +37,7 @@ VerticalLine::VerticalLine(Widget *parent) { } -void VerticalLine::repaintEvent(RepaintEvent* repaintEvent) +void VerticalLine::repaintEvent(const RepaintEvent& repaintEvent) { if(height() < 2) { diff --git a/dggui/verticalline.h b/dggui/verticalline.h index 2479d0d..2099913 100644 --- a/dggui/verticalline.h +++ b/dggui/verticalline.h @@ -41,7 +41,7 @@ public: protected: // From Widget: - virtual void repaintEvent(RepaintEvent* repaintEvent) override; + void repaintEvent(const RepaintEvent& repaintEvent) override; private: Image vline; diff --git a/dggui/widget.cc b/dggui/widget.cc index 077fa72..07cbd19 100644 --- a/dggui/widget.cc +++ b/dggui/widget.cc @@ -244,7 +244,7 @@ std::vector Widget::getPixelBuffers() if(dirty) { - repaintEvent(nullptr); + repaintEvent({}); pixbuf.dirty = true; dirty = false; } diff --git a/dggui/widget.h b/dggui/widget.h index bf391c5..6f19809 100644 --- a/dggui/widget.h +++ b/dggui/widget.h @@ -71,12 +71,12 @@ public: void redraw(); // From LayoutItem - virtual void resize(std::size_t width, std::size_t height) override; - virtual void move(int x, int y) override; - virtual int x() const override; - virtual int y() const override; - virtual std::size_t width() const override; - virtual std::size_t height() const override; + void resize(std::size_t width, std::size_t height) override; + void move(int x, int y) override; + int x() const override; + int y() const override; + std::size_t width() const override; + std::size_t height() const override; Point position() const; @@ -90,11 +90,11 @@ public: void removeChild(Widget* widget); void reparent(Widget* parent); - virtual void repaintEvent(RepaintEvent* repaintEvent) {} - virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) {} - virtual void buttonEvent(ButtonEvent* buttonEvent) {} - virtual void scrollEvent(ScrollEvent* scrollEvent) {} - virtual void keyEvent(KeyEvent* keyEvent) {} + virtual void repaintEvent(const RepaintEvent& repaintEvent) {} + virtual void mouseMoveEvent(const MouseMoveEvent& mouseMoveEvent) {} + virtual void buttonEvent(const ButtonEvent& buttonEvent) {} + virtual void scrollEvent(const ScrollEvent& scrollEvent) {} + virtual void keyEvent(const KeyEvent& keyEvent) {} virtual void mouseLeaveEvent() {} virtual void mouseEnterEvent() {} diff --git a/plugingui/bleedcontrolframecontent.h b/plugingui/bleedcontrolframecontent.h index fadb98e..f7b3227 100644 --- a/plugingui/bleedcontrolframecontent.h +++ b/plugingui/bleedcontrolframecontent.h @@ -44,7 +44,7 @@ public: SettingsNotifier& settings_notifier); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; void setEnabled(bool enabled); diff --git a/plugingui/diskstreamingframecontent.h b/plugingui/diskstreamingframecontent.h index 10ed90a..14ae855 100644 --- a/plugingui/diskstreamingframecontent.h +++ b/plugingui/diskstreamingframecontent.h @@ -46,7 +46,7 @@ public: SettingsNotifier& settings_notifier); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; private: void limitSettingsValueChanged(std::size_t value); diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h index 4c5cc9e..ac52a96 100644 --- a/plugingui/drumkitframecontent.h +++ b/plugingui/drumkitframecontent.h @@ -48,7 +48,7 @@ public: BrowseFile(dggui::Widget* parent); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; std::size_t getLineEditWidth(); std::size_t getButtonWidth(); @@ -77,7 +77,7 @@ public: Config& config); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; void kitBrowseClick(); void midimapBrowseClick(); diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc index 6323e94..1245bba 100644 --- a/plugingui/drumkittab.cc +++ b/plugingui/drumkittab.cc @@ -82,13 +82,13 @@ void DrumkitTab::resize(std::size_t width, std::size_t height) height-instrument_name_label.height()-5); } -void DrumkitTab::buttonEvent(dggui::ButtonEvent* buttonEvent) +void DrumkitTab::buttonEvent(const dggui::ButtonEvent& buttonEvent) { if(map_image) { - if(buttonEvent->button == dggui::MouseButton::right) + if(buttonEvent.button == dggui::MouseButton::right) { - if(buttonEvent->direction == dggui::Direction::down) + if(buttonEvent.direction == dggui::Direction::down) { dggui::Painter painter(*this); painter.drawImage(drumkit_image_x, drumkit_image_y, *map_image); @@ -97,7 +97,7 @@ void DrumkitTab::buttonEvent(dggui::ButtonEvent* buttonEvent) return; } - if(buttonEvent->direction == dggui::Direction::up) + if(buttonEvent.direction == dggui::Direction::up) { dggui::Painter painter(*this); painter.clear(); @@ -112,16 +112,16 @@ void DrumkitTab::buttonEvent(dggui::ButtonEvent* buttonEvent) } } - if(buttonEvent->button == dggui::MouseButton::left) + if(buttonEvent.button == dggui::MouseButton::left) { - if(buttonEvent->direction == dggui::Direction::down) + if(buttonEvent.direction == dggui::Direction::down) { - triggerAudition(buttonEvent->x, buttonEvent->y); + triggerAudition(buttonEvent.x, buttonEvent.y); highlightInstrument(current_index); redraw(); } - if(buttonEvent->direction == dggui::Direction::up) + if(buttonEvent.direction == dggui::Direction::up) { if(shows_instrument_overlay) { @@ -140,21 +140,21 @@ void DrumkitTab::buttonEvent(dggui::ButtonEvent* buttonEvent) } } -void DrumkitTab::scrollEvent(dggui::ScrollEvent* scrollEvent) +void DrumkitTab::scrollEvent(const dggui::ScrollEvent& scrollEvent) { - current_velocity -= 0.01 * scrollEvent->delta; + current_velocity -= 0.01 * scrollEvent.delta; current_velocity = std::max(std::min(current_velocity, 1.0f), 0.0f); updateVelocityLabel(); velocity_label.resizeToText(); - triggerAudition(scrollEvent->x, scrollEvent->y); + triggerAudition(scrollEvent.x, scrollEvent.y); } -void DrumkitTab::mouseMoveEvent(dggui::MouseMoveEvent* mouseMoveEvent) +void DrumkitTab::mouseMoveEvent(const dggui::MouseMoveEvent& mouseMoveEvent) { // change to image coordinates - const auto x = mouseMoveEvent->x - drumkit_image_x; - const auto y = mouseMoveEvent->y - drumkit_image_y; + const auto x = mouseMoveEvent.x - drumkit_image_x; + const auto y = mouseMoveEvent.y - drumkit_image_y; auto index = pos_to_colour_index(x, y); diff --git a/plugingui/drumkittab.h b/plugingui/drumkittab.h index ad89fb1..f513276 100644 --- a/plugingui/drumkittab.h +++ b/plugingui/drumkittab.h @@ -54,9 +54,9 @@ public: // From dggui::Widget: void resize(std::size_t width, std::size_t height) override; - void buttonEvent(dggui::ButtonEvent* buttonEvent) override; - void scrollEvent(dggui::ScrollEvent* scrollEvent) override; - void mouseMoveEvent(dggui::MouseMoveEvent* mouseMoveEvent) override; + void buttonEvent(const dggui::ButtonEvent& buttonEvent) override; + void scrollEvent(const dggui::ScrollEvent& scrollEvent) override; + void mouseMoveEvent(const dggui::MouseMoveEvent& mouseMoveEvent) override; void mouseLeaveEvent() override; void init(const std::string& image_file, const std::string& map_file); diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc index d4fc009..433ece2 100644 --- a/plugingui/filebrowser.cc +++ b/plugingui/filebrowser.cc @@ -139,7 +139,7 @@ void FileBrowser::resize(std::size_t width, std::size_t height) btn_sel.resize(btn_w, btn_h); } -void FileBrowser::repaintEvent(dggui::RepaintEvent* repaintEvent) +void FileBrowser::repaintEvent(const dggui::RepaintEvent& repaintEvent) { dggui::Painter p(*this); p.drawImageStretched(0,0, back, width(), height()); diff --git a/plugingui/filebrowser.h b/plugingui/filebrowser.h index 0620ef3..eef3c33 100644 --- a/plugingui/filebrowser.h +++ b/plugingui/filebrowser.h @@ -54,8 +54,8 @@ public: // From Widget: bool isFocusable() override { return true; } - virtual void repaintEvent(dggui::RepaintEvent* repaintEvent) override; - virtual void resize(std::size_t width, std::size_t height) override; + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override; + void resize(std::size_t width, std::size_t height) override; //! Return the filename selected in the browser. std::string getFilename() const; diff --git a/plugingui/humaniservisualiser.cc b/plugingui/humaniservisualiser.cc index 1045e31..426ec52 100644 --- a/plugingui/humaniservisualiser.cc +++ b/plugingui/humaniservisualiser.cc @@ -45,7 +45,7 @@ HumaniserVisualiser::HumaniserVisualiser(dggui::Widget* parent, canvas.move(7, 7); } -void HumaniserVisualiser::repaintEvent(dggui::RepaintEvent *repaintEvent) +void HumaniserVisualiser::repaintEvent(const dggui::RepaintEvent& repaintEvent) { dggui::Painter p(*this); @@ -90,7 +90,7 @@ HumaniserVisualiser::Canvas::Canvas(dggui::Widget* parent, this, &HumaniserVisualiser::Canvas::velocityStddevChanged); } -void HumaniserVisualiser::Canvas::repaintEvent(dggui::RepaintEvent *repaintEvent) +void HumaniserVisualiser::Canvas::repaintEvent(const dggui::RepaintEvent& repaintEvent) { if(width() < 1 || height() < 1) { diff --git a/plugingui/humaniservisualiser.h b/plugingui/humaniservisualiser.h index 028f10d..75aabd7 100644 --- a/plugingui/humaniservisualiser.h +++ b/plugingui/humaniservisualiser.h @@ -45,8 +45,8 @@ public: SettingsNotifier& settings_notifier); // From Widget: - virtual void repaintEvent(dggui::RepaintEvent *repaintEvent) override; - virtual void resize(std::size_t width, std::size_t height) override; + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override; + void resize(std::size_t width, std::size_t height) override; private: dggui::TexturedBox box{getImageCache(), ":resources/widget.png", @@ -62,7 +62,7 @@ private: SettingsNotifier& settings_notifier); // From Widget: - virtual void repaintEvent(dggui::RepaintEvent *repaintEvent) override; + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override; void latencyEnabledChanged(bool enabled); void velocityEnabledChanged(bool enabled); diff --git a/plugingui/mainwindow.cc b/plugingui/mainwindow.cc index a4ad7b5..357ae5d 100644 --- a/plugingui/mainwindow.cc +++ b/plugingui/mainwindow.cc @@ -81,7 +81,7 @@ bool MainWindow::processEvents() return true; } -void MainWindow::repaintEvent(dggui::RepaintEvent* repaintEvent) +void MainWindow::repaintEvent(const dggui::RepaintEvent& repaintEvent) { if(!visible()) { diff --git a/plugingui/mainwindow.h b/plugingui/mainwindow.h index ae0da8b..253800d 100644 --- a/plugingui/mainwindow.h +++ b/plugingui/mainwindow.h @@ -65,7 +65,7 @@ private: void changeDrumkitTabVisibility(bool visible); // From Widget - void repaintEvent(dggui::RepaintEvent* repaintEvent) override final; + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override final; Config config; SettingsNotifier settings_notifier; diff --git a/plugingui/powerwidget.cc b/plugingui/powerwidget.cc index 9be0c48..b61fd82 100644 --- a/plugingui/powerwidget.cc +++ b/plugingui/powerwidget.cc @@ -66,7 +66,7 @@ void PowerWidget::chk_shelf(bool v) settings.powermap_shelf.store(v); } -void PowerWidget::repaintEvent(dggui::RepaintEvent *repaintEvent) +void PowerWidget::repaintEvent(const dggui::RepaintEvent& repaintEvent) { dggui::Painter p(*this); box.setSize(width() - 59 - 64, height()); @@ -118,7 +118,7 @@ PowerWidget::Canvas::Canvas(dggui::Widget* parent, parameterChangedFloat(0); } -void PowerWidget::Canvas::repaintEvent(dggui::RepaintEvent *repaintEvent) +void PowerWidget::Canvas::repaintEvent(const dggui::RepaintEvent& repaintEvent) { if(width() < 1 || height() < 1) { @@ -214,20 +214,20 @@ void PowerWidget::Canvas::repaintEvent(dggui::RepaintEvent *repaintEvent) p.drawText(8, height() / 2 - (font.textWidth(_("out")) / 2), font, _("out"), false, true); } -void PowerWidget::Canvas::buttonEvent(dggui::ButtonEvent* buttonEvent) +void PowerWidget::Canvas::buttonEvent(const dggui::ButtonEvent& buttonEvent) { const float x0 = brd; const float y0 = brd; const float width0 = (int)width() - 2 * brd; const float height0 = (int)height() - 2 * brd; - float mx0 = (float)(buttonEvent->x - x0) / width0; - float my0 = (float)(((int)height() - buttonEvent->y) - y0) / height0; + float mx0 = (float)(buttonEvent.x - x0) / width0; + float my0 = (float)(((int)height() - buttonEvent.y) - y0) / height0; float radius_x = radius * 2; float radius_y = radius * width0 / height0 * 2; - switch(buttonEvent->direction) + switch(buttonEvent.direction) { case dggui::Direction::up: in_point = -1; @@ -262,15 +262,15 @@ float clamp(float val, float min, float max) } } -void PowerWidget::Canvas::mouseMoveEvent(dggui::MouseMoveEvent* mouseMoveEvent) +void PowerWidget::Canvas::mouseMoveEvent(const dggui::MouseMoveEvent& mouseMoveEvent) { const float x0 = brd; const float y0 = brd; const float width0 = (int)width() - 2 * brd; const float height0 = (int)height() - 2 * brd; - float mx0 = (float)(mouseMoveEvent->x - x0) / width0; - float my0 = (float)(((int)height() - mouseMoveEvent->y) - y0) / height0; + float mx0 = (float)(mouseMoveEvent.x - x0) / width0; + float my0 = (float)(((int)height() - mouseMoveEvent.y) - y0) / height0; switch(in_point) { @@ -296,18 +296,18 @@ void PowerWidget::Canvas::mouseMoveEvent(dggui::MouseMoveEvent* mouseMoveEvent) switch(in_point) { case 0: - settings.fixed0_x.store(clamp((float)mouseMoveEvent->x / width())); - settings.fixed0_y.store(1.0f - clamp((float)mouseMoveEvent->y / height())); + settings.fixed0_x.store(clamp((float)mouseMoveEvent.x / width())); + settings.fixed0_y.store(1.0f - clamp((float)mouseMoveEvent.y / height())); redraw(); break; case 1: - settings.fixed1_x.store(clamp((float)mouseMoveEvent->x / width())); - settings.fixed1_y.store(1.0f - clamp((float)mouseMoveEvent->y / height())); + settings.fixed1_x.store(clamp((float)mouseMoveEvent.x / width())); + settings.fixed1_y.store(1.0f - clamp((float)mouseMoveEvent.y / height())); redraw(); break; case 2: - settings.fixed2_x.store(clamp((float)mouseMoveEvent->x / width())); - settings.fixed2_y.store(1.0f - clamp((float)mouseMoveEvent->y / height())); + settings.fixed2_x.store(clamp((float)mouseMoveEvent.x / width())); + settings.fixed2_y.store(1.0f - clamp((float)mouseMoveEvent.y / height())); redraw(); break; default: diff --git a/plugingui/powerwidget.h b/plugingui/powerwidget.h index 3a7bb8e..6080b37 100644 --- a/plugingui/powerwidget.h +++ b/plugingui/powerwidget.h @@ -51,8 +51,8 @@ public: SettingsNotifier& settings_notifier); // From Widget: - virtual void repaintEvent(dggui::RepaintEvent *repaintEvent) override; - virtual void resize(std::size_t width, std::size_t height) override; + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override; + void resize(std::size_t width, std::size_t height) override; private: dggui::TexturedBox box{getImageCache(), ":resources/widget.png", @@ -68,11 +68,11 @@ private: SettingsNotifier& settings_notifier); // From Widget: - virtual bool catchMouse() override { return true; } - virtual void repaintEvent(dggui::RepaintEvent *repaintEvent) override; - virtual void buttonEvent(dggui::ButtonEvent* buttonEvent) override; - virtual void mouseMoveEvent(dggui::MouseMoveEvent* mouseMoveEvent) override; - virtual void mouseLeaveEvent() override; + bool catchMouse() override { return true; } + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override; + void buttonEvent(const dggui::ButtonEvent& buttonEvent) override; + void mouseMoveEvent(const dggui::MouseMoveEvent& mouseMoveEvent) override; + void mouseLeaveEvent() override; private: Powermap power_map; diff --git a/plugingui/resamplingframecontent.h b/plugingui/resamplingframecontent.h index 3bdddc6..758fb63 100644 --- a/plugingui/resamplingframecontent.h +++ b/plugingui/resamplingframecontent.h @@ -46,7 +46,7 @@ public: SettingsNotifier& settings_notifier); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; private: void updateContent(); diff --git a/plugingui/statusframecontent.h b/plugingui/statusframecontent.h index 55f7a16..123df89 100644 --- a/plugingui/statusframecontent.h +++ b/plugingui/statusframecontent.h @@ -44,7 +44,7 @@ public: SettingsNotifier& settings_notifier); // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + void resize(std::size_t width, std::size_t height) override; void updateContent(); diff --git a/plugingui/visualizerframecontent.h b/plugingui/visualizerframecontent.h index abf54c4..3579f9f 100644 --- a/plugingui/visualizerframecontent.h +++ b/plugingui/visualizerframecontent.h @@ -48,8 +48,8 @@ public: VisualizerframeContent(dggui::Widget* parent, Settings& settings, SettingsNotifier& settings_notifier); - // From Widget - virtual void resize(std::size_t width, std::size_t height) override; + // From Widget + void resize(std::size_t width, std::size_t height) override; private: HumaniserVisualiser visualizer; diff --git a/test/uitests/framewidgettest.cc b/test/uitests/framewidgettest.cc index 97f9ed0..9660074 100644 --- a/test/uitests/framewidgettest.cc +++ b/test/uitests/framewidgettest.cc @@ -141,7 +141,7 @@ public: return !closing; } - void repaintEvent(dggui::RepaintEvent* repaintEvent) override + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override { dggui::Painter painter(*this); painter.setColour(dggui::Colour(0.85)); diff --git a/test/uitests/powerwidgettest.cc b/test/uitests/powerwidgettest.cc index 4d01168..fd1346d 100644 --- a/test/uitests/powerwidgettest.cc +++ b/test/uitests/powerwidgettest.cc @@ -96,7 +96,7 @@ public: return !closing; } - void repaintEvent(dggui::RepaintEvent* repaintEvent) override + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override { dggui::Painter painter(*this); painter.setColour(dggui::Colour(0.85)); diff --git a/test/uitests/tabwidgettest.cc b/test/uitests/tabwidgettest.cc index 804e979..ac023fd 100644 --- a/test/uitests/tabwidgettest.cc +++ b/test/uitests/tabwidgettest.cc @@ -126,7 +126,7 @@ public: return !closing; } - void repaintEvent(dggui::RepaintEvent* repaintEvent) override + void repaintEvent(const dggui::RepaintEvent& repaintEvent) override { dggui::Painter painter(*this); painter.setColour(dggui::Colour(0.85)); -- cgit v1.2.3