rotation: ncvisual, not ncplane #515

This commit is contained in:
nick black 2020-05-04 00:51:42 -04:00 committed by Nick Black
parent 0b22b561d2
commit 0135a6b54d
6 changed files with 24 additions and 22 deletions

View File

@ -124,10 +124,6 @@ notcurses_plane - operations on ncplanes
**int ncblit_rgba(struct ncplane* nc, int placey, int placex, int linesize, const unsigned char* data, int begy, int begx, int leny, int lenx);**
**int ncplane_rotate_cw(struct ncplane* n);**
**int ncplane_rotate_ccw(struct ncplane* n);**
**int ncplane_destroy(struct ncplane* ncp);**
**void notcurses_drop_planes(struct notcurses* nc);**

View File

@ -42,6 +42,11 @@ typedef int (*streamcb)(struct notcurses*, struct ncvisual*, void*);
**struct ncplane* ncvisual_plane(struct ncvisual* ncv);**
**int ncplane_rotate_cw(struct ncplane* n);**
**int ncplane_rotate_ccw(struct ncplane* n);**
# DESCRIPTION
The frame will be scaled to the size of the ncplane per the ncscale_e style.
@ -54,6 +59,9 @@ or **begx** are an error. It is an error to specify any region beyond the
boundaries of the frame. Supplying zero for either **leny** or **lenx** will
result in a zero-area rendering.
Both **ncplane_rotate_cw** and **ncplane_rotate_ccw** execute a rotation of
π/2 radians, in the clockwise or counterclockwise direction respectively.
# RETURN VALUES
**notcurses_canopen** returns true if this functionality is enabled, or false

View File

@ -979,16 +979,6 @@ namespace ncpp
return error_guard<bool, bool> (ncplane_translate_abs (plane, y, x), false);
}
bool rotate_cw () const NOEXCEPT_MAYBE
{
return error_guard (ncplane_rotate_cw (plane), -1);
}
bool rotate_ccw () const noexcept
{
return error_guard (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
{

View File

@ -84,6 +84,16 @@ namespace ncpp
Plane* get_plane () const noexcept;
bool rotate_cw () const NOEXCEPT_MAYBE
{
return error_guard (ncvisual_rotate_cw (visual), -1);
}
bool rotate_ccw () const noexcept
{
return error_guard (ncvisual_rotate_ccw (visual), -1);
}
private:
ncvisual *visual = nullptr;
};

View File

@ -1129,12 +1129,10 @@ ncplane_move_below(struct ncplane* n, struct ncplane* below){
// Return the plane below this one, or NULL if this is at the bottom.
API struct ncplane* ncplane_below(struct ncplane* n);
// Rotate the plane pi/2 radians clockwise or counterclockwise. Note that
// rotation only applies to geometry and color. Most glyphs cannot be rotated.
// The resulting plane is thus populated only by null glyphs, spaces, full
// blocks, and partial blocks.
API int ncplane_rotate_cw(struct ncplane* n);
API int ncplane_rotate_ccw(struct ncplane* n);
// Rotate the visual π/2 radians clockwise or counterclockwise. This cannot
// be performed on arbitrary planes, because glyphs cannot be arbitrarily rotated.
API int ncvisual_rotate_cw(struct ncvisual* n);
API int ncvisual_rotate_ccw(struct ncvisual* n);
// Retrieve the current contents of the cell under the cursor. The EGC is
// returned, or NULL on error. This EGC must be free()d by the caller. The

View File

@ -425,8 +425,8 @@ int ncplane_putegc_stainable(struct ncplane* n, const char* gclust, int* sbytes)
int ncplane_putwegc_stainable(struct ncplane* n, const wchar_t* gclust, int* sbytes);
int ncplane_format(struct ncplane* n, int ystop, int xstop, uint32_t attrword);
int ncplane_stain(struct ncplane* n, int ystop, int xstop, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr);
int ncplane_rotate_cw(struct ncplane* n);
int ncplane_rotate_ccw(struct ncplane* n);
int ncvisual_rotate_cw(struct ncvisual* n);
int ncvisual_rotate_ccw(struct ncvisual* n);
void ncplane_translate(const struct ncplane* src, const struct ncplane* dst, int* y, int* x);
bool ncplane_translate_abs(const struct ncplane* n, int* y, int* x);
typedef enum {