diff options
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 28 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index c1fea4158..ea3cc5ad3 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -54,6 +54,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" #include "gui/widgets/textfield.h" +#include "gui/widgets/windowcontainer.h" #include "net/inventoryhandler.h" @@ -746,6 +747,33 @@ bool InventoryWindow::isAnyInputFocused() return false; } +InventoryWindow *InventoryWindow::getFirstVisible() +{ + std::set<Widget*> list; + FOR_EACH (WindowList::const_iterator, it, invInstances) + { + if ((*it) && (*it)->isWindowVisible()) + list.insert(*it); + } + InventoryWindow *const window = dynamic_cast<InventoryWindow*>( + windowContainer->findFirstWidget(list)); + return window; +} + +void InventoryWindow::nextTab() +{ + InventoryWindow *const window = getFirstVisible(); + if (window) + window->mFilter->nextTab(); +} + +void InventoryWindow::prevTab() +{ + InventoryWindow *const window = getFirstVisible(); + if (window) + window->mFilter->prevTab(); +} + void InventoryWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 98cac78a6..f2952c2f5 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -156,6 +156,12 @@ class InventoryWindow final : public Window, static bool isAnyInputFocused(); + static InventoryWindow *getFirstVisible(); + + static void nextTab(); + + static void prevTab(); + private: /** * Updates the weight bar. |