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
8294b96f
Commit
8294b96f
authored
May 18, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete dartdocs for painting.dart (#4003)
parent
4e1108e7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
203 additions
and
32 deletions
+203
-32
box_painter.dart
packages/flutter/lib/src/painting/box_painter.dart
+108
-18
colors.dart
packages/flutter/lib/src/painting/colors.dart
+13
-0
edge_insets.dart
packages/flutter/lib/src/painting/edge_insets.dart
+16
-4
text_editing.dart
packages/flutter/lib/src/painting/text_editing.dart
+26
-0
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+7
-0
transforms.dart
packages/flutter/lib/src/painting/transforms.dart
+12
-0
box.dart
packages/flutter/lib/src/rendering/box.dart
+17
-6
error.dart
packages/flutter/lib/src/rendering/error.dart
+1
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+1
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+2
-2
No files found.
packages/flutter/lib/src/painting/box_painter.dart
View file @
8294b96f
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/painting/colors.dart
View file @
8294b96f
...
...
@@ -4,7 +4,16 @@
import
'dart:ui'
show
Color
,
lerpDouble
,
hashValues
;
/// A color represented using [alpha], [hue], [saturation], and [value].
///
/// An [HSVColor] is represented in a parameter space that's motivated by human
/// perception. The representation is useful for some color computations (e.g.,
/// rotating the hue through the colors of the rainbow).
class
HSVColor
{
/// Creates a color.
///
/// All the arguments must not be null and be in their respective ranges. See
/// the fields for each parameter for a description of their ranges.
const
HSVColor
.
fromAHSV
(
this
.
alpha
,
this
.
hue
,
this
.
saturation
,
this
.
value
);
/// Alpha, from 0.0 to 1.0.
...
...
@@ -19,18 +28,22 @@ class HSVColor {
/// Value, from 0.0 to 1.0.
final
double
value
;
/// Returns a copy of this color with the alpha parameter replaced with the given value.
HSVColor
withAlpha
(
double
alpha
)
{
return
new
HSVColor
.
fromAHSV
(
alpha
,
hue
,
saturation
,
value
);
}
/// Returns a copy of this color with the hue parameter replaced with the given value.
HSVColor
withHue
(
double
hue
)
{
return
new
HSVColor
.
fromAHSV
(
alpha
,
hue
,
saturation
,
value
);
}
/// Returns a copy of this color with the saturation parameter replaced with the given value.
HSVColor
withSaturation
(
double
saturation
)
{
return
new
HSVColor
.
fromAHSV
(
alpha
,
hue
,
saturation
,
value
);
}
/// Returns a copy of this color with the value parameter replaced with the given value.
HSVColor
withValue
(
double
value
)
{
return
new
HSVColor
.
fromAHSV
(
alpha
,
hue
,
saturation
,
value
);
}
...
...
packages/flutter/lib/src/painting/edge_insets.dart
View file @
8294b96f
...
...
@@ -11,14 +11,14 @@ import 'basic_types.dart';
/// 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.
class
EdgeInsets
{
/// C
onstruct
s insets from offsets from the left, top, right, and bottom.
/// C
reate
s insets from offsets from the left, top, right, and bottom.
const
EdgeInsets
.
fromLTRB
(
this
.
left
,
this
.
top
,
this
.
right
,
this
.
bottom
);
/// C
onstruct
s insets where all the offsets are value.
/// C
reate
s insets where all the offsets are value.
const
EdgeInsets
.
all
(
double
value
)
:
left
=
value
,
top
=
value
,
right
=
value
,
bottom
=
value
;
/// C
onstruct
s insets with only the given values non-zero.
/// C
reate
s insets with only the given values non-zero.
const
EdgeInsets
.
only
({
this
.
left
:
0.0
,
this
.
top
:
0.0
,
...
...
@@ -26,11 +26,12 @@ class EdgeInsets {
this
.
bottom
:
0.0
});
/// C
onstruct
s insets with symmetrical vertical and horizontal offsets.
/// C
reate
s insets with symmetrical vertical and horizontal offsets.
const
EdgeInsets
.
symmetric
({
double
vertical:
0.0
,
double
horizontal:
0.0
})
:
left
=
horizontal
,
top
=
vertical
,
right
=
horizontal
,
bottom
=
vertical
;
/// Creates insets that match the given window padding.
EdgeInsets
.
fromWindowPadding
(
ui
.
WindowPadding
padding
)
:
left
=
padding
.
left
,
top
=
padding
.
top
,
right
=
padding
.
right
,
bottom
=
padding
.
bottom
;
...
...
@@ -61,10 +62,16 @@ class EdgeInsets {
/// An EdgeInsets with top and bottom as well as left and right flipped.
EdgeInsets
get
flipped
=>
new
EdgeInsets
.
fromLTRB
(
left
,
top
,
right
,
bottom
);
/// Returns a new rect that is bigger than the given rect in each direction by
/// the amount of inset in each direction. Specifically, the left edge of the
/// rect is moved left by [left], the top edge of the rect is moved up by
/// [top], the right edge of the rect is moved right by [right], and the
/// bottom edge of the rect is moved down by [bottom].
Rect
inflateRect
(
Rect
rect
)
{
return
new
Rect
.
fromLTRB
(
rect
.
left
-
left
,
rect
.
top
-
top
,
rect
.
right
+
right
,
rect
.
bottom
+
bottom
);
}
/// Returns the difference between two EdgeInsets.
EdgeInsets
operator
-(
EdgeInsets
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
left
-
other
.
left
,
...
...
@@ -74,6 +81,7 @@ class EdgeInsets {
);
}
/// Returns the sum of two EdgeInsets.
EdgeInsets
operator
+(
EdgeInsets
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
left
+
other
.
left
,
...
...
@@ -83,6 +91,7 @@ class EdgeInsets {
);
}
/// Scales the EdgeInsets in each dimension by the given factor.
EdgeInsets
operator
*(
double
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
left
*
other
,
...
...
@@ -92,6 +101,7 @@ class EdgeInsets {
);
}
/// Divides the EdgeInsets in each dimension by the given factor.
EdgeInsets
operator
/(
double
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
left
/
other
,
...
...
@@ -101,6 +111,7 @@ class EdgeInsets {
);
}
/// Integer divides the EdgeInsets in each dimension by the given factor.
EdgeInsets
operator
~/(
double
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
(
left
~/
other
).
toDouble
(),
...
...
@@ -110,6 +121,7 @@ class EdgeInsets {
);
}
/// Computes the remainder in each dimension by the given factor.
EdgeInsets
operator
%(
double
other
)
{
return
new
EdgeInsets
.
fromLTRB
(
left
%
other
,
...
...
packages/flutter/lib/src/painting/text_editing.dart
View file @
8294b96f
...
...
@@ -8,6 +8,13 @@ export 'dart:ui' show TextAffinity, TextPosition;
/// A range of characters in a string of text.
class
TextRange
{
/// Creates a text range.
///
/// The [start] and [end] arguments must not be null. Both the [start] and
/// [end] must either be greater than or equal to zero or both exactly -1.
///
/// Instead of creating an empty text range, consider using the [empty]
/// constant.
const
TextRange
({
this
.
start
,
this
.
end
});
/// A text range that starts and ends at offset.
...
...
@@ -19,9 +26,13 @@ class TextRange {
static
const
TextRange
empty
=
const
TextRange
(
start:
-
1
,
end:
-
1
);
/// The index of the first character in the range.
///
/// If [start] and [end] are both -1, the text range is empty.
final
int
start
;
/// The next index after the characters in this range.
///
/// If [start] and [end] are both -1, the text range is empty.
final
int
end
;
/// Whether this range represents a valid position in the text.
...
...
@@ -74,6 +85,9 @@ class TextRange {
/// A range of text that represents a selection.
class
TextSelection
extends
TextRange
{
/// Creates a text selection.
///
/// The [baseOffset] and [extentOffset] arguments must not be null.
const
TextSelection
({
int
baseOffset
,
int
extentOffset
,
...
...
@@ -86,11 +100,23 @@ class TextSelection extends TextRange {
end:
baseOffset
<
extentOffset
?
extentOffset
:
baseOffset
);
/// Creates a collapsed selection at the given offset.
///
/// A collapsed selection starts and ends at the same offset, which means it
/// contains zero characters but instead serves as an insertion point in the
/// text.
///
/// The [offset] argument must not be null.
const
TextSelection
.
collapsed
({
int
offset
,
this
.
affinity
:
TextAffinity
.
downstream
})
:
baseOffset
=
offset
,
extentOffset
=
offset
,
isDirectional
=
false
,
super
.
collapsed
(
offset
);
/// Creates a collapsed selection at the given text position.
///
/// A collapsed selection starts and ends at the same offset, which means it
/// contains zero characters but instead serves as an insertion point in the
/// text.
TextSelection
.
fromPosition
(
TextPosition
position
)
:
baseOffset
=
position
.
offset
,
extentOffset
=
position
.
offset
,
...
...
packages/flutter/lib/src/painting/text_painter.dart
View file @
8294b96f
...
...
@@ -229,6 +229,13 @@ class TextPainter {
return
_paragraph
.
getPositionForOffset
(
offset
);
}
/// Returns the text range of the word at the given offset. Characters not
/// part of a word, such as spaces, symbols, and punctuation, have word breaks
/// on both sides. In such cases, this method will return a text range that
/// contains the given text position.
///
/// Word boundaries are defined more precisely in Unicode Standard Annex #29
/// <http://www.unicode.org/reports/tr29/#Word_Boundaries>.
TextRange
getWordBoundary
(
TextPosition
position
)
{
assert
(!
_needsLayout
);
List
<
int
>
indices
=
_paragraph
.
getWordBoundary
(
position
.
offset
);
...
...
packages/flutter/lib/src/painting/transforms.dart
View file @
8294b96f
...
...
@@ -9,6 +9,7 @@ import 'package:vector_math/vector_math_64.dart';
import
'basic_types.dart'
;
/// Utility functions for working with matrices.
class
MatrixUtils
{
MatrixUtils
.
_
();
...
...
@@ -68,6 +69,7 @@ class MatrixUtils {
&&
a
.
storage
[
15
]
==
b
.
storage
[
15
];
}
/// Whether the given matrix is the identity matrix.
static
bool
isIdentity
(
Matrix4
a
)
{
assert
(
a
!=
null
);
return
a
.
storage
[
0
]
==
1.0
// col 1
...
...
@@ -88,6 +90,10 @@ class MatrixUtils {
&&
a
.
storage
[
15
]
==
1.0
;
}
/// Applies the given matrix as a perspective transform to the given point.
///
/// This function assumes the given point has a z-coordinate of 0.0. The
/// z-coordinate of the result is ignored.
static
Point
transformPoint
(
Matrix4
transform
,
Point
point
)
{
Vector3
position3
=
new
Vector3
(
point
.
x
,
point
.
y
,
0.0
);
Vector3
transformed3
=
transform
.
perspectiveTransform
(
position3
);
...
...
@@ -101,6 +107,12 @@ class MatrixUtils {
return
math
.
max
(
a
,
math
.
max
(
b
,
math
.
max
(
c
,
d
)));
}
/// Returns a rect that bounds the result of applying the given matrix as a
/// perspective transform to the given rect.
///
/// This function assumes the given rect is in the plane with z equals 0.0.
/// The transformed rect is then projected back into the plane with z equals
/// 0.0 before computing its bounding rect.
static
Rect
transformRect
(
Rect
rect
,
Matrix4
transform
)
{
assert
(
rect
!=
null
);
assert
(
transform
.
determinant
!=
0.0
);
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
8294b96f
...
...
@@ -41,9 +41,9 @@ enum Axis {
/// * `0.0 <= minWidth <= maxWidth <= double.INFINITY`
/// * `0.0 <= minHeight <= maxHeight <= double.INFINITY`
///
///
Note: `double.INFINITY`
is a legal value for each constraint.
///
[double.INFINITY]
is a legal value for each constraint.
class
BoxConstraints
extends
Constraints
{
/// C
onstructs box constraints with the given constraints
/// C
reates box constraints with the given constraints.
const
BoxConstraints
({
this
.
minWidth
:
0.0
,
this
.
maxWidth
:
double
.
INFINITY
,
...
...
@@ -51,19 +51,30 @@ class BoxConstraints extends Constraints {
this
.
maxHeight
:
double
.
INFINITY
});
/// The minimum width that satisfies the constraints.
final
double
minWidth
;
/// The maximum width that satisfies the constraints.
///
/// Might be [double.INFINITY].
final
double
maxWidth
;
/// The minimum height that satisfies the constraints.
final
double
minHeight
;
/// The maximum height that satisfies the constraints.
///
/// Might be [double.INFINITY].
final
double
maxHeight
;
/// C
onstruct
s box constraints that is respected only by the given size.
/// C
reate
s box constraints that is respected only by the given size.
BoxConstraints
.
tight
(
Size
size
)
:
minWidth
=
size
.
width
,
maxWidth
=
size
.
width
,
minHeight
=
size
.
height
,
maxHeight
=
size
.
height
;
/// C
onstruct
s box constraints that require the given width or height.
/// C
reate
s box constraints that require the given width or height.
const
BoxConstraints
.
tightFor
({
double
width
,
double
height
...
...
@@ -72,14 +83,14 @@ class BoxConstraints extends Constraints {
minHeight
=
height
!=
null
?
height
:
0.0
,
maxHeight
=
height
!=
null
?
height
:
double
.
INFINITY
;
/// C
onstruct
s box constraints that forbid sizes larger than the given size.
/// C
reate
s box constraints that forbid sizes larger than the given size.
BoxConstraints
.
loose
(
Size
size
)
:
minWidth
=
0.0
,
maxWidth
=
size
.
width
,
minHeight
=
0.0
,
maxHeight
=
size
.
height
;
/// C
onstruct
s box constraints that expand to fill another box contraints.
/// C
reate
s box constraints that expand to fill another box contraints.
///
/// If width or height is given, the constraints will require exactly the
/// given value in the given dimension.
...
...
packages/flutter/lib/src/rendering/error.dart
View file @
8294b96f
...
...
@@ -25,7 +25,7 @@ const double _kMaxHeight = 100000.0;
/// Again to help simplify the class, this box tries to be 100000.0 pixels wide
/// and high, to approximate being infinitely high but without using infinities.
class
RenderErrorBox
extends
RenderBox
{
/// C
onstruct
s a RenderErrorBox render object.
/// C
reate
s a RenderErrorBox render object.
///
/// A message can optionally be provided. If a message is provided, an attempt
/// will be made to render the message when the box paints.
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
8294b96f
...
...
@@ -1316,7 +1316,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Subclasses that set [sizedByParent] to true should override this function
/// to compute their size.
///
///
Note:
This function is called only if [sizedByParent] is true.
/// This function is called only if [sizedByParent] is true.
void
performResize
();
/// Do the work of computing the layout for this render object.
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
8294b96f
...
...
@@ -115,7 +115,7 @@ typedef void GlobalKeyRemoveListener(GlobalKey key);
/// [UniqueKey] instead.
@optionalTypeArgs
abstract
class
GlobalKey
<
T
extends
State
<
StatefulWidget
>>
extends
Key
{
/// C
onstruct
s a LabeledGlobalKey, which is a GlobalKey with a label used for debugging.
/// C
reate
s a LabeledGlobalKey, which is a GlobalKey with a label used for debugging.
/// The label is not used for comparing the identity of the key.
factory
GlobalKey
({
String
debugLabel
})
=>
new
LabeledGlobalKey
<
T
>(
debugLabel
);
// the label is purely for debugging purposes and is otherwise ignored
...
...
@@ -564,7 +564,7 @@ abstract class RenderObjectWidget extends Widget {
@override
RenderObjectElement
createElement
();
/// C
onstruct
s an instance of the RenderObject class that this
/// C
reate
s an instance of the RenderObject class that this
/// RenderObjectWidget represents, using the configuration described by this
/// RenderObjectWidget.
RenderObject
createRenderObject
(
BuildContext
context
);
...
...
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