mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +08:00
Factorize box layout functions. (#185)
|hbox| and |vbox| are similar. They are just the same component, but drawing in a different direction. This patchs factorize the layout logic. Goal is to reduce code size and reuse it for the |gridbox| dom element. Bug: https://github.com/ArthurSonzogni/FTXUI/issues/114
This commit is contained in:
24
src/ftxui/dom/box_helper.hpp
Normal file
24
src/ftxui/dom/box_helper.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef FTXUI_DOM_BOX_HELPER_HPP
|
||||
#define FTXUI_DOM_BOX_HELPER_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ftxui {
|
||||
namespace box_helper {
|
||||
|
||||
struct Element {
|
||||
// Input:
|
||||
int min_size = 0;
|
||||
int flex_grow = 0;
|
||||
int flex_shrink = 0;
|
||||
|
||||
// Output;
|
||||
int size = 0;
|
||||
};
|
||||
|
||||
void Compute(std::vector<Element>* elements, int target_size);
|
||||
|
||||
} // namespace box_helper
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_DOM_BOX_HELPER_HPP */
|
Reference in New Issue
Block a user