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
2e2aa748
Commit
2e2aa748
authored
Nov 19, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #484 from abarth/image_alignment
Add `alignment` to image widgets
parents
5734821f
d234c65d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+4
-4
image.dart
packages/flutter/lib/src/rendering/image.dart
+14
-0
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+16
-0
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
2e2aa748
...
...
@@ -582,8 +582,8 @@ void paintImage({
ImageFit
fit
,
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
,
double
positionX:
0.5
,
double
positionY:
0.5
double
alignX
,
double
alignY
})
{
Size
outputSize
=
rect
.
size
;
Size
inputSize
=
new
Size
(
image
.
width
.
toDouble
(),
image
.
height
.
toDouble
());
...
...
@@ -644,8 +644,8 @@ void paintImage({
Paint
paint
=
new
Paint
()..
isAntiAlias
=
false
;
if
(
colorFilter
!=
null
)
paint
.
colorFilter
=
colorFilter
;
double
dx
=
(
outputSize
.
width
-
destinationSize
.
width
)
*
positionX
;
double
dy
=
(
outputSize
.
height
-
destinationSize
.
height
)
*
positionY
;
double
dx
=
(
outputSize
.
width
-
destinationSize
.
width
)
*
(
alignX
??
0.5
)
;
double
dy
=
(
outputSize
.
height
-
destinationSize
.
height
)
*
(
alignY
??
0.5
)
;
Point
destinationPosition
=
rect
.
topLeft
+
new
Offset
(
dx
,
dy
);
Rect
destinationRect
=
destinationPosition
&
destinationSize
;
if
(
centerSlice
==
null
)
...
...
packages/flutter/lib/src/rendering/image.dart
View file @
2e2aa748
...
...
@@ -24,6 +24,7 @@ class RenderImage extends RenderBox {
double
height
,
ColorFilter
colorFilter
,
ImageFit
fit
,
FractionalOffset
alignment
,
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
})
:
_image
=
image
,
...
...
@@ -31,6 +32,7 @@ class RenderImage extends RenderBox {
_height
=
height
,
_colorFilter
=
colorFilter
,
_fit
=
fit
,
_alignment
=
alignment
,
_repeat
=
repeat
,
_centerSlice
=
centerSlice
;
...
...
@@ -86,6 +88,16 @@ class RenderImage extends RenderBox {
markNeedsPaint
();
}
/// How to align the image within its bounds.
FractionalOffset
get
alignment
=>
_alignment
;
FractionalOffset
_alignment
;
void
set
alignment
(
FractionalOffset
value
)
{
if
(
value
==
_alignment
)
return
;
_alignment
=
value
;
markNeedsPaint
();
}
/// Not yet implemented.
ImageRepeat
get
repeat
=>
_repeat
;
ImageRepeat
_repeat
;
...
...
@@ -194,6 +206,8 @@ class RenderImage extends RenderBox {
image:
_image
,
colorFilter:
_colorFilter
,
fit:
_fit
,
alignX:
_alignment
?.
x
,
alignY:
_alignment
?.
y
,
centerSlice:
_centerSlice
,
repeat:
_repeat
);
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
2e2aa748
...
...
@@ -1021,6 +1021,7 @@ class Image extends LeafRenderObjectWidget {
this
.
height
,
this
.
colorFilter
,
this
.
fit
,
this
.
alignment
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
...
...
@@ -1030,6 +1031,7 @@ class Image extends LeafRenderObjectWidget {
final
double
height
;
final
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
FractionalOffset
alignment
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
...
...
@@ -1039,6 +1041,7 @@ class Image extends LeafRenderObjectWidget {
height:
height
,
colorFilter:
colorFilter
,
fit:
fit
,
alignment:
alignment
,
repeat:
repeat
,
centerSlice:
centerSlice
);
...
...
@@ -1047,6 +1050,7 @@ class Image extends LeafRenderObjectWidget {
renderObject
.
width
=
width
;
renderObject
.
height
=
height
;
renderObject
.
colorFilter
=
colorFilter
;
renderObject
.
alignment
=
alignment
;
renderObject
.
fit
=
fit
;
renderObject
.
repeat
=
repeat
;
renderObject
.
centerSlice
=
centerSlice
;
...
...
@@ -1061,6 +1065,7 @@ class ImageListener extends StatefulComponent {
this
.
height
,
this
.
colorFilter
,
this
.
fit
,
this
.
alignment
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
)
{
...
...
@@ -1072,6 +1077,7 @@ class ImageListener extends StatefulComponent {
final
double
height
;
final
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
FractionalOffset
alignment
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
...
...
@@ -1111,6 +1117,7 @@ class _ImageListenerState extends State<ImageListener> {
height:
config
.
height
,
colorFilter:
config
.
colorFilter
,
fit:
config
.
fit
,
alignment:
config
.
alignment
,
repeat:
config
.
repeat
,
centerSlice:
config
.
centerSlice
);
...
...
@@ -1125,6 +1132,7 @@ class NetworkImage extends StatelessComponent {
this
.
height
,
this
.
colorFilter
,
this
.
fit
,
this
.
alignment
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
...
...
@@ -1134,6 +1142,7 @@ class NetworkImage extends StatelessComponent {
final
double
height
;
final
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
FractionalOffset
alignment
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
...
...
@@ -1144,6 +1153,7 @@ class NetworkImage extends StatelessComponent {
height:
height
,
colorFilter:
colorFilter
,
fit:
fit
,
alignment:
alignment
,
repeat:
repeat
,
centerSlice:
centerSlice
);
...
...
@@ -1178,6 +1188,7 @@ class RawImage extends StatelessComponent {
this
.
height
,
this
.
colorFilter
,
this
.
fit
,
this
.
alignment
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
...
...
@@ -1187,6 +1198,7 @@ class RawImage extends StatelessComponent {
final
double
height
;
final
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
FractionalOffset
alignment
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
...
...
@@ -1198,6 +1210,7 @@ class RawImage extends StatelessComponent {
height:
height
,
colorFilter:
colorFilter
,
fit:
fit
,
alignment:
alignment
,
repeat:
repeat
,
centerSlice:
centerSlice
);
...
...
@@ -1213,6 +1226,7 @@ class AssetImage extends StatelessComponent {
this
.
height
,
this
.
colorFilter
,
this
.
fit
,
this
.
alignment
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
...
...
@@ -1223,6 +1237,7 @@ class AssetImage extends StatelessComponent {
final
double
height
;
final
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
FractionalOffset
alignment
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
...
...
@@ -1233,6 +1248,7 @@ class AssetImage extends StatelessComponent {
height:
height
,
colorFilter:
colorFilter
,
fit:
fit
,
alignment:
alignment
,
repeat:
repeat
,
centerSlice:
centerSlice
);
...
...
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