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
8e5dd7a3
Commit
8e5dd7a3
authored
Jan 12, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove clamp() in favour of double.clamp()
Fixes #961
parent
f10f79f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
22 deletions
+12
-22
sector_layout.dart
examples/rendering/lib/sector_layout.dart
+2
-2
box.dart
packages/flutter/lib/src/rendering/box.dart
+10
-10
object.dart
packages/flutter/lib/src/rendering/object.dart
+0
-10
No files found.
examples/rendering/lib/sector_layout.dart
View file @
8e5dd7a3
...
...
@@ -29,11 +29,11 @@ class SectorConstraints extends Constraints {
final
double
maxDeltaTheta
;
double
constrainDeltaRadius
(
double
deltaRadius
)
{
return
clamp
(
min:
minDeltaRadius
,
max:
maxDeltaRadius
,
value:
d
eltaRadius
);
return
deltaRadius
.
clamp
(
minDeltaRadius
,
maxD
eltaRadius
);
}
double
constrainDeltaTheta
(
double
deltaTheta
)
{
return
clamp
(
min:
minDeltaTheta
,
max:
maxDeltaTheta
,
value:
d
eltaTheta
);
return
deltaTheta
.
clamp
(
minDeltaTheta
,
maxD
eltaTheta
);
}
bool
get
isTight
=>
minDeltaTheta
>=
maxDeltaTheta
&&
minDeltaTheta
>=
maxDeltaTheta
;
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
8e5dd7a3
...
...
@@ -126,10 +126,10 @@ class BoxConstraints extends Constraints {
/// as close as possible to the original constraints.
BoxConstraints
enforce
(
BoxConstraints
constraints
)
{
return
new
BoxConstraints
(
minWidth:
clamp
(
min:
constraints
.
minWidth
,
max:
constraints
.
maxWidth
,
value:
min
Width
),
maxWidth:
clamp
(
min:
constraints
.
minWidth
,
max:
constraints
.
maxWidth
,
value:
maxWidth
),
minHeight:
clamp
(
min:
constraints
.
minHeight
,
max:
constraints
.
maxHeight
,
value:
min
Height
),
maxHeight:
clamp
(
min:
constraints
.
minHeight
,
max:
constraints
.
maxHeight
,
value:
maxHeight
)
minWidth:
minWidth
.
clamp
(
constraints
.
minWidth
,
constraints
.
max
Width
),
maxWidth:
maxWidth
.
clamp
(
constraints
.
minWidth
,
constraints
.
maxWidth
),
minHeight:
minHeight
.
clamp
(
constraints
.
minHeight
,
constraints
.
max
Height
),
maxHeight:
maxHeight
.
clamp
(
constraints
.
minHeight
,
constraints
.
maxHeight
)
);
}
...
...
@@ -137,10 +137,10 @@ class BoxConstraints extends Constraints {
/// the given width and height as possible while still respecting the original
/// box constraints.
BoxConstraints
tighten
({
double
width
,
double
height
})
{
return
new
BoxConstraints
(
minWidth:
width
==
null
?
minWidth
:
math
.
max
(
math
.
min
(
maxWidth
,
width
),
min
Width
),
maxWidth:
width
==
null
?
maxWidth
:
math
.
max
(
math
.
min
(
maxWidth
,
width
),
min
Width
),
minHeight:
height
==
null
?
minHeight
:
math
.
max
(
math
.
min
(
maxHeight
,
height
),
min
Height
),
maxHeight:
height
==
null
?
maxHeight
:
math
.
max
(
math
.
min
(
maxHeight
,
height
),
min
Height
));
return
new
BoxConstraints
(
minWidth:
width
==
null
?
minWidth
:
width
.
clamp
(
minWidth
,
max
Width
),
maxWidth:
width
==
null
?
maxWidth
:
width
.
clamp
(
minWidth
,
max
Width
),
minHeight:
height
==
null
?
minHeight
:
height
.
clamp
(
minHeight
,
max
Height
),
maxHeight:
height
==
null
?
maxHeight
:
height
.
clamp
(
minHeight
,
max
Height
));
}
/// Returns box constraints with the same width constraints but with
...
...
@@ -155,14 +155,14 @@ class BoxConstraints extends Constraints {
/// possible to the given width.
double
constrainWidth
([
double
width
=
double
.
INFINITY
])
{
assert
(
isNormalized
);
return
clamp
(
min:
minWidth
,
max:
maxWidth
,
value:
w
idth
);
return
width
.
clamp
(
minWidth
,
maxW
idth
);
}
/// Returns the height that both satisfies the constraints and is as close as
/// possible to the given height.
double
constrainHeight
([
double
height
=
double
.
INFINITY
])
{
assert
(
isNormalized
);
return
clamp
(
min:
minHeight
,
max:
maxHeight
,
value:
h
eight
);
return
height
.
clamp
(
minHeight
,
maxH
eight
);
}
/// Returns the size that both satisfies the constraints and is as close as
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
8e5dd7a3
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:developer'
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -1162,15 +1161,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
}
/// Obsolete function that will be removed eventually.
double
clamp
(
{
double
min:
0.0
,
double
value:
0.0
,
double
max:
double
.
INFINITY
})
{
assert
(
min
!=
null
);
assert
(
value
!=
null
);
assert
(
max
!=
null
);
return
math
.
max
(
min
,
math
.
min
(
max
,
value
));
}
/// Generic mixin for render objects with one child.
///
/// Provides a child model for a render object subclass that has a unique child.
...
...
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