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

Public Member Functions

 DrawLineSlide ()
 
void setStyle (FatBits::Style s)
 
bool onChar (SkUnichar uni) override
 
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 374 of file FatBitsSlide.cpp.

Constructor & Destructor Documentation

◆ DrawLineSlide()

DrawLineSlide::DrawLineSlide ( )
inline

Definition at line 381 of file FatBitsSlide.cpp.

381 {
382 fFB.setWHZ(24*2, 16*2, fZoom);
383 fPts[0].set(1, 1);
384 fPts[1].set(5, 4);
385 fPts[2].set(2, 6);
386 SkMatrix::Scale(fZoom, fZoom).mapPoints(fPts, 3);
387 fIsRect = false;
388 fName = "FatBits";
389 }
void setWHZ(int width, int height, int zoom)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition: SkMatrix.cpp:770
SkString fName
Definition: Slide.h:54
void set(float x, float y)
Definition: SkPoint_impl.h:200

Member Function Documentation

◆ draw()

void DrawLineSlide::draw ( SkCanvas canvas)
inlineoverridevirtual

Implements Slide.

Definition at line 443 of file FatBitsSlide.cpp.

443 {
444 fFB.drawBG(canvas);
445 if (fFB.getTriangle()) {
446 fFB.drawTriangle(canvas, fPts);
447 } else if (fIsRect) {
448 fFB.drawRect(canvas, fPts);
449 } else {
450 fFB.drawLine(canvas, fPts);
451 }
452 fFB.drawFG(canvas);
453
454 {
455 SkString str;
456 str.printf("%s %s %s",
457 fFB.getAA() ? "AA" : "BW",
458 FatBits::kHair_Style == fFB.getStyle() ? "Hair" : "Stroke",
459 fFB.getUseClip() ? "clip" : "noclip");
461 paint.setColor(SK_ColorBLUE);
463 canvas->drawString(str, 10, 16, font, paint);
464 }
465 }
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
void drawLine(SkCanvas *, SkPoint pts[2])
bool getAA() const
bool getUseClip() const
void drawTriangle(SkCanvas *canvas, SkPoint pts[3])
void drawRect(SkCanvas *canvas, SkPoint pts[2])
void drawBG(SkCanvas *)
bool getTriangle() const
Style getStyle() const
void drawFG(SkCanvas *)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
Definition: SkFont.h:35
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkTypeface > DefaultTypeface()
font
Font Metadata and Metrics.

◆ onChar()

bool DrawLineSlide::onChar ( SkUnichar  uni)
inlineoverridevirtual

Reimplemented from Slide.

Definition at line 393 of file FatBitsSlide.cpp.

393 {
394 switch (uni) {
395 case 'c':
396 fFB.setUseClip(!fFB.getUseClip());
397 return true;
398 case 'r':
399 fIsRect = !fIsRect;
400 return true;
401 case 'o':
402 fFB.toggleRectAsOval();
403 return true;
404 case 'x':
405 fFB.setGrid(!fFB.getGrid());
406 return true;
407 case 's':
408 if (FatBits::kStroke_Style == fFB.getStyle()) {
410 } else {
412 }
413 return true;
414 case 'k': {
415 const SkPaint::Cap caps[] = {
417 };
418 fFB.fStrokeCap = caps[(fFB.fStrokeCap + 1) % 3];
419 return true;
420 }
421 case 'a':
422 fFB.setAA(!fFB.getAA());
423 return true;
424 case 'w':
426 return true;
427 case 'g':
428 fFB.togglePixelColors();
429 return true;
430 case 't':
431 fFB.setTriangle(!fFB.getTriangle());
432 return true;
433 case '-':
434 fFB.fStrokeWidth -= 0.125f;
435 return true;
436 case '=':
437 fFB.fStrokeWidth += 0.125f;
438 return true;
439 }
440 return false;
441 }
void setStyle(FatBits::Style s)
void setGrid(bool g)
void setTriangle(bool ut)
void setShowSkeleton(bool ss)
void setAA(bool aa)
void togglePixelColors()
void toggleRectAsOval()
void setUseClip(bool uc)
SkPaint::Cap fStrokeCap
float fStrokeWidth
bool getShowSkeleton() const
bool getGrid() const
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336

◆ onClick()

bool DrawLineSlide::onClick ( Click )
inlineoverrideprotectedvirtual

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

Implements ClickHandlerSlide.

Definition at line 483 of file FatBitsSlide.cpp.

483 {
484 int index = IndexClick::GetIndex(click);
485 if (index >= 0 && index <= 2) {
486 fPts[index] = click->fCurr;
487 } else {
488 SkScalar dx = click->fCurr.fX - click->fPrev.fX;
489 SkScalar dy = click->fCurr.fY - click->fPrev.fY;
490 fPts[0].offset(dx, dy);
491 fPts[1].offset(dx, dy);
492 fPts[2].offset(dx, dy);
493 }
494 return true;
495 }
static int GetIndex(Click *click)
float SkScalar
Definition: extension.cpp:12
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
void offset(float dx, float dy)
Definition: SkPoint_impl.h:269

◆ onFindClickHandler()

Click * DrawLineSlide::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 468 of file FatBitsSlide.cpp.

468 {
469 SkPoint pt = { x, y };
470 int index = -1;
471 int count = fFB.getTriangle() ? 3 : 2;
472 SkScalar tol = 12;
473
474 for (int i = 0; i < count; ++i) {
475 if (SkPointPriv::EqualsWithinTolerance(fPts[i], pt, tol)) {
476 index = i;
477 break;
478 }
479 }
480 return new IndexClick(index);
481 }
int count
Definition: FontMgrTest.cpp:50
static bool EqualsWithinTolerance(const SkPoint &p1, const SkPoint &p2)
Definition: SkPointPriv.h:54
double y
double x

◆ setStyle()

void DrawLineSlide::setStyle ( FatBits::Style  s)
inline

Definition at line 391 of file FatBitsSlide.cpp.

391{ fFB.setStyle(s); }
void setStyle(Style s)
struct MyStruct s

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