FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
clear_under.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// 本原始碼的使用受 MIT 授權條款約束,詳情請參閱 LICENSE 文件。
3#include <memory> // for make_shared
4#include <utility> // for move
5
6#include "ftxui/dom/elements.hpp" // for Element, clear_under
7#include "ftxui/dom/node.hpp" // for Node
8#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
9#include "ftxui/screen/box.hpp" // for Box
10#include "ftxui/screen/screen.hpp" // for Pixel, Screen
11
12namespace ftxui {
13
14namespace {
15using ftxui::Screen;
16
17class ClearUnder : public NodeDecorator {
18 public:
20
21 void Render(Screen& screen) override {
22 for (int y = box_.y_min; y <= box_.y_max; ++y) {
23 for (int x = box_.x_min; x <= box_.x_max; ++x) {
24 screen.PixelAt(x, y) = Pixel();
25 screen.PixelAt(x, y).character = " "; // 考慮像素已寫入。
26 }
27 }
28 Node::Render(screen);
29 }
30};
31} // namespace
32
33/// @brief 在繪製 |child| 之前,清除下方的像素。這在與 dbox 結合使用時非常有用。
34/// @see ftxui::dbox
35/// @ingroup dom
37 return std::make_shared<ClearUnder>(std::move(element));
38}
39
40} // namespace ftxui
NodeDecorator(Element child)
friend void Render(Screen &screen, Node *node, Selection &selection)
Element clear_under(Element element)
在繪製 |child| 之前,清除下方的像素。這在與 dbox 結合使用時非常有用。
像素的矩形網格。
Definition screen.hpp:26
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
std::shared_ptr< Node > Element
Definition elements.hpp:22
void Render(Screen &screen, const Element &element)