Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
SGSlide Class Reference
Inheritance diagram for SGSlide:
ClickHandlerSlide Slide SkRefCnt SkRefCntBase

Public Member Functions

 SGSlide ()
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from ClickHandlerSlide
bool onMouse (SkScalar x, SkScalar y, skui::InputState clickState, skui::ModifierKey modifierKeys) final
 
- Public Member Functions inherited from Slide
virtual SkISize getDimensions () const
 
virtual void gpuTeardown ()
 
virtual void draw (SkCanvas *canvas)=0
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onChar (SkUnichar c)
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi) override
 
bool onClick (Click *click) override
 
virtual ClickonFindClickHandler (SkScalar x, SkScalar y, skui::ModifierKey modi)=0
 
virtual bool onClick (Click *)=0
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

Definition at line 29 of file SGSlide.cpp.

Constructor & Destructor Documentation

◆ SGSlide()

SGSlide::SGSlide ( )
inline

Definition at line 53 of file SGSlide.cpp.

53 {
54 fGroup = sksg::Group::Make();
55
56 fScene = sksg::Scene::Make(fGroup);
57
58 auto r = sksg::Rect::Make({20, 20, 400, 300});
60 auto d = sksg::Draw::Make(r, p);
61 this->appendNode(d, r, p);
62
63 r = sksg::Rect::Make({60, 70, 300, 400});
65 d = sksg::Draw::Make(r, p);
66 this->appendNode(d, r, p);
67 fName = "SceneGraph";
68 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
SkString fName
Definition: Slide.h:54
static sk_sp< Color > Make(SkColor c)
Definition: SkSGPaint.cpp:44
static sk_sp< Draw > Make(sk_sp< GeometryNode > geo, sk_sp< PaintNode > paint)
Definition: SkSGDraw.h:35
static sk_sp< Group > Make()
Definition: SkSGGroup.h:31
static sk_sp< Rect > Make()
Definition: SkSGRect.h:36
static std::unique_ptr< Scene > Make(sk_sp< RenderNode > root)
Definition: SkSGScene.cpp:16
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

Member Function Documentation

◆ draw()

void SGSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 70 of file SGSlide.cpp.

70 {
71 fScene->render(canvas);
72 }

◆ onClick()

bool SGSlide::onClick ( Click )
inlineoverrideprotectedvirtual

Override to track clicks. Return true as long as you want to track the pen/mouse.

Implements ClickHandlerSlide.

Definition at line 84 of file SGSlide.cpp.

84 {
85 sksg::Draw* node = nullptr;
86 if (click->fMeta.findPtr("node", (void**)&node)) {
87 if (auto info = this->findInfo(node)) {
88 auto geo = info->fGeo;
89 sksg::Rect* r = (sksg::Rect*)geo;
90 SkScalar dx = click->fCurr.fX - click->fPrev.fX;
91 SkScalar dy = click->fCurr.fY - click->fPrev.fY;
92 r->setL(r->getL() + dx);
93 r->setR(r->getR() + dx);
94 r->setT(r->getT() + dy);
95 r->setB(r->getB() + dy);
96 }
97 return true;
98 }
99 return false;
100 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
float SkScalar
Definition: extension.cpp:12
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

◆ onFindClickHandler()

Click * SGSlide::onFindClickHandler ( SkScalar  x,
SkScalar  y,
skui::ModifierKey  modi 
)
inlineoverrideprotectedvirtual

Return a Click object to handle the click. onClick will be called repeatedly with the latest mouse state tracked on the Click object until it returns false.

Implements ClickHandlerSlide.

Definition at line 75 of file SGSlide.cpp.

75 {
76 if (auto node = fScene->nodeAt({x, y})) {
77 Click* click = new Click();
78 click->fMeta.setPtr("node", (void*)node);
79 return click;
80 }
81 return nullptr;
82 }

The documentation for this class was generated from the following file: