mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Allow a Dimension::Fit to extend beyond the terminal maximum height
This commit is contained in:
committed by
Boris Jaulmes
parent
55af678fb9
commit
da7eebd98f
@@ -183,7 +183,7 @@ Element align_right(Element);
|
|||||||
Element nothing(Element element);
|
Element nothing(Element element);
|
||||||
|
|
||||||
namespace Dimension {
|
namespace Dimension {
|
||||||
Dimensions Fit(Element&);
|
Dimensions Fit(Element&, bool extend_beyond_screen = false);
|
||||||
} // namespace Dimension
|
} // namespace Dimension
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ Element& operator|=(Element& e, Decorator d) {
|
|||||||
/// The minimal dimension that will fit the given element.
|
/// The minimal dimension that will fit the given element.
|
||||||
/// @see Fixed
|
/// @see Fixed
|
||||||
/// @see Full
|
/// @see Full
|
||||||
Dimensions Dimension::Fit(Element& e) {
|
Dimensions Dimension::Fit(Element& e, bool extend_beyond_screen) {
|
||||||
const Dimensions fullsize = Dimension::Full();
|
const Dimensions fullsize = Dimension::Full();
|
||||||
Box box;
|
Box box;
|
||||||
box.x_min = 0;
|
box.x_min = 0;
|
||||||
@@ -106,7 +106,9 @@ Dimensions Dimension::Fit(Element& e) {
|
|||||||
|
|
||||||
// Don't give the element more space than it needs:
|
// Don't give the element more space than it needs:
|
||||||
box.x_max = std::min(box.x_max, e->requirement().min_x);
|
box.x_max = std::min(box.x_max, e->requirement().min_x);
|
||||||
box.y_max = std::min(box.y_max, e->requirement().min_y);
|
box.y_max = extend_beyond_screen
|
||||||
|
? e->requirement().min_y // can exceed size in Y if extend_beyond_screen==true
|
||||||
|
: std::min(box.y_max, e->requirement().min_y);
|
||||||
|
|
||||||
e->SetBox(box);
|
e->SetBox(box);
|
||||||
status.need_iteration = false;
|
status.need_iteration = false;
|
||||||
@@ -116,10 +118,12 @@ Dimensions Dimension::Fit(Element& e) {
|
|||||||
if (!status.need_iteration) {
|
if (!status.need_iteration) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Increase the size of the box until it fits, but not more than the with of
|
// Increase the size of the box until it fits, but not more than the size of
|
||||||
// the terminal emulator:
|
// the terminal emulator:
|
||||||
box.x_max = std::min(e->requirement().min_x, fullsize.dimx);
|
box.x_max = std::min(e->requirement().min_x, fullsize.dimx);
|
||||||
box.y_max = std::min(e->requirement().min_y, fullsize.dimy);
|
box.y_max = extend_beyond_screen
|
||||||
|
? e->requirement().min_y // can exceed size in Y if extend_beyond_screen==true
|
||||||
|
: std::min(e->requirement().min_y, fullsize.dimy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user