mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-17 16:38:09 +08:00
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:
@@ -89,13 +89,22 @@ class Border : public Node {
|
||||
screen.at(box_.x_max, box_.y_min) = charset[1];
|
||||
screen.at(box_.x_min, box_.y_max) = charset[2];
|
||||
screen.at(box_.x_max, box_.y_max) = charset[3];
|
||||
|
||||
for (float x = box_.x_min + 1; x < box_.x_max; ++x) {
|
||||
screen.at(x, box_.y_min) = charset[4];
|
||||
screen.at(x, box_.y_max) = charset[4];
|
||||
Pixel& p1 = screen.PixelAt(x, box_.y_min);
|
||||
Pixel& p2 = screen.PixelAt(x, box_.y_max);
|
||||
p1.character = charset[4];
|
||||
p2.character = charset[4];
|
||||
p1.automerge = true;
|
||||
p2.automerge = true;
|
||||
}
|
||||
for (float y = box_.y_min + 1; y < box_.y_max; ++y) {
|
||||
screen.at(box_.x_min, y) = charset[5];
|
||||
screen.at(box_.x_max, y) = charset[5];
|
||||
Pixel& p3 = screen.PixelAt(box_.x_min, y);
|
||||
Pixel& p4 = screen.PixelAt(box_.x_max, y);
|
||||
p3.character = charset[5];
|
||||
p4.character = charset[5];
|
||||
p3.automerge = true;
|
||||
p4.automerge = true;
|
||||
}
|
||||
|
||||
// Draw title.
|
||||
@@ -109,12 +118,20 @@ class Border : public Node {
|
||||
screen.PixelAt(box_.x_min, box_.y_max) = charset_pixel[2];
|
||||
screen.PixelAt(box_.x_max, box_.y_max) = charset_pixel[3];
|
||||
for (float x = box_.x_min + 1; x < box_.x_max; ++x) {
|
||||
screen.PixelAt(x, box_.y_min) = charset_pixel[4];
|
||||
screen.PixelAt(x, box_.y_max) = charset_pixel[4];
|
||||
Pixel& p1 = screen.PixelAt(x, box_.y_min);
|
||||
Pixel& p2 = screen.PixelAt(x, box_.y_max);
|
||||
p1 = charset_pixel[5];
|
||||
p2 = charset_pixel[5];
|
||||
p1.automerge = true;
|
||||
p2.automerge = true;
|
||||
}
|
||||
for (float y = box_.y_min + 1; y < box_.y_max; ++y) {
|
||||
screen.PixelAt(box_.x_min, y) = charset_pixel[5];
|
||||
screen.PixelAt(box_.x_max, y) = charset_pixel[5];
|
||||
Pixel& p3 = screen.PixelAt(box_.x_min, y);
|
||||
Pixel& p4 = screen.PixelAt(box_.x_max, y);
|
||||
p3 = charset_pixel[5];
|
||||
p4 = charset_pixel[5];
|
||||
p3.automerge = true;
|
||||
p4.automerge = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user