notcurses/include/ncpp/Pile.hh
Marek Habersack d32bef358d [C++] API sync
After a long delay, apologies :)

Added:
  * NotCurses: `can_sextant` (`notcurses_cansextant`)
  * Notcurses: `linesigs_enable` (`notcurses_linesigs_enable`)
  * Notcurses: `linesigs_disable` (`notcurses_linesigs_disable`)
  * Pile: `top_with` (`ncpile_top`)
  * Pile: `bottom_with` (`ncpile_bottom`)
  * Plane: `resize_maximize` (`ncplane_resize_maximize`)
  * Plane: `get_abs_x` (`ncplane_abs_x`)
  * Plane: `get_abs_y` (`ncplane_abs_y`)
  * Plane: `get_abs_yx` (`ncplane_abs_yx`)
  * Plane: `load_egc32` (`cell_load_egc32`)
  * Plane: `is_descendant_of` (`ncplane_descendant_p`)
  * Progbar: new class, wraps `ncprogbar_*`

Changed:
  * Plane (ABI break): `at_cursor` overloads now return `int` where
    before they returned `bool` because the underlying Notcurses API
    only signalled the operation status with the return value while now
    it returns actual information.
2021-02-07 23:10:24 -05:00

78 lines
1.4 KiB
C++

#ifndef __NCPP_PILE_HH
#define __NCPP_PILE_HH
#include <exception>
#include <notcurses/notcurses.h>
#include "NotCurses.hh"
#include "Plane.hh"
namespace ncpp
{
class NCPP_API_EXPORT Pile : public Plane
{
public:
Pile (ncplane_options const* nopts, NotCurses* ncinst = nullptr)
: Plane (ncinst)
{
if (nopts == nullptr) {
throw invalid_argument ("'nopts' must be a valid pointer");
}
notcurses *n;
if (ncinst == nullptr) {
n = NotCurses::get_instance ();
} else {
n = *ncinst;
}
ncplane *pile = ncpile_create (n, nopts);
if (pile == nullptr) {
throw init_error ("Notcurses failed to create a new pile");
}
set_plane (pile);
}
bool render () const NOEXCEPT_MAYBE
{
return error_guard (ncpile_render (to_ncplane ()), -1);
}
bool rasterize () const NOEXCEPT_MAYBE
{
return error_guard (ncpile_rasterize (to_ncplane ()), -1);
}
bool show () const NOEXCEPT_MAYBE
{
if (!render ()) {
return false;
}
return rasterize ();
}
static Plane* top_with (const Plane& plane) noexcept
{
ncplane* ret = ncpile_top (const_cast<Plane&>(plane));
if (ret == nullptr) {
return nullptr;
}
return map_plane (ret);
}
static Plane* bottom_with (const Plane& plane) noexcept
{
ncplane* ret = ncpile_bottom (const_cast<Plane&>(plane));
if (ret == nullptr) {
return nullptr;
}
return map_plane (ret);
}
};
}
#endif