Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
liujiuri
engine
提交
dfaf9182
E
engine
项目概览
liujiuri
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
dfaf9182
编写于
3月 25, 2016
作者:
A
Adam Barth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for mouse events
The Material Gallery is now fully interactive.
上级
0ef388f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
1 deletion
+80
-1
sky/services/pointer/pointer.mojom
sky/services/pointer/pointer.mojom
+2
-0
sky/shell/platform/glfw/window_impl.cc
sky/shell/platform/glfw/window_impl.cc
+75
-1
sky/shell/platform/glfw/window_impl.h
sky/shell/platform/glfw/window_impl.h
+3
-0
未找到文件。
sky/services/pointer/pointer.mojom
浏览文件 @
dfaf9182
...
...
@@ -5,6 +5,8 @@
[DartPackage="sky_services"]
module pointer;
// See https://github.com/flutter/engine/blob/master/sky/specs/pointer.md
enum PointerType {
DOWN,
UP,
...
...
sky/shell/platform/glfw/window_impl.cc
浏览文件 @
dfaf9182
...
...
@@ -21,11 +21,20 @@ void OnWindowSizeChanged(GLFWwindow* window, int width, int height) {
ToImpl
(
window
)
->
UpdateViewportMetrics
(
width
,
height
);
}
void
OnMouseButtonChanged
(
GLFWwindow
*
window
,
int
button
,
int
action
,
int
mods
)
{
ToImpl
(
window
)
->
DispatchMouseButtonEvent
(
button
,
action
,
mods
);
}
void
OnCursorPosChanged
(
GLFWwindow
*
window
,
double
x
,
double
y
)
{
ToImpl
(
window
)
->
DispatchMouseMoveEvent
(
x
,
y
);
}
}
// namespace
WindowImpl
::
WindowImpl
(
GLFWwindow
*
window
)
:
window_
(
window
),
shell_view_
(
new
ShellView
(
Shell
::
Shared
()))
{
shell_view_
(
new
ShellView
(
Shell
::
Shared
())),
buttons_
(
0
)
{
glfwSetWindowUserPointer
(
window_
,
this
);
auto
platform_view
=
static_cast
<
sky
::
shell
::
PlatformViewGLFW
*>
(
shell_view_
->
view
());
...
...
@@ -38,6 +47,7 @@ WindowImpl::WindowImpl(GLFWwindow* window)
UpdateViewportMetrics
(
width
,
height
);
glfwSetWindowSizeCallback
(
window_
,
OnWindowSizeChanged
);
glfwSetMouseButtonCallback
(
window_
,
OnMouseButtonChanged
);
}
WindowImpl
::~
WindowImpl
()
{
...
...
@@ -61,5 +71,69 @@ void WindowImpl::UpdateViewportMetrics(int width, int height) {
engine_
->
OnViewportMetricsChanged
(
metrics
.
Pass
());
}
void
WindowImpl
::
DispatchMouseButtonEvent
(
int
button
,
int
action
,
int
mods
)
{
pointer
::
PointerType
type
;
if
(
action
==
GLFW_PRESS
)
{
if
(
!
buttons_
)
{
type
=
pointer
::
PointerType
::
DOWN
;
glfwSetCursorPosCallback
(
window_
,
OnCursorPosChanged
);
}
else
{
type
=
pointer
::
PointerType
::
MOVE
;
}
// GLFW's button order matches what we want:
// https://github.com/flutter/engine/blob/master/sky/specs/pointer.md
// http://www.glfw.org/docs/3.2/group__buttons.html
buttons_
|=
1
<<
button
;
}
else
if
(
action
==
GLFW_RELEASE
)
{
buttons_
&=
~
(
1
<<
button
);
if
(
!
buttons_
)
{
type
=
pointer
::
PointerType
::
UP
;
glfwSetCursorPosCallback
(
window_
,
nullptr
);
}
else
{
type
=
pointer
::
PointerType
::
MOVE
;
}
}
else
{
DLOG
(
INFO
)
<<
"Unknown mouse action: "
<<
action
;
return
;
}
double
x
=
0.
f
,
y
=
0.
f
;
glfwGetCursorPos
(
window_
,
&
x
,
&
y
);
base
::
TimeDelta
time_stamp
=
base
::
TimeTicks
::
Now
()
-
base
::
TimeTicks
();
auto
pointer_data
=
pointer
::
Pointer
::
New
();
pointer_data
->
time_stamp
=
time_stamp
.
InMicroseconds
();
pointer_data
->
type
=
type
;
pointer_data
->
kind
=
pointer
::
PointerKind
::
MOUSE
;
pointer_data
->
x
=
x
;
pointer_data
->
y
=
y
;
pointer_data
->
buttons
=
buttons_
;
pointer_data
->
pressure
=
1.0
;
pointer_data
->
pressure_max
=
1.0
;
auto
pointer_packet
=
pointer
::
PointerPacket
::
New
();
pointer_packet
->
pointers
.
push_back
(
pointer_data
.
Pass
());
engine_
->
OnPointerPacket
(
pointer_packet
.
Pass
());
}
void
WindowImpl
::
DispatchMouseMoveEvent
(
double
x
,
double
y
)
{
base
::
TimeDelta
time_stamp
=
base
::
TimeTicks
::
Now
()
-
base
::
TimeTicks
();
auto
pointer_data
=
pointer
::
Pointer
::
New
();
pointer_data
->
time_stamp
=
time_stamp
.
InMicroseconds
();
pointer_data
->
type
=
pointer
::
PointerType
::
MOVE
;
pointer_data
->
kind
=
pointer
::
PointerKind
::
MOUSE
;
pointer_data
->
x
=
x
;
pointer_data
->
y
=
y
;
pointer_data
->
buttons
=
buttons_
;
pointer_data
->
pressure
=
1.0
;
pointer_data
->
pressure_max
=
1.0
;
auto
pointer_packet
=
pointer
::
PointerPacket
::
New
();
pointer_packet
->
pointers
.
push_back
(
pointer_data
.
Pass
());
engine_
->
OnPointerPacket
(
pointer_packet
.
Pass
());
}
}
// namespace shell
}
// namespace sky
sky/shell/platform/glfw/window_impl.h
浏览文件 @
dfaf9182
...
...
@@ -24,11 +24,14 @@ class WindowImpl {
const
std
::
string
&
bundle_path
);
void
UpdateViewportMetrics
(
int
width
,
int
height
);
void
DispatchMouseButtonEvent
(
int
button
,
int
action
,
int
mods
);
void
DispatchMouseMoveEvent
(
double
x
,
double
y
);
private:
GLFWwindow
*
window_
;
std
::
unique_ptr
<
ShellView
>
shell_view_
;
sky
::
SkyEnginePtr
engine_
;
int
buttons_
;
DISALLOW_COPY_AND_ASSIGN
(
WindowImpl
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录