FTXUI
0.8.1
C++ functional terminal UI.
inverted.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, inverted
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
class
Inverted :
public
NodeDecorator {
13
public
:
14
using
NodeDecorator::NodeDecorator
;
15
16
void
Render
(Screen& screen)
override
{
17
Node::Render
(screen);
18
for
(
int
y =
box_
.
y_min
; y <=
box_
.
y_max
; ++y) {
19
for
(
int
x =
box_
.
x_min
; x <=
box_
.
x_max
; ++x) {
20
screen.PixelAt(x, y).inverted =
true
;
21
}
22
}
23
}
24
};
25
26
/// @brief Add a filter that will invert the foreground and the background
27
/// colors.
28
/// @ingroup dom
29
Element
inverted
(
Element
child) {
30
return
std::make_shared<Inverted>(std::move(child));
31
}
32
33
}
// namespace ftxui
34
35
// Copyright 2020 Arthur Sonzogni. All rights reserved.
36
// Use of this source code is governed by the MIT license that can be found in
37
// the LICENSE file.
ftxui::Box::x_min
int x_min
Definition:
box.hpp:7
ftxui::Node::box_
Box box_
Definition:
node.hpp:41
ftxui::Box::y_max
int y_max
Definition:
box.hpp:10
ftxui
Definition:
captured_mouse.hpp:6
node.hpp
ftxui::Node::Render
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition:
node.cpp:27
ftxui::inverted
Element inverted(Element)
Add a filter that will invert the foreground and the background colors.
Definition:
inverted.cpp:29
box.hpp
ftxui::Box::x_max
int x_max
Definition:
box.hpp:8
elements.hpp
node_decorator.hpp
ftxui::Element
std::shared_ptr< Node > Element
Definition:
elements.hpp:15
ftxui::Box::y_min
int y_min
Definition:
box.hpp:9
ftxui::Render
void Render(Screen &screen, const Element &node)
Display an element on a ftxui::Screen.
Definition:
node.cpp:34
ftxui::NodeDecorator::NodeDecorator
NodeDecorator(Element child)
Definition:
node_decorator.hpp:15
screen.hpp