OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBorderView.h" | 8 #include "SkBorderView.h" |
9 #include "SkAnimator.h" | 9 #include "SkAnimator.h" |
10 #include "SkWidgetViews.h" | 10 #include "SkWidgetViews.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 evt.setScalar("dimY", this->height()); | 45 evt.setScalar("dimY", this->height()); |
46 fAnim.doUserEvent(evt); | 46 fAnim.doUserEvent(evt); |
47 } | 47 } |
48 | 48 |
49 /*virtual*/ void SkBorderView::onDraw(SkCanvas* canvas) | 49 /*virtual*/ void SkBorderView::onDraw(SkCanvas* canvas) |
50 { | 50 { |
51 SkPaint paint; | 51 SkPaint paint; |
52 SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetM
Secs()); | 52 SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetM
Secs()); |
53 | 53 |
54 if (diff == SkAnimator::kDifferent) | 54 if (diff == SkAnimator::kDifferent) |
55 this->inval(NULL); | 55 this->inval(nullptr); |
56 else if (diff == SkAnimator::kPartiallyDifferent) | 56 else if (diff == SkAnimator::kPartiallyDifferent) |
57 { | 57 { |
58 SkRect bounds; | 58 SkRect bounds; |
59 fAnim.getInvalBounds(&bounds); | 59 fAnim.getInvalBounds(&bounds); |
60 this->inval(&bounds); | 60 this->inval(&bounds); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 /*virtual*/ bool SkBorderView::onEvent(const SkEvent& evt) | 64 /*virtual*/ bool SkBorderView::onEvent(const SkEvent& evt) |
65 { | 65 { |
66 if (evt.isType(SK_EventType_Inval)) | 66 if (evt.isType(SK_EventType_Inval)) |
67 { | 67 { |
68 this->inval(NULL); | 68 this->inval(nullptr); |
69 return true; | 69 return true; |
70 } | 70 } |
71 if (evt.isType("recommendDim")) | 71 if (evt.isType("recommendDim")) |
72 { | 72 { |
73 evt.findScalar("leftMargin", &fLeft); | 73 evt.findScalar("leftMargin", &fLeft); |
74 evt.findScalar("rightMargin", &fRight); | 74 evt.findScalar("rightMargin", &fRight); |
75 evt.findScalar("topMargin", &fTop); | 75 evt.findScalar("topMargin", &fTop); |
76 evt.findScalar("bottomMargin", &fBottom); | 76 evt.findScalar("bottomMargin", &fBottom); |
77 | 77 |
78 //setup_views.cpp uses SkView::Layout instead of SkStackViewLayout | 78 //setup_views.cpp uses SkView::Layout instead of SkStackViewLayout |
79 //but that gives me an error | 79 //but that gives me an error |
80 SkStackViewLayout* layout; | 80 SkStackViewLayout* layout; |
81 fMargin.set(fLeft, fTop, fRight, fBottom); | 81 fMargin.set(fLeft, fTop, fRight, fBottom); |
82 if (this->getLayout()) | 82 if (this->getLayout()) |
83 { | 83 { |
84 layout = (SkStackViewLayout*)this->getLayout(); | 84 layout = (SkStackViewLayout*)this->getLayout(); |
85 layout->setMargin(fMargin); | 85 layout->setMargin(fMargin); |
86 } | 86 } |
87 else | 87 else |
88 { | 88 { |
89 layout = new SkStackViewLayout; | 89 layout = new SkStackViewLayout; |
90 layout->setMargin(fMargin); | 90 layout->setMargin(fMargin); |
91 this->setLayout(layout)->unref(); | 91 this->setLayout(layout)->unref(); |
92 } | 92 } |
93 this->invokeLayout(); | 93 this->invokeLayout(); |
94 } | 94 } |
95 return this->INHERITED::onEvent(evt); | 95 return this->INHERITED::onEvent(evt); |
96 } | 96 } |
OLD | NEW |