Fix focus vs flexbox interaction. (#405)

- Fix focus in flexbox. This required resetting the focus state at the
  beginning of the ComputeRequirement(), because it can now run several
  times.

  This resolves:https://github.com/ArthurSonzogni/FTXUI/issues/399

- Add Box::Union.

- Add a preliminary implementation of forwarding selected_box from
  within the flexbox.
This commit is contained in:
Arthur Sonzogni
2022-05-22 21:41:29 +02:00
committed by GitHub
parent f9256fa132
commit 11519ef1c6
10 changed files with 77 additions and 8 deletions

View File

@@ -432,6 +432,29 @@ TEST(FlexboxTest, GapY) {
" ");
}
TEST(FlexboxTest, Focus) {
auto document = vbox({
paragraph("0 -"),
paragraph("1 -"),
paragraph("2 -"),
paragraph("3 -"),
paragraph("4 -"),
paragraph("5 -"),
paragraph("6 -"),
paragraph("7 -") | focus,
paragraph("8 -"),
paragraph("9 -"),
}) | yframe | flex;
Screen screen(1, 3);
Render(screen, document);
EXPECT_EQ(screen.ToString(),
"7\r\n"
"-\r\n"
"8"
);
}
} // namespace ftxui
// Copyright 2021 Arthur Sonzogni. All rights reserved.