Christian Burger
0a086ff604
Window managers are now descendants of windows instead of owning the window in which they exist. This makes a clean window hierarchy.
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/**
|
|
* @author Christian Burger (christian@krikkel.de)
|
|
*/
|
|
|
|
#include <kNCurses/HorizontalTilingWindowManager.hpp>
|
|
#include <kNCurses/Window.hpp>
|
|
#include <ncursesw/ncurses.h>
|
|
#include <algorithm>
|
|
|
|
namespace krikkel::NCurses
|
|
{
|
|
using std::list;
|
|
using std::recursive_mutex;
|
|
using std::scoped_lock;
|
|
|
|
HorizontalTilingWindowManager::HorizontalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex)
|
|
: TilingWindowManager(rootWindow, ncursesMutex)
|
|
{}
|
|
|
|
void HorizontalTilingWindowManager::updateLayout()
|
|
{
|
|
scoped_lock lock(*ncursesMutex);
|
|
|
|
size_t stackSize = visibleStack.size();
|
|
if(stackSize == 0)
|
|
{
|
|
clear();
|
|
return;
|
|
}
|
|
|
|
int availableWidth = width();
|
|
int availableHeight = height();
|
|
int windowWidth = availableWidth / stackSize - 1;
|
|
|
|
if((windowWidth + 1) * stackSize < availableWidth)
|
|
++windowWidth;
|
|
|
|
uint16_t x = 0;
|
|
list<Window *>::iterator it = visibleStack.begin();
|
|
for(size_t index = 0
|
|
; index < visibleStack.size() - 1
|
|
; ++index)
|
|
{
|
|
resizeWindow(*it++, availableHeight, windowWidth, 0, x);
|
|
x += windowWidth;
|
|
{
|
|
move(0, x++);
|
|
vline(availableHeight);
|
|
}
|
|
}
|
|
resizeWindow(*it, availableHeight, availableWidth - x, 0, x);
|
|
}
|
|
} |