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
62757672
Commit
62757672
authored
Mar 25, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2904 from Hixie/imagefit
ImageFit.fitWidth/fitHeight and minor docs fixes
parents
03830d56
67769cb9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+18
-0
box.dart
packages/flutter/lib/src/rendering/box.dart
+1
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+11
-2
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
62757672
...
...
@@ -669,6 +669,14 @@ enum ImageFit {
/// As small as possible while still covering the entire box.
cover
,
/// Make sure the full width of the image is shown, regardless of
/// whether this means the image overflows the box vertically.
fitWidth
,
/// Make sure the full height of the image is shown, regardless of
/// whether this means the image overflows the box horizontally.
fitHeight
,
/// Center the image within the box and discard any portions of the image that
/// lie outside the box.
none
,
...
...
@@ -773,6 +781,16 @@ void paintImage({
}
destinationSize
=
outputSize
;
break
;
case
ImageFit
.
fitWidth
:
sourceSize
=
new
Size
(
inputSize
.
width
,
inputSize
.
width
*
outputSize
.
height
/
outputSize
.
width
);
sourcePosition
=
new
Point
(
0.0
,
(
inputSize
.
height
-
sourceSize
.
height
)
*
(
alignment
?.
dy
??
0.5
));
destinationSize
=
new
Size
(
outputSize
.
width
,
sourceSize
.
height
*
outputSize
.
width
/
sourceSize
.
width
);
break
;
case
ImageFit
.
fitHeight
:
sourceSize
=
new
Size
(
inputSize
.
height
*
outputSize
.
width
/
outputSize
.
height
,
inputSize
.
height
);
sourcePosition
=
new
Point
((
inputSize
.
width
-
sourceSize
.
width
)
*
(
alignment
?.
dx
??
0.5
),
0.0
);
destinationSize
=
new
Size
(
sourceSize
.
width
*
outputSize
.
height
/
sourceSize
.
height
,
outputSize
.
height
);
break
;
case
ImageFit
.
none
:
sourceSize
=
new
Size
(
math
.
min
(
inputSize
.
width
,
outputSize
.
width
),
math
.
min
(
inputSize
.
height
,
outputSize
.
height
));
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
62757672
...
...
@@ -410,7 +410,7 @@ class BoxHitTestEntry extends HitTestEntry {
/// Parent data used by [RenderBox] and its subclasses.
class
BoxParentData
extends
ParentData
{
/// The offset at which to paint the child in the parent's coordinate system
/// The offset at which to paint the child in the parent's coordinate system
.
Offset
offset
=
Offset
.
zero
;
@override
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
62757672
...
...
@@ -567,11 +567,14 @@ int _getAlphaFromOpacity(double opacity) => (opacity * 255).round();
/// This class paints its child into an intermediate buffer and then blends the
/// child back into the scene partially transparent.
///
/// This class is relatively expensive because it requires painting the child
/// into an intermediate buffer.
/// For values of opacity other than 0.0 and 1.0, this class is relatively
/// expensive because it requires painting the child into an intermediate
/// buffer. For the value 0.0, the child is simply not painted at all. For the
/// value 1.0, the child is painted immediately without an intermediate buffer.
class
RenderOpacity
extends
RenderProxyBox
{
RenderOpacity
({
RenderBox
child
,
double
opacity:
1.0
})
:
_opacity
=
opacity
,
_alpha
=
_getAlphaFromOpacity
(
opacity
),
super
(
child
)
{
assert
(
opacity
!=
null
);
assert
(
opacity
>=
0.0
&&
opacity
<=
1.0
);
}
...
...
@@ -582,6 +585,12 @@ class RenderOpacity extends RenderProxyBox {
///
/// An opacity of 1.0 is fully opaque. An opacity of 0.0 is fully transparent
/// (i.e., invisible).
///
/// The opacity must not be null.
///
/// Values 1.0 and 0.0 are painted with a fast path. Other values
/// require painting the child into an intermediate buffer, which is
/// expensive.
double
get
opacity
=>
_opacity
;
double
_opacity
;
void
set
opacity
(
double
newOpacity
)
{
...
...
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