FTXUI  0.11.1
C++ functional terminal UI.
clear_under.cpp
Go to the documentation of this file.
1 #include <memory> // for make_shared
2 #include <utility> // for move
3 
4 #include "ftxui/dom/elements.hpp" // for Element, clear_under
5 #include "ftxui/dom/node.hpp" // for Node
6 #include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
7 #include "ftxui/screen/box.hpp" // for Box
8 #include "ftxui/screen/screen.hpp" // for Pixel, Screen
9 
10 namespace ftxui {
11 
12 using ftxui::Screen;
13 
14 class ClearUnder : public NodeDecorator {
15  public:
17 
18  void Render(Screen& screen) override {
19  for (int y = box_.y_min; y <= box_.y_max; ++y) {
20  for (int x = box_.x_min; x <= box_.x_max; ++x) {
21  screen.PixelAt(x, y) = Pixel();
22  }
23  }
24  Node::Render(screen);
25  }
26 };
27 
28 /// @brief Before drawing |child|, clear the pixels below. This is useful in
29 // combinaison with dbox.
30 /// @see ftxui::dbox
31 /// @ingroup dom
33  return std::make_shared<ClearUnder>(std::move(child));
34 }
35 
36 } // namespace ftxui
37 
38 // Copyright 2020 Arthur Sonzogni. All rights reserved.
39 // Use of this source code is governed by the MIT license that can be found in
40 // the LICENSE file.
NodeDecorator(Element child)
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition: node.cpp:27
Box box_
Definition: node.hpp:50
A rectangular grid of Pixel.
Definition: screen.hpp:49
Element clear_under(Element element)
Before drawing |child|, clear the pixels below. This is useful in.
Definition: clear_under.cpp:32
std::shared_ptr< Node > Element
Definition: elements.hpp:16
void Render(Screen &screen, const Element &node)
Display an element on a ftxui::Screen.
Definition: node.cpp:40
int x_max
Definition: box.hpp:8
int y_min
Definition: box.hpp:9
int y_max
Definition: box.hpp:10
int x_min
Definition: box.hpp:7