Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
92aee352
Commit
92aee352
authored
12 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Fix gesture trail width calculation
Change-Id: I41e0a95437aa9b8ec9a8eefb3bc5eb0452284b60
parent
4aff3bf0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
+27
-9
27 additions, 9 deletions
...id/inputmethod/keyboard/internal/GesturePreviewTrail.java
with
27 additions
and
9 deletions
java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
+
27
−
9
View file @
92aee352
...
...
@@ -101,6 +101,16 @@ final class GesturePreviewTrail {
}
}
/**
* Calculate the alpha of a gesture trail.
* A gesture trail starts from fully opaque. After mFadeStartDelay has been passed, the alpha
* of a trail reduces in proportion to the elapsed time. Then after mFadeDuration has been
* passed, a trail becomes fully transparent.
*
* @param elapsedTime the elapsed time since a trail has been made.
* @param params gesture trail display parameters
* @return the width of a gesture trail
*/
private
static
int
getAlpha
(
final
int
elapsedTime
,
final
Params
params
)
{
if
(
elapsedTime
<
params
.
mFadeoutStartDelay
)
{
return
Constants
.
Color
.
ALPHA_OPAQUE
;
...
...
@@ -111,10 +121,19 @@ final class GesturePreviewTrail {
return
Constants
.
Color
.
ALPHA_OPAQUE
-
decreasingAlpha
;
}
/**
* Calculate the width of a gesture trail.
* A gesture trail starts from the width of mTrailStartWidth and reduces its width in proportion
* to the elapsed time. After mTrailEndWidth has been passed, the width becomes mTraiLEndWidth.
*
* @param elapsedTime the elapsed time since a trail has been made.
* @param params gesture trail display parameters
* @return the width of a gesture trail
*/
private
static
float
getWidth
(
final
int
elapsedTime
,
final
Params
params
)
{
return
Math
.
max
((
params
.
mTrailLingerDuration
-
elapsedTime
)
*
(
params
.
mTrailStartWidth
-
params
.
mTrailEndWidth
)
/
params
.
mTrailLingerDuration
,
0.0f
)
;
final
int
deltaTime
=
params
.
mTrailLingerDuration
-
elapsedTime
;
final
float
deltaWidth
=
params
.
mTrailStartWidth
-
params
.
mTrailEndWidth
;
return
(
deltaTime
*
deltaWidth
)
/
params
.
mTrailLingerDuration
+
params
.
mTrailEndWidth
;
}
private
final
RoundedLine
mRoundedLine
=
new
RoundedLine
();
...
...
@@ -154,7 +173,7 @@ final class GesturePreviewTrail {
final
RoundedLine
line
=
mRoundedLine
;
int
p1x
=
getXCoordValue
(
xCoords
[
startIndex
]);
int
p1y
=
yCoords
[
startIndex
];
int
lastTime
=
sinceDown
-
eventTimes
[
startIndex
];
final
int
lastTime
=
sinceDown
-
eventTimes
[
startIndex
];
float
maxWidth
=
getWidth
(
lastTime
,
params
);
float
r1
=
maxWidth
/
2.0f
;
// Initialize bounds rectangle.
...
...
@@ -167,20 +186,19 @@ final class GesturePreviewTrail {
final
float
r2
=
width
/
2.0f
;
// Draw trail line only when the current point isn't a down point.
if
(!
isDownEventXCoord
(
xCoords
[
i
]))
{
final
int
alpha
=
getAlpha
(
elapsedTime
,
params
);
paint
.
setAlpha
(
alpha
);
final
Path
path
=
line
.
makePath
(
p1x
,
p1y
,
r1
,
p2x
,
p2y
,
r2
);
if
(
path
!=
null
)
{
final
int
alpha
=
getAlpha
(
elapsedTime
,
params
);
paint
.
setAlpha
(
alpha
);
canvas
.
drawPath
(
path
,
paint
);
// Take union for the bounds.
outBoundsRect
.
union
(
p2x
,
p2y
);
maxWidth
=
Math
.
max
(
maxWidth
,
width
);
}
// Take union for the bounds.
maxWidth
=
Math
.
max
(
maxWidth
,
width
);
}
p1x
=
p2x
;
p1y
=
p2y
;
r1
=
r2
;
lastTime
=
elapsedTime
;
}
// Take care of trail line width.
final
int
inset
=
-((
int
)
maxWidth
+
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment