kNCurses/include/kNCurses/TilingWindowManager.hpp

66 lines
2.4 KiB
C++

/**
* @brief Window manager for tiling (template pattern, abstract parent)
*
* A window manager contains windows of a given size, lays them out and can hide
* or show them. There is no concrete window manager for tiling horizontally and
* vertically at the same time. Instead nesting the window managers is adviced,
* since the window manager classes are derived from windows in the end.
*
* This is an abstract class used by the concrete classes
* `VerticalTilingWindowManager` and `HorizontalTilingWindowManager`. Both
* specify the virtual and protected, declared but undefined methods used by the
* public interface to facilitate the function depending on the orientation
* (horizontally or vertically).
*
* @author Christian Burger (christian@krikkel.de)
*/
#ifndef C51BA18F_0915_43B9_BD5D_129F0CDBC1CD
#define C51BA18F_0915_43B9_BD5D_129F0CDBC1CD
#include "Window.hpp"
#include <list>
#include <mutex>
#include <utility>
namespace krikkel::NCurses
{
class SingleUserInput;
class TilingWindowManager : public Window
{
public:
/// @todo figure out more appropiate names …
typedef int16_t windowDimension;
typedef uint16_t windowPosition;
typedef std::pair<Window *, windowDimension> WindowStackElement;
TilingWindowManager(NCursesWindow *rootWindow, std::recursive_mutex *ncursesMutex);
std::recursive_mutex *getNCursesMutex();
void addWindow(Window *window, windowDimension size = -1);
int resize(int rows, int cols) override;
int refresh() override;
void updateLayout();
void hideWindow(Window *window);
void showWindow(Window *window);
void invertWindowsVisibility();
protected:
/// @todo rename to `nCursesMutex`?
std::recursive_mutex *ncursesMutex;
std::list<WindowStackElement> stack, visibleStack;
windowDimension getRelativeUnitSizeForVisibleWindows(windowDimension spaceAvailable);
virtual void resizeAndMoveWindow(Window *window
, windowDimension dimension
, windowPosition position) = 0;
virtual void windowBorder() = 0;
virtual windowDimension getAvailableSpace() = 0;
virtual void moveCursor(windowPosition position) = 0;
};
}
#endif /* C51BA18F_0915_43B9_BD5D_129F0CDBC1CD */