[C++] API sync

Changed:

 * Visual: tiny reformatting to fit the overall ncpp style
 * Visual: added error guard in `render`
 * Visual: error_guard update in `rotate`

Added:

 * Visual: simple_streamer (`ncvisual_simple_streamer`)
 * Visual: polyfill (`ncvisual_polyfill_yx`)
 * Visual: at (`ncvisual_at_yx`)
 * Visual: set (`ncvisual_set_yx`)
pull/690/head
Marek Habersack 4 years ago committed by Nick Black
parent 841c0a4b8f
commit 4d2e4e82d3

@ -17,28 +17,28 @@ namespace ncpp
{ {
public: public:
explicit Visual (const char *file, nc_err_e *ncerr) explicit Visual (const char *file, nc_err_e *ncerr)
: Root(NotCurses::get_instance()) : Root (NotCurses::get_instance ())
{ {
visual = ncvisual_from_file (file, ncerr); visual = ncvisual_from_file (file, ncerr);
if (visual == nullptr) if (visual == nullptr)
throw init_error ("Notcurses failed to create a new visual"); throw init_error ("Notcurses failed to create a new visual");
} }
explicit Visual (const uint32_t* rgba, int rows, int rowstride, int cols) explicit Visual (const uint32_t* rgba, int rows, int rowstride, int cols)
: Root(NotCurses::get_instance()) : Root (NotCurses::get_instance ())
{ {
visual = ncvisual_from_rgba (rgba, rows, rowstride, cols); visual = ncvisual_from_rgba (rgba, rows, rowstride, cols);
if (visual == nullptr) if (visual == nullptr)
throw init_error ("Notcurses failed to create a new visual"); throw init_error ("Notcurses failed to create a new visual");
} }
explicit Visual (const Plane& p, ncblitter_e blit, int begy, int begx, int leny, int lenx) explicit Visual (const Plane& p, ncblitter_e blit, int begy, int begx, int leny, int lenx)
: Root(NotCurses::get_instance()) : Root (NotCurses::get_instance ())
{ {
visual = ncvisual_from_plane (p, blit, begy, begx, leny, lenx); visual = ncvisual_from_plane (p, blit, begy, begx, leny, lenx);
if (visual == nullptr) if (visual == nullptr)
throw init_error ("Notcurses failed to create a new visual"); throw init_error ("Notcurses failed to create a new visual");
} }
~Visual () noexcept ~Visual () noexcept
{ {
@ -63,7 +63,7 @@ namespace ncpp
ncplane* render (const ncvisual_options* vopts) const NOEXCEPT_MAYBE ncplane* render (const ncvisual_options* vopts) const NOEXCEPT_MAYBE
{ {
return ncvisual_render (get_notcurses (), visual, vopts); // FIXME error_guard return error_guard<ncplane*, ncplane*> (ncvisual_render (get_notcurses (), visual, vopts), nullptr);
} }
int stream (const ncvisual_options* vopts, nc_err_e* ncerr, float timescale, streamcb streamer, void *curry = nullptr) const NOEXCEPT_MAYBE int stream (const ncvisual_options* vopts, nc_err_e* ncerr, float timescale, streamcb streamer, void *curry = nullptr) const NOEXCEPT_MAYBE
@ -78,7 +78,31 @@ namespace ncpp
bool rotate (double rads) const NOEXCEPT_MAYBE bool rotate (double rads) const NOEXCEPT_MAYBE
{ {
return error_guard (ncvisual_rotate (visual, rads), NCERR_SUCCESS); // FIXME invert case nc_err_e ret = ncvisual_rotate (visual, rads);
return error_guard_cond (ret, ret != NCERR_SUCCESS);
}
bool simple_streamer (ncvisual_options* vopts, const timespec* tspec, void* curry = nullptr) const NOEXCEPT_MAYBE
{
return error_guard (ncvisual_simple_streamer (visual, vopts, tspec, curry), -1);
}
int polyfill (int y, int x, uint32_t rgba) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncvisual_polyfill_yx (visual, y, x, rgba), -1);
}
bool at (int y, int x, uint32_t* pixel) const
{
if (pixel == nullptr)
throw invalid_argument ("'pixel' must be a valid pointer");
return error_guard (ncvisual_at_yx (visual, y, x, pixel), -1);
}
bool set (int y, int x, uint32_t pixel) const NOEXCEPT_MAYBE
{
return error_guard (ncvisual_set_yx (visual, y, x, pixel), -1);
} }
private: private:

Loading…
Cancel
Save