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
6562c149
Commit
6562c149
authored
Nov 20, 2015
by
Tony Gentilcore
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a FractionalOffset alignment parameter to BackgroundImage
parent
4355302e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
35 deletions
+43
-35
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+42
-1
box.dart
packages/flutter/lib/src/rendering/box.dart
+1
-34
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
6562c149
...
...
@@ -661,7 +661,8 @@ class BackgroundImage {
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
,
this
.
colorFilter
this
.
colorFilter
,
this
.
alignment
})
:
_imageResource
=
image
;
/// How the background image should be inscribed into the box.
...
...
@@ -682,6 +683,9 @@ class BackgroundImage {
/// A color filter to apply to the background image before painting it.
final
ColorFilter
colorFilter
;
/// How to align the image within its bounds.
final
FractionalOffset
alignment
;
/// The image to be painted into the background.
ui
.
Image
get
image
=>
_image
;
ui
.
Image
_image
;
...
...
@@ -730,6 +734,7 @@ class BackgroundImage {
repeat
==
typedOther
.
repeat
&&
centerSlice
==
typedOther
.
centerSlice
&&
colorFilter
==
typedOther
.
colorFilter
&&
alignment
==
typedOther
.
alignment
&&
_imageResource
==
typedOther
.
_imageResource
;
}
...
...
@@ -739,6 +744,7 @@ class BackgroundImage {
value
=
37
*
value
+
repeat
.
hashCode
;
value
=
37
*
value
+
centerSlice
.
hashCode
;
value
=
37
*
value
+
colorFilter
.
hashCode
;
value
=
37
*
value
+
alignment
.
hashCode
;
value
=
37
*
value
+
_imageResource
.
hashCode
;
return
value
;
}
...
...
@@ -988,6 +994,8 @@ class BoxPainter {
rect:
rect
,
image:
image
,
colorFilter:
backgroundImage
.
colorFilter
,
alignX:
backgroundImage
.
alignment
?.
x
,
alignY:
backgroundImage
.
alignment
?.
y
,
fit:
backgroundImage
.
fit
,
repeat:
backgroundImage
.
repeat
);
...
...
@@ -1093,3 +1101,36 @@ class BoxPainter {
_paintBorder
(
canvas
,
rect
);
}
}
/// An offset that's expressed as a fraction of a Size.
///
/// FractionalOffset(1.0, 0.0) represents the top right of the Size,
/// FractionalOffset(0.0, 1.0) represents the bottom left of the Size,
class
FractionalOffset
{
const
FractionalOffset
(
this
.
x
,
this
.
y
);
final
double
x
;
final
double
y
;
bool
operator
==(
dynamic
other
)
{
if
(
other
is
!
FractionalOffset
)
return
false
;
final
FractionalOffset
typedOther
=
other
;
return
x
==
typedOther
.
x
&&
y
==
typedOther
.
y
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
x
.
hashCode
;
value
=
37
*
value
+
y
.
hashCode
;
return
value
;
}
static
FractionalOffset
lerp
(
FractionalOffset
a
,
FractionalOffset
b
,
double
t
)
{
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
new
FractionalOffset
(
b
.
x
*
t
,
b
.
y
*
t
);
if
(
b
==
null
)
return
new
FractionalOffset
(
b
.
x
*
(
1.0
-
t
),
b
.
y
*
(
1.0
-
t
));
return
new
FractionalOffset
(
ui
.
lerpDouble
(
a
.
x
,
b
.
x
,
t
),
ui
.
lerpDouble
(
a
.
y
,
b
.
y
,
t
));
}
String
toString
()
=>
'
$runtimeType
(
$x
,
$y
)'
;
}
packages/flutter/lib/src/rendering/box.dart
View file @
6562c149
...
...
@@ -13,7 +13,7 @@ import 'package:vector_math/vector_math_64.dart';
import
'debug.dart'
;
import
'object.dart'
;
export
'package:flutter/painting.dart'
show
TextBaseline
;
export
'package:flutter/painting.dart'
show
FractionalOffset
,
TextBaseline
;
// This class should only be used in debug builds
class
_DebugSize
extends
Size
{
...
...
@@ -780,39 +780,6 @@ abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare
}
}
/// An offset that's expressed as a fraction of a Size.
///
/// FractionalOffset(1.0, 0.0) represents the top right of the Size,
/// FractionalOffset(0.0, 1.0) represents the bottom left of the Size,
class
FractionalOffset
{
const
FractionalOffset
(
this
.
x
,
this
.
y
);
final
double
x
;
final
double
y
;
bool
operator
==(
dynamic
other
)
{
if
(
other
is
!
FractionalOffset
)
return
false
;
final
FractionalOffset
typedOther
=
other
;
return
x
==
typedOther
.
x
&&
y
==
typedOther
.
y
;
}
int
get
hashCode
{
int
value
=
373
;
value
=
37
*
value
+
x
.
hashCode
;
value
=
37
*
value
+
y
.
hashCode
;
return
value
;
}
static
FractionalOffset
lerp
(
FractionalOffset
a
,
FractionalOffset
b
,
double
t
)
{
if
(
a
==
null
&&
b
==
null
)
return
null
;
if
(
a
==
null
)
return
new
FractionalOffset
(
b
.
x
*
t
,
b
.
y
*
t
);
if
(
b
==
null
)
return
new
FractionalOffset
(
b
.
x
*
(
1.0
-
t
),
b
.
y
*
(
1.0
-
t
));
return
new
FractionalOffset
(
ui
.
lerpDouble
(
a
.
x
,
b
.
x
,
t
),
ui
.
lerpDouble
(
a
.
y
,
b
.
y
,
t
));
}
String
toString
()
=>
'
$runtimeType
(
$x
,
$y
)'
;
}
class
AnimatedFractionalOffsetValue
extends
AnimatedValue
<
FractionalOffset
>
{
AnimatedFractionalOffsetValue
(
FractionalOffset
begin
,
{
FractionalOffset
end
,
Curve
curve
,
Curve
reverseCurve
})
:
super
(
begin
,
end:
end
,
curve:
curve
,
reverseCurve:
reverseCurve
);
...
...
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