mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
Add test for flex layout in absolute position
This commit is contained in:
@@ -27,7 +27,7 @@ static int check_flex_box_1( void )
|
||||
};
|
||||
box = LCUIWidget_GetById( "flex-box-1" );
|
||||
CHECK( box->x == 0 && box->y == 0 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 + 1 );
|
||||
for( LinkedList_Each( node, &box->children ) ) {
|
||||
child = node->data;
|
||||
sprintf( str, "[%d] (%g, %g) == (%g, %g)", child->index,
|
||||
@@ -56,8 +56,8 @@ static int check_flex_box_2( void )
|
||||
{ offset_x2 + BLOCK_SIZE, BLOCK_SIZE * 2 }
|
||||
};
|
||||
box = LCUIWidget_GetById( "flex-box-2" );
|
||||
CHECK( box->x == 0 && box->y == BLOCK_SIZE * 3 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 );
|
||||
CHECK( box->x == 0 && box->y == BLOCK_SIZE * 3 + 1 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 + 1 );
|
||||
for( LinkedList_Each( node, &box->children ) ) {
|
||||
child = node->data;
|
||||
sprintf( str, "[%d] (%g, %g) == (%g, %g)", child->index,
|
||||
@@ -86,8 +86,34 @@ static int check_flex_box_3( void )
|
||||
{ offset_x2 + BLOCK_SIZE, BLOCK_SIZE * 2 }
|
||||
};
|
||||
box = LCUIWidget_GetById( "flex-box-3" );
|
||||
CHECK( box->x == 0 && box->y == BLOCK_SIZE * 3 * 2 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 );
|
||||
CHECK( box->x == 0 && box->y == BLOCK_SIZE * 3 * 2 + 2 );
|
||||
CHECK( box->height == BLOCK_SIZE * 3 + 1 );
|
||||
for( LinkedList_Each( node, &box->children ) ) {
|
||||
child = node->data;
|
||||
sprintf( str, "[%d] (%g, %g) == (%g, %g)", child->index,
|
||||
child->x, child->y, simples[i][0], simples[i][1] );
|
||||
CHECK_WITH_TEXT( str, child->x == simples[i][0] &&
|
||||
child->y == simples[i][1] );
|
||||
i += 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_flex_box_4( void )
|
||||
{
|
||||
char str[256];
|
||||
int ret = 0, i = 0;
|
||||
LinkedListNode *node;
|
||||
LCUI_Widget child, box;
|
||||
const float offset_x = 480 - BLOCK_SIZE * 3;
|
||||
float simples[][2] = {
|
||||
{ 0, 0 },
|
||||
{ offset_x, BLOCK_SIZE },
|
||||
{ offset_x + BLOCK_SIZE, BLOCK_SIZE },
|
||||
{ offset_x + BLOCK_SIZE * 2, BLOCK_SIZE }
|
||||
};
|
||||
box = LCUIWidget_GetById( "flex-box-4" );
|
||||
CHECK( box->height == BLOCK_SIZE * 2 );
|
||||
for( LinkedList_Each( node, &box->children ) ) {
|
||||
child = node->data;
|
||||
sprintf( str, "[%d] (%g, %g) == (%g, %g)", child->index,
|
||||
@@ -105,6 +131,7 @@ static int check_layout( void )
|
||||
ret += check_flex_box_1();
|
||||
ret += check_flex_box_2();
|
||||
ret += check_flex_box_3();
|
||||
ret += check_flex_box_4();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.flex-box {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
.inline-block {
|
||||
padding: 5px;
|
||||
display: inline-block;
|
||||
@@ -26,4 +29,21 @@
|
||||
.box-2 {
|
||||
height: 64px;
|
||||
background-color: #957bbe;
|
||||
}
|
||||
}
|
||||
.bottom {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
.bottom-box {
|
||||
width: auto;
|
||||
max-width: 480px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
.bottom-content {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<lcui-app>
|
||||
<resource type="text/css" src="test_widget_flex_layout.css"/>
|
||||
<ui>
|
||||
<w id="flex-box-1" class="flex-items-left">
|
||||
<w id="flex-box-1" class="flex-box flex-items-left">
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
@@ -22,7 +22,7 @@
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
</w>
|
||||
<w id="flex-box-2" class="flex-items-center">
|
||||
<w id="flex-box-2" class="flex-box flex-items-center">
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
@@ -42,7 +42,7 @@
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
</w>
|
||||
<w id="flex-box-3" class="flex-items-right">
|
||||
<w id="flex-box-3" class="flex-box flex-items-right">
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
@@ -62,5 +62,25 @@
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
</w>
|
||||
<w class="bottom">
|
||||
<w class="bottom-box">
|
||||
<w class="bottom-content">
|
||||
<w id="flex-box-4" class="flex-items-right">
|
||||
<w class="block">
|
||||
<w class="box-2" />
|
||||
</w>
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
<w class="inline-block">
|
||||
<w class="box-1" />
|
||||
</w>
|
||||
</w>
|
||||
</w>
|
||||
</w>
|
||||
</w>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
|
||||
Reference in New Issue
Block a user