Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
d4e68ab5
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4e68ab5
编写于
8月 11, 2015
作者:
C
Collin Jackson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add weight chart to fitness app
上级
bc30e0e5
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
123 addition
and
14 deletion
+123
-14
examples/fitness/lib/feed.dart
examples/fitness/lib/feed.dart
+45
-14
examples/fitness/lib/main.dart
examples/fitness/lib/main.dart
+1
-0
examples/fitness/pubspec.yaml
examples/fitness/pubspec.yaml
+1
-0
sky/engine/core/core.gni
sky/engine/core/core.gni
+3
-0
sky/engine/core/painting/Canvas.cpp
sky/engine/core/painting/Canvas.cpp
+8
-0
sky/engine/core/painting/Canvas.h
sky/engine/core/painting/Canvas.h
+1
-0
sky/engine/core/painting/Canvas.idl
sky/engine/core/painting/Canvas.idl
+1
-0
sky/engine/core/painting/Paint.cpp
sky/engine/core/painting/Paint.cpp
+4
-0
sky/engine/core/painting/Paint.dart
sky/engine/core/painting/Paint.dart
+4
-0
sky/engine/core/painting/Typeface.cpp
sky/engine/core/painting/Typeface.cpp
+17
-0
sky/engine/core/painting/Typeface.h
sky/engine/core/painting/Typeface.h
+32
-0
sky/engine/core/painting/Typeface.idl
sky/engine/core/painting/Typeface.idl
+6
-0
未找到文件。
examples/fitness/lib/feed.dart
浏览文件 @
d4e68ab5
...
@@ -173,28 +173,59 @@ class FeedFragment extends StatefulComponent {
...
@@ -173,28 +173,59 @@ class FeedFragment extends StatefulComponent {
});
});
}
}
Widget
buildChart
()
{
double
startX
;
double
endX
;
double
startY
;
double
endY
;
List
<
Point
>
dataSet
=
new
List
<
Point
>();
for
(
FitnessItem
item
in
userData
)
{
if
(
item
is
Measurement
)
{
double
x
=
item
.
when
.
millisecondsSinceEpoch
.
toDouble
();
double
y
=
item
.
weight
;
if
(
startX
==
null
)
startX
=
x
;
endX
=
x
;
if
(
startY
==
null
||
startY
>
y
)
startY
=
y
;
if
(
endY
==
null
||
endY
<
y
)
endY
=
y
;
dataSet
.
add
(
new
Point
(
x
,
y
));
}
}
playfair
.
ChartData
data
=
new
playfair
.
ChartData
(
startX:
startX
,
startY:
startY
,
endX:
endX
,
endY:
endY
,
dataSet:
dataSet
);
return
new
playfair
.
Chart
(
data:
data
);
}
Widget
buildBody
()
{
Widget
buildBody
()
{
TextStyle
style
=
Theme
.
of
(
this
).
text
.
title
;
TextStyle
style
=
Theme
.
of
(
this
).
text
.
title
;
if
(
userData
.
length
==
0
)
return
new
Material
(
type:
MaterialType
.
canvas
,
child:
new
Flex
(
[
new
Text
(
"No data yet.
\n
Add some!"
,
style:
style
)],
justifyContent:
FlexJustifyContent
.
center
)
);
switch
(
_fitnessMode
)
{
switch
(
_fitnessMode
)
{
case
FitnessMode
.
feed
:
case
FitnessMode
.
feed
:
if
(
userData
.
length
>
0
)
return
new
FitnessItemList
(
return
new
FitnessItemList
(
items:
userData
,
items:
userData
,
onDismissed:
_handleItemDismissed
onDismissed:
_handleItemDismissed
);
return
new
Material
(
type:
MaterialType
.
canvas
,
child:
new
Flex
(
[
new
Text
(
"No data yet.
\n
Add some!"
,
style:
style
)],
justifyContent:
FlexJustifyContent
.
center
)
);
);
case
FitnessMode
.
chart
:
case
FitnessMode
.
chart
:
return
new
Material
(
return
new
Material
(
type:
MaterialType
.
canvas
,
type:
MaterialType
.
canvas
,
child:
new
Flex
([
child:
new
Container
(
new
Text
(
"Charts are coming soon!"
,
style:
style
)
padding:
const
EdgeDims
.
all
(
20.0
),
],
justifyContent:
FlexJustifyContent
.
center
)
child:
buildChart
()
)
);
);
}
}
}
}
...
...
examples/fitness/lib/main.dart
浏览文件 @
d4e68ab5
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
library
fitness
;
library
fitness
;
import
'package:playfair/playfair.dart'
as
playfair
;
import
'package:sky/editing/input.dart'
;
import
'package:sky/editing/input.dart'
;
import
'package:sky/painting/text_style.dart'
;
import
'package:sky/painting/text_style.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/theme/colors.dart'
as
colors
;
...
...
examples/fitness/pubspec.yaml
浏览文件 @
d4e68ab5
...
@@ -2,6 +2,7 @@ name: fitness
...
@@ -2,6 +2,7 @@ name: fitness
dependencies
:
dependencies
:
sky
:
any
sky
:
any
sky_tools
:
any
sky_tools
:
any
playfair
:
any
path
:
"
^1.3.6"
path
:
"
^1.3.6"
dependency_overrides
:
dependency_overrides
:
material_design_icons
:
material_design_icons
:
...
...
sky/engine/core/core.gni
浏览文件 @
d4e68ab5
...
@@ -464,6 +464,8 @@ sky_core_files = [
...
@@ -464,6 +464,8 @@ sky_core_files = [
"painting/Size.cpp",
"painting/Size.cpp",
"painting/Size.h",
"painting/Size.h",
"painting/TransferMode.h",
"painting/TransferMode.h",
"painting/Typeface.cpp",
"painting/Typeface.h",
"rendering/BidiRun.h",
"rendering/BidiRun.h",
"rendering/BidiRunForLine.cpp",
"rendering/BidiRunForLine.cpp",
"rendering/BidiRunForLine.h",
"rendering/BidiRunForLine.h",
...
@@ -682,6 +684,7 @@ core_idl_files = get_path_info([
...
@@ -682,6 +684,7 @@ core_idl_files = get_path_info([
"painting/PictureRecorder.idl",
"painting/PictureRecorder.idl",
"painting/RRect.idl",
"painting/RRect.idl",
"painting/Shader.idl",
"painting/Shader.idl",
"painting/Typeface.idl",
"view/EventCallback.idl",
"view/EventCallback.idl",
"view/FrameCallback.idl",
"view/FrameCallback.idl",
"view/View.idl",
"view/View.idl",
...
...
sky/engine/core/painting/Canvas.cpp
浏览文件 @
d4e68ab5
...
@@ -264,6 +264,14 @@ void Canvas::drawPaintingNode(PaintingNode* paintingNode, const Point& p)
...
@@ -264,6 +264,14 @@ void Canvas::drawPaintingNode(PaintingNode* paintingNode, const Point& p)
translate
(
-
p
.
sk_point
.
x
(),
-
p
.
sk_point
.
y
());
translate
(
-
p
.
sk_point
.
x
(),
-
p
.
sk_point
.
y
());
}
}
void
Canvas
::
drawText
(
const
String
&
text
,
const
Point
&
p
,
const
Paint
&
paint
)
{
if
(
!
m_canvas
)
return
;
ASSERT
(
text
);
m_canvas
->
drawText
(
text
.
utf8
().
data
(),
text
.
length
(),
p
.
sk_point
.
x
(),
p
.
sk_point
.
y
(),
paint
.
sk_paint
);
}
void
Canvas
::
drawAtlas
(
CanvasImage
*
atlas
,
void
Canvas
::
drawAtlas
(
CanvasImage
*
atlas
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
const
Vector
<
SkColor
>&
colors
,
SkXfermode
::
Mode
mode
,
const
Vector
<
SkColor
>&
colors
,
SkXfermode
::
Mode
mode
,
...
...
sky/engine/core/painting/Canvas.h
浏览文件 @
d4e68ab5
...
@@ -91,6 +91,7 @@ public:
...
@@ -91,6 +91,7 @@ public:
void
drawPicture
(
Picture
*
picture
);
void
drawPicture
(
Picture
*
picture
);
void
drawDrawable
(
Drawable
*
drawable
);
void
drawDrawable
(
Drawable
*
drawable
);
void
drawPaintingNode
(
PaintingNode
*
paintingNode
,
const
Point
&
p
);
void
drawPaintingNode
(
PaintingNode
*
paintingNode
,
const
Point
&
p
);
void
drawText
(
const
String
&
text
,
const
Point
&
p
,
const
Paint
&
paint
);
void
drawAtlas
(
CanvasImage
*
atlas
,
void
drawAtlas
(
CanvasImage
*
atlas
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
const
Vector
<
RSTransform
>&
transforms
,
const
Vector
<
Rect
>&
rects
,
...
...
sky/engine/core/painting/Canvas.idl
浏览文件 @
d4e68ab5
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
void
drawPicture
(
Picture
picture
)
;
void
drawPicture
(
Picture
picture
)
;
void
drawDrawable
(
Drawable
drawable
)
;
void
drawDrawable
(
Drawable
drawable
)
;
void
drawPaintingNode
(
PaintingNode
paintingNode
,
Point
p
)
;
void
drawPaintingNode
(
PaintingNode
paintingNode
,
Point
p
)
;
void
drawText
(
DOMString
text
,
Point
p
,
Paint
paint
)
;
//
TODO
(
eseidel
):
Paint
should
be
optional
,
but
optional
doesn
't work.
//
TODO
(
eseidel
):
Paint
should
be
optional
,
but
optional
doesn
't work.
[RaisesException] void drawAtlas(Image image,
[RaisesException] void drawAtlas(Image image,
...
...
sky/engine/core/painting/Paint.cpp
浏览文件 @
d4e68ab5
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include "sky/engine/core/painting/PaintingStyle.h"
#include "sky/engine/core/painting/PaintingStyle.h"
#include "sky/engine/core/painting/Shader.h"
#include "sky/engine/core/painting/Shader.h"
#include "sky/engine/core/painting/TransferMode.h"
#include "sky/engine/core/painting/TransferMode.h"
#include "sky/engine/core/painting/Typeface.h"
#include "sky/engine/core/script/dom_dart_state.h"
#include "sky/engine/core/script/dom_dart_state.h"
#include "sky/engine/wtf/text/StringBuilder.h"
#include "sky/engine/wtf/text/StringBuilder.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorFilter.h"
...
@@ -35,6 +36,7 @@ enum PaintFields {
...
@@ -35,6 +36,7 @@ enum PaintFields {
kShader
,
kShader
,
kStyle
,
kStyle
,
kTransferMode
,
kTransferMode
,
kTypeface
,
// kNumberOfPaintFields must be last.
// kNumberOfPaintFields must be last.
kNumberOfPaintFields
,
kNumberOfPaintFields
,
...
@@ -82,6 +84,8 @@ Paint DartConverter<Paint>::FromDart(Dart_Handle dart_paint) {
...
@@ -82,6 +84,8 @@ Paint DartConverter<Paint>::FromDart(Dart_Handle dart_paint) {
paint
.
setStyle
(
DartConverter
<
PaintingStyle
>::
FromDart
(
values
[
kStyle
]));
paint
.
setStyle
(
DartConverter
<
PaintingStyle
>::
FromDart
(
values
[
kStyle
]));
if
(
!
Dart_IsNull
(
values
[
kTransferMode
]))
if
(
!
Dart_IsNull
(
values
[
kTransferMode
]))
paint
.
setXfermodeMode
(
DartConverter
<
TransferMode
>::
FromDart
(
values
[
kTransferMode
]));
paint
.
setXfermodeMode
(
DartConverter
<
TransferMode
>::
FromDart
(
values
[
kTransferMode
]));
if
(
!
Dart_IsNull
(
values
[
kTypeface
]))
paint
.
setTypeface
(
DartConverter
<
Typeface
*>::
FromDart
(
values
[
kTypeface
])
->
typeface
());
result
.
is_null
=
false
;
result
.
is_null
=
false
;
return
result
;
return
result
;
...
...
sky/engine/core/painting/Paint.dart
浏览文件 @
d4e68ab5
...
@@ -43,6 +43,7 @@ class Paint {
...
@@ -43,6 +43,7 @@ class Paint {
Shader
_shader
;
Shader
_shader
;
PaintingStyle
_style
;
PaintingStyle
_style
;
TransferMode
_transferMode
;
TransferMode
_transferMode
;
Typeface
typeface
;
// Must match PaintFields enum in Paint.cpp.
// Must match PaintFields enum in Paint.cpp.
List
<
dynamic
>
get
_value
{
List
<
dynamic
>
get
_value
{
...
@@ -57,6 +58,7 @@ class Paint {
...
@@ -57,6 +58,7 @@ class Paint {
_shader
,
_shader
,
_style
,
_style
,
_transferMode
,
_transferMode
,
typeface
];
];
}
}
...
@@ -71,6 +73,8 @@ class Paint {
...
@@ -71,6 +73,8 @@ class Paint {
// TODO(mpcomplete): Figure out how to show a drawLooper.
// TODO(mpcomplete): Figure out how to show a drawLooper.
if
(
_drawLooper
!=
null
)
if
(
_drawLooper
!=
null
)
result
+=
', drawLooper:true'
;
result
+=
', drawLooper:true'
;
if
(
typeface
!=
null
)
result
+=
', typeface:
$_typeface
'
;
result
+=
')'
;
result
+=
')'
;
return
result
;
return
result
;
}
}
...
...
sky/engine/core/painting/Typeface.cpp
0 → 100644
浏览文件 @
d4e68ab5
// 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.
#include "sky/engine/core/painting/Typeface.h"
namespace
blink
{
Typeface
::
Typeface
(
PassRefPtr
<
SkTypeface
>
typeface
)
:
typeface_
(
typeface
)
{
}
Typeface
::~
Typeface
()
{
}
}
// namespace blink
sky/engine/core/painting/Typeface.h
0 → 100644
浏览文件 @
d4e68ab5
// 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.
#ifndef SKY_ENGINE_CORE_PAINTING_TYPEFACE_H_
#define SKY_ENGINE_CORE_PAINTING_TYPEFACE_H_
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCounted.h"
#include "third_party/skia/include/core/SkTypeface.h"
namespace
blink
{
class
Typeface
:
public
RefCounted
<
Typeface
>
,
public
DartWrappable
{
DEFINE_WRAPPERTYPEINFO
();
public:
~
Typeface
()
override
;
SkTypeface
*
typeface
()
{
return
typeface_
.
get
();
}
void
set_typeface
(
PassRefPtr
<
SkTypeface
>
typeface
)
{
typeface_
=
typeface
;
}
protected:
Typeface
(
PassRefPtr
<
SkTypeface
>
typeface
);
private:
RefPtr
<
SkTypeface
>
typeface_
;
};
}
// namespace blink
#endif // SKY_ENGINE_CORE_PAINTING_TYPEFACE_H_
sky/engine/core/painting/Typeface.idl
0 → 100644
浏览文件 @
d4e68ab5
//
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
.
interface
Typeface
{
}
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录