Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
6c27d383
Commit
6c27d383
authored
Oct 22, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FractionalOffset alignment value in Stack and IndexedStack
parent
d25039df
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
64 deletions
+29
-64
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+1
-1
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+17
-31
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+10
-30
stack_test.dart
packages/unit/test/widget/stack_test.dart
+1
-2
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
6c27d383
...
...
@@ -241,7 +241,7 @@ class DropdownButton<T> extends StatelessComponent {
new
IndexedStack
(
items
,
key:
indexedStackKey
,
index:
selectedIndex
,
horizontalAlignment:
0.5
alignment:
const
FractionalOffset
(
0.5
,
0.0
)
),
new
Container
(
child:
new
Icon
(
type:
'navigation/arrow_drop_down'
,
size:
36
),
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
6c27d383
...
...
@@ -186,9 +186,8 @@ abstract class RenderStackBase extends RenderBox
RenderBoxContainerDefaultsMixin
<
RenderBox
,
StackParentData
>
{
RenderStackBase
({
List
<
RenderBox
>
children
,
double
horizontalAlignment:
0.0
,
double
verticalAlignment:
0.0
})
:
_horizontalAlignment
=
horizontalAlignment
,
_verticalAlignment
=
verticalAlignment
{
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
})
:
_alignment
=
alignment
{
addAll
(
children
);
}
...
...
@@ -199,20 +198,11 @@ abstract class RenderStackBase extends RenderBox
child
.
parentData
=
new
StackParentData
();
}
double
get
horizontalAlignment
=>
_horizontalAlignment
;
double
_horizontalAlignment
;
void
set
horizontalAlignment
(
double
value
)
{
if
(
_horizontalAlignment
!=
value
)
{
_horizontalAlignment
=
value
;
markNeedsLayout
();
}
}
double
get
verticalAlignment
=>
_verticalAlignment
;
double
_verticalAlignment
;
void
set
verticalAlignment
(
double
value
)
{
if
(
_verticalAlignment
!=
value
)
{
_verticalAlignment
=
value
;
FractionalOffset
get
alignment
=>
_alignment
;
FractionalOffset
_alignment
;
void
set
alignment
(
FractionalOffset
value
)
{
if
(
_alignment
!=
value
)
{
_alignment
=
value
;
markNeedsLayout
();
}
}
...
...
@@ -327,8 +317,8 @@ abstract class RenderStackBase extends RenderBox
final
StackParentData
childParentData
=
child
.
parentData
;
if
(!
childParentData
.
isPositioned
)
{
double
x
=
(
size
.
width
-
child
.
size
.
width
)
*
horizontalAlignment
;
double
y
=
(
size
.
height
-
child
.
size
.
height
)
*
verticalAlignment
;
double
x
=
(
size
.
width
-
child
.
size
.
width
)
*
alignment
.
x
;
double
y
=
(
size
.
height
-
child
.
size
.
height
)
*
alignment
.
y
;
childParentData
.
position
=
new
Point
(
x
,
y
);
}
else
{
BoxConstraints
childConstraints
=
const
BoxConstraints
();
...
...
@@ -395,12 +385,12 @@ abstract class RenderStackBase extends RenderBox
/// are no non-positioned children, the stack becomes as large as possible.
///
/// The final location of non-positioned children is determined by the alignment
/// parameter
s
. The left of each non-positioned child becomes the
/// parameter. The left of each non-positioned child becomes the
/// difference between the child's width and the stack's width scaled by
///
horizontalAlignment
. The top of each non-positioned child is computed
/// similarly and scaled by
verticalAlignement. So if the alignment parameter
s
///
alignment.x
. The top of each non-positioned child is computed
/// similarly and scaled by
alignement.y. So if the alignment x and y propertie
s
/// are 0.0 (the default) then the non-positioned children remain in the
/// upper-left corner. If the alignment
parameter
s are 0.5 then the
/// upper-left corner. If the alignment
x and y propertie
s are 0.5 then the
/// non-positioned children are centered within the stack.
///
/// Next, the positioned children are laid out. If a child has top and bottom
...
...
@@ -418,12 +408,10 @@ abstract class RenderStackBase extends RenderBox
class
RenderStack
extends
RenderStackBase
{
RenderStack
({
List
<
RenderBox
>
children
,
double
horizontalAlignment:
0.0
,
double
verticalAlignment:
0.0
alignment:
const
FractionalOffset
(
0.0
,
0.0
)
})
:
super
(
children:
children
,
horizontalAlignment:
horizontalAlignment
,
verticalAlignment:
verticalAlignment
alignment:
alignment
);
void
paintStack
(
PaintingContext
context
,
Offset
offset
)
{
...
...
@@ -438,13 +426,11 @@ class RenderStack extends RenderStackBase {
class
RenderIndexedStack
extends
RenderStackBase
{
RenderIndexedStack
({
List
<
RenderBox
>
children
,
double
horizontalAlignment:
0.0
,
double
verticalAlignment:
0.0
,
alignment:
const
FractionalOffset
(
0.0
,
0.0
),
int
index:
0
})
:
_index
=
index
,
super
(
children:
children
,
horizontalAlignment:
horizontalAlignment
,
verticalAlignment:
verticalAlignment
alignment:
alignment
);
int
get
index
=>
_index
;
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
6c27d383
...
...
@@ -592,54 +592,34 @@ class BlockBody extends MultiChildRenderObjectWidget {
class
Stack
extends
MultiChildRenderObjectWidget
{
Stack
(
List
<
Widget
>
children
,
{
Key
key
,
this
.
horizontalAlignment
:
0.0
,
this
.
verticalAlignment
:
0.0
})
:
super
(
key:
key
,
children:
children
)
{
assert
(
horizontalAlignment
!=
null
);
assert
(
verticalAlignment
!=
null
);
}
this
.
alignment
:
const
FractionalOffset
(
0.0
,
0.0
)
})
:
super
(
key:
key
,
children:
children
);
final
double
horizontalAlignment
;
final
double
verticalAlignment
;
final
FractionalOffset
alignment
;
RenderStack
createRenderObject
()
{
return
new
RenderStack
(
horizontalAlignment:
horizontalAlignment
,
verticalAlignment:
verticalAlignment
);
}
RenderStack
createRenderObject
()
=>
new
RenderStack
(
alignment:
alignment
);
void
updateRenderObject
(
RenderStack
renderObject
,
Stack
oldWidget
)
{
renderObject
.
horizontalAlignment
=
horizontalAlignment
;
renderObject
.
verticalAlignment
=
verticalAlignment
;
renderObject
.
alignment
=
alignment
;
}
}
class
IndexedStack
extends
MultiChildRenderObjectWidget
{
IndexedStack
(
List
<
Widget
>
children
,
{
Key
key
,
this
.
horizontalAlignment
:
0.0
,
this
.
verticalAlignment
:
0.0
,
this
.
alignment
:
const
FractionalOffset
(
0.0
,
0.0
),
this
.
index
:
0
})
:
super
(
key:
key
,
children:
children
);
final
int
index
;
final
double
horizontalAlignment
;
final
double
verticalAlignment
;
RenderIndexedStack
createRenderObject
()
{
return
new
RenderIndexedStack
(
index:
index
,
verticalAlignment:
verticalAlignment
,
horizontalAlignment:
horizontalAlignment
);
}
final
FractionalOffset
alignment
;
RenderIndexedStack
createRenderObject
()
=>
new
RenderIndexedStack
(
index:
index
,
alignment:
alignment
);
void
updateRenderObject
(
RenderIndexedStack
renderObject
,
IndexedStack
oldWidget
)
{
super
.
updateRenderObject
(
renderObject
,
oldWidget
);
renderObject
.
index
=
index
;
renderObject
.
horizontalAlignment
=
horizontalAlignment
;
renderObject
.
verticalAlignment
=
verticalAlignment
;
renderObject
.
alignment
=
alignment
;
}
}
...
...
packages/unit/test/widget/stack_test.dart
View file @
6c27d383
...
...
@@ -103,8 +103,7 @@ void main() {
new
Container
(
key:
child0Key
,
width:
20.0
,
height:
20.0
),
new
Container
(
key:
child1Key
,
width:
10.0
,
height:
10.0
)
],
horizontalAlignment:
0.5
,
verticalAlignment:
0.5
alignment:
const
FractionalOffset
(
0.5
,
0.5
)
)
)
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment