The clear_under cannot clear background color
Hello! When I tested the latest ftxui (not release 5.0.0), I found that the performance of "Modal" has changed compared to release 5.0.0, as the "Modal" component does not clear the background color. Later, I discovered that there had been a change in the implementation of "Pixel" and "clear_under" due to the "Color Alpha Support". I checked the source code and found that the render function of clear_under sets the background color of pixels to Color::Default (i.e. transparent). Due to changes in the implementation of dbox, "clear_under" does not truly clear the background color of pixels below the Node. The first option, in my opinion, is to change the code to below in order to better match the "clear" of clear_under.
//In src/ftxui/dom/clear_under.cpp
class ClearUnder : public NodeDecorator {
public:
using NodeDecorator::NodeDecorator;
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) {
auto& pixel = screen.PixelAt(x, y);
pixel = Pixel();
pixel.character = " "; // Consider the pixel written.
pixel.background_color = Color::Opaque; //Some operations to set the background color opaque
}
}
Node::Render(screen);
}
};The other option is to provide users with a customized option to set the content and color to be filled after clear_under (including whether background_comlor is transparent).
Element clear_under(Element element, std::string fill_content, Color c) {
return std::make_shared<ClearUnder>(std::move(element), fill_content, c);
}Thank you!
Source: ArthurSonzogni/FTXUI