Make Slide::getDimensions pure virtual.

The default behavior is to not let the user move the slide to the top or
left. Implement for SampleSlide and stub out for NIMASlide (which isn't
so easy to implement).

Change-Id: I16074e704f4086199932d83e28c28d1ee39fbd9d
Reviewed-on: https://skia-review.googlesource.com/151600
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2018-09-04 18:35:20 -04:00 committed by Skia Commit-Bot
parent 7af2bc8802
commit 211511237f
5 changed files with 13 additions and 3 deletions

View File

@ -341,6 +341,10 @@ NIMASlide::NIMASlide(const SkString& name, const SkString& path)
NIMASlide::~NIMASlide() {}
SkISize NIMASlide::getDimensions() const {
return SkISize::MakeEmpty(); // TODO
}
void NIMASlide::draw(SkCanvas* canvas) {
canvas->save();

View File

@ -31,6 +31,8 @@ public:
NIMASlide(const SkString& name, const SkString& path);
~NIMASlide() override;
SkISize getDimensions() const override;
void draw(SkCanvas* canvas) override;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;

View File

@ -23,6 +23,10 @@ SampleSlide::SampleSlide(const SampleFactory factory)
SampleSlide::~SampleSlide() { delete fClick; }
SkISize SampleSlide::getDimensions() const {
return SkISize::Make(SkScalarCeilToInt(fSample->width()), SkScalarCeilToInt(fSample->height()));
}
void SampleSlide::draw(SkCanvas* canvas) {
SkASSERT(fSample);
fSample->draw(canvas);

View File

@ -16,6 +16,8 @@ public:
SampleSlide(const SampleFactory factory);
~SampleSlide() override;
SkISize getDimensions() const override;
void draw(SkCanvas* canvas) override;
void load(SkScalar winWidth, SkScalar winHeight) override;
void resize(SkScalar winWidth, SkScalar winHeight) override {

View File

@ -21,9 +21,7 @@ class Slide : public SkRefCnt {
public:
virtual ~Slide() {}
virtual SkISize getDimensions() const {
return SkISize::Make(0, 0);
}
virtual SkISize getDimensions() const = 0;
virtual void draw(SkCanvas* canvas) = 0;
virtual bool animate(const SkAnimTimer&) { return false; }