Christian Burger
3be5336ca0
Laying out the windows in the window manager frame, is a very similar process regardless of doing it horizontally or vertically. So the template design pattern was applied and the general functionality was pulled up; only specific functionalities were put into the corresponding classes. kNCursesDemoApp: Separated the screen into three windows vertically. The top and bottom window contain another two windows each, lay out horizontally. The top left window is fixed to width 1 and the top right takes the rest of the space. Bottom two windows take 50 % of the space each. Remarks: There are still some rendering bugs, when hiding and showing windows. E. g. when hiding the top or middle window with `<F1>` or `<F2>` respectively, the bottom window has some errors. Maybe some timing issue.
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
/**
|
|
* @author Christian Burger (christian@krikkel.de)
|
|
*/
|
|
|
|
#include "Debug.hpp"
|
|
#include <kNCurses/VerticalTilingWindowManager.hpp>
|
|
#include <kNCurses/Window.hpp>
|
|
#include <ncursesw/ncurses.h>
|
|
#include <algorithm>
|
|
|
|
namespace krikkel::NCurses
|
|
{
|
|
using std::recursive_mutex;
|
|
|
|
VerticalTilingWindowManager::VerticalTilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex)
|
|
: TilingWindowManager(rootWindow, ncursesMutex)
|
|
{}
|
|
|
|
void VerticalTilingWindowManager::resizeAndMoveWindow(Window *window, windowDimension dimension, windowPosition position)
|
|
{
|
|
__debug_log("(" + std::to_string(0 + begx()) + ", " + std::to_string(position + begy()) + ", " + std::to_string(width()) + ", " + std::to_string(dimension) + ")");
|
|
window->resize(dimension, width());
|
|
window->mvwin(position + begy(), 0 + begx());
|
|
}
|
|
|
|
TilingWindowManager::windowDimension VerticalTilingWindowManager::getAvailableSpace()
|
|
{
|
|
return height();
|
|
}
|
|
|
|
void VerticalTilingWindowManager::windowBorder()
|
|
{
|
|
hline(width());
|
|
}
|
|
|
|
void VerticalTilingWindowManager::moveCursor(TilingWindowManager::windowPosition position)
|
|
{
|
|
move(position, 0);
|
|
}
|
|
|
|
} |