added class HorizontalTilingWindowManager

Just some minor changes to
`VerticalTilingWindowManager`. Not part of the
demo, yet.
This commit is contained in:
Christian Burger 2022-05-08 21:12:06 +02:00
parent 792f12c96c
commit a801752620
4 changed files with 78 additions and 3 deletions

View file

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

View file

@ -12,7 +12,6 @@ namespace krikkel::NCurses
using std::list; using std::list;
using std::recursive_mutex; using std::recursive_mutex;
using std::scoped_lock; using std::scoped_lock;
using std::find;
VerticalTilingWindowManager::VerticalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex) VerticalTilingWindowManager::VerticalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex)
: TilingWindowManager(rootWindow, ncursesMutex) : TilingWindowManager(rootWindow, ncursesMutex)

View file

@ -0,0 +1,25 @@
/**
* @brief Window manager
* @author Christian Burger (christian@krikkel.de)
*/
#ifndef B7BCF793_2FAB_49CC_9E00_CDEA370D38F9
#define B7BCF793_2FAB_49CC_9E00_CDEA370D38F9
#include "TilingWindowManager.hpp"
namespace krikkel::NCurses
{
class Window;
class SingleUserInput;
class HorizontalTilingWindowManager : public TilingWindowManager
{
public:
HorizontalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex);
void updateLayout() override;
};
}
#endif /* B7BCF793_2FAB_49CC_9E00_CDEA370D38F9 */

View file

@ -6,14 +6,13 @@
#ifndef C10F5DF3_1DB4_4714_A84D_115F492F5CDC #ifndef C10F5DF3_1DB4_4714_A84D_115F492F5CDC
#define C10F5DF3_1DB4_4714_A84D_115F492F5CDC #define C10F5DF3_1DB4_4714_A84D_115F492F5CDC
#include <kNCurses/TilingWindowManager.hpp> #include "TilingWindowManager.hpp"
namespace krikkel::NCurses namespace krikkel::NCurses
{ {
class Window; class Window;
class SingleUserInput; class SingleUserInput;
class VerticalTilingWindowManager : public TilingWindowManager class VerticalTilingWindowManager : public TilingWindowManager
{ {
public: public: