added class HorizontalTilingWindowManager
Just some minor changes to `VerticalTilingWindowManager`. Not part of the demo, yet.
This commit is contained in:
parent
792f12c96c
commit
a801752620
52
HorizontalTilingWindowManager.cpp
Normal file
52
HorizontalTilingWindowManager.cpp
Normal 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);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ namespace krikkel::NCurses
|
|||
using std::list;
|
||||
using std::recursive_mutex;
|
||||
using std::scoped_lock;
|
||||
using std::find;
|
||||
|
||||
VerticalTilingWindowManager::VerticalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex)
|
||||
: TilingWindowManager(rootWindow, ncursesMutex)
|
||||
|
|
25
include/kNCurses/HorizontalTilingWindowManager.hpp
Normal file
25
include/kNCurses/HorizontalTilingWindowManager.hpp
Normal 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 */
|
|
@ -6,14 +6,13 @@
|
|||
#ifndef C10F5DF3_1DB4_4714_A84D_115F492F5CDC
|
||||
#define C10F5DF3_1DB4_4714_A84D_115F492F5CDC
|
||||
|
||||
#include <kNCurses/TilingWindowManager.hpp>
|
||||
#include "TilingWindowManager.hpp"
|
||||
|
||||
namespace krikkel::NCurses
|
||||
{
|
||||
class Window;
|
||||
class SingleUserInput;
|
||||
|
||||
|
||||
class VerticalTilingWindowManager : public TilingWindowManager
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue