4 Commits

Author SHA1 Message Date
KenReneris
c915cd3025 Merge 2d50269730 into 853d87e917 2025-08-29 04:38:50 -07:00
Arthur Sonzogni
853d87e917 Fix HTML entities in README.md
Some checks failed
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (cl, cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (clang, clang++, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.cxx }}, ${{ matrix.os }} (gcc, g++, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
2025-08-29 07:36:35 +02:00
Ken Reneris
2d50269730 private changes. don't shrink table content 2025-06-28 09:15:37 -07:00
Ken Reneris
df2ddcc588 Add gridbox children to children_ so that layout will see need_iteration when a flex node is in the grid 2025-06-28 08:51:41 -07:00
5 changed files with 48 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
<p align="center"> <p align="center">
<img src="https://github.com/ArthurSonzogni/FTXUI/assets/4759106/6925b6da-0a7e-49d9-883c-c890e1f36007" alt="Demo image"></img> <img src="https://github.com/ArthurSonzogni/FTXUI/assets/4759106/6925b6da-0a7e-49d9-883c-c890e1f36007" alt="Demo image"></img>
<br/> <br/>

View File

@@ -58,11 +58,39 @@ void ComputeShrinkHard(std::vector<Element>* elements,
element.size = element.min_size + added_space; element.size = element.min_size + added_space;
} }
}
// Called when the size allowed is lower than the requested size, and the
// shrinkable element can not absorbe the (negative) extra_space. This assign
// zero to shrinkable elements and distribute the remaining (negative)
// extra_space toward the other non shrinkable elements.
void ComputeShrinkHardHack(std::vector<Element>* elements,
int extra_space,
int size)
{
for (Element& element : *elements)
{
if (element.flex_shrink != 0)
{
element.size = 0;
}
}
for (auto it = elements->rbegin(); it != elements->rend(); ++it)
{
Element& element = *it;
auto remove = std::min(element.min_size, -extra_space);
element.size = element.min_size - remove;
extra_space += remove;
}
} }
} // namespace } // namespace
void Compute(std::vector<Element>* elements, int target_size) { void Compute(std::vector<Element>* elements, int target_size, bool hack) {
int size = 0; int size = 0;
int flex_grow_sum = 0; int flex_grow_sum = 0;
int flex_shrink_sum = 0; int flex_shrink_sum = 0;
@@ -84,8 +112,14 @@ void Compute(std::vector<Element>* elements, int target_size) {
ComputeShrinkEasy(elements, extra_space, flex_shrink_sum); ComputeShrinkEasy(elements, extra_space, flex_shrink_sum);
} else { } else {
ComputeShrinkHard(elements, extra_space + flex_shrink_size, if (hack)
size - flex_shrink_size); {
ComputeShrinkHardHack(elements, extra_space + flex_shrink_size, size - flex_shrink_size);
}
else
{
ComputeShrinkHard(elements, extra_space + flex_shrink_size, size - flex_shrink_size);
}
} }
} }

View File

@@ -19,7 +19,7 @@ struct Element {
int size = 0; int size = 0;
}; };
void Compute(std::vector<Element>* elements, int target_size); void Compute(std::vector<Element>* elements, int target_size, bool hack=false);
} // namespace ftxui::box_helper } // namespace ftxui::box_helper
#endif /* end of include guard: FTXUI_DOM_BOX_HELPER_HPP */ #endif /* end of include guard: FTXUI_DOM_BOX_HELPER_HPP */

View File

@@ -46,6 +46,12 @@ class GridBox : public Node {
line.push_back(filler()); line.push_back(filler());
} }
} }
for (const auto& line : lines_) {
for (const auto &element : line) {
children_.push_back( element );
}
}
} }
void ComputeRequirement() override { void ComputeRequirement() override {
@@ -109,7 +115,7 @@ class GridBox : public Node {
const int target_size_x = box.x_max - box.x_min + 1; const int target_size_x = box.x_max - box.x_min + 1;
const int target_size_y = box.y_max - box.y_min + 1; const int target_size_y = box.y_max - box.y_min + 1;
box_helper::Compute(&elements_x, target_size_x); box_helper::Compute(&elements_x, target_size_x, true);
box_helper::Compute(&elements_y, target_size_y); box_helper::Compute(&elements_y, target_size_y);
Box box_y = box; Box box_y = box;

View File

@@ -216,13 +216,13 @@ Element Table::Render() {
// Line // Line
if ((x + y) % 2 == 1) { if ((x + y) % 2 == 1) {
it = std::move(it) | flex; it = std::move(it)| flex; //it = std::move(it); // | flex;
continue; continue;
} }
// Cells // Cells
if ((x % 2) == 1 && (y % 2) == 1) { if ((x % 2) == 1 && (y % 2) == 1) {
it = std::move(it) | flex_shrink; // it = std::move(it) | flex_shrink; //it = std::move(it) | flex_shrink;
continue; continue;
} }