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
10
11namespace ftxui {
12class Node;
13
14/// @brief Requirement is a structure that defines the layout requirements for a
15/// Node in the terminal user interface.
16///
17/// It specifies the minimum size required to fully draw the element,
18/// @ingroup dom
19struct FTXUI_EXPORT(DOM) Requirement {
20 // The required size to fully draw the element.
21 int min_x = 0;
22 int min_y = 0;
23
24 // How much flexibility is given to the component.
25 int flex_grow_x = 0;
26 int flex_grow_y = 0;
27 int flex_shrink_x = 0;
28 int flex_shrink_y = 0;
29
30 // Focus management to support the frame/focus/select element.
31 struct Focused {
32 bool enabled = false;
33 Box box;
34 Node* node = nullptr;
35 Screen::Cursor::Shape cursor_shape = Screen::Cursor::Shape::Hidden;
36
37 // Internal for interactions with components.
38 bool component_active = false;
39 bool component_focused = false;
40
41 // Return whether this requirement should be preferred over the other.
42 bool Prefer(const Focused& other) const {
43 if (!other.enabled) {
44 return false;
45 }
46 if (!enabled) {
47 return true;
48 }
49 if (other.component_focused != component_focused) {
50 return other.component_focused;
51 }
52
53 return other.component_active && !component_active;
54 }
55 };
56 Focused focused;
57};
58
59} // namespace ftxui
60
61#endif // FTXUI_DOM_REQUIREMENT_HPP
The FTXUI ftxui:: namespace.
Definition animation.hpp:11
Node * node
Definition node.hpp:96