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

Public Member Functions

 XferSlide ()
 
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) 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 109 of file XferSlide.cpp.

Constructor & Destructor Documentation

◆ XferSlide()

XferSlide::XferSlide ( )
inline

Definition at line 111 of file XferSlide.cpp.

111 {
113 for (int i = 0; i < N; ++i) {
114 fDrs[i].reset(new CircDrawable(200, colors[i]));
115 fDrs[i]->fLoc.set(100.f + i * 100, 100.f + i * 100);
117 }
118 fSelected = nullptr;
119
120 this->addButtons();
121 fName = "XferDemo";
122 }
@ kSrcOver
r = s + (1-sa)*d
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
SkBlendMode fMode
Definition: XferSlide.cpp:73
SkPoint fLoc
Definition: XferSlide.cpp:74
SkString fName
Definition: Slide.h:54
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
PODArray< SkColor > colors
Definition: SkRecords.h:276
void set(float x, float y)
Definition: SkPoint_impl.h:200

Member Function Documentation

◆ draw()

void XferSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 124 of file XferSlide.cpp.

124 {
125 for (int i = 0; i < N_Modes; ++i) {
126 fModeButtons[i].draw(canvas);
127 }
128
130 if (fSelected) {
131 for (int i = 0; i < N_Modes; ++i) {
132 if (fSelected->fMode == gModes[i]) {
133 canvas->drawRect(fModeRect[i], paint);
134 break;
135 }
136 }
137 }
138
139 canvas->saveLayer(nullptr, nullptr);
140 for (int i = 0; i < N; ++i) {
141 fDrs[i]->draw(canvas);
142 }
143 canvas->restore();
144 }
const SkBlendMode gModes[]
Definition: XferSlide.cpp:23
const int N_Modes
Definition: XferSlide.cpp:34
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void restore()
Definition: SkCanvas.cpp:461
void draw(SkCanvas *, const SkMatrix *=nullptr)
Definition: SkDrawable.cpp:43
const Paint & paint
Definition: color_source.cc:38
void draw(SkCanvas *canvas)
Definition: XferSlide.cpp:50

◆ onClick()

bool XferSlide::onClick ( Click )
inlineoverrideprotectedvirtual

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

Implements ClickHandlerSlide.

Definition at line 166 of file XferSlide.cpp.

166 {
167 int32_t mode;
168 if (click->fMeta.findS32("mode", &mode)) {
169 if (fSelected && skui::InputState::kUp == click->fState) {
170 fSelected->fMode = gModes[mode];
171 }
172 } else {
173 fSelected->fLoc.fX += click->fCurr.fX - click->fPrev.fX;
174 fSelected->fLoc.fY += click->fCurr.fY - click->fPrev.fY;
175 }
176 return true;
177 }
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 mode
Definition: switches.h:228
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ onFindClickHandler()

Click * XferSlide::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 147 of file XferSlide.cpp.

147 {
148 // Check mode buttons first
149 for (int i = 0; i < N_Modes; ++i) {
150 if (fModeButtons[i].hitTest(x, y)) {
151 Click* click = new Click();
152 click->fMeta.setS32("mode", i);
153 return click;
154 }
155 }
156 fSelected = nullptr;
157 for (int i = N - 1; i >= 0; --i) {
158 if (fDrs[i]->hitTest(x, y)) {
159 fSelected = fDrs[i].get();
160 break;
161 }
162 }
163 return fSelected ? new Click() : nullptr;
164 }
T * get() const
Definition: SkRefCnt.h:303
double y
double x

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