summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/button.cc8
-rw-r--r--plugingui/checkbox.cc14
-rw-r--r--plugingui/checkbox.h6
-rw-r--r--plugingui/combobox.cc30
-rw-r--r--plugingui/combobox.h10
-rw-r--r--plugingui/eventhandler.cc20
-rw-r--r--plugingui/filebrowser.cc2
-rw-r--r--plugingui/filebrowser.h2
-rw-r--r--plugingui/guievent.h100
-rw-r--r--plugingui/knob.cc43
-rw-r--r--plugingui/knob.h10
-rw-r--r--plugingui/label.cc2
-rw-r--r--plugingui/label.h4
-rw-r--r--plugingui/led.cc2
-rw-r--r--plugingui/led.h2
-rw-r--r--plugingui/lineedit.cc20
-rw-r--r--plugingui/lineedit.h6
-rw-r--r--plugingui/listbox.cc2
-rw-r--r--plugingui/listbox.h2
-rw-r--r--plugingui/listboxbasic.cc24
-rw-r--r--plugingui/listboxbasic.h8
-rw-r--r--plugingui/listboxthin.cc2
-rw-r--r--plugingui/listboxthin.h2
-rw-r--r--plugingui/nativewindow_pugl.cc20
-rw-r--r--plugingui/nativewindow_win32.cc42
-rw-r--r--plugingui/nativewindow_x11.cc43
-rw-r--r--plugingui/progressbar.cc2
-rw-r--r--plugingui/progressbar.h2
-rw-r--r--plugingui/scrollbar.cc8
-rw-r--r--plugingui/slider.cc216
-rw-r--r--plugingui/slider.h47
-rw-r--r--plugingui/verticalline.cc16
-rw-r--r--plugingui/verticalline.h16
-rw-r--r--plugingui/widget.cc6
-rw-r--r--plugingui/widget.h31
-rw-r--r--plugingui/window.cc2
-rw-r--r--plugingui/window.h2
37 files changed, 388 insertions, 386 deletions
diff --git a/plugingui/button.cc b/plugingui/button.cc
index 5ff97a7..baa3067 100644
--- a/plugingui/button.cc
+++ b/plugingui/button.cc
@@ -81,9 +81,9 @@ Button::~Button()
delete(box_down.center);
}
-void Button::buttonEvent(ButtonEvent *e)
+void Button::buttonEvent(ButtonEvent* buttonEvent)
{
- if(e->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
draw_state = down;
button_state = down;
@@ -91,7 +91,7 @@ void Button::buttonEvent(ButtonEvent *e)
repaintEvent(nullptr);
}
- if(e->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
draw_state = up;
button_state = up;
@@ -104,7 +104,7 @@ void Button::buttonEvent(ButtonEvent *e)
}
}
-void Button::repaintEvent(RepaintEvent *e)
+void Button::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index b9468d3..0d37127 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -32,7 +32,7 @@
namespace GUI {
-CheckBox::CheckBox(Widget *parent)
+CheckBox::CheckBox(Widget* parent)
: Widget(parent)
, bg_on(":switch_back_on.png")
, bg_off(":switch_back_off.png")
@@ -42,9 +42,9 @@ CheckBox::CheckBox(Widget *parent)
{
}
-void CheckBox::buttonEvent(ButtonEvent *e)
+void CheckBox::buttonEvent(ButtonEvent* buttonEvent)
{
- if(e->direction == ButtonEvent::Up || e->doubleclick)
+ if((buttonEvent->direction == Direction::up) || buttonEvent->doubleClick)
{
middle = false;
internalSetChecked(!state);
@@ -63,11 +63,11 @@ void CheckBox::setText(std::string text)
repaintEvent(nullptr);
}
-void CheckBox::keyEvent(KeyEvent *e)
+void CheckBox::keyEvent(KeyEvent* keyEvent)
{
- if(e->keycode == KeyEvent::KeyCharacter && e->text == " ")
+ if(keyEvent->keycode == Key::character && keyEvent->text == " ")
{
- if(e->direction == KeyEvent::Up)
+ if(keyEvent->direction == Direction::up)
{
middle = false;
internalSetChecked(!state);
@@ -81,7 +81,7 @@ void CheckBox::keyEvent(KeyEvent *e)
}
}
-void CheckBox::repaintEvent(RepaintEvent *e)
+void CheckBox::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/checkbox.h b/plugingui/checkbox.h
index ce2ca45..093c5c3 100644
--- a/plugingui/checkbox.h
+++ b/plugingui/checkbox.h
@@ -50,9 +50,9 @@ protected:
virtual void clicked() {}
// From Widget:
- virtual void repaintEvent(RepaintEvent *e) override;
- virtual void buttonEvent(ButtonEvent *e) override;
- virtual void keyEvent(KeyEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
+ virtual void buttonEvent(ButtonEvent* buttonEvent) override;
+ virtual void keyEvent(KeyEvent* keyEvent) override;
private:
void internalSetChecked(bool checked);
diff --git a/plugingui/combobox.cc b/plugingui/combobox.cc
index 6e6a9c8..1323dab 100644
--- a/plugingui/combobox.cc
+++ b/plugingui/combobox.cc
@@ -37,12 +37,12 @@ namespace GUI {
void ComboBox::listboxSelectHandler()
{
- ButtonEvent e;
- e.direction = ButtonEvent::Down;
- buttonEvent(&e);
+ ButtonEvent buttonEvent;
+ buttonEvent.direction = Direction::down;
+ this->buttonEvent(&buttonEvent);
}
-ComboBox::ComboBox(Widget *parent)
+ComboBox::ComboBox(Widget* parent)
: Widget(parent)
, listbox(parent)
{
@@ -113,7 +113,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 *e)
+void ComboBox::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
@@ -148,7 +148,7 @@ void ComboBox::repaintEvent(RepaintEvent *e)
}
}
-void ComboBox::scrollEvent(ScrollEvent *e)
+void ComboBox::scrollEvent(ScrollEvent* scrollEvent)
{
/*
scroll_offset += e->delta;
@@ -164,16 +164,16 @@ void ComboBox::scrollEvent(ScrollEvent *e)
*/
}
-void ComboBox::keyEvent(KeyEvent *e)
+void ComboBox::keyEvent(KeyEvent* keyEvent)
{
- if(e->direction != KeyEvent::Up)
+ if(keyEvent->direction != Direction::up)
{
return;
}
/*
- switch(e->keycode) {
- case KeyEvent::KeyUp:
+ switch(keyEvent->keycode) {
+ case Key::up:
{
selected--;
if(selected < 0)
@@ -190,7 +190,7 @@ void ComboBox::keyEvent(KeyEvent *e)
}
}
break;
- case KeyEvent::KeyDown:
+ case Key::down:
{
// Number of items that can be displayed at a time.
int numitems = height() / (font.textHeight() + padding);
@@ -210,10 +210,10 @@ void ComboBox::keyEvent(KeyEvent *e)
}
}
break;
- case KeyEvent::KeyHome:
+ case Key::home:
selected = 0;
break;
- case KeyEvent::KeyEnd:
+ case Key::end:
selected = items.size() - 1;
break;
default:
@@ -224,9 +224,9 @@ void ComboBox::keyEvent(KeyEvent *e)
*/
}
-void ComboBox::buttonEvent(ButtonEvent *e)
+void ComboBox::buttonEvent(ButtonEvent* buttonEvent)
{
- if(e->direction != ButtonEvent::Down)
+ if(buttonEvent->direction != Direction::down)
{
return;
}
diff --git a/plugingui/combobox.h b/plugingui/combobox.h
index da157ef..1e4fb8d 100644
--- a/plugingui/combobox.h
+++ b/plugingui/combobox.h
@@ -38,7 +38,7 @@ namespace GUI {
class ComboBox : public Widget {
public:
- ComboBox(Widget *parent);
+ ComboBox(Widget* parent);
~ComboBox();
void addItem(std::string name, std::string value);
@@ -50,10 +50,10 @@ public:
// From Widget:
bool isFocusable() override { return true; }
- virtual void repaintEvent(RepaintEvent *e) override;
- virtual void buttonEvent(ButtonEvent *e) override;
- virtual void scrollEvent(ScrollEvent *e) override;
- virtual void keyEvent(KeyEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
+ virtual void buttonEvent(ButtonEvent* buttonEvent) override;
+ virtual void scrollEvent(ScrollEvent* scrollEvent) override;
+ virtual void keyEvent(KeyEvent* keyEvent) override;
Notifier<std::string, std::string> valueChangedNotifier;
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index 4b55ce5..ff8fded 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -62,11 +62,11 @@ void EventHandler::processEvents()
}
switch(event->type()) {
- case Event::Repaint:
+ case EventType::repaint:
window.redraw();
break;
- case Event::Resize:
+ case EventType::resize:
{
auto resizeEvent = static_cast<ResizeEvent*>(event);
if((resizeEvent->width != window.width()) ||
@@ -77,7 +77,7 @@ void EventHandler::processEvents()
}
break;
- case Event::MouseMove:
+ case EventType::mouseMove:
{
auto moveEvent = static_cast<MouseMoveEvent*>(event);
@@ -119,7 +119,7 @@ void EventHandler::processEvents()
}
break;
- case Event::Button:
+ case EventType::button:
{
if(lastWasDoubleClick)
{
@@ -129,13 +129,13 @@ void EventHandler::processEvents()
auto buttonEvent = static_cast<ButtonEvent*>(event);
- lastWasDoubleClick = buttonEvent->doubleclick;
+ lastWasDoubleClick = buttonEvent->doubleClick;
auto widget = window.find(buttonEvent->x, buttonEvent->y);
if(window.buttonDownFocus())
{
- if(buttonEvent->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
auto widget = window.buttonDownFocus();
buttonEvent->x -= widget->windowX();
@@ -157,7 +157,7 @@ void EventHandler::processEvents()
widget->buttonEvent(buttonEvent);
- if((buttonEvent->direction == ButtonEvent::Down) &&
+ if((buttonEvent->direction == Direction::down) &&
widget->catchMouse())
{
window.setButtonDownFocus(widget);
@@ -171,7 +171,7 @@ void EventHandler::processEvents()
}
break;
- case Event::Scroll:
+ case EventType::scroll:
{
auto scrollEvent = static_cast<ScrollEvent*>(event);
@@ -186,7 +186,7 @@ void EventHandler::processEvents()
}
break;
- case Event::Key:
+ case EventType::key:
{
auto keyEvent = static_cast<KeyEvent*>(event);
if(window.keyboardFocus())
@@ -196,7 +196,7 @@ void EventHandler::processEvents()
}
break;
- case Event::Close:
+ case EventType::close:
closeNotifier();
break;
}
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 6872a4e..6313415 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -129,7 +129,7 @@ void FileBrowser::resize(int w, int h)
btn_sel.resize((w - 1 - 2*brd) / 2, btn_h);
}
-void FileBrowser::repaintEvent(RepaintEvent *e)
+void FileBrowser::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
p.drawImageStretched(0,0, back, width(), height());
diff --git a/plugingui/filebrowser.h b/plugingui/filebrowser.h
index bd8b698..bd9dd8e 100644
--- a/plugingui/filebrowser.h
+++ b/plugingui/filebrowser.h
@@ -49,7 +49,7 @@ public:
// From Widget:
bool isFocusable() override { return true; }
- virtual void repaintEvent(RepaintEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
virtual void resize(int w, int h) override;
private:
diff --git a/plugingui/guievent.h b/plugingui/guievent.h
index e92f2e2..6e2ded9 100644
--- a/plugingui/guievent.h
+++ b/plugingui/guievent.h
@@ -37,20 +37,21 @@
namespace GUI {
+enum class EventType {
+ mouseMove,
+ repaint,
+ button,
+ scroll,
+ key,
+ close,
+ resize
+};
+
class Event {
public:
- typedef enum {
- MouseMove,
- Repaint,
- Button,
- Scroll,
- Key,
- Close,
- Resize
- } Type;
virtual ~Event() {}
- virtual Type type() = 0;
+ virtual EventType type() = 0;
#ifdef X11
::Window window_id;
@@ -59,36 +60,40 @@ public:
class MouseMoveEvent : public Event {
public:
- Type type() { return MouseMove; }
+ EventType type() { return EventType::mouseMove; }
int x;
int y;
};
+
+enum class Direction {
+ up,
+ down,
+};
+
+enum class MouseButton {
+ right,
+ middle,
+ left,
+};
+
class ButtonEvent : public Event {
public:
- Type type() { return Button; }
+ EventType type() { return EventType::button; }
int x;
int y;
- enum {
- Up,
- Down,
- } direction;
-
- enum {
- Right,
- Middle,
- Left,
- } button;
+ Direction direction;
+ MouseButton button;
- bool doubleclick;
+ bool doubleClick;
};
class ScrollEvent : public Event {
public:
- Type type() { return Scroll; }
+ EventType type() { return EventType::scroll; }
int x;
int y;
@@ -98,7 +103,7 @@ public:
class RepaintEvent : public Event {
public:
- Type type() { return Repaint; }
+ EventType type() { return EventType::repaint; }
int x;
int y;
@@ -106,43 +111,40 @@ public:
size_t height;
};
+enum class Key {
+ unknown,
+ left,
+ right,
+ up,
+ down,
+ deleteKey,
+ backspace,
+ home,
+ end,
+ pageDown,
+ pageUp,
+ enter,
+ character, //!< The actual character is stored in KeyEvent::text
+};
+
class KeyEvent : public Event {
public:
- Type type() { return Key; }
+ EventType type() { return EventType::key; }
- enum {
- Up,
- Down,
- } direction;
+ Direction direction;
- int keycode;
+ Key keycode;
std::string text;
-
- enum {
- KeyUnknown = -1,
- KeyLeft = 1,
- KeyRight = 2,
- KeyUp = 3,
- KeyDown = 4,
- KeyDelete = 5,
- KeyBackspace = 6,
- KeyHome = 7,
- KeyEnd = 8,
- KeyPageDown = 9,
- KeyPageUp = 10,
- KeyEnter = 11,
- KeyCharacter = 0xffff // character data is stored in 'text'
- };
};
class CloseEvent : public Event {
public:
- Type type() { return Close; }
+ EventType type() { return EventType::close; }
};
class ResizeEvent : public Event {
public:
- Type type() { return Resize; }
+ EventType type() { return EventType::resize; }
size_t width;
size_t height;
diff --git a/plugingui/knob.cc b/plugingui/knob.cc
index 535448b..7b784ab 100644
--- a/plugingui/knob.cc
+++ b/plugingui/knob.cc
@@ -63,55 +63,56 @@ float Knob::value()
return currentValue;
}
-void Knob::scrollEvent(ScrollEvent *e)
+void Knob::scrollEvent(ScrollEvent* scrollEvent)
{
- float value = currentValue - (e->delta / 200.0);
+ float value = currentValue - (scrollEvent->delta / 200.0);
internalSetValue(value);
}
-void Knob::mouseMoveEvent(MouseMoveEvent *e)
+void Knob::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
{
if(state == down)
{
- if(mouse_offset_x == (e->x + -1 * e->y))
+ if(mouse_offset_x == (mouseMoveEvent->x + (-1 * mouseMoveEvent->y)))
{
return;
}
- float dval = mouse_offset_x - (e->x + -1 * e->y);
+ float dval =
+ mouse_offset_x - (mouseMoveEvent->x + (-1 * mouseMoveEvent->y));
float value = currentValue - (dval / 300.0);
internalSetValue(value);
- mouse_offset_x = e->x + -1 * e->y;
+ mouse_offset_x = mouseMoveEvent->x + (-1 * mouseMoveEvent->y);
}
}
-void Knob::keyEvent(KeyEvent *e)
+void Knob::keyEvent(KeyEvent* keyEvent)
{
- if(e->direction != KeyEvent::Up)
+ if(keyEvent->direction != Direction::up)
{
return;
}
float value = currentValue;
- switch(e->keycode) {
- case KeyEvent::KeyUp:
+ switch(keyEvent->keycode) {
+ case Key::up:
value += 0.01;
break;
- case KeyEvent::KeyDown:
+ case Key::down:
value -= 0.01;
break;
- case KeyEvent::KeyRight:
+ case Key::right:
value += 0.01;
break;
- case KeyEvent::KeyLeft:
+ case Key::left:
value -= 0.01;
break;
- case KeyEvent::KeyHome:
+ case Key::home:
value = 0;
break;
- case KeyEvent::KeyEnd:
+ case Key::end:
value = 1;
break;
default:
@@ -121,23 +122,23 @@ void Knob::keyEvent(KeyEvent *e)
internalSetValue(value);
}
-void Knob::buttonEvent(ButtonEvent *e)
+void Knob::buttonEvent(ButtonEvent* buttonEvent)
{
- if(e->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
state = down;
- mouse_offset_x = e->x + -1*e->y;
+ mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y);
}
- if(e->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
state = up;
- mouse_offset_x = e->x + -1*e->y;
+ mouse_offset_x = buttonEvent->x + (-1 * buttonEvent->y);
clicked();
}
}
-void Knob::repaintEvent(RepaintEvent *e)
+void Knob::repaintEvent(RepaintEvent* repaintEvent)
{
int diameter = (width()>height()?height():width());
int radius = diameter / 2;
diff --git a/plugingui/knob.h b/plugingui/knob.h
index 469f238..3ad8887 100644
--- a/plugingui/knob.h
+++ b/plugingui/knob.h
@@ -51,11 +51,11 @@ protected:
virtual void clicked() {}
// From Widget:
- virtual void repaintEvent(RepaintEvent *e) override;
- virtual void buttonEvent(ButtonEvent *e) override;
- virtual void mouseMoveEvent(MouseMoveEvent *e) override;
- virtual void scrollEvent(ScrollEvent *e) override;
- virtual void keyEvent(KeyEvent *e) override;
+ 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;
private:
//! Sets the internal value and sends out the changed notification.
diff --git a/plugingui/label.cc b/plugingui/label.cc
index 7d82f1b..1de715b 100644
--- a/plugingui/label.cc
+++ b/plugingui/label.cc
@@ -42,7 +42,7 @@ void Label::setText(std::string text)
repaintEvent(nullptr);
}
-void Label::repaintEvent(GUI::RepaintEvent *e)
+void Label::repaintEvent(GUI::RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/label.h b/plugingui/label.h
index 644d4b7..0ba67c5 100644
--- a/plugingui/label.h
+++ b/plugingui/label.h
@@ -32,8 +32,6 @@
namespace GUI {
-class RepaintEvent;
-
class Label : public Widget {
public:
Label(Widget *parent);
@@ -42,7 +40,7 @@ public:
protected:
// From Widget:
- virtual void repaintEvent(RepaintEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
private:
std::string _text;
diff --git a/plugingui/led.cc b/plugingui/led.cc
index 1d844c3..6950140 100644
--- a/plugingui/led.cc
+++ b/plugingui/led.cc
@@ -45,7 +45,7 @@ void LED::setState(state_t state)
}
}
-void LED::repaintEvent(RepaintEvent *e)
+void LED::repaintEvent(RepaintEvent* repaintEvent)
{
size_t h = height() - 1;
size_t w = width() - 1;
diff --git a/plugingui/led.h b/plugingui/led.h
index 977dbb3..6b1b730 100644
--- a/plugingui/led.h
+++ b/plugingui/led.h
@@ -45,7 +45,7 @@ public:
protected:
// From Widget:
- void repaintEvent(RepaintEvent *e) override;
+ void repaintEvent(RepaintEvent* repaintEvent) override;
private:
state_t state;
diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc
index ff936f4..1a9b8c8 100644
--- a/plugingui/lineedit.cc
+++ b/plugingui/lineedit.cc
@@ -96,7 +96,7 @@ void LineEdit::buttonEvent(ButtonEvent *buttonEvent)
return;
}
- if(buttonEvent->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
for(int i = 0; i < (int)visibleText.length(); ++i)
{
@@ -120,10 +120,10 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
bool change = false;
- if(keyEvent->direction == KeyEvent::Up)
+ if(keyEvent->direction == Direction::up)
{
switch(keyEvent->keycode) {
- case KeyEvent::KeyLeft:
+ case Key::left:
if(pos == 0)
{
return;
@@ -137,7 +137,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
}
break;
- case KeyEvent::KeyRight:
+ case Key::right:
if(pos == _text.length())
{
return;
@@ -151,19 +151,19 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
}
break;
- case KeyEvent::KeyHome:
+ case Key::home:
pos = 0;
visibleText = _text;
offsetPos = 0;
break;
- case KeyEvent::KeyEnd:
+ case Key::end:
pos = _text.length();
visibleText = _text;
offsetPos = 0;
break;
- case KeyEvent::KeyDelete:
+ case Key::deleteKey:
if(pos < _text.length())
{
std::string t = _text.substr(0, pos);
@@ -173,7 +173,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
}
break;
- case KeyEvent::KeyBackspace:
+ case Key::backspace:
if(pos > 0)
{
std::string t = _text.substr(0, pos - 1);
@@ -184,7 +184,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
}
break;
- case KeyEvent::KeyCharacter:
+ case Key::character:
{
std::string pre = _text.substr(0, pos);
std::string post = _text.substr(pos, std::string::npos);
@@ -194,7 +194,7 @@ void LineEdit::keyEvent(KeyEvent *keyEvent)
}
break;
- case KeyEvent::KeyEnter:
+ case Key::enter:
enterPressedNotifier();
break;
diff --git a/plugingui/lineedit.h b/plugingui/lineedit.h
index 21e448b..515ea94 100644
--- a/plugingui/lineedit.h
+++ b/plugingui/lineedit.h
@@ -50,9 +50,9 @@ public:
Notifier<> enterPressedNotifier;
//protected:
- virtual void keyEvent(KeyEvent *keyEvent);
- virtual void repaintEvent(RepaintEvent *repaintEvent);
- virtual void buttonEvent(ButtonEvent *buttonEvent);
+ virtual void keyEvent(KeyEvent *keyEvent) override;
+ virtual void repaintEvent(RepaintEvent *repaintEvent) override;
+ virtual void buttonEvent(ButtonEvent *buttonEvent) override;
protected:
virtual void textChanged() {}
diff --git a/plugingui/listbox.cc b/plugingui/listbox.cc
index a573e0e..8097ca9 100644
--- a/plugingui/listbox.cc
+++ b/plugingui/listbox.cc
@@ -99,7 +99,7 @@ void ListBox::clearSelectedValue()
basic.clearSelectedValue();
}
-void ListBox::repaintEvent(RepaintEvent *e)
+void ListBox::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/listbox.h b/plugingui/listbox.h
index cd54aa9..f805fcb 100644
--- a/plugingui/listbox.h
+++ b/plugingui/listbox.h
@@ -50,7 +50,7 @@ public:
void clearSelectedValue();
// From Widget:
- virtual void repaintEvent(RepaintEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
virtual void resize(int w, int h) override;
// Forwarded notifiers from ListBoxBasic::basic
diff --git a/plugingui/listboxbasic.cc b/plugingui/listboxbasic.cc
index 4f66046..d1002b6 100644
--- a/plugingui/listboxbasic.cc
+++ b/plugingui/listboxbasic.cc
@@ -201,13 +201,13 @@ void ListBoxBasic::scrollEvent(ScrollEvent* scrollEvent)
void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
{
- if(keyEvent->direction != KeyEvent::Down)
+ if(keyEvent->direction != Direction::down)
{
return;
}
switch(keyEvent->keycode) {
- case KeyEvent::KeyUp:
+ case Key::up:
if(marked == 0)
{
return;
@@ -221,7 +221,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
}
break;
- case KeyEvent::KeyDown:
+ case Key::down:
{
// Number of items that can be displayed at a time.
int numitems = height() / (font.textHeight() + padding);
@@ -240,7 +240,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
}
break;
- case KeyEvent::KeyHome:
+ case Key::home:
marked = 0;
if(marked < scroll.value())
{
@@ -248,7 +248,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
}
break;
- case KeyEvent::KeyEnd:
+ case Key::end:
{
// Number of items that can be displayed at a time.
int numitems = height() / (font.textHeight() + padding);
@@ -261,7 +261,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
}
break;
- case KeyEvent::KeyCharacter:
+ case Key::character:
if(keyEvent->text == " ")
{
setSelection(marked);
@@ -269,7 +269,7 @@ void ListBoxBasic::keyEvent(KeyEvent* keyEvent)
}
break;
- case KeyEvent::KeyEnter:
+ case Key::enter:
setSelection(marked);
selectionNotifier();
break;
@@ -288,7 +288,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent)
{
if(buttonEvent->y > 0 && buttonEvent->y < btn_size)
{
- if(buttonEvent->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
return;
}
@@ -299,7 +299,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent)
if(buttonEvent->y > ((int)height() - btn_size) &&
buttonEvent->y < ((int)height() - 1))
{
- if(buttonEvent->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
return;
}
@@ -308,7 +308,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent)
}
}
- if(buttonEvent->direction == ButtonEvent::Up)
+ if(buttonEvent->direction == Direction::up)
{
int skip = scroll.value();
size_t yoffset = padding / 2;
@@ -327,7 +327,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent)
repaintEvent(nullptr);
}
- if(buttonEvent->direction != ButtonEvent::Up)
+ if(buttonEvent->direction != Direction::up)
{
int skip = scroll.value();
size_t yoffset = padding / 2;
@@ -344,7 +344,7 @@ void ListBoxBasic::buttonEvent(ButtonEvent* buttonEvent)
repaintEvent(nullptr);
}
- if(buttonEvent->doubleclick)
+ if(buttonEvent->doubleClick)
{
selectionNotifier();
}
diff --git a/plugingui/listboxbasic.h b/plugingui/listboxbasic.h
index 1ada745..3a190da 100644
--- a/plugingui/listboxbasic.h
+++ b/plugingui/listboxbasic.h
@@ -70,10 +70,10 @@ protected:
// From Widget:
bool isFocusable() override { return true; }
- virtual void repaintEvent(RepaintEvent *e) override;
- virtual void buttonEvent(ButtonEvent *e) override;
- virtual void keyEvent(KeyEvent *e) override;
- virtual void scrollEvent(ScrollEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
+ virtual void buttonEvent(ButtonEvent* buttonEvent) override;
+ virtual void keyEvent(KeyEvent* keyEvent) override;
+ virtual void scrollEvent(ScrollEvent* scrollEvent) override;
ScrollBar scroll;
diff --git a/plugingui/listboxthin.cc b/plugingui/listboxthin.cc
index 0120c50..16ea49e 100644
--- a/plugingui/listboxthin.cc
+++ b/plugingui/listboxthin.cc
@@ -94,7 +94,7 @@ std::string ListBoxThin::selectedValue()
return basic.selectedValue();
}
-void ListBoxThin::repaintEvent(RepaintEvent *e)
+void ListBoxThin::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/listboxthin.h b/plugingui/listboxthin.h
index 19114d5..bc9399b 100644
--- a/plugingui/listboxthin.h
+++ b/plugingui/listboxthin.h
@@ -50,7 +50,7 @@ public:
std::string selectedValue();
// From Widget:
- virtual void repaintEvent(GUI::RepaintEvent *e) override;
+ virtual void repaintEvent(GUI::RepaintEvent* repaintEvent) override;
virtual void resize(int w, int h) override;
// Forwarded notifier from ListBoxBasic::basic
diff --git a/plugingui/nativewindow_pugl.cc b/plugingui/nativewindow_pugl.cc
index dadb724..0c7ba96 100644
--- a/plugingui/nativewindow_pugl.cc
+++ b/plugingui/nativewindow_pugl.cc
@@ -83,7 +83,7 @@ static void onMouse(PuglView* view, int button, bool press, int x, int y)
e->y = y;
e->button = button;
e->direction = press?1:-1;
- e->doubleclick = false;
+ e->doubleClick = false;
eventq.push_back(e);
}
@@ -97,18 +97,18 @@ static void onKeyboard(PuglView* view, bool press, uint32_t key)
printf("%d\n", key);
switch(key) {
- case PUGL_KEY_LEFT: e->keycode = GUI::KeyEvent::KeyLeft; break;
- case PUGL_KEY_RIGHT: e->keycode = GUI::KeyEvent::KeyRight; break;
- case PUGL_KEY_UP: e->keycode = GUI::KeyEvent::KeyUp; break;
- case PUGL_KEY_DOWN: e->keycode = GUI::KeyEvent::KeyDown; break;
- case PUGL_KEY_PAGE_UP: e->keycode = GUI::KeyEvent::KeyPageDown; break;
- case PUGL_KEY_PAGE_DOWN: e->keycode = GUI::KeyEvent::KeyPageUp; break;
- default: e->keycode = GUI::KeyEvent::KeyUnknown; break;
+ case PUGL_KEY_LEFT: e->keycode = GUI::Key::left; break;
+ case PUGL_KEY_RIGHT: e->keycode = GUI::Key::right; break;
+ case PUGL_KEY_UP: e->keycode = GUI::Key::up; break;
+ case PUGL_KEY_DOWN: e->keycode = GUI::Key::down; break;
+ case PUGL_KEY_PAGE_UP: e->keycode = GUI::Key::pageDown; break;
+ case PUGL_KEY_PAGE_DOWN: e->keycode = GUI::Key::pageUp; break;
+ default: e->keycode = GUI::Key::unknown; break;
}
// TODO: perform character type check
- if(e->keycode == GUI::KeyEvent::KeyUnknown) {
- e->keycode = GUI::KeyEvent::KeyCharacter;
+ if(e->keycode == GUI::Key::unknown) {
+ e->keycode = GUI::Key::character;
e->text.assign(1, (char)key);
}
diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc
index 8718147..e9f37a7 100644
--- a/plugingui/nativewindow_win32.cc
+++ b/plugingui/nativewindow_win32.cc
@@ -134,19 +134,19 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
msg == WM_LBUTTONDBLCLK ||
msg == WM_LBUTTONDOWN)
{
- buttonEvent->button = ButtonEvent::Left;
+ buttonEvent->button = MouseButton::left;
}
else if(msg == WM_RBUTTONUP ||
msg == WM_RBUTTONDBLCLK ||
msg == WM_RBUTTONDOWN)
{
- buttonEvent->button = ButtonEvent::Middle;
+ buttonEvent->button = MouseButton::middle;
}
else if(msg == WM_MBUTTONUP ||
msg == WM_MBUTTONDBLCLK ||
msg == WM_MBUTTONDOWN)
{
- buttonEvent->button = ButtonEvent::Right;
+ buttonEvent->button = MouseButton::right;
}
else
{
@@ -158,13 +158,13 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
msg == WM_RBUTTONUP ||
msg == WM_MBUTTONUP)
{
- buttonEvent->direction = ButtonEvent::Up;
+ buttonEvent->direction = Direction::up;
}
else if(msg == WM_LBUTTONDOWN ||
msg == WM_RBUTTONDOWN ||
msg == WM_MBUTTONDOWN)
{
- buttonEvent->direction = ButtonEvent::Down;
+ buttonEvent->direction = Direction::down;
}
else
{
@@ -172,7 +172,7 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
break; // unknown direction
}
- buttonEvent->doubleclick = (msg == WM_LBUTTONDBLCLK ||
+ buttonEvent->doubleClick = (msg == WM_LBUTTONDBLCLK ||
msg == WM_RBUTTONDBLCLK ||
msg == WM_MBUTTONDBLCLK);
@@ -185,22 +185,22 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
KeyEvent* keyEvent = new KeyEvent();
switch(wp) {
- case VK_LEFT: keyEvent->keycode = KeyEvent::KeyLeft; break;
- case VK_RIGHT: keyEvent->keycode = KeyEvent::KeyRight; break;
- case VK_UP: keyEvent->keycode = KeyEvent::KeyUp; break;
- case VK_DOWN: keyEvent->keycode = KeyEvent::KeyDown; break;
- case VK_BACK: keyEvent->keycode = KeyEvent::KeyBackspace; break;
- case VK_DELETE: keyEvent->keycode = KeyEvent::KeyDelete; break;
- case VK_HOME: keyEvent->keycode = KeyEvent::KeyHome; break;
- case VK_END: keyEvent->keycode = KeyEvent::KeyEnd; break;
- case VK_PRIOR: keyEvent->keycode = KeyEvent::KeyPageUp; break;
- case VK_NEXT: keyEvent->keycode = KeyEvent::KeyPageDown; break;
- case VK_RETURN: keyEvent->keycode = KeyEvent::KeyEnter; break;
- default: keyEvent->keycode = KeyEvent::KeyUnknown; break;
+ case VK_LEFT: keyEvent->keycode = Key::left; break;
+ case VK_RIGHT: keyEvent->keycode = Key::right; break;
+ case VK_UP: keyEvent->keycode = Key::up; break;
+ case VK_DOWN: keyEvent->keycode = Key::down; break;
+ case VK_BACK: keyEvent->keycode = Key::backspace; break;
+ case VK_DELETE: keyEvent->keycode = Key::deleteKey; break;
+ case VK_HOME: keyEvent->keycode = Key::home; break;
+ case VK_END: keyEvent->keycode = Key::end; break;
+ case VK_PRIOR: keyEvent->keycode = Key::pageUp; break;
+ case VK_NEXT: keyEvent->keycode = Key::pageDown; break;
+ case VK_RETURN: keyEvent->keycode = Key::enter; break;
+ default: keyEvent->keycode = Key::unknown; break;
}
keyEvent->text = "";
- keyEvent->direction = KeyEvent::Up;
+ keyEvent->direction = Direction::up;
native->event = keyEvent;
}
@@ -211,9 +211,9 @@ LRESULT CALLBACK NativeWindowWin32::dialogProc(HWND hwnd, UINT msg,
if(wp >= ' ') // Filter control chars.
{
KeyEvent* keyEvent = new KeyEvent();
- keyEvent->keycode = KeyEvent::KeyCharacter;
+ keyEvent->keycode = Key::character;
keyEvent->text += (char)wp;
- keyEvent->direction = KeyEvent::Up;
+ keyEvent->direction = Direction::up;
native->event = keyEvent;
}
}
diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc
index fbac0e7..d47c67f 100644
--- a/plugingui/nativewindow_x11.cc
+++ b/plugingui/nativewindow_x11.cc
@@ -446,25 +446,26 @@ Event* NativeWindowX11::getNextEvent()
buttonEvent->y = xevent.xbutton.y;
switch(xevent.xbutton.button) {
case 1:
- buttonEvent->button = ButtonEvent::Left;
+ buttonEvent->button = MouseButton::left;
break;
case 2:
- buttonEvent->button = ButtonEvent::Middle;
+ buttonEvent->button = MouseButton::middle;
break;
case 3:
- buttonEvent->button = ButtonEvent::Right;
+ buttonEvent->button = MouseButton::right;
break;
default:
WARN(X11, "Unknown button %d, setting to Left\n",
xevent.xbutton.button);
- buttonEvent->button = ButtonEvent::Left;
+ buttonEvent->button = MouseButton::left;
break;
}
buttonEvent->direction =
- (xevent.type == ButtonPress) ? ButtonEvent::Down : ButtonEvent::Up;
+ (xevent.type == ButtonPress) ?
+ Direction::down : Direction::up;
- buttonEvent->doubleclick =
+ buttonEvent->doubleClick =
(xevent.type == ButtonPress) &&
((xevent.xbutton.time - last_click) < 200);
@@ -483,32 +484,32 @@ Event* NativeWindowX11::getNextEvent()
keyEvent->window_id = xevent.xkey.window;
switch(xevent.xkey.keycode) {
- case 113: keyEvent->keycode = KeyEvent::KeyLeft; break;
- case 114: keyEvent->keycode = KeyEvent::KeyRight; break;
- case 111: keyEvent->keycode = KeyEvent::KeyUp; break;
- case 116: keyEvent->keycode = KeyEvent::KeyDown; break;
- case 119: keyEvent->keycode = KeyEvent::KeyDelete; break;
- case 22: keyEvent->keycode = KeyEvent::KeyBackspace; break;
- case 110: keyEvent->keycode = KeyEvent::KeyHome; break;
- case 115: keyEvent->keycode = KeyEvent::KeyEnd; break;
- case 117: keyEvent->keycode = KeyEvent::KeyPageDown; break;
- case 112: keyEvent->keycode = KeyEvent::KeyPageUp; break;
- case 36: keyEvent->keycode = KeyEvent::KeyEnter; break;
- default: keyEvent->keycode = KeyEvent::KeyUnknown; break;
+ case 113: keyEvent->keycode = Key::left; break;
+ case 114: keyEvent->keycode = Key::right; break;
+ case 111: keyEvent->keycode = Key::up; break;
+ case 116: keyEvent->keycode = Key::down; break;
+ case 119: keyEvent->keycode = Key::deleteKey; break;
+ case 22: keyEvent->keycode = Key::backspace; break;
+ case 110: keyEvent->keycode = Key::home; break;
+ case 115: keyEvent->keycode = Key::end; break;
+ case 117: keyEvent->keycode = Key::pageDown; break;
+ case 112: keyEvent->keycode = Key::pageUp; break;
+ case 36: keyEvent->keycode = Key::enter; break;
+ default: keyEvent->keycode = Key::unknown; break;
}
char stringBuffer[1024];
int size = XLookupString(&xevent.xkey, stringBuffer,
sizeof(stringBuffer), nullptr, nullptr);
- if(size && keyEvent->keycode == KeyEvent::KeyUnknown)
+ if(size && keyEvent->keycode == Key::unknown)
{
- keyEvent->keycode = KeyEvent::KeyCharacter;
+ keyEvent->keycode = Key::character;
}
keyEvent->text.append(stringBuffer, size);
keyEvent->direction =
- (xevent.type == KeyPress) ? KeyEvent::Down : KeyEvent::Up;
+ (xevent.type == KeyPress) ? Direction::down : Direction::up;
event = keyEvent;
}
diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc
index a53aa40..6882789 100644
--- a/plugingui/progressbar.cc
+++ b/plugingui/progressbar.cc
@@ -90,7 +90,7 @@ void ProgressBar::setProgress(float progress)
repaintEvent(nullptr);
}
-void ProgressBar::repaintEvent(RepaintEvent *e)
+void ProgressBar::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
diff --git a/plugingui/progressbar.h b/plugingui/progressbar.h
index e5e567d..26fbbea 100644
--- a/plugingui/progressbar.h
+++ b/plugingui/progressbar.h
@@ -53,7 +53,7 @@ public:
protected:
// From Widget:
- virtual void repaintEvent(RepaintEvent *e) override;
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
private:
ProgressBarState state;
diff --git a/plugingui/scrollbar.cc b/plugingui/scrollbar.cc
index 7e6d47a..2a9d3fd 100644
--- a/plugingui/scrollbar.cc
+++ b/plugingui/scrollbar.cc
@@ -178,7 +178,7 @@ void ScrollBar::buttonEvent(ButtonEvent* buttonEvent)
{
if((buttonEvent->y < (int)width()) && buttonEvent->y > 0)
{
- if(buttonEvent->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
addValue(-1);
}
@@ -189,7 +189,7 @@ void ScrollBar::buttonEvent(ButtonEvent* buttonEvent)
if((buttonEvent->y > ((int)height() - (int)width())) &&
(buttonEvent->y < (int)height()))
{
- if(buttonEvent->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
addValue(1);
}
@@ -197,13 +197,13 @@ void ScrollBar::buttonEvent(ButtonEvent* buttonEvent)
return;
}
- if(buttonEvent->direction == ButtonEvent::Down)
+ if(buttonEvent->direction == Direction::down)
{
yOffset = buttonEvent->y;
valueOffset = value();
}
- dragging = (buttonEvent->direction == ButtonEvent::Down);
+ dragging = (buttonEvent->direction == Direction::down);
}
} // GUI::
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index 4f56344..a3c10f9 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -31,128 +31,132 @@
#include <hugin.hpp>
#include <stdio.h>
-GUI::Slider::Slider(Widget *parent)
- : GUI::Widget(parent)
-{
- state = up;
+namespace GUI {
- val = 0.0;
- maximum = 1.0;
- minimum = 0.0;
+Slider::Slider(Widget *parent)
+ : Widget(parent)
+{
+ state = State::up;
- handler = NULL;
- ptr = NULL;
+ currentValue = 0.0;
+ maximum = 1.0;
+ minimum = 0.0;
}
-void GUI::Slider::setValue(float v)
+void Slider::setValue(float newValue)
{
- val = v;
- if(handler) handler(ptr);
- repaintEvent(NULL);
+ currentValue = newValue;
+ repaintEvent(nullptr);
+ clickNotifier();
}
-float GUI::Slider::value()
+float Slider::value()
{
- return val;
+ return currentValue;
}
-void GUI::Slider::registerClickHandler(void (*handler)(void *), void *ptr)
+void Slider::repaintEvent(RepaintEvent* repaintEvent)
{
- this->handler = handler;
- this->ptr = ptr;
+ Painter p(*this);
+
+ float alpha = 0.8;
+
+ int xpos = (int)((currentValue / maximum) * (float)(width() - 1));
+
+ if(hasKeyboardFocus())
+ {
+ p.setColour(Colour(0.6, alpha));
+ }
+ else
+ {
+ p.setColour(Colour(0.5, alpha));
+ }
+
+ p.drawFilledRectangle(0,0,width(),height());
+
+ //p.setColour(Colour(0.1, alpha));
+ //p.drawRectangle(0,0,width()-1,height() - 1);
+
+ p.setColour(Colour(1, 0, 0, alpha));
+ p.drawLine(xpos, 0, xpos, height() - 1);
+
+ //p.setColour(Colour(0.8, alpha));
+ //switch(state) {
+ //case State::up:
+ // p.drawLine(0, 0, 0, height() - 1);
+ // p.drawLine(0, 0, width() - 1, 0);
+ // break;
+ //case State::down:
+ // p.drawLine(width() - 1, 0, width() - 1, height() - 1);
+ // p.drawLine(width() - 1, height() - 1, 0, height() - 1);
+ // break;
+ //}
+
+ p.setColour(Colour(0.3, alpha));
+ p.drawPoint(0, height() - 1);
+ p.drawPoint(width() - 1, 0);
}
-void GUI::Slider::mouseMoveEvent(MouseMoveEvent *e)
+void Slider::buttonEvent(ButtonEvent* buttonEvent)
{
- if(state == down) {
- val = maximum / (float)width() * (float)e->x;
-
- if(val < 0) val = 0;
- if(val > 1) val = 1;
-
- if(handler) handler(ptr);
- repaintEvent(NULL);
- }
+ if(buttonEvent->direction == Direction::down)
+ {
+ state = State::down;
+ currentValue = maximum / (float)width() * (float)buttonEvent->x;
+
+ if(currentValue < 0)
+ {
+ currentValue = 0;
+ }
+
+ if(currentValue > 1)
+ {
+ currentValue = 1;
+ }
+
+ repaintEvent(nullptr);
+ clickNotifier();
+ }
+
+ if(buttonEvent->direction == Direction::up)
+ {
+ state = State::up;
+ currentValue = maximum / (float)width() * (float)buttonEvent->x;
+
+ if(currentValue < 0)
+ {
+ currentValue = 0;
+ }
+
+ if(currentValue > 1)
+ {
+ currentValue = 1;
+ }
+
+ repaintEvent(nullptr);
+ clickNotifier();
+ }
}
-void GUI::Slider::buttonEvent(ButtonEvent *e)
+void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
{
- if(e->direction == ButtonEvent::Down) {
- state = down;
- val = maximum / (float)width() * (float)e->x;
-
- if(val < 0) val = 0;
- if(val > 1) val = 1;
-
- if(handler) handler(ptr);
- repaintEvent(NULL);
- }
- if(e->direction == ButtonEvent::Up) {
- state = up;
- val = maximum / (float)width() * (float)e->x;
-
- if(val < 0) val = 0;
- if(val > 1) val = 1;
-
- repaintEvent(NULL);
- clicked();
- if(handler) handler(ptr);
- }
+ if(state == State::down)
+ {
+ currentValue = maximum / (float)width() * (float)mouseMoveEvent->x;
+
+ if(currentValue < 0)
+ {
+ currentValue = 0;
+ }
+
+ if(currentValue > 1)
+ {
+ currentValue = 1;
+ }
+
+ repaintEvent(nullptr);
+ clickNotifier();
+ }
}
-void GUI::Slider::repaintEvent(GUI::RepaintEvent *e)
-{
- //DEBUG(slider, "Slider::repaintEvent (%f)\n", val);
-
- Painter p(*this);
-
- float alpha = 0.8;
-
- int xpos = (int)((val / maximum) * (float)(width() - 1));
-
- if(hasKeyboardFocus()) {
- p.setColour(Colour(0.6, alpha));
- } else {
- p.setColour(Colour(0.5, alpha));
- }
- p.drawFilledRectangle(0,0,width(),height());
- /*
- p.setColour(Colour(0.1, alpha));
- p.drawRectangle(0,0,width()-1,height()-1);
- */
- p.setColour(Colour(1, 0, 0, alpha));
- p.drawLine(xpos, 0, xpos, height()-1);
- /*
- p.setColour(Colour(0.8, alpha));
- switch(state) {
- case up:
- p.drawLine(0,0,0,height()-1);
- p.drawLine(0,0,width()-1,0);
- break;
- case down:
- p.drawLine(width()-1,0, width()-1,height()-1);
- p.drawLine(width()-1,height()-1,0, height()-1);
- break;
- }
- */
- p.setColour(Colour(0.3, alpha));
- p.drawPoint(0,height()-1);
- p.drawPoint(width()-1,0);
-}
-
-#ifdef TEST_SLIDER
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
-
-#endif/*TEST_SLIDER*/
+} // GUI::
diff --git a/plugingui/slider.h b/plugingui/slider.h
index f07ccff..01cbd54 100644
--- a/plugingui/slider.h
+++ b/plugingui/slider.h
@@ -24,8 +24,7 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __DRUMGIZMO_SLIDER_H__
-#define __DRUMGIZMO_SLIDER_H__
+#pragma once
#include "widget.h"
@@ -33,38 +32,32 @@ namespace GUI {
class Slider : public Widget {
public:
- Slider(Widget *parent);
+ Slider(Widget* parent);
- bool catchMouse() { return true; }
+ // From Widget:
+ bool catchMouse() override { return true; }
- void setValue(float value);
- float value();
+ void setValue(float value);
+ float value();
- void registerClickHandler(void (*handler)(void *), void *ptr);
+ Notifier<> clickNotifier;
- //protected:
- virtual void clicked() {}
-
- virtual void repaintEvent(RepaintEvent *e);
- virtual void buttonEvent(ButtonEvent *e);
- virtual void mouseMoveEvent(MouseMoveEvent *e);
+protected:
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
+ virtual void buttonEvent(ButtonEvent* buttonEvent) override;
+ virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override;
private:
- typedef enum {
- up,
- down
- } state_t;
-
- float val;
- float maximum;
- float minimum;
+ enum class State {
+ up,
+ down
+ };
- state_t state;
-
- void (*handler)(void *);
- void *ptr;
-};
+ float currentValue;
+ float maximum;
+ float minimum;
+ State state;
};
-#endif/*__DRUMGIZMO_SLIDER_H__*/
+} // GUI::
diff --git a/plugingui/verticalline.cc b/plugingui/verticalline.cc
index bbf0d28..31c14d4 100644
--- a/plugingui/verticalline.cc
+++ b/plugingui/verticalline.cc
@@ -28,14 +28,18 @@
#include "painter.h"
-GUI::VerticalLine::VerticalLine(GUI::Widget *parent)
- : Widget(parent), vline(":vertline.png")
+namespace GUI {
+
+VerticalLine::VerticalLine(Widget *parent)
+ : Widget(parent)
+ , vline(":vertline.png")
{
}
-void GUI::VerticalLine::repaintEvent(RepaintEvent *e)
+void VerticalLine::repaintEvent(RepaintEvent* repaintEvent)
{
- (void)e;
- GUI::Painter p(*this);
- p.drawImageStretched(0, 0, vline, width(), height());
+ Painter p(*this);
+ p.drawImageStretched(0, 0, vline, width(), height());
}
+
+} // GUI::
diff --git a/plugingui/verticalline.h b/plugingui/verticalline.h
index 7c1bc27..1d05eac 100644
--- a/plugingui/verticalline.h
+++ b/plugingui/verticalline.h
@@ -24,8 +24,7 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __DRUMGIZMO_VERTICALLINE_H__
-#define __DRUMGIZMO_VERTICALLINE_H__
+#pragma once
#include "widget.h"
#include "image.h"
@@ -34,15 +33,14 @@ namespace GUI {
class VerticalLine : public Widget {
public:
- VerticalLine(Widget *parent);
+ VerticalLine(Widget* parent);
- //protected:
- virtual void repaintEvent(RepaintEvent *e);
+protected:
+ // From Widget:
+ virtual void repaintEvent(RepaintEvent* repaintEvent) override;
private:
- Image vline;
+ Image vline;
};
-};
-
-#endif/*__DRUMGIZMO_VERTICALLINE_H__*/
+} // GUI::
diff --git a/plugingui/widget.cc b/plugingui/widget.cc
index 6106f7c..942337f 100644
--- a/plugingui/widget.cc
+++ b/plugingui/widget.cc
@@ -173,17 +173,17 @@ Window *Widget::window()
return _window;
}
-void Widget::repaint_r(RepaintEvent *e)
+void Widget::repaint_r(RepaintEvent* repaintEvent)
{
Painter p(*this); // make sure pixbuf refcount is incremented.
- repaintEvent(e);
+ this->repaintEvent(repaintEvent);
std::vector<Widget*>::iterator i = children.begin();
while(i != children.end())
{
Widget *w = *i;
- w->repaint_r(e);
+ w->repaint_r(repaintEvent);
i++;
}
}
diff --git a/plugingui/widget.h b/plugingui/widget.h
index 32acd5c..806ee5c 100644
--- a/plugingui/widget.h
+++ b/plugingui/widget.h
@@ -45,15 +45,16 @@ public:
virtual void show();
virtual void hide();
- virtual void resize(int width, int height);
- virtual void move(size_t x, size_t y);
+ // From LayoutItem
+ virtual void resize(int width, int height) override;
+ virtual void move(size_t x, size_t y) override;
+ virtual size_t x() override;
+ virtual size_t y() override;
+ virtual size_t width() override;
+ virtual size_t height() override;
- virtual size_t x();
- virtual size_t y();
virtual size_t windowX();
virtual size_t windowY();
- virtual size_t width();
- virtual size_t height();
virtual bool isFocusable() { return false; }
virtual bool catchMouse() { return false; }
@@ -61,23 +62,23 @@ public:
void addChild(Widget *widget);
void removeChild(Widget *widget);
- virtual void repaintEvent(RepaintEvent *e) {}
- virtual void mouseMoveEvent(MouseMoveEvent *e) {}
- virtual void buttonEvent(ButtonEvent *e) {}
- virtual void scrollEvent(ScrollEvent *e) {}
- virtual void keyEvent(KeyEvent *e) {}
+ 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 mouseLeaveEvent() {}
virtual void mouseEnterEvent() {}
- Widget *find(size_t x, size_t y);
+ Widget* find(size_t x, size_t y);
- virtual Window *window();
+ virtual Window* window();
- void repaint_r(RepaintEvent *e);
+ void repaint_r(RepaintEvent* repaintEvent);
PixelBufferAlpha pixbuf;
- std::vector<PixelBufferAlpha *> getPixelBuffers();
+ std::vector<PixelBufferAlpha*> getPixelBuffers();
bool hasKeyboardFocus();
diff --git a/plugingui/window.cc b/plugingui/window.cc
index a7e220e..b54bc3c 100644
--- a/plugingui/window.cc
+++ b/plugingui/window.cc
@@ -88,7 +88,7 @@ void GUI::Window::setCaption(std::string caption)
native->setCaption(caption);
}
-void GUI::Window::repaintEvent(GUI::RepaintEvent *e)
+void GUI::Window::repaintEvent(GUI::RepaintEvent* repaintEvent)
{
if(!visible()) return;
diff --git a/plugingui/window.h b/plugingui/window.h
index f8deef0..23d91e0 100644
--- a/plugingui/window.h
+++ b/plugingui/window.h
@@ -59,7 +59,7 @@ public:
void addChild(Widget *widget);
- void repaintEvent(GUI::RepaintEvent *e);
+ void repaintEvent(GUI::RepaintEvent* repaintEvent);
void beginPaint();
void endPaint();