mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-17 00:21:13 +08:00
Minor tweaks.
This commit is contained in:
parent
da7eebd98f
commit
2157605cd1
@ -46,6 +46,9 @@ current (development)
|
|||||||
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
|
||||||
reflecting the current scroll position. Proposed by @ibrahimnasson in
|
reflecting the current scroll position. Proposed by @ibrahimnasson in
|
||||||
[issue 752](https://github.com/ArthurSonzogni/FTXUI/issues/752)
|
[issue 752](https://github.com/ArthurSonzogni/FTXUI/issues/752)
|
||||||
|
- Feature: Add `extend_beyond_screen` option to `Dimension::Fit(..)`, allowing
|
||||||
|
the element to be larger than the screen. Proposed by @LordWhiro. See #572 and
|
||||||
|
#949.
|
||||||
|
|
||||||
### Screen
|
### Screen
|
||||||
- Feature: Add `Box::IsEmpty()`.
|
- Feature: Add `Box::IsEmpty()`.
|
||||||
|
@ -55,7 +55,8 @@ int main() {
|
|||||||
content.DecorateCellsAlternateRow(color(Color::White), 3, 2);
|
content.DecorateCellsAlternateRow(color(Color::White), 3, 2);
|
||||||
|
|
||||||
auto document = table.Render();
|
auto document = table.Render();
|
||||||
auto screen = Screen::Create(Dimension::Fit(document));
|
auto screen =
|
||||||
|
Screen::Create(Dimension::Fit(document, /*extend_beyond_screen=*/true));
|
||||||
Render(screen, document);
|
Render(screen, document);
|
||||||
screen.Print();
|
screen.Print();
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
@ -106,9 +106,10 @@ Dimensions Dimension::Fit(Element& e, bool extend_beyond_screen) {
|
|||||||
|
|
||||||
// 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 = extend_beyond_screen
|
box.y_max = e->requirement().min_y;
|
||||||
? e->requirement().min_y // can exceed size in Y if extend_beyond_screen==true
|
if (!extend_beyond_screen) {
|
||||||
: std::min(box.y_max, e->requirement().min_y);
|
box.y_max = std::min(box.y_max, fullsize.dimy);
|
||||||
|
}
|
||||||
|
|
||||||
e->SetBox(box);
|
e->SetBox(box);
|
||||||
status.need_iteration = false;
|
status.need_iteration = false;
|
||||||
@ -118,12 +119,14 @@ Dimensions Dimension::Fit(Element& e, bool extend_beyond_screen) {
|
|||||||
if (!status.need_iteration) {
|
if (!status.need_iteration) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Increase the size of the box until it fits, but not more than the size of
|
// Increase the size of the box until it fits...
|
||||||
// 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 = extend_beyond_screen
|
box.y_max = e->requirement().min_y;
|
||||||
? e->requirement().min_y // can exceed size in Y if extend_beyond_screen==true
|
|
||||||
: std::min(e->requirement().min_y, fullsize.dimy);
|
// ... but don't go beyond the screen size:
|
||||||
|
if (!extend_beyond_screen) {
|
||||||
|
box.y_max = std::min(box.y_max, fullsize.dimy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user