38namespace sksg {
class InvalidationController; }
57static constexpr float kAspectRatio = 1.5f;
61static constexpr float kFocusDuration = 500;
62static constexpr SkSize kFocusInset = { 100.0f, 100.0f };
63static constexpr SkPoint kFocusCtrl0 = { 0.3f, 1.0f };
64static constexpr SkPoint kFocusCtrl1 = { 0.0f, 1.0f };
65static constexpr SkColor kFocusShade = 0xa0000000;
68static constexpr SkUnichar kUnfocusKey =
' ';
73 : fSlide(
std::move(slide)) {
82 : fAdapter(
std::move(adapter)) {}
85 void onTick(
float t)
override {
93 return sk_make_sp<ForwardingAnimator>(
sk_ref_sp(
this));
98 const auto isize = fSlide->getDimensions();
107 fSlide->draw(canvas);
110 const RenderNode*
onNodeAt(
const SkPoint&)
const override {
return nullptr; }
114 fSlide->animate(t * 1e6);
142 , fMap(kFocusCtrl1, kFocusCtrl0)
143 , fState(
State::kIdle) {
148 bool hasFocus()
const {
return fState == State::kFocused; }
151 if (fState != State::kIdle)
161 fM0 = SlideMatrix(fTarget->
fSlide, fTarget->
fRect);
162 fM1 = SlideMatrix(fTarget->
fSlide, fRect);
168 fState = State::kFocusing;
179 swap(fOpacity0, fOpacity1);
182 fState = State::kUnfocusing;
196 const auto pt = xform.mapXY(
x,
y);
209 if (!this->isAnimating())
216 const auto rel_t = (t - fTimeBase) / kFocusDuration,
220 for (
int i = 0;
i < 9; ++
i) {
221 m[
i] = fM0[
i] + map_t * (fM1[
i] - fM0[
i]);
227 const auto shadeOpacity = fOpacity0 + map_t * (fOpacity1 - fOpacity0);
228 fShadePaint->setOpacity(shadeOpacity);
234 case State::kFocusing:
235 fState = State::kFocused;
237 case State::kUnfocusing:
238 fState = State::kIdle;
243 case State::kFocused:
257 bool isAnimating()
const {
return fState == State::kFocusing || fState == State::kUnfocusing; }
272 State fState = State::kIdle;
276 : fSlides(
std::move(slides))
277 , fColumns(columns) {
314 const auto cellWidth = winWidth / fColumns;
315 fCellSize =
SkSize::Make(cellWidth, cellWidth / kAspectRatio);
319 for (
int i = 0;
i < fSlides.
size(); ++
i) {
320 const auto& slide = fSlides[
i];
321 slide->
load(winWidth, winHeight);
325 fCellSize.
height() * (
i / fColumns),
331 auto adapter = sk_make_sp<SlideAdapter>(slide);
334 slideSize.height())),
336 slideGrp->addChild(adapter);
339 slideMatrix->getMatrix()));
342 fSceneAnimators.push_back(adapter->makeForwardingAnimator());
345 fRecs.push_back({ slide, slideRoot, slideMatrix, slideRect });
352 fFocusController = std::make_unique<FocusController>(
this, focusRect);
356 for (
const auto& slide : fSlides) {
362 fFocusController.reset();
373 fScene->render(canvas);
378 if (fTimeBase == 0) {
383 const auto t = msec - fTimeBase;
384 for (
const auto& anim : fSceneAnimators) {
387 fFocusController->tick(t);
393 if (fFocusController->hasFocus()) {
394 if (c == kUnfocusKey) {
395 fFocusController->startUnfocus();
398 return fFocusController->onChar(c);
406 modifiers &=
~skui::ModifierKey::kFirstPress;
410 if (fFocusController->hasFocus()) {
411 return fFocusController->onMouse(
x,
y,
state, modifiers);
414 const auto* cell = this->findCell(
x,
y);
418 static constexpr SkScalar kClickMoveTolerance = 4;
422 fTrackingCell = cell;
426 if (cell == fTrackingCell &&
428 fFocusController->startFocus(cell);
441 if (x < 0 || y < 0 || x >=
size.width() ||
y >=
size.height()) {
445 const int col =
static_cast<int>(
x / fCellSize.
width()),
446 row =
static_cast<int>(
y / fCellSize.
height()),
447 idx = row * fColumns + col;
449 return idx < (
int)fRecs.size() ? &fRecs[idx] :
nullptr;
constexpr SkColor SK_ColorBLACK
sk_sp< T > sk_ref_sp(T *obj)
void swap(sk_sp< T > &a, sk_sp< T > &b)
#define SkScalarRoundToInt(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
static sk_sp< sksg::RenderNode > MakeLabel(const SkString &txt, const SkPoint &pos, const SkMatrix &dstXform)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
float computeYFromX(float x) const
@ kAntiAlias
may have transparent pixels on glyph edges
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
@ kCenter_ScaleToFit
scales and aligns to center
SkScalar getScaleX() const
static const SkMatrix & I()
SkScalar getScaleY() const
virtual void onTick(float t)=0
Animator(const Animator &)=delete
Animator & operator=(const Animator &)=delete
void onTick(float t) override
bool onMouse(SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
FocusController(const SlideDir *dir, const SkRect &focusRect)
void startFocus(const Rec *target)
SlideDir(const SkString &name, skia_private::TArray< sk_sp< Slide > > &&, int columns=kDefaultColumnCount)
void load(SkScalar winWidth, SkScalar winHeight) override
void draw(SkCanvas *) override
bool onChar(SkUnichar) override
bool animate(double) override
SkISize getDimensions() const override
bool onMouse(SkScalar x, SkScalar y, skui::InputState, skui::ModifierKey modifiers) override
virtual bool onMouse(SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
virtual bool onChar(SkUnichar c)
virtual SkISize getDimensions() const
const SkString & getName()
virtual void load(SkScalar winWidth, SkScalar winHeight)
void reset(T *ptr=nullptr)
static sk_sp< Color > Make(SkColor c)
static sk_sp< Draw > Make(sk_sp< GeometryNode > geo, sk_sp< PaintNode > paint)
void removeChild(const sk_sp< RenderNode > &)
void addChild(sk_sp< RenderNode >)
static sk_sp< Group > Make()
static sk_sp< Matrix > Make(const T &m)
void invalidate(bool damage=true)
virtual SkRect onRevalidate(InvalidationController *, const SkMatrix &ctm)=0
static sk_sp< Plane > Make()
static sk_sp< Rect > Make()
virtual const RenderNode * onNodeAt(const SkPoint &p) const =0
virtual void onRender(SkCanvas *, const RenderContext *) const =0
static std::unique_ptr< Scene > Make(sk_sp< RenderNode > root)
static sk_sp< Text > Make(sk_sp< SkTypeface > tf, const SkString &text)
static const int kLabelSize
static SkMSec NanosToMSec(double nanos)
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::enable_if_t< sknonstd::is_bitmask_enum< E >::value, bool > constexpr Any(E e)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
static constexpr SkPoint Make(float x, float y)
static float Distance(const SkPoint &a, const SkPoint &b)
static SkRect Make(const SkISize &size)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkRect makeInset(float dx, float dy) const
bool contains(SkScalar x, SkScalar y) const
static constexpr SkRect MakeSize(const SkSize &size)
static constexpr SkSize Make(SkScalar w, SkScalar h)
sk_sp< sksg::RenderNode > fSlideRoot
sk_sp< sksg::Matrix< SkMatrix > > fMatrix