/** * @author Christian Burger (christian@krikkel.de) */ #include #include #include #include namespace krikkel::NCurses { using std::list; using std::recursive_mutex; using std::scoped_lock; VerticalTilingWindowManager::VerticalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex) : TilingWindowManager(rootWindow, ncursesMutex) {} void VerticalTilingWindowManager::updateLayout() { size_t stackSize = visibleStack.size(); if(stackSize == 0) { rootWindow->clear(); return; } scoped_lock lock(*ncursesMutex); int availableWidth = rootWindow->width(); int availableHeight = rootWindow->height(); int windowHeight = availableHeight / stackSize - 1; if((windowHeight + 1) * stackSize < availableHeight) ++windowHeight; uint16_t y = 0; list::iterator it = visibleStack.begin(); for(size_t index = 0 ; index < visibleStack.size() - 1 ; ++index) { resizeWindow(*it++, windowHeight, availableWidth, y, 0); y += windowHeight; { rootWindow->move(y++, 0); rootWindow->hline(availableWidth); } } resizeWindow(*it, availableHeight - y, availableWidth, y, 0); } }