/** * @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() { scoped_lock lock(*ncursesMutex); size_t stackSize = visibleStack.size(); if(stackSize == 0) { clear(); return; } int availableWidth = width(); int availableHeight = 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; { move(y++, 0); hline(availableWidth); } } resizeWindow(*it, availableHeight - y, availableWidth, y, 0); } }