mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
- makes the event logic not involve a boolean return value (since we ignored it anyway) - splits the event handling logic into two steps, hit testing and event dispatch - introduces an App class on the Dart side to factor out the interaction with the C++ side - ports sector-layout and simple_render_tree to the new App infrastructure - port simple_render_tree to the new event handling logic - implement hit testing for the sector-layout demo R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1143343004
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
// 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/config.h"
|
|
#include "sky/engine/core/view/View.h"
|
|
|
|
namespace blink {
|
|
|
|
PassRefPtr<View> View::create(const base::Closure& scheduleFrameCallback)
|
|
{
|
|
return adoptRef(new View(scheduleFrameCallback));
|
|
}
|
|
|
|
View::View(const base::Closure& scheduleFrameCallback)
|
|
: m_scheduleFrameCallback(scheduleFrameCallback)
|
|
{
|
|
}
|
|
|
|
View::~View()
|
|
{
|
|
}
|
|
|
|
double View::width() const
|
|
{
|
|
double w = m_displayMetrics.physical_size.width;
|
|
return w / m_displayMetrics.device_pixel_ratio;
|
|
}
|
|
|
|
double View::height() const
|
|
{
|
|
double h = m_displayMetrics.physical_size.height;
|
|
return h / m_displayMetrics.device_pixel_ratio;
|
|
}
|
|
|
|
void View::setEventCallback(PassOwnPtr<EventCallback> callback)
|
|
{
|
|
m_eventCallback = callback;
|
|
}
|
|
|
|
void View::setBeginFrameCallback(PassOwnPtr<BeginFrameCallback> callback)
|
|
{
|
|
m_beginFrameCallback = callback;
|
|
}
|
|
|
|
void View::scheduleFrame()
|
|
{
|
|
m_scheduleFrameCallback.Run();
|
|
}
|
|
|
|
void View::setDisplayMetrics(const SkyDisplayMetrics& metrics)
|
|
{
|
|
m_displayMetrics = metrics;
|
|
}
|
|
|
|
void View::handleInputEvent(PassRefPtr<Event> event)
|
|
{
|
|
if (m_eventCallback)
|
|
m_eventCallback->handleEvent(event.get());
|
|
}
|
|
|
|
void View::beginFrame(base::TimeTicks frameTime)
|
|
{
|
|
if (!m_beginFrameCallback)
|
|
return;
|
|
double frameTimeMS = (frameTime - base::TimeTicks()).InMillisecondsF();
|
|
m_beginFrameCallback->handleEvent(frameTimeMS);
|
|
}
|
|
|
|
} // namespace blink
|