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
0c229008
Commit
0c229008
authored
Oct 13, 2015
by
Kris Giesing
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into events-merge
parents
ec205ac5
42469d2c
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
742 additions
and
640 deletions
+742
-640
pubspec.yaml
examples/game/pubspec.yaml
+2
-2
pubspec.yaml
examples/raw/pubspec.yaml
+1
-1
sector_layout.dart
examples/rendering/lib/sector_layout.dart
+527
-0
pubspec.yaml
examples/rendering/pubspec.yaml
+1
-1
sector_layout.dart
examples/rendering/sector_layout.dart
+2
-532
nine_patch.dart
examples/widgets/nine_patch.dart
+14
-0
pubspec.yaml
examples/widgets/pubspec.yaml
+4
-1
sector.dart
examples/widgets/sector.dart
+32
-26
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+78
-41
box.dart
packages/flutter/lib/src/rendering/box.dart
+1
-1
image.dart
packages/flutter/lib/src/rendering/image.dart
+35
-16
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+41
-12
label.dart
packages/flutter_sprites/lib/label.dart
+1
-1
pubspec.yaml
packages/flutter_sprites/pubspec.yaml
+3
-6
No files found.
examples/game/pubspec.yaml
View file @
0c229008
...
@@ -2,12 +2,12 @@ name: asteroids
...
@@ -2,12 +2,12 @@ name: asteroids
dependencies
:
dependencies
:
flutter
:
"
>=0.0.3
<0.1.0"
flutter
:
"
>=0.0.3
<0.1.0"
sky_tools
:
any
sky_tools
:
any
sky
sprites
:
any
flutter_
sprites
:
any
box2d
:
any
box2d
:
any
dependency_overrides
:
dependency_overrides
:
material_design_icons
:
material_design_icons
:
path
:
../../sky/packages/material_design_icons
path
:
../../sky/packages/material_design_icons
flutter
:
flutter
:
path
:
../../sky/packages/sky
path
:
../../sky/packages/sky
sky
sprites
:
flutter_
sprites
:
path
:
../../skysprites
path
:
../../skysprites
examples/raw/pubspec.yaml
View file @
0c229008
name
:
raw
name
:
sky_raw_examples
dependencies
:
dependencies
:
flutter
:
"
>=0.0.3
<0.1.0"
flutter
:
"
>=0.0.3
<0.1.0"
sky_tools
:
any
sky_tools
:
any
...
...
examples/rendering/lib/sector_layout.dart
0 → 100644
View file @
0c229008
This diff is collapsed.
Click to expand it.
examples/rendering/pubspec.yaml
View file @
0c229008
name
:
rendering
name
:
flutter_rendering_examples
dependencies
:
dependencies
:
flutter
:
"
>=0.0.3
<0.1.0"
flutter
:
"
>=0.0.3
<0.1.0"
sky_tools
:
any
sky_tools
:
any
...
...
examples/rendering/sector_layout.dart
View file @
0c229008
This diff is collapsed.
Click to expand it.
examples/widgets/nine_patch.dart
0 → 100644
View file @
0c229008
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/painting.dart'
;
import
'package:flutter/material.dart'
;
void
main
(
)
{
runApp
(
new
NetworkImage
(
src:
"http://38.media.tumblr.com/avatar_497c78dc767d_128.png"
,
fit:
ImageFit
.
contain
,
centerSlice:
new
Rect
.
fromLTRB
(
40.0
,
40.0
,
88.0
,
88.0
)
));
}
examples/widgets/pubspec.yaml
View file @
0c229008
name
:
widget
s
name
:
sky_widgets_example
s
dependencies
:
dependencies
:
flutter
:
"
>=0.0.3
<0.1.0"
flutter
:
"
>=0.0.3
<0.1.0"
sky_tools
:
any
sky_tools
:
any
flutter_rendering_examples
:
any
dependency_overrides
:
dependency_overrides
:
material_design_icons
:
material_design_icons
:
path
:
../../sky/packages/material_design_icons
path
:
../../sky/packages/material_design_icons
flutter
:
flutter
:
path
:
../../sky/packages/sky
path
:
../../sky/packages/sky
flutter_rendering_examples
:
path
:
../rendering
examples/widgets/sector.dart
.old
→
examples/widgets/sector.dart
View file @
0c229008
...
@@ -7,7 +7,7 @@ import 'dart:math' as math;
...
@@ -7,7 +7,7 @@ import 'dart:math' as math;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import '
../rendering
/sector_layout.dart';
import
'
package:flutter_rendering_examples
/sector_layout.dart'
;
RenderBox
initCircle
(
)
{
RenderBox
initCircle
(
)
{
return
new
RenderBoxToRenderSectorAdapter
(
return
new
RenderBoxToRenderSectorAdapter
(
...
@@ -16,10 +16,14 @@ RenderBox initCircle() {
...
@@ -16,10 +16,14 @@ RenderBox initCircle() {
);
);
}
}
class SectorApp extends MaterialApp {
class
SectorApp
extends
StatefulComponent
{
SectorAppState
createState
()
=>
new
SectorAppState
();
}
class
SectorAppState
extends
State
<
SectorApp
>
{
RenderBoxToRenderSectorAdapter sectors = initCircle();
final
RenderBoxToRenderSectorAdapter
sectors
=
initCircle
();
math.Random rand = new math.Random(1);
final
math
.
Random
rand
=
new
math
.
Random
(
1
);
void
addSector
()
{
void
addSector
()
{
double
deltaTheta
;
double
deltaTheta
;
...
@@ -52,27 +56,27 @@ class SectorApp extends MaterialApp {
...
@@ -52,27 +56,27 @@ class SectorApp extends MaterialApp {
RenderBoxToRenderSectorAdapter
sectorAddIcon
=
initSector
(
const
Color
(
0xFF00DD00
));
RenderBoxToRenderSectorAdapter
sectorAddIcon
=
initSector
(
const
Color
(
0xFF00DD00
));
RenderBoxToRenderSectorAdapter
sectorRemoveIcon
=
initSector
(
const
Color
(
0xFFDD0000
));
RenderBoxToRenderSectorAdapter
sectorRemoveIcon
=
initSector
(
const
Color
(
0xFFDD0000
));
bool enabledAdd = true;
bool
_
enabledAdd
=
true
;
bool enabledRemove = false;
bool
_
enabledRemove
=
false
;
void
updateEnabledState
()
{
void
updateEnabledState
()
{
setState
(()
{
setState
(()
{
var
ring
=
(
sectors
.
child
as
RenderSectorRing
);
var
ring
=
(
sectors
.
child
as
RenderSectorRing
);
SectorDimensions
currentSize
=
ring
.
getIntrinsicDimensions
(
const
SectorConstraints
(),
ring
.
deltaRadius
);
SectorDimensions
currentSize
=
ring
.
getIntrinsicDimensions
(
const
SectorConstraints
(),
ring
.
deltaRadius
);
enabledAdd = currentSize.deltaTheta < kTwoPi;
_
enabledAdd
=
currentSize
.
deltaTheta
<
kTwoPi
;
enabledRemove = ring.firstChild != null;
_
enabledRemove
=
ring
.
firstChild
!=
null
;
});
});
}
}
Widget
buildBody
()
{
Widget
buildBody
()
{
return
new
Material
(
return
new
Material
(
child: new Column([
child:
new
Column
(
<
Widget
>
[
new
Container
(
new
Container
(
padding:
new
EdgeDims
.
symmetric
(
horizontal:
8.0
,
vertical:
25.0
),
padding:
new
EdgeDims
.
symmetric
(
horizontal:
8.0
,
vertical:
25.0
),
child: new Row([
child:
new
Row
(
<
Widget
>
[
new
RaisedButton
(
new
RaisedButton
(
enabled: enabledAdd,
enabled:
_
enabledAdd
,
child:
new
IntrinsicWidth
(
child:
new
IntrinsicWidth
(
child: new Row([
child:
new
Row
(
<
Widget
>
[
new
Container
(
new
Container
(
padding:
new
EdgeDims
.
all
(
4.0
),
padding:
new
EdgeDims
.
all
(
4.0
),
margin:
new
EdgeDims
.
only
(
right:
10.0
),
margin:
new
EdgeDims
.
only
(
right:
10.0
),
...
@@ -84,9 +88,9 @@ class SectorApp extends MaterialApp {
...
@@ -84,9 +88,9 @@ class SectorApp extends MaterialApp {
onPressed:
addSector
onPressed:
addSector
),
),
new
RaisedButton
(
new
RaisedButton
(
enabled: enabledRemove,
enabled:
_
enabledRemove
,
child:
new
IntrinsicWidth
(
child:
new
IntrinsicWidth
(
child: new Row([
child:
new
Row
(
<
Widget
>
[
new
Container
(
new
Container
(
padding:
new
EdgeDims
.
all
(
4.0
),
padding:
new
EdgeDims
.
all
(
4.0
),
margin:
new
EdgeDims
.
only
(
right:
10.0
),
margin:
new
EdgeDims
.
only
(
right:
10.0
),
...
@@ -117,18 +121,20 @@ class SectorApp extends MaterialApp {
...
@@ -117,18 +121,20 @@ class SectorApp extends MaterialApp {
);
);
}
}
Widget build() {
Widget
build
(
BuildContext
context
)
{
return new Theme(
return
new
MaterialApp
(
data: new ThemeData.light(),
theme:
new
ThemeData
.
light
(),
child: new Title(
title:
'Sector Layout'
,
title: 'Sector Layout',
routes:
<
String
,
RouteBuilder
>{
child: new Scaffold(
'/'
:
(
RouteArguments
args
)
{
toolBar: new ToolBar(
return
new
Scaffold
(
center: new Text('Sector Layout in a Widget Tree')
toolBar:
new
ToolBar
(
),
center:
new
Text
(
'Sector Layout in a Widget Tree'
)
body: buildBody()
),
)
body:
buildBody
()
)
);
}
}
);
);
}
}
}
}
...
...
packages/flutter/lib/src/painting/box_painter.dart
View file @
0c229008
...
@@ -10,43 +10,47 @@ import 'package:flutter/services.dart';
...
@@ -10,43 +10,47 @@ import 'package:flutter/services.dart';
import
'shadows.dart'
;
import
'shadows.dart'
;
/// An immutable set of offsets in each of the four cardinal directions
/// An immutable set of offsets in each of the four cardinal directions
.
///
///
/// Typically used for an offset from each of the four sides of a box. For
/// Typically used for an offset from each of the four sides of a box. For
/// example, the padding inside a box can be represented using this class.
/// example, the padding inside a box can be represented using this class.
class
EdgeDims
{
class
EdgeDims
{
/// Constructs an EdgeDims from offsets from the top, right, bottom and left
/// Constructs an EdgeDims from offsets from the top, right, bottom and left
.
const
EdgeDims
.
TRBL
(
this
.
top
,
this
.
right
,
this
.
bottom
,
this
.
left
);
const
EdgeDims
.
TRBL
(
this
.
top
,
this
.
right
,
this
.
bottom
,
this
.
left
);
/// Constructs an EdgeDims where all the offsets are value
/// Constructs an EdgeDims where all the offsets are value
.
const
EdgeDims
.
all
(
double
value
)
const
EdgeDims
.
all
(
double
value
)
:
top
=
value
,
right
=
value
,
bottom
=
value
,
left
=
value
;
:
top
=
value
,
right
=
value
,
bottom
=
value
,
left
=
value
;
/// Constructs an EdgeDims with only the given values non-zero
/// Constructs an EdgeDims with only the given values non-zero
.
const
EdgeDims
.
only
({
this
.
top
:
0.0
,
const
EdgeDims
.
only
({
this
.
top
:
0.0
,
this
.
right
:
0.0
,
this
.
right
:
0.0
,
this
.
bottom
:
0.0
,
this
.
bottom
:
0.0
,
this
.
left
:
0.0
});
this
.
left
:
0.0
});
/// Constructs an EdgeDims with symmetrical vertical and horizontal offsets
/// Constructs an EdgeDims with symmetrical vertical and horizontal offsets
.
const
EdgeDims
.
symmetric
({
double
vertical:
0.0
,
const
EdgeDims
.
symmetric
({
double
vertical:
0.0
,
double
horizontal:
0.0
})
double
horizontal:
0.0
})
:
top
=
vertical
,
left
=
horizontal
,
bottom
=
vertical
,
right
=
horizontal
;
:
top
=
vertical
,
left
=
horizontal
,
bottom
=
vertical
,
right
=
horizontal
;
/// The offset from the top
/// The offset from the top
.
final
double
top
;
final
double
top
;
/// The offset from the right
/// The offset from the right
.
final
double
right
;
final
double
right
;
/// The offset from the bottom
/// The offset from the bottom
.
final
double
bottom
;
final
double
bottom
;
/// The offset from the left
/// The offset from the left
.
final
double
left
;
final
double
left
;
/// Whether every dimension is non-negative.
bool
get
isNonNegative
=>
top
>=
0.0
&&
right
>=
0.0
&&
bottom
>=
0.0
&&
left
>=
0.0
;
bool
get
isNonNegative
=>
top
>=
0.0
&&
right
>=
0.0
&&
bottom
>=
0.0
&&
left
>=
0.0
;
/// The size that this edge dims would occupy with an empty interior.
Size
get
collapsedSize
=>
new
Size
(
left
+
right
,
top
+
bottom
);
EdgeDims
operator
-(
EdgeDims
other
)
{
EdgeDims
operator
-(
EdgeDims
other
)
{
return
new
EdgeDims
.
TRBL
(
return
new
EdgeDims
.
TRBL
(
top
-
other
.
top
,
top
-
other
.
top
,
...
@@ -101,7 +105,7 @@ class EdgeDims {
...
@@ -101,7 +105,7 @@ class EdgeDims {
);
);
}
}
/// Linearly interpolate between two EdgeDims
/// Linearly interpolate between two EdgeDims
.
///
///
/// If either is null, this function interpolates from [EdgeDims.zero].
/// If either is null, this function interpolates from [EdgeDims.zero].
static
EdgeDims
lerp
(
EdgeDims
a
,
EdgeDims
b
,
double
t
)
{
static
EdgeDims
lerp
(
EdgeDims
a
,
EdgeDims
b
,
double
t
)
{
...
@@ -119,7 +123,7 @@ class EdgeDims {
...
@@ -119,7 +123,7 @@ class EdgeDims {
);
);
}
}
/// An EdgeDims with zero offsets in each direction
/// An EdgeDims with zero offsets in each direction
.
static
const
EdgeDims
zero
=
const
EdgeDims
.
TRBL
(
0.0
,
0.0
,
0.0
,
0.0
);
static
const
EdgeDims
zero
=
const
EdgeDims
.
TRBL
(
0.0
,
0.0
,
0.0
,
0.0
);
bool
operator
==(
dynamic
other
)
{
bool
operator
==(
dynamic
other
)
{
...
@@ -416,88 +420,121 @@ void paintImage({
...
@@ -416,88 +420,121 @@ void paintImage({
Rect
rect
,
Rect
rect
,
ui
.
Image
image
,
ui
.
Image
image
,
ui
.
ColorFilter
colorFilter
,
ui
.
ColorFilter
colorFilter
,
fit:
ImageFit
.
scaleDown
,
ImageFit
fit
,
repeat:
ImageRepeat
.
noRepeat
,
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
,
double
positionX:
0.5
,
double
positionX:
0.5
,
double
positionY:
0.5
double
positionY:
0.5
})
{
})
{
Size
bounds
=
rect
.
size
;
Size
outputSize
=
rect
.
size
;
Size
imageSize
=
new
Size
(
image
.
width
.
toDouble
(),
image
.
height
.
toDouble
());
Size
inputSize
=
new
Size
(
image
.
width
.
toDouble
(),
image
.
height
.
toDouble
());
Offset
sliceBorder
;
if
(
centerSlice
!=
null
)
{
sliceBorder
=
new
Offset
(
centerSlice
.
left
+
inputSize
.
width
-
centerSlice
.
right
,
centerSlice
.
top
+
inputSize
.
height
-
centerSlice
.
bottom
);
outputSize
-=
sliceBorder
;
inputSize
-=
sliceBorder
;
}
Size
sourceSize
;
Size
sourceSize
;
Size
destinationSize
;
Size
destinationSize
;
switch
(
fit
)
{
fit
??=
centerSlice
==
null
?
ImageFit
.
scaleDown
:
ImageFit
.
fill
;
assert
(
centerSlice
==
null
||
(
fit
!=
ImageFit
.
none
&&
fit
!=
ImageFit
.
cover
));
switch
(
fit
)
{
case
ImageFit
.
fill
:
case
ImageFit
.
fill
:
sourceSize
=
i
mage
Size
;
sourceSize
=
i
nput
Size
;
destinationSize
=
bounds
;
destinationSize
=
outputSize
;
break
;
break
;
case
ImageFit
.
contain
:
case
ImageFit
.
contain
:
sourceSize
=
i
mage
Size
;
sourceSize
=
i
nput
Size
;
if
(
bounds
.
width
/
bounds
.
height
>
sourceSize
.
width
/
sourceSize
.
height
)
if
(
outputSize
.
width
/
outputSize
.
height
>
sourceSize
.
width
/
sourceSize
.
height
)
destinationSize
=
new
Size
(
sourceSize
.
width
*
bounds
.
height
/
sourceSize
.
height
,
bounds
.
height
);
destinationSize
=
new
Size
(
sourceSize
.
width
*
outputSize
.
height
/
sourceSize
.
height
,
outputSize
.
height
);
else
else
destinationSize
=
new
Size
(
bounds
.
width
,
sourceSize
.
height
*
bounds
.
width
/
sourceSize
.
width
);
destinationSize
=
new
Size
(
outputSize
.
width
,
sourceSize
.
height
*
outputSize
.
width
/
sourceSize
.
width
);
break
;
break
;
case
ImageFit
.
cover
:
case
ImageFit
.
cover
:
if
(
bounds
.
width
/
bounds
.
height
>
imageSize
.
width
/
image
Size
.
height
)
if
(
outputSize
.
width
/
outputSize
.
height
>
inputSize
.
width
/
input
Size
.
height
)
sourceSize
=
new
Size
(
i
mageSize
.
width
,
imageSize
.
width
*
bounds
.
height
/
bounds
.
width
);
sourceSize
=
new
Size
(
i
nputSize
.
width
,
inputSize
.
width
*
outputSize
.
height
/
outputSize
.
width
);
else
else
sourceSize
=
new
Size
(
i
mageSize
.
height
*
bounds
.
width
/
bounds
.
height
,
image
Size
.
height
);
sourceSize
=
new
Size
(
i
nputSize
.
height
*
outputSize
.
width
/
outputSize
.
height
,
input
Size
.
height
);
destinationSize
=
bounds
;
destinationSize
=
outputSize
;
break
;
break
;
case
ImageFit
.
none
:
case
ImageFit
.
none
:
sourceSize
=
new
Size
(
math
.
min
(
i
mageSize
.
width
,
bounds
.
width
),
sourceSize
=
new
Size
(
math
.
min
(
i
nputSize
.
width
,
outputSize
.
width
),
math
.
min
(
i
mageSize
.
height
,
bounds
.
height
));
math
.
min
(
i
nputSize
.
height
,
outputSize
.
height
));
destinationSize
=
sourceSize
;
destinationSize
=
sourceSize
;
break
;
break
;
case
ImageFit
.
scaleDown
:
case
ImageFit
.
scaleDown
:
sourceSize
=
i
mage
Size
;
sourceSize
=
i
nput
Size
;
destinationSize
=
bounds
;
destinationSize
=
outputSize
;
if
(
sourceSize
.
height
>
destinationSize
.
height
)
if
(
sourceSize
.
height
>
destinationSize
.
height
)
destinationSize
=
new
Size
(
sourceSize
.
width
*
destinationSize
.
height
/
sourceSize
.
height
,
sourceSize
.
height
);
destinationSize
=
new
Size
(
sourceSize
.
width
*
destinationSize
.
height
/
sourceSize
.
height
,
sourceSize
.
height
);
if
(
sourceSize
.
width
>
destinationSize
.
width
)
if
(
sourceSize
.
width
>
destinationSize
.
width
)
destinationSize
=
new
Size
(
destinationSize
.
width
,
sourceSize
.
height
*
destinationSize
.
width
/
sourceSize
.
width
);
destinationSize
=
new
Size
(
destinationSize
.
width
,
sourceSize
.
height
*
destinationSize
.
width
/
sourceSize
.
width
);
break
;
break
;
}
}
if
(
centerSlice
!=
null
)
{
outputSize
+=
sliceBorder
;
destinationSize
+=
sliceBorder
;
// We don't have the ability to draw a subset of the image at the same time
// as we apply a nine-patch stretch.
assert
(
sourceSize
==
inputSize
);
}
// TODO(abarth): Implement |repeat|.
// TODO(abarth): Implement |repeat|.
Paint
paint
=
new
Paint
()..
isAntiAlias
=
false
;
Paint
paint
=
new
Paint
()..
isAntiAlias
=
false
;
if
(
colorFilter
!=
null
)
if
(
colorFilter
!=
null
)
paint
.
colorFilter
=
colorFilter
;
paint
.
colorFilter
=
colorFilter
;
double
dx
=
(
bounds
.
width
-
destinationSize
.
width
)
*
positionX
;
double
dx
=
(
outputSize
.
width
-
destinationSize
.
width
)
*
positionX
;
double
dy
=
(
bounds
.
height
-
destinationSize
.
height
)
*
positionY
;
double
dy
=
(
outputSize
.
height
-
destinationSize
.
height
)
*
positionY
;
Point
destinationPosition
=
rect
.
topLeft
+
new
Offset
(
dx
,
dy
);
Point
destinationPosition
=
rect
.
topLeft
+
new
Offset
(
dx
,
dy
);
canvas
.
drawImageRect
(
image
,
Point
.
origin
&
sourceSize
,
destinationPosition
&
destinationSize
,
paint
);
Rect
destinationRect
=
destinationPosition
&
destinationSize
;
if
(
centerSlice
==
null
)
canvas
.
drawImageRect
(
image
,
Point
.
origin
&
sourceSize
,
destinationRect
,
paint
);
else
canvas
.
drawImageNine
(
image
,
centerSlice
,
destinationRect
,
paint
);
}
}
typedef
void
BackgroundImageChangeListener
(
);
typedef
void
BackgroundImageChangeListener
(
);
/// A background image for a box
/// A background image for a box
.
class
BackgroundImage
{
class
BackgroundImage
{
/// How the background image should be inscribed into the box
/// How the background image should be inscribed into the box
.
final
ImageFit
fit
;
final
ImageFit
fit
;
/// How to paint any portions of the box not covered by the background image
/// How to paint any portions of the box not covered by the background image
.
final
ImageRepeat
repeat
;
final
ImageRepeat
repeat
;
/// A color filter to apply to the background image before painting it
/// The center slice for a nine-patch image.
///
/// The region of the image inside the center slice will be stretched both
/// horizontally and vertically to fit the image into its destination. The
/// region of the image above and below the center slice will be stretched
/// only horizontally and the region of the image to the left and right of
/// the center slice will be stretched only vertically.
final
Rect
centerSlice
;
/// A color filter to apply to the background image before painting it.
final
ui
.
ColorFilter
colorFilter
;
final
ui
.
ColorFilter
colorFilter
;
BackgroundImage
({
BackgroundImage
({
ImageResource
image
,
ImageResource
image
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
,
this
.
colorFilter
this
.
colorFilter
})
:
_imageResource
=
image
;
})
:
_imageResource
=
image
;
ui
.
Image
_image
;
/// The image to be painted into the background.
/// The image to be painted into the background
ui
.
Image
get
image
=>
_image
;
ui
.
Image
get
image
=>
_image
;
ui
.
Image
_image
;
ImageResource
_imageResource
;
ImageResource
_imageResource
;
final
List
<
BackgroundImageChangeListener
>
_listeners
=
final
List
<
BackgroundImageChangeListener
>
_listeners
=
new
List
<
BackgroundImageChangeListener
>();
new
List
<
BackgroundImageChangeListener
>();
/// Call listener when the background images changes (e.g., arrives from the network)
/// Call listener when the background images changes (e.g., arrives from the network)
.
void
addChangeListener
(
BackgroundImageChangeListener
listener
)
{
void
addChangeListener
(
BackgroundImageChangeListener
listener
)
{
// We add the listener to the _imageResource first so that the first change
// We add the listener to the _imageResource first so that the first change
// listener doesn't get callback synchronously if the image resource is
// listener doesn't get callback synchronously if the image resource is
...
@@ -507,7 +544,7 @@ class BackgroundImage {
...
@@ -507,7 +544,7 @@ class BackgroundImage {
_listeners
.
add
(
listener
);
_listeners
.
add
(
listener
);
}
}
/// No longer call listener when the background image changes
/// No longer call listener when the background image changes
.
void
removeChangeListener
(
BackgroundImageChangeListener
listener
)
{
void
removeChangeListener
(
BackgroundImageChangeListener
listener
)
{
_listeners
.
remove
(
listener
);
_listeners
.
remove
(
listener
);
// We need to remove ourselves as listeners from the _imageResource so that
// We need to remove ourselves as listeners from the _imageResource so that
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
0c229008
...
@@ -633,7 +633,7 @@ abstract class RenderBox extends RenderObject {
...
@@ -633,7 +633,7 @@ abstract class RenderBox extends RenderObject {
}
}
}
}
String
debugDescribeSettings
(
String
prefix
)
=>
'
${super.debugDescribeSettings(prefix)}${prefix}
size:
$
size
\n
'
;
String
debugDescribeSettings
(
String
prefix
)
=>
'
${super.debugDescribeSettings(prefix)}${prefix}
size:
$
{ hasSize ? size : "MISSING" }
\n
'
;
}
}
/// A mixin that provides useful default behaviors for boxes with children
/// A mixin that provides useful default behaviors for boxes with children
...
...
packages/flutter/lib/src/rendering/image.dart
View file @
0c229008
...
@@ -9,7 +9,7 @@ import 'package:flutter/painting.dart';
...
@@ -9,7 +9,7 @@ import 'package:flutter/painting.dart';
import
'box.dart'
;
import
'box.dart'
;
import
'object.dart'
;
import
'object.dart'
;
/// An image in the render tree
/// An image in the render tree
.
///
///
/// The render image attempts to find a size for itself that fits in the given
/// The render image attempts to find a size for itself that fits in the given
/// constraints and preserves the image's intrinisc aspect ratio.
/// constraints and preserves the image's intrinisc aspect ratio.
...
@@ -19,18 +19,20 @@ class RenderImage extends RenderBox {
...
@@ -19,18 +19,20 @@ class RenderImage extends RenderBox {
double
width
,
double
width
,
double
height
,
double
height
,
ui
.
ColorFilter
colorFilter
,
ui
.
ColorFilter
colorFilter
,
fit:
ImageFit
.
scaleDown
,
ImageFit
fit
,
repeat:
ImageRepeat
.
noRepeat
repeat:
ImageRepeat
.
noRepeat
,
Rect
centerSlice
})
:
_image
=
image
,
})
:
_image
=
image
,
_width
=
width
,
_width
=
width
,
_height
=
height
,
_height
=
height
,
_colorFilter
=
colorFilter
,
_colorFilter
=
colorFilter
,
_fit
=
fit
,
_fit
=
fit
,
_repeat
=
repeat
;
_repeat
=
repeat
,
_centerSlice
=
centerSlice
;
ui
.
Image
_image
;
/// The image to display.
/// The image to display
ui
.
Image
get
image
=>
_image
;
ui
.
Image
get
image
=>
_image
;
ui
.
Image
_image
;
void
set
image
(
ui
.
Image
value
)
{
void
set
image
(
ui
.
Image
value
)
{
if
(
value
==
_image
)
if
(
value
==
_image
)
return
;
return
;
...
@@ -40,9 +42,9 @@ class RenderImage extends RenderBox {
...
@@ -40,9 +42,9 @@ class RenderImage extends RenderBox {
markNeedsLayout
();
markNeedsLayout
();
}
}
double
_width
;
/// If non-null, requires the image to have this width.
/// If non-null, requires the image to have this width
double
get
width
=>
_width
;
double
get
width
=>
_width
;
double
_width
;
void
set
width
(
double
value
)
{
void
set
width
(
double
value
)
{
if
(
value
==
_width
)
if
(
value
==
_width
)
return
;
return
;
...
@@ -50,9 +52,9 @@ class RenderImage extends RenderBox {
...
@@ -50,9 +52,9 @@ class RenderImage extends RenderBox {
markNeedsLayout
();
markNeedsLayout
();
}
}
double
_height
;
/// If non-null, requires the image to have this height.
/// If non-null, requires the image to have this height
double
get
height
=>
_height
;
double
get
height
=>
_height
;
double
_height
;
void
set
height
(
double
value
)
{
void
set
height
(
double
value
)
{
if
(
value
==
_height
)
if
(
value
==
_height
)
return
;
return
;
...
@@ -60,9 +62,9 @@ class RenderImage extends RenderBox {
...
@@ -60,9 +62,9 @@ class RenderImage extends RenderBox {
markNeedsLayout
();
markNeedsLayout
();
}
}
ui
.
ColorFilter
_colorFilter
;
/// If non-null, apply this color filter to the image before painint.
/// If non-null, apply this color filter to the image before painint.
ui
.
ColorFilter
get
colorFilter
=>
_colorFilter
;
ui
.
ColorFilter
get
colorFilter
=>
_colorFilter
;
ui
.
ColorFilter
_colorFilter
;
void
set
colorFilter
(
ui
.
ColorFilter
value
)
{
void
set
colorFilter
(
ui
.
ColorFilter
value
)
{
if
(
value
==
_colorFilter
)
if
(
value
==
_colorFilter
)
return
;
return
;
...
@@ -70,9 +72,9 @@ class RenderImage extends RenderBox {
...
@@ -70,9 +72,9 @@ class RenderImage extends RenderBox {
markNeedsPaint
();
markNeedsPaint
();
}
}
ImageFit
_fit
;
/// How to inscribe the image into the place allocated during layout.
/// How to inscribe the image into the place allocated during layout
ImageFit
get
fit
=>
_fit
;
ImageFit
get
fit
=>
_fit
;
ImageFit
_fit
;
void
set
fit
(
ImageFit
value
)
{
void
set
fit
(
ImageFit
value
)
{
if
(
value
==
_fit
)
if
(
value
==
_fit
)
return
;
return
;
...
@@ -80,9 +82,9 @@ class RenderImage extends RenderBox {
...
@@ -80,9 +82,9 @@ class RenderImage extends RenderBox {
markNeedsPaint
();
markNeedsPaint
();
}
}
ImageRepeat
_repeat
;
/// Not yet implemented.
/// Not yet implemented
ImageRepeat
get
repeat
=>
_repeat
;
ImageRepeat
get
repeat
=>
_repeat
;
ImageRepeat
_repeat
;
void
set
repeat
(
ImageRepeat
value
)
{
void
set
repeat
(
ImageRepeat
value
)
{
if
(
value
==
_repeat
)
if
(
value
==
_repeat
)
return
;
return
;
...
@@ -90,7 +92,23 @@ class RenderImage extends RenderBox {
...
@@ -90,7 +92,23 @@ class RenderImage extends RenderBox {
markNeedsPaint
();
markNeedsPaint
();
}
}
/// Find a size for the render image within the given constraints
/// The center slice for a nine-patch image.
///
/// The region of the image inside the center slice will be stretched both
/// horizontally and vertically to fit the image into its destination. The
/// region of the image above and below the center slice will be stretched
/// only horizontally and the region of the image to the left and right of
/// the center slice will be stretched only vertically.
Rect
get
centerSlice
=>
_centerSlice
;
Rect
_centerSlice
;
void
set
centerSlice
(
Rect
value
)
{
if
(
value
==
_centerSlice
)
return
;
_centerSlice
=
value
;
markNeedsPaint
();
}
/// Find a size for the render image within the given constraints.
///
///
/// - The dimensions of the RenderImage must fit within the constraints.
/// - The dimensions of the RenderImage must fit within the constraints.
/// - The aspect ratio of the RenderImage matches the instrinsic aspect
/// - The aspect ratio of the RenderImage matches the instrinsic aspect
...
@@ -170,6 +188,7 @@ class RenderImage extends RenderBox {
...
@@ -170,6 +188,7 @@ class RenderImage extends RenderBox {
image:
_image
,
image:
_image
,
colorFilter:
_colorFilter
,
colorFilter:
_colorFilter
,
fit:
_fit
,
fit:
_fit
,
centerSlice:
_centerSlice
,
repeat:
_repeat
repeat:
_repeat
);
);
}
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
0c229008
...
@@ -809,8 +809,9 @@ class Image extends LeafRenderObjectWidget {
...
@@ -809,8 +809,9 @@ class Image extends LeafRenderObjectWidget {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
colorFilter
,
this
.
colorFilter
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
ui
.
Image
image
;
final
ui
.
Image
image
;
...
@@ -819,6 +820,7 @@ class Image extends LeafRenderObjectWidget {
...
@@ -819,6 +820,7 @@ class Image extends LeafRenderObjectWidget {
final
ui
.
ColorFilter
colorFilter
;
final
ui
.
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
ImageFit
fit
;
final
ImageRepeat
repeat
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
RenderImage
createRenderObject
()
=>
new
RenderImage
(
RenderImage
createRenderObject
()
=>
new
RenderImage
(
image:
image
,
image:
image
,
...
@@ -826,7 +828,8 @@ class Image extends LeafRenderObjectWidget {
...
@@ -826,7 +828,8 @@ class Image extends LeafRenderObjectWidget {
height:
height
,
height:
height
,
colorFilter:
colorFilter
,
colorFilter:
colorFilter
,
fit:
fit
,
fit:
fit
,
repeat:
repeat
);
repeat:
repeat
,
centerSlice:
centerSlice
);
void
updateRenderObject
(
RenderImage
renderObject
,
Image
oldWidget
)
{
void
updateRenderObject
(
RenderImage
renderObject
,
Image
oldWidget
)
{
renderObject
.
image
=
image
;
renderObject
.
image
=
image
;
...
@@ -835,6 +838,7 @@ class Image extends LeafRenderObjectWidget {
...
@@ -835,6 +838,7 @@ class Image extends LeafRenderObjectWidget {
renderObject
.
colorFilter
=
colorFilter
;
renderObject
.
colorFilter
=
colorFilter
;
renderObject
.
fit
=
fit
;
renderObject
.
fit
=
fit
;
renderObject
.
repeat
=
repeat
;
renderObject
.
repeat
=
repeat
;
renderObject
.
centerSlice
=
centerSlice
;
}
}
}
}
...
@@ -845,8 +849,9 @@ class ImageListener extends StatefulComponent {
...
@@ -845,8 +849,9 @@ class ImageListener extends StatefulComponent {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
colorFilter
,
this
.
colorFilter
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
)
{
})
:
super
(
key:
key
)
{
assert
(
image
!=
null
);
assert
(
image
!=
null
);
}
}
...
@@ -857,6 +862,7 @@ class ImageListener extends StatefulComponent {
...
@@ -857,6 +862,7 @@ class ImageListener extends StatefulComponent {
final
ui
.
ColorFilter
colorFilter
;
final
ui
.
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
ImageFit
fit
;
final
ImageRepeat
repeat
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
_ImageListenerState
createState
()
=>
new
_ImageListenerState
();
_ImageListenerState
createState
()
=>
new
_ImageListenerState
();
}
}
...
@@ -894,7 +900,8 @@ class _ImageListenerState extends State<ImageListener> {
...
@@ -894,7 +900,8 @@ class _ImageListenerState extends State<ImageListener> {
height:
config
.
height
,
height:
config
.
height
,
colorFilter:
config
.
colorFilter
,
colorFilter:
config
.
colorFilter
,
fit:
config
.
fit
,
fit:
config
.
fit
,
repeat:
config
.
repeat
repeat:
config
.
repeat
,
centerSlice:
config
.
centerSlice
);
);
}
}
}
}
...
@@ -906,8 +913,9 @@ class NetworkImage extends StatelessComponent {
...
@@ -906,8 +913,9 @@ class NetworkImage extends StatelessComponent {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
colorFilter
,
this
.
colorFilter
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
String
src
;
final
String
src
;
...
@@ -916,6 +924,7 @@ class NetworkImage extends StatelessComponent {
...
@@ -916,6 +924,7 @@ class NetworkImage extends StatelessComponent {
final
ui
.
ColorFilter
colorFilter
;
final
ui
.
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
ImageFit
fit
;
final
ImageRepeat
repeat
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
ImageListener
(
return
new
ImageListener
(
...
@@ -924,7 +933,8 @@ class NetworkImage extends StatelessComponent {
...
@@ -924,7 +933,8 @@ class NetworkImage extends StatelessComponent {
height:
height
,
height:
height
,
colorFilter:
colorFilter
,
colorFilter:
colorFilter
,
fit:
fit
,
fit:
fit
,
repeat:
repeat
repeat:
repeat
,
centerSlice:
centerSlice
);
);
}
}
}
}
...
@@ -937,8 +947,9 @@ class AssetImage extends StatelessComponent {
...
@@ -937,8 +947,9 @@ class AssetImage extends StatelessComponent {
this
.
width
,
this
.
width
,
this
.
height
,
this
.
height
,
this
.
colorFilter
,
this
.
colorFilter
,
this
.
fit
:
ImageFit
.
scaleDown
,
this
.
fit
,
this
.
repeat
:
ImageRepeat
.
noRepeat
this
.
repeat
:
ImageRepeat
.
noRepeat
,
this
.
centerSlice
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
String
name
;
final
String
name
;
...
@@ -948,6 +959,7 @@ class AssetImage extends StatelessComponent {
...
@@ -948,6 +959,7 @@ class AssetImage extends StatelessComponent {
final
ui
.
ColorFilter
colorFilter
;
final
ui
.
ColorFilter
colorFilter
;
final
ImageFit
fit
;
final
ImageFit
fit
;
final
ImageRepeat
repeat
;
final
ImageRepeat
repeat
;
final
Rect
centerSlice
;
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
ImageListener
(
return
new
ImageListener
(
...
@@ -956,11 +968,28 @@ class AssetImage extends StatelessComponent {
...
@@ -956,11 +968,28 @@ class AssetImage extends StatelessComponent {
height:
height
,
height:
height
,
colorFilter:
colorFilter
,
colorFilter:
colorFilter
,
fit:
fit
,
fit:
fit
,
repeat:
repeat
repeat:
repeat
,
centerSlice:
centerSlice
);
);
}
}
}
}
class
WidgetToRenderBoxAdapter
extends
LeafRenderObjectWidget
{
WidgetToRenderBoxAdapter
(
RenderBox
renderBox
)
:
renderBox
=
renderBox
,
// WidgetToRenderBoxAdapter objects are keyed to their render box. This
// prevents the widget being used in the widget hierarchy in two different
// places, which would cause the RenderBox to get inserted in multiple
// places in the RenderObject tree.
super
(
key:
new
GlobalObjectKey
(
renderBox
))
{
assert
(
renderBox
!=
null
);
}
final
RenderBox
renderBox
;
RenderBox
createRenderObject
()
=>
renderBox
;
}
// EVENT HANDLING
// EVENT HANDLING
...
...
packages/flutter_sprites/lib/label.dart
View file @
0c229008
part of
skysprites
;
part of
skysprites
;
/// Labels are used to display a string of text in a the node tree. To align
/// Labels are used to display a string of text in a the node tree. To align
/// the label, the textAlign property of t
eh
[TextStyle] can be set.
/// the label, the textAlign property of t
he
[TextStyle] can be set.
class
Label
extends
Node
{
class
Label
extends
Node
{
/// Creates a new Label with the provided [_text] and [_textStyle].
/// Creates a new Label with the provided [_text] and [_textStyle].
Label
(
this
.
_text
,
[
this
.
_textStyle
])
{
Label
(
this
.
_text
,
[
this
.
_textStyle
])
{
...
...
packages/flutter_sprites/pubspec.yaml
View file @
0c229008
name
:
sky
sprites
name
:
flutter_
sprites
description
:
A sprite toolkit built on top of Flutter
description
:
A sprite toolkit built on top of Flutter
version
:
0.0.
1
version
:
0.0.
2
author
:
Flutter Authors <flutter-dev@googlegroups.com>
author
:
Flutter Authors <flutter-dev@googlegroups.com>
homepage
:
http://flutter.io
homepage
:
http://flutter.io
dependencies
:
dependencies
:
flutter
:
"
>=0.0.3
<0.1.0"
flutter
:
"
>=0.0.3
<0.1.0"
sky_tools
:
"
>=0.0.18
<0.1.0"
sky_tools
:
"
>=0.0.18
<0.1.0"
box2d
:
any
box2d
:
"
>=0.2.0
<0.3.0"
dependency_overrides
:
flutter
:
path
:
../sky/packages/sky
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