FTXUI 7.0.3
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 是一個結構,定義了終端使用者介面中節點的佈局要求。
15///
16/// 它指定了完全繪製元素所需的最小尺寸。
17/// @ingroup dom
18struct FTXUI_EXPORT(DOM) Requirement {
19 // 完整繪製此元素所需的尺寸。
20 int min_x = 0;
21 int min_y = 0;
22
23 // 賦予此元件多少彈性。
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 // 焦點管理,支援frame/focus/select元素。
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 // 內部用於與元件互動。
37 bool component_active = false;
38 bool component_focused = false;
39
40 // 回傳此需求是否應優先於另一個需求。
41 bool Prefer(const Focused& other) const {
42 if (!other.enabled) {
43 return false;
44 }
45 if (!enabled) {
46 return true;
47 }
48 if (other.component_focused != component_focused) {
49 return other.component_focused;
50 }
51
52 return other.component_active && !component_active;
53 }
54 };
55 Focused focused;
56};
57
58} // namespace ftxui
59
60#endif // FTXUI_DOM_REQUIREMENT_HPP
FTXUI ftxui:: 命名空間
Definition animation.hpp:11
Node * node
Definition node.hpp:93