summaryrefslogtreecommitdiff
path: root/plugingui/tabwidget.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-30 10:30:47 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-30 10:30:47 +0200
commit8fe6d2ec950ed1ebdedd776bab125dff90e5a20f (patch)
tree08a27b00831425367c1831269008feac14b97028 /plugingui/tabwidget.cc
parentd1e803d4be4cadc3e1204cbd096ae3bbe57c7a95 (diff)
Add support for rotating the tabs using the scroll-wheel.
Diffstat (limited to 'plugingui/tabwidget.cc')
-rw-r--r--plugingui/tabwidget.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugingui/tabwidget.cc b/plugingui/tabwidget.cc
index 06e7425..dde2137 100644
--- a/plugingui/tabwidget.cc
+++ b/plugingui/tabwidget.cc
@@ -46,6 +46,7 @@ void TabWidget::addTab(const std::string& title, Widget* widget)
button.setText(title);
stack.addWidget(widget);
CONNECT(&button, switchTabNotifier, this, &TabWidget::switchTab);
+ CONNECT(&button, scrollNotifier, this, &TabWidget::rotateTab);
sizeChanged(width(), height());
}
@@ -54,6 +55,24 @@ std::size_t TabWidget::getBarHeight() const
return topbar.height();
}
+void TabWidget::rotateTab(float delta)
+{
+ Widget* widget{nullptr};
+ if(delta > 0.0f)
+ {
+ widget = stack.getWidgetAfter(stack.getCurrentWidget());
+ }
+ else
+ {
+ widget = stack.getWidgetBefore(stack.getCurrentWidget());
+ }
+
+ if(widget)
+ {
+ switchTab(widget);
+ }
+}
+
void TabWidget::switchTab(Widget* tabWidget)
{
stack.setCurrentWidget(tabWidget);