Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: samplecode/SampleSVGFile.cpp

Issue 2217483002: Show SVG file name in SampleApp title (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDOM.h" 10 #include "SkDOM.h"
11 #include "SkOSFile.h"
11 #include "SkStream.h" 12 #include "SkStream.h"
12 #include "SkSVGDOM.h" 13 #include "SkSVGDOM.h"
13 #include "SkView.h" 14 #include "SkView.h"
14 15
15 namespace { 16 namespace {
16 17
17 class SVGFileView : public SampleView { 18 class SVGFileView : public SampleView {
18 public: 19 public:
19 SVGFileView(const char path[]) { 20 SVGFileView(const char path[])
21 : fLabel(SkStringPrintf("[%s]", SkOSPath::Basename(path).c_str())) {
20 SkFILEStream svgStream(path); 22 SkFILEStream svgStream(path);
21 if (!svgStream.isValid()) { 23 if (!svgStream.isValid()) {
22 SkDebugf("file not found: \"path\"\n", path); 24 SkDebugf("file not found: \"path\"\n", path);
23 return; 25 return;
24 } 26 }
25 27
26 SkDOM xmlDom; 28 SkDOM xmlDom;
27 if (!xmlDom.build(svgStream)) { 29 if (!xmlDom.build(svgStream)) {
28 SkDebugf("XML parsing failed: \"path\"\n", path); 30 SkDebugf("XML parsing failed: \"path\"\n", path);
29 return; 31 return;
(...skipping 12 matching lines...) Expand all
42 } 44 }
43 45
44 void onSizeChange() override { 46 void onSizeChange() override {
45 if (fDom) { 47 if (fDom) {
46 fDom->setContainerSize(SkSize::Make(this->width(), this->height())); 48 fDom->setContainerSize(SkSize::Make(this->width(), this->height()));
47 } 49 }
48 50
49 this->INHERITED::onSizeChange(); 51 this->INHERITED::onSizeChange();
50 } 52 }
51 53
54 bool onQuery(SkEvent* evt) override {
55 if (SampleCode::TitleQ(*evt)) {
56 SampleCode::TitleR(evt, fLabel.c_str());
57 return true;
58 }
59
60 return this->INHERITED::onQuery(evt);
61 }
52 private: 62 private:
53 sk_sp<SkSVGDOM> fDom; 63 sk_sp<SkSVGDOM> fDom;
64 SkString fLabel;
54 65
55 typedef SampleView INHERITED; 66 typedef SampleView INHERITED;
56 }; 67 };
57 68
58 } // anonymous namespace 69 } // anonymous namespace
59 70
60 SampleView* CreateSampleSVGFileView(const char filename[]); 71 SampleView* CreateSampleSVGFileView(const char filename[]);
61 SampleView* CreateSampleSVGFileView(const char filename[]) { 72 SampleView* CreateSampleSVGFileView(const char filename[]) {
62 return new SVGFileView(filename); 73 return new SVGFileView(filename);
63 } 74 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698