FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
requirement.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_DOM_REQUIREMENT_HPP
5#define FTXUI_DOM_REQUIREMENT_HPP
6
7#include "ftxui/screen/box.hpp"
8#include "ftxui/screen/screen.hpp"
9
10 namespace ftxui {
11 class Node;
12
13/// @brief Requirement is a structure that defines the layout requirements for a
14/// Node in the terminal user interface.
15///
16/// It specifies the minimum size required to fully draw the element,
17/// @ingroup dom
18 struct Requirement {
19 // The required size to fully draw the element.
20 int min_x = 0;
21 int min_y = 0;
22
23 // How much flexibility is given to the component.
24 int flex_grow_x = 0;
25 int flex_grow_y = 0;
26 int flex_shrink_x = 0;
27 int flex_shrink_y = 0;
28
29 // Focus management to support the frame/focus/select element.
30 struct Focused {
31 bool enabled = false;
32 Box box;
33 Node* node = nullptr;
34 Screen::Cursor::Shape cursor_shape = Screen::Cursor::Shape::Hidden;
35
36 // Internal for interactions with components.
37 bool component_active = false;
38
39 // Return whether this requirement should be preferred over the other.
40 bool Prefer(const Focused& other) const {
41 if (!other.enabled) {
42 return false;
43 }
44 if (!enabled) {
45 return true;
46 }
47
48 return other.component_active && !component_active;
49 }
50 };
51 Focused focused;
52};
53
54} // namespace ftxui
55
56#endif // FTXUI_DOM_REQUIREMENT_HPP
box.hpp
ftxui::Requirement::flex_grow_y
int flex_grow_y
Definition requirement.hpp:25
ftxui::Requirement::min_y
int min_y
Definition requirement.hpp:21
ftxui::Requirement::flex_grow_x
int flex_grow_x
Definition requirement.hpp:24
ftxui::Requirement::min_x
int min_x
Definition requirement.hpp:20
ftxui::Requirement::focused
Focused focused
Definition requirement.hpp:51
ftxui::Requirement::flex_shrink_y
int flex_shrink_y
Definition requirement.hpp:27
ftxui::Requirement::flex_shrink_x
int flex_shrink_x
Definition requirement.hpp:26
ftxui::Node
Node is the base class for all elements in the DOM tree.
Definition node.hpp:37
ftxui::Requirement
Requirement is a structure that defines the layout requirements for a Node in the terminal user inter...
Definition requirement.hpp:18
ftxui::Box
Box is a structure that represents a rectangular area in a 2D space.
Definition box.hpp:16
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
screen.hpp
ftxui::Requirement::Focused
Definition requirement.hpp:30
ftxui::Requirement::Focused::cursor_shape
Screen::Cursor::Shape cursor_shape
Definition requirement.hpp:34
ftxui::Requirement::Focused::enabled
bool enabled
Definition requirement.hpp:31
ftxui::Requirement::Focused::Prefer
bool Prefer(const Focused &other) const
Definition requirement.hpp:40
ftxui::Requirement::Focused::box
Box box
Definition requirement.hpp:32
ftxui::Requirement::Focused::node
Node * node
Definition requirement.hpp:33
ftxui::Requirement::Focused::component_active
bool component_active
Definition requirement.hpp:37
ftxui::Screen::Cursor::Shape
Shape
Definition screen.hpp:52
ftxui::Screen::Cursor::Hidden
@ Hidden
Definition screen.hpp:53