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
3f2369db
Commit
3f2369db
authored
Sep 01, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial support for labels in skysprites
parent
37d0c1a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
label.dart
packages/flutter_sprites/lib/label.dart
+58
-0
skysprites.dart
packages/flutter_sprites/lib/skysprites.dart
+2
-0
No files found.
packages/flutter_sprites/lib/label.dart
0 → 100644
View file @
3f2369db
part of
skysprites
;
class
Label
extends
Node
{
Label
(
this
.
_text
,
[
this
.
_textStyle
])
{
if
(
_textStyle
==
null
)
{
_textStyle
=
new
TextStyle
();
}
}
String
_text
;
String
get
text
=>
_text
;
set
text
(
String
text
)
{
_text
=
text
;
_painter
=
null
;
}
TextStyle
_textStyle
;
TextStyle
get
textStyle
=>
_textStyle
;
set
textStyle
(
TextStyle
textStyle
)
{
_textStyle
=
textStyle
;
_painter
=
null
;
}
TextPainter
_painter
;
double
_width
;
final
double
_maxWidth
=
10000.0
;
void
paint
(
PaintingCanvas
canvas
)
{
if
(
_painter
==
null
)
{
PlainTextSpan
textSpan
=
new
PlainTextSpan
(
_text
);
StyledTextSpan
styledTextSpan
=
new
StyledTextSpan
(
_textStyle
,
[
textSpan
]);
_painter
=
new
TextPainter
(
styledTextSpan
);
_painter
.
maxWidth
=
_maxWidth
;
_painter
.
minWidth
=
_maxWidth
;
_painter
.
layout
();
_width
=
_painter
.
maxContentWidth
;
}
Offset
offset
=
Offset
.
zero
;
if
(
_textStyle
.
textAlign
==
TextAlign
.
center
)
{
//canvas.translate(-_maxWidth / 2.0, 0.0);
offset
=
new
Offset
(-
_maxWidth
/
2.0
,
0.0
);
}
else
if
(
_textStyle
.
textAlign
==
TextAlign
.
right
)
{
//canvas.translate(-_maxWidth, 0.0);
offset
=
new
Offset
(-
_maxWidth
,
0.0
);
}
_painter
.
paint
(
canvas
,
offset
);
}
}
packages/flutter_sprites/lib/skysprites.dart
View file @
3f2369db
...
...
@@ -17,6 +17,7 @@ import 'package:sky/mojo/asset_bundle.dart';
import
'package:sky/mojo/shell.dart'
as
shell
;
import
'package:sky/rendering/box.dart'
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/painting/text_painter.dart'
;
import
'package:sky/widgets/framework.dart'
;
import
'package:sky_services/media/media.mojom.dart'
;
import
'package:vector_math/vector_math.dart'
;
...
...
@@ -26,6 +27,7 @@ part 'constraint.dart';
part
'action_spline.dart'
;
part
'color_secuence.dart'
;
part
'image_map.dart'
;
part
'label.dart'
;
part
'layer.dart'
;
part
'node.dart'
;
part
'node3d.dart'
;
...
...
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