Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
Progbar.hh
Go to the documentation of this file.
1#ifndef __NCPP_PROGBAR_HH
2#define __NCPP_PROGBAR_HH
3
4#include <exception>
6
7#include "NotCurses.hh"
8#include "Plane.hh"
9
10namespace ncpp
11{
13 {
14 public:
16 : Root (nullptr)
17 {
18 if (opts == nullptr) {
19 throw invalid_argument ("Argument 'opts' must be a valid pointer");
20 }
21
22 progbar = ncprogbar_create (n, opts);
23 if (progbar == nullptr) {
24 throw init_error ("Notcurses failed to create ncprogbar");
25 }
26 }
27
29 {
30 if (!is_notcurses_stopped ()) {
31 ncprogbar_destroy (progbar);
32 }
33 }
34
35 Plane* get_plane () const noexcept
36 {
37 ncplane *ret = ncprogbar_plane (progbar);
38 if (ret == nullptr) {
39 return nullptr;
40 }
41
42 return Plane::map_plane (ret);
43 }
44
45 void set_progress (double p) const noexcept
46 {
47 ncprogbar_set_progress (progbar, p);
48 }
49
50 double get_progress () const noexcept
51 {
52 return ncprogbar_progress (progbar);
53 }
54
55 private:
56 ncprogbar *progbar = nullptr;
57 };
58}
59
60#endif // __NCPP_PROGBAR_HH
#define NCPP_API_EXPORT
Definition _helpers.hh:9
double get_progress() const noexcept
Definition Progbar.hh:50
Progbar(Plane &n, const ncprogbar_options *opts)
Definition Progbar.hh:15
Plane * get_plane() const noexcept
Definition Progbar.hh:35
void set_progress(double p) const noexcept
Definition Progbar.hh:45
const struct ncplane_options * opts
Definition notcurses.h:3483
vopts n
Definition notcurses.h:3502
ncprogbar * ncprogbar_create(ncplane *n, const ncprogbar_options *opts)
Definition progbar.c:4
ncplane * ncprogbar_plane(ncprogbar *n)
Definition progbar.c:32
void ncprogbar_destroy(ncprogbar *n)
Definition progbar.c:190
int ncprogbar_set_progress(ncprogbar *n, double p)
Definition progbar.c:176
double ncprogbar_progress(const ncprogbar *n)
Definition progbar.c:186