diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-30 10:30:47 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-30 10:30:47 +0200 |
commit | 8fe6d2ec950ed1ebdedd776bab125dff90e5a20f (patch) | |
tree | 08a27b00831425367c1831269008feac14b97028 /plugingui/tabwidget.cc | |
parent | d1e803d4be4cadc3e1204cbd096ae3bbe57c7a95 (diff) |
Add support for rotating the tabs using the scroll-wheel.
Diffstat (limited to 'plugingui/tabwidget.cc')
-rw-r--r-- | plugingui/tabwidget.cc | 19 |
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); |