mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
da0283ac25
Get rid of annoying empty line in notcurses-view (and ncvisuals at offsets in general) Implement most of the Selector widget. Need to add styling and scrolling still. #166 Reenable ubuntu focal build Subtitles! We decode them, and display them in notcurses-view. If ncvisual_simple_streamer() is provided an extra ncplane, it will use it to display subtitles. #95 We now build Python by default, as things are working much better. ncplane_set_base() now takes channel, attrword, and EGC, so you can usually avoid having to set up and release a cell. ncplane_set_base_cell() takes over duty from ncplane_set_base() for ease of conversion. notcurses-demo and notcurses-view now both accept a 0 for delay multiplier, meaning 'go as fast as you possibly can'. Very small multipliers (e.g. 0.00001) no longer cause floating point exceptions. fading routines no longer cause floating point exceptions on very small timescales.
84 lines
1.9 KiB
C++
84 lines
1.9 KiB
C++
#ifndef __NCPP_VISUAL_HH
|
|
#define __NCPP_VISUAL_HH
|
|
|
|
#include <notcurses.h>
|
|
|
|
#include "Root.hh"
|
|
#include "NCScale.hh"
|
|
|
|
namespace ncpp
|
|
{
|
|
class Plane;
|
|
|
|
class NCPP_API_EXPORT Visual : public Root
|
|
{
|
|
public:
|
|
explicit Visual (Plane *plane, const char *file, int *averr)
|
|
: Visual (reinterpret_cast<ncplane*>(plane), file, averr)
|
|
{}
|
|
|
|
explicit Visual (ncplane *plane, const char *file, int *averr)
|
|
{
|
|
if (plane == nullptr)
|
|
throw new invalid_argument ("'plane' must be a valid pointer");
|
|
|
|
visual = ncplane_visual_open (reinterpret_cast<ncplane*>(plane), file, averr);
|
|
if (visual == nullptr)
|
|
throw new init_error ("notcurses failed to create a new visual");
|
|
}
|
|
|
|
explicit Visual (const char *file, int *averr, int y, int x, NCScale scale)
|
|
{
|
|
visual = ncvisual_open_plane (get_notcurses (), file, averr, y, x, static_cast<ncscale_e>(scale));
|
|
if (visual == nullptr)
|
|
throw new init_error ("notcurses failed to create a new visual");
|
|
}
|
|
|
|
~Visual () noexcept
|
|
{
|
|
destroy_plane (get_plane ());
|
|
if (!is_notcurses_stopped ())
|
|
ncvisual_destroy (visual);
|
|
}
|
|
|
|
operator ncvisual* () const noexcept
|
|
{
|
|
return visual;
|
|
}
|
|
|
|
operator ncvisual const* () const noexcept
|
|
{
|
|
return visual;
|
|
}
|
|
|
|
AVFrame* decode (int *averr) const noexcept
|
|
{
|
|
return ncvisual_decode (visual, averr);
|
|
}
|
|
|
|
bool render (int begy, int begx, int leny, int lenx) const noexcept
|
|
{
|
|
return ncvisual_render (visual, begy, begx, leny, lenx) != -1;
|
|
}
|
|
|
|
int stream (int *averr, float timescale, streamcb streamer, void *curry = nullptr) const noexcept
|
|
{
|
|
return ncvisual_stream (get_notcurses (), visual, averr, timescale, streamer, curry);
|
|
}
|
|
|
|
char* subtitle () const noexcept
|
|
{
|
|
return ncvisual_subtitle (visual);
|
|
}
|
|
|
|
Plane* get_plane () const noexcept;
|
|
|
|
private:
|
|
static void destroy_plane (Plane *plane) noexcept;
|
|
|
|
private:
|
|
ncvisual *visual = nullptr;
|
|
};
|
|
}
|
|
#endif
|