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>
diff --git a/tools/viewer/NIMASlide.cpp b/tools/viewer/NIMASlide.cpp
index 4d094c4..c1a3356 100644
--- a/tools/viewer/NIMASlide.cpp
+++ b/tools/viewer/NIMASlide.cpp
@@ -341,6 +341,10 @@
NIMASlide::~NIMASlide() {}
+SkISize NIMASlide::getDimensions() const {
+ return SkISize::MakeEmpty(); // TODO
+}
+
void NIMASlide::draw(SkCanvas* canvas) {
canvas->save();
diff --git a/tools/viewer/NIMASlide.h b/tools/viewer/NIMASlide.h
index b4d5d2b..d1b1298 100644
--- a/tools/viewer/NIMASlide.h
+++ b/tools/viewer/NIMASlide.h
@@ -31,6 +31,8 @@
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;
diff --git a/tools/viewer/SampleSlide.cpp b/tools/viewer/SampleSlide.cpp
index 13597f7..9b1737a 100644
--- a/tools/viewer/SampleSlide.cpp
+++ b/tools/viewer/SampleSlide.cpp
@@ -23,6 +23,10 @@
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);
diff --git a/tools/viewer/SampleSlide.h b/tools/viewer/SampleSlide.h
index ec5253a..7cf1d3c 100644
--- a/tools/viewer/SampleSlide.h
+++ b/tools/viewer/SampleSlide.h
@@ -16,6 +16,8 @@
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 {
diff --git a/tools/viewer/Slide.h b/tools/viewer/Slide.h
index 023cd6b..a2ee307 100644
--- a/tools/viewer/Slide.h
+++ b/tools/viewer/Slide.h
@@ -21,9 +21,7 @@
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; }