Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
Pile.hh
Go to the documentation of this file.
1#ifndef __NCPP_PILE_HH
2#define __NCPP_PILE_HH
3
4#include <exception>
6
7#include "NotCurses.hh"
8#include "Plane.hh"
9
10namespace ncpp
11{
12 class NCPP_API_EXPORT Pile : public Plane
13 {
14 public:
15 Pile (ncplane_options const* nopts, NotCurses* ncinst = nullptr)
16 : Plane (ncinst)
17 {
18 if (nopts == nullptr) {
19 throw invalid_argument ("'nopts' must be a valid pointer");
20 }
21
22 notcurses *n;
23 if (ncinst == nullptr) {
24 n = NotCurses::get_instance ();
25 } else {
26 n = *ncinst;
27 }
28
29 ncplane *pile = ncpile_create (n, nopts);
30 if (pile == nullptr) {
31 throw init_error ("Notcurses failed to create a new pile");
32 }
33
34 set_plane (pile);
35 }
36
37 bool render () const NOEXCEPT_MAYBE
38 {
39 return error_guard (ncpile_render (to_ncplane ()), -1);
40 }
41
43 {
44 return error_guard (ncpile_rasterize (to_ncplane ()), -1);
45 }
46
47 bool show () const NOEXCEPT_MAYBE
48 {
49 if (!render ()) {
50 return false;
51 }
52
53 return rasterize ();
54 }
55
56 static Plane* top_with (const Plane& plane) noexcept
57 {
58 ncplane* ret = ncpile_top (const_cast<Plane&>(plane));
59 if (ret == nullptr) {
60 return nullptr;
61 }
62
63 return map_plane (ret);
64 }
65
66 static Plane* bottom_with (const Plane& plane) noexcept
67 {
68 ncplane* ret = ncpile_bottom (const_cast<Plane&>(plane));
69 if (ret == nullptr) {
70 return nullptr;
71 }
72
73 return map_plane (ret);
74 }
75 };
76}
77#endif
#define NCPP_API_EXPORT
Definition _helpers.hh:9
#define NOEXCEPT_MAYBE
Definition Root.hh:15
static Plane * top_with(const Plane &plane) noexcept
Definition Pile.hh:56
bool render() const NOEXCEPT_MAYBE
Definition Pile.hh:37
bool rasterize() const NOEXCEPT_MAYBE
Definition Pile.hh:42
Pile(ncplane_options const *nopts, NotCurses *ncinst=nullptr)
Definition Pile.hh:15
bool show() const NOEXCEPT_MAYBE
Definition Pile.hh:47
static Plane * bottom_with(const Plane &plane) noexcept
Definition Pile.hh:66
ncplane * ncpile_top(ncplane *n)
Definition notcurses.c:2540
ncplane * ncpile_create(notcurses *nc, const struct ncplane_options *nopts)
Definition notcurses.c:711
ncplane * ncpile_bottom(ncplane *n)
Definition notcurses.c:2544
vopts n
Definition notcurses.h:3502
int ncpile_render(ncplane *n)
Definition render.c:1569
int ncpile_rasterize(ncplane *n)
Definition render.c:1517