mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 09:39:03 -04:00
Added: * Plane: gradient (`ncplane_gradient`) * Plane: gradient_sized (`ncplane_gradient_sized`) * NotCurses: drop_planes (`ncplane_drop_planes`) * NcReel: constructor which takes `Plane&` * Visual: constructors which take `Plane const*`, `Plane&` and `Plane const&`) * ncpp_build: a nonsensical "demo" which exists purely to test whether the C++ builds and does absolutely nothing interesting. Broke: * All exceptions throw temporary objects instead of allocated instances. Less typing in `catch` :P (and more conventional)
78 lines
1.3 KiB
C++
78 lines
1.3 KiB
C++
#ifndef __NCPP_MENU_HH
|
|
#define __NCPP_MENU_HH
|
|
|
|
#include <notcurses.h>
|
|
|
|
#include "Root.hh"
|
|
|
|
namespace ncpp
|
|
{
|
|
class Plane;
|
|
|
|
class NCPP_API_EXPORT Menu : public Root
|
|
{
|
|
public:
|
|
static ncmenu_options default_options;
|
|
|
|
public:
|
|
explicit Menu (const ncmenu_options *opts = nullptr)
|
|
{
|
|
menu = ncmenu_create (get_notcurses (), opts == nullptr ? &default_options : opts);
|
|
if (menu == nullptr)
|
|
throw init_error ("notcurses failed to create a new menu");
|
|
}
|
|
|
|
~Menu ()
|
|
{
|
|
if (!is_notcurses_stopped ())
|
|
ncmenu_destroy (menu);
|
|
}
|
|
|
|
bool unroll (int sectionidx) const noexcept
|
|
{
|
|
return ncmenu_unroll (menu, sectionidx) >= 0;
|
|
}
|
|
|
|
bool rollup () const noexcept
|
|
{
|
|
return ncmenu_rollup (menu) >= 0;
|
|
}
|
|
|
|
bool nextsection () const noexcept
|
|
{
|
|
return ncmenu_nextsection (menu) >= 0;
|
|
}
|
|
|
|
bool prevsection () const noexcept
|
|
{
|
|
return ncmenu_prevsection (menu) >= 0;
|
|
}
|
|
|
|
bool nextitem () const noexcept
|
|
{
|
|
return ncmenu_nextitem (menu) >= 0;
|
|
}
|
|
|
|
bool previtem () const noexcept
|
|
{
|
|
return ncmenu_previtem (menu) >= 0;
|
|
}
|
|
|
|
const char* get_selected (ncinput *ni = nullptr) const noexcept
|
|
{
|
|
return ncmenu_selected (menu, ni);
|
|
}
|
|
|
|
bool offer_input (const struct ncinput* nc) const noexcept
|
|
{
|
|
return ncmenu_offer_input (menu, nc);
|
|
}
|
|
|
|
Plane* get_plane () const noexcept;
|
|
|
|
private:
|
|
ncmenu *menu;
|
|
};
|
|
}
|
|
#endif
|