From 52e92a99be3ea61b6d5cc501133a12c92062fd61 Mon Sep 17 00:00:00 2001 From: Clement Roblot Date: Wed, 27 Nov 2024 00:29:08 +0700 Subject: [PATCH] More robust saturation mechanism --- src/ftxui/dom/hbox.cpp | 4 ++-- src/ftxui/dom/vbox.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ftxui/dom/hbox.cpp b/src/ftxui/dom/hbox.cpp index 6676e37..00bc508 100644 --- a/src/ftxui/dom/hbox.cpp +++ b/src/ftxui/dom/hbox.cpp @@ -78,10 +78,10 @@ class HBox : public Node { selection.y_max > box_.y_max || selection.x_max > box_.x_max; if (xmin_saturated) { - selection.x_min = box_.x_min; + selection.x_min = std::min(box_.x_min, selection.x_min); } if (xmax_saturated) { - selection.x_max = box_.x_max; + selection.x_max = std::max(box_.x_max, selection.x_max); } for (auto& child : children_) { diff --git a/src/ftxui/dom/vbox.cpp b/src/ftxui/dom/vbox.cpp index 361f5e2..761a8b3 100644 --- a/src/ftxui/dom/vbox.cpp +++ b/src/ftxui/dom/vbox.cpp @@ -76,11 +76,12 @@ class VBox : public Node { selection.x_min < box_.x_min || selection.y_min < box_.y_min; const bool ymax_saturated = selection.x_max > box_.x_max || selection.y_max > box_.y_max; + if (ymin_saturated) { - selection.y_min = box_.y_min; + selection.y_min = std::min(box_.y_min, selection.y_min); } if (ymax_saturated) { - selection.y_max = box_.y_max; + selection.y_max = std::max(box_.y_max, selection.y_max); } for (auto& child : children_) {