Automerge feature. (#313)

Add the `automerge` attribute to the Pixel bit field. It controls
whether two pixels must be automerged. Defining this allows two
mergeable characters not to be merged.

This was requested by:
https://github.com/ArthurSonzogni/FTXUI/issues/285
This commit is contained in:
Arthur Sonzogni
2022-01-22 15:38:01 +01:00
committed by GitHub
parent 4267b40a68
commit 6039474a26
5 changed files with 56 additions and 22 deletions

View File

@@ -31,7 +31,9 @@ class Separator : public Node {
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {
screen.PixelAt(x, y).character = value_;
Pixel& pixel = screen.PixelAt(x, y);
pixel.character = value_;
pixel.automerge = true;
}
}
}
@@ -56,7 +58,9 @@ class SeparatorAuto : public Node {
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {
screen.PixelAt(x, y).character = c;
Pixel& pixel = screen.PixelAt(x, y);
pixel.character = c;
pixel.automerge = true;
}
}
}
@@ -66,7 +70,9 @@ class SeparatorAuto : public Node {
class SeparatorWithPixel : public SeparatorAuto {
public:
SeparatorWithPixel(Pixel pixel) : SeparatorAuto(LIGHT), pixel_(pixel) {}
SeparatorWithPixel(Pixel pixel) : SeparatorAuto(LIGHT), pixel_(pixel) {
pixel_.automerge = true;
}
void Render(Screen& screen) override {
for (int y = box_.y_min; y <= box_.y_max; ++y) {
for (int x = box_.x_min; x <= box_.x_max; ++x) {