mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
[C++] API sync
New classes: * MultiSelector (`ncmultiselector_*`) Added: * Direct: cursor_{enable,disable} * Plane: high_gradient (`ncplane_highgradient`) * Plane: high_gradient_sized (`ncplane_highgradient_sized`) * Plane: rotate_cw (`ncplane_rotate_cw`) * Plane: rotate_ccw (`ncplane_rotate_ccw`) Updated: * NotCurses: added all the margin initializers to the default options
This commit is contained in:
parent
ba90c70a47
commit
3e78dd7d1f
@ -162,6 +162,7 @@ target_compile_definitions(notcurses-static
|
||||
# libnotcurses++
|
||||
set(NCPP_SOURCES
|
||||
src/libcpp/Menu.cc
|
||||
src/libcpp/MultiSelector.cc
|
||||
src/libcpp/NotCurses.cc
|
||||
src/libcpp/Plane.cc
|
||||
src/libcpp/Reel.cc
|
||||
|
@ -84,10 +84,20 @@ namespace ncpp
|
||||
ncdirect_styles_off (direct, static_cast<unsigned>(stylebits));
|
||||
}
|
||||
|
||||
int cursor_move_yx (int y, int x) const noexcept
|
||||
{
|
||||
return ncdirect_cursor_move_yx (direct, y, x);
|
||||
}
|
||||
int cursor_move_yx (int y, int x) const noexcept
|
||||
{
|
||||
return ncdirect_cursor_move_yx (direct, y, x);
|
||||
}
|
||||
|
||||
bool cursor_enable () const noexcept
|
||||
{
|
||||
return ncdirect_cursor_enable (direct) != -1;
|
||||
}
|
||||
|
||||
bool cursor_disable () const noexcept
|
||||
{
|
||||
return ncdirect_cursor_disable (direct) != -1;
|
||||
}
|
||||
|
||||
private:
|
||||
ncdirect *direct;
|
||||
|
67
include/ncpp/MultiSelector.hh
Normal file
67
include/ncpp/MultiSelector.hh
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef __NCPP_MULTI_SELECTOR_HH
|
||||
#define __NCPP_MULTI_SELECTOR_HH
|
||||
|
||||
#include <notcurses/notcurses.h>
|
||||
|
||||
#include "Root.hh"
|
||||
#include "NCAlign.hh"
|
||||
|
||||
namespace ncpp
|
||||
{
|
||||
class Plane;
|
||||
|
||||
class NCPP_API_EXPORT MultiSelector : public Root
|
||||
{
|
||||
public:
|
||||
static multiselector_options default_options;
|
||||
|
||||
public:
|
||||
explicit MultiSelector (Plane *plane, int y, int x, const multiselector_options *opts = nullptr)
|
||||
: MultiSelector (reinterpret_cast<ncplane*>(plane), y, x, opts)
|
||||
{}
|
||||
|
||||
explicit MultiSelector (Plane const* plane, int y, int x, const multiselector_options *opts = nullptr)
|
||||
: MultiSelector (const_cast<Plane*>(plane), y, x, opts)
|
||||
{}
|
||||
|
||||
explicit MultiSelector (Plane &plane, int y, int x, const multiselector_options *opts = nullptr)
|
||||
: MultiSelector (reinterpret_cast<ncplane*>(&plane), y, x, opts)
|
||||
{}
|
||||
|
||||
explicit MultiSelector (Plane const& plane, int y, int x, const multiselector_options *opts = nullptr)
|
||||
: MultiSelector (const_cast<Plane*>(&plane), y, x, opts)
|
||||
{}
|
||||
|
||||
explicit MultiSelector (ncplane *plane, int y, int x, const multiselector_options *opts = nullptr)
|
||||
{
|
||||
if (plane == nullptr)
|
||||
throw invalid_argument ("'plane' must be a valid pointer");
|
||||
|
||||
multiselector = ncmultiselector_create (plane, y, x, opts == nullptr ? &default_options : opts);
|
||||
if (multiselector == nullptr)
|
||||
throw init_error ("notcurses failed to create a new multiselector");
|
||||
}
|
||||
|
||||
~MultiSelector ()
|
||||
{
|
||||
if (!is_notcurses_stopped ())
|
||||
ncmultiselector_destroy (multiselector, nullptr);
|
||||
}
|
||||
|
||||
bool offer_input (const struct ncinput *nc) const noexcept
|
||||
{
|
||||
return ncmultiselector_offer_input (multiselector, nc);
|
||||
}
|
||||
|
||||
const int get_selected (bool *selected, unsigned count) const noexcept
|
||||
{
|
||||
return ncmultiselector_selected (multiselector, selected, count);
|
||||
}
|
||||
|
||||
Plane* get_plane () const noexcept;
|
||||
|
||||
private:
|
||||
ncmultiselector *multiselector;
|
||||
};
|
||||
}
|
||||
#endif
|
@ -128,6 +128,16 @@ namespace ncpp
|
||||
return ncplane_gradient_sized (plane, egc, attrword, ul, ur, ll, lr, ylen, xstop) != -1;
|
||||
}
|
||||
|
||||
bool high_gradient (uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const noexcept
|
||||
{
|
||||
return ncplane_highgradient (plane, ul, ur, ll, lr, ylen, xlen) != -1;
|
||||
}
|
||||
|
||||
bool high_gradient_sized (uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const noexcept
|
||||
{
|
||||
return ncplane_highgradient_sized (plane, ul, ur, ll, lr, ylen, xlen) != -1;
|
||||
}
|
||||
|
||||
void greyscale () const noexcept
|
||||
{
|
||||
ncplane_greyscale (plane);
|
||||
@ -876,11 +886,21 @@ namespace ncpp
|
||||
ncplane_translate (src.plane, dst.plane, y, x);
|
||||
}
|
||||
|
||||
bool translate_abs (int *y = nullptr, int *x = nullptr)
|
||||
bool translate_abs (int *y = nullptr, int *x = nullptr) noexcept
|
||||
{
|
||||
return ncplane_translate_abs (*this, y, x);
|
||||
}
|
||||
|
||||
bool rotate_cw () const noexcept
|
||||
{
|
||||
return ncplane_rotate_cw (plane) != -1;
|
||||
}
|
||||
|
||||
bool rotate_ccw () const noexcept
|
||||
{
|
||||
return ncplane_rotate_ccw (plane) != -1;
|
||||
}
|
||||
|
||||
// Upstream call doesn't take ncplane* but we put it here for parity with has_no_background below
|
||||
bool has_no_foreground (Cell &cell) const noexcept
|
||||
{
|
||||
|
24
src/libcpp/MultiSelector.cc
Normal file
24
src/libcpp/MultiSelector.cc
Normal file
@ -0,0 +1,24 @@
|
||||
#include <ncpp/Plane.hh>
|
||||
#include <ncpp/MultiSelector.hh>
|
||||
|
||||
using namespace ncpp;
|
||||
|
||||
multiselector_options MultiSelector::default_options = {
|
||||
/* title */ nullptr,
|
||||
/* secondary */ nullptr,
|
||||
/* footer */ nullptr,
|
||||
/* items */ nullptr,
|
||||
/* itemcount */ 0,
|
||||
/* maxdisplay */ 0,
|
||||
/* opchannels */ 0,
|
||||
/* descchannels */ 0,
|
||||
/* titlechannels */ 0,
|
||||
/* footchannels */ 0,
|
||||
/* boxchannels */ 0,
|
||||
/* bgchannels */ 0,
|
||||
};
|
||||
|
||||
Plane* MultiSelector::get_plane () const noexcept
|
||||
{
|
||||
return Plane::map_plane (ncmultiselector_plane (multiselector));
|
||||
}
|
@ -12,6 +12,10 @@ notcurses_options NotCurses::default_notcurses_options = {
|
||||
/* no_winch_sighandler */ false,
|
||||
/* renderfp */ nullptr,
|
||||
/* loglevel */ NCLogLevel::Silent,
|
||||
/* margin_t */ 0,
|
||||
/* margin_r */ 0,
|
||||
/* margin_b */ 0,
|
||||
/* margin_l */ 0,
|
||||
};
|
||||
|
||||
NotCurses *NotCurses::_instance = nullptr;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <ncpp/Menu.hh>
|
||||
#include <ncpp/Plane.hh>
|
||||
#include <ncpp/Reel.hh>
|
||||
#include <ncpp/MultiSelector.hh>
|
||||
#include <ncpp/Selector.hh>
|
||||
#include <ncpp/Visual.hh>
|
||||
#include <ncpp/Direct.hh>
|
||||
|
Loading…
x
Reference in New Issue
Block a user