mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 20:47:05 +08:00
Make flexible element to be shrinkable.
This make the application "just-fast" to look better.
This commit is contained in:
parent
cccbe5baa9
commit
1974e9f9fc
@ -53,7 +53,7 @@ class HBox : public Node {
|
|||||||
|
|
||||||
child_box.x_max = x + child->requirement().min.x - 1;
|
child_box.x_max = x + child->requirement().min.x - 1;
|
||||||
|
|
||||||
if (child->requirement().flex.x && remaining_extra_space > 0) {
|
if (child->requirement().flex.x) {
|
||||||
int added_space = remaining_extra_space * child->requirement().flex.x /
|
int added_space = remaining_extra_space * child->requirement().flex.x /
|
||||||
remaining_flex;
|
remaining_flex;
|
||||||
remaining_extra_space -= added_space;
|
remaining_extra_space -= added_space;
|
||||||
|
@ -53,7 +53,7 @@ TEST(HBoxTest, ScreenSmaller1Flex) {
|
|||||||
Screen screen(11, 1);
|
Screen screen(11, 1);
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_", screen.ToString());
|
EXPECT_EQ("text_text_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenSmaller2Flex) {
|
TEST(HBoxTest, ScreenSmaller2Flex) {
|
||||||
@ -61,7 +61,7 @@ TEST(HBoxTest, ScreenSmaller2Flex) {
|
|||||||
Screen screen(10, 1);
|
Screen screen(10, 1);
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text", screen.ToString());
|
EXPECT_EQ("texttext_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenFitFlex) {
|
TEST(HBoxTest, ScreenFitFlex) {
|
||||||
|
@ -54,7 +54,7 @@ class VBox : public Node {
|
|||||||
|
|
||||||
child_box.y_max = y + child->requirement().min.y - 1;
|
child_box.y_max = y + child->requirement().min.y - 1;
|
||||||
|
|
||||||
if (child->requirement().flex.y && remaining_extra_space > 0) {
|
if (child->requirement().flex.y) {
|
||||||
int added_space = remaining_extra_space * child->requirement().flex.y /
|
int added_space = remaining_extra_space * child->requirement().flex.y /
|
||||||
remaining_flex;
|
remaining_flex;
|
||||||
remaining_extra_space -= added_space;
|
remaining_extra_space -= added_space;
|
||||||
|
@ -45,7 +45,7 @@ TEST(VBoxTest, ScreenSmaller1Flex) {
|
|||||||
Screen screen(6, 1);
|
Screen screen(6, 1);
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1", screen.ToString());
|
EXPECT_EQ("text_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VBoxTest, ScreenFitFlex) {
|
TEST(VBoxTest, ScreenFitFlex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user