mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
introduce ncplane_resize_realign #364
This commit is contained in:
parent
bfdf801a12
commit
2d9598b913
4
NEWS.md
4
NEWS.md
@ -12,6 +12,10 @@ rearrangements of Notcurses.
|
||||
* The `ncplane_options` struct includes a function pointer member,
|
||||
`resizecb`. If not `NULL`, this function will be called after the parent
|
||||
plane is resized. See `notcurses_plane.3` for more information.
|
||||
* `ncplane_resize_realign()` has been added, suitable for use as a
|
||||
`resizecb`. It realigns the plane against its parent.
|
||||
* `NCCHANNEL_ALPHA_MASK` has been renamed `CHANNEL_ALPHA_MASK`, to match
|
||||
the other declarations.
|
||||
|
||||
* 1.7.3 (2020-09-19)
|
||||
* API changes pursuant to 2.0 API finalization:
|
||||
|
@ -96,7 +96,7 @@ API int notcurses_ucs32_to_utf8(const char32_t* ucs32, unsigned ucs32count,
|
||||
unsigned char* resultbuf, size_t buflen);
|
||||
|
||||
// extract these bits to get a channel's alpha value
|
||||
#define NCCHANNEL_ALPHA_MASK 0x30000000ull
|
||||
#define CHANNEL_ALPHA_MASK 0x30000000ull
|
||||
// background cannot be highcontrast, only foreground
|
||||
#define CELL_ALPHA_HIGHCONTRAST 0x30000000ull
|
||||
#define CELL_ALPHA_TRANSPARENT 0x20000000ull
|
||||
@ -124,7 +124,7 @@ API int notcurses_ucs32_to_utf8(const char32_t* ucs32, unsigned ucs32count,
|
||||
// palette-indexed foreground color
|
||||
#define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u)
|
||||
// extract these bits to get the background alpha mask
|
||||
#define CELL_BG_ALPHA_MASK NCCHANNEL_ALPHA_MASK
|
||||
#define CELL_BG_ALPHA_MASK CHANNEL_ALPHA_MASK
|
||||
// extract these bits to get the foreground alpha mask
|
||||
#define CELL_FG_ALPHA_MASK (CELL_BG_ALPHA_MASK << 32u)
|
||||
|
||||
@ -223,16 +223,16 @@ channel_set(unsigned* channel, unsigned rgb){
|
||||
// Extract the 2-bit alpha component from a 32-bit channel.
|
||||
static inline unsigned
|
||||
channel_alpha(unsigned channel){
|
||||
return channel & NCCHANNEL_ALPHA_MASK;
|
||||
return channel & CHANNEL_ALPHA_MASK;
|
||||
}
|
||||
|
||||
// Set the 2-bit alpha component of the 32-bit channel.
|
||||
static inline int
|
||||
channel_set_alpha(unsigned* channel, unsigned alpha){
|
||||
if(alpha & ~NCCHANNEL_ALPHA_MASK){
|
||||
if(alpha & ~CHANNEL_ALPHA_MASK){
|
||||
return -1;
|
||||
}
|
||||
*channel = alpha | (*channel & ~NCCHANNEL_ALPHA_MASK);
|
||||
*channel = alpha | (*channel & ~CHANNEL_ALPHA_MASK);
|
||||
if(alpha != CELL_ALPHA_OPAQUE){
|
||||
*channel |= CELL_BGDEFAULT_MASK;
|
||||
}
|
||||
@ -1036,6 +1036,10 @@ ncplane_new(struct ncplane* n, int rows, int cols, int y, int x, void* opaque, c
|
||||
return ncplane_create(n, &nopts);
|
||||
}
|
||||
|
||||
// Suitable for use as a `resizecb`. This will realign the plane 'n' against its
|
||||
// parent, using the alignment specified at ncplane_create()-time.
|
||||
API int ncplane_resize_realign(struct ncplane* n);
|
||||
|
||||
// Plane 'n' will be unbound from its parent plane, if it is currently bound,
|
||||
// and will be made a bound child of 'newparent', if 'newparent' is not NULL.
|
||||
API struct ncplane* ncplane_reparent(struct ncplane* n, struct ncplane* newparent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user