From 0135a6b54dc19d85fb68a19abd168488f9e4408c Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 4 May 2020 00:51:42 -0400 Subject: [PATCH] rotation: ncvisual, not ncplane #515 --- doc/man/man3/notcurses_plane.3.md | 4 ---- doc/man/man3/notcurses_visual.3.md | 8 ++++++++ include/ncpp/Plane.hh | 10 ---------- include/ncpp/Visual.hh | 10 ++++++++++ include/notcurses/notcurses.h | 10 ++++------ python/src/notcurses/build_notcurses.py | 4 ++-- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/doc/man/man3/notcurses_plane.3.md b/doc/man/man3/notcurses_plane.3.md index f6f0b963f..146e449ee 100644 --- a/doc/man/man3/notcurses_plane.3.md +++ b/doc/man/man3/notcurses_plane.3.md @@ -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);** diff --git a/doc/man/man3/notcurses_visual.3.md b/doc/man/man3/notcurses_visual.3.md index e95d72fd9..33c177e02 100644 --- a/doc/man/man3/notcurses_visual.3.md +++ b/doc/man/man3/notcurses_visual.3.md @@ -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 diff --git a/include/ncpp/Plane.hh b/include/ncpp/Plane.hh index c8d6d329f..67c6cca5b 100644 --- a/include/ncpp/Plane.hh +++ b/include/ncpp/Plane.hh @@ -979,16 +979,6 @@ namespace ncpp return error_guard (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 { diff --git a/include/ncpp/Visual.hh b/include/ncpp/Visual.hh index d29562621..000e58778 100644 --- a/include/ncpp/Visual.hh +++ b/include/ncpp/Visual.hh @@ -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; }; diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 6a1ab6fc0..79295f3ba 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -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 diff --git a/python/src/notcurses/build_notcurses.py b/python/src/notcurses/build_notcurses.py index d1dd51fce..7e76e42a1 100644 --- a/python/src/notcurses/build_notcurses.py +++ b/python/src/notcurses/build_notcurses.py @@ -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 {