| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 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 | 8 |
| 9 | 9 |
| 10 #include "SkDisplayEvent.h" | 10 #include "SkDisplayEvent.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 SK_MEMBER(target, String), | 38 SK_MEMBER(target, String), |
| 39 SK_MEMBER(x, Float), | 39 SK_MEMBER(x, Float), |
| 40 SK_MEMBER(y, Float) | 40 SK_MEMBER(y, Float) |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 DEFINE_GET_MEMBER(SkDisplayEvent); | 45 DEFINE_GET_MEMBER(SkDisplayEvent); |
| 46 | 46 |
| 47 SkDisplayEvent::SkDisplayEvent() : code((SkKey) -1), disable(false), | 47 SkDisplayEvent::SkDisplayEvent() : code((SkKey) -1), disable(false), |
| 48 kind(kUser), x(0), y(0), fLastCode((SkKey) -1), fMax((SkKey) -1), fTarget(NU
LL) { | 48 kind(kUser), x(0), y(0), fLastCode((SkKey) -1), fMax((SkKey) -1), fTarget(nu
llptr) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 SkDisplayEvent::~SkDisplayEvent() { | 51 SkDisplayEvent::~SkDisplayEvent() { |
| 52 deleteMembers(); | 52 deleteMembers(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool SkDisplayEvent::addChild(SkAnimateMaker& , SkDisplayable* child) { | 55 bool SkDisplayEvent::addChild(SkAnimateMaker& , SkDisplayable* child) { |
| 56 *fChildren.append() = child; | 56 *fChildren.append() = child; |
| 57 return true; | 57 return true; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool SkDisplayEvent::contains(SkDisplayable* match) { | 60 bool SkDisplayEvent::contains(SkDisplayable* match) { |
| 61 for (int index = 0; index < fChildren.count(); index++) { | 61 for (int index = 0; index < fChildren.count(); index++) { |
| 62 if (fChildren[index] == match || fChildren[index]->contains(match)) | 62 if (fChildren[index] == match || fChildren[index]->contains(match)) |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 SkDisplayable* SkDisplayEvent::contains(const SkString& match) { | 68 SkDisplayable* SkDisplayEvent::contains(const SkString& match) { |
| 69 for (int index = 0; index < fChildren.count(); index++) { | 69 for (int index = 0; index < fChildren.count(); index++) { |
| 70 SkDisplayable* child = fChildren[index]; | 70 SkDisplayable* child = fChildren[index]; |
| 71 if (child->contains(match)) | 71 if (child->contains(match)) |
| 72 return child; | 72 return child; |
| 73 } | 73 } |
| 74 return NULL; | 74 return nullptr; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SkDisplayEvent::deleteMembers() { | 77 void SkDisplayEvent::deleteMembers() { |
| 78 for (int index = 0; index < fChildren.count(); index++) { | 78 for (int index = 0; index < fChildren.count(); index++) { |
| 79 SkDisplayable* evt = fChildren[index]; | 79 SkDisplayable* evt = fChildren[index]; |
| 80 delete evt; | 80 delete evt; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 #ifdef SK_DUMP_ENABLED | 84 #ifdef SK_DUMP_ENABLED |
| 85 void SkDisplayEvent::dumpEvent(SkAnimateMaker* maker) { | 85 void SkDisplayEvent::dumpEvent(SkAnimateMaker* maker) { |
| 86 dumpBase(maker); | 86 dumpBase(maker); |
| 87 SkString str; | 87 SkString str; |
| 88 SkDump::GetEnumString(SkType_EventKind, kind, &str); | 88 SkDump::GetEnumString(SkType_EventKind, kind, &str); |
| 89 SkDebugf("kind=\"%s\" ", str.c_str()); | 89 SkDebugf("kind=\"%s\" ", str.c_str()); |
| 90 if (kind == SkDisplayEvent::kKeyPress || kind == SkDisplayEvent::kKeyPressUp
) { | 90 if (kind == SkDisplayEvent::kKeyPress || kind == SkDisplayEvent::kKeyPressUp
) { |
| 91 if (code >= 0) | 91 if (code >= 0) |
| 92 SkDump::GetEnumString(SkType_EventCode, code, &str); | 92 SkDump::GetEnumString(SkType_EventCode, code, &str); |
| 93 else | 93 else |
| 94 str.set("none"); | 94 str.set("none"); |
| 95 SkDebugf("code=\"%s\" ", str.c_str()); | 95 SkDebugf("code=\"%s\" ", str.c_str()); |
| 96 } | 96 } |
| 97 if (kind == SkDisplayEvent::kKeyChar) { | 97 if (kind == SkDisplayEvent::kKeyChar) { |
| 98 if (fMax != (SkKey) -1 && fMax != code) | 98 if (fMax != (SkKey) -1 && fMax != code) |
| 99 SkDebugf("keys=\"%c - %c\" ", code, fMax); | 99 SkDebugf("keys=\"%c - %c\" ", code, fMax); |
| 100 else | 100 else |
| 101 SkDebugf("key=\"%c\" ", code); | 101 SkDebugf("key=\"%c\" ", code); |
| 102 } | 102 } |
| 103 if (fTarget != NULL) { | 103 if (fTarget != nullptr) { |
| 104 SkDebugf("target=\"%s\" ", fTarget->id); | 104 SkDebugf("target=\"%s\" ", fTarget->id); |
| 105 } | 105 } |
| 106 if (kind >= SkDisplayEvent::kMouseDown && kind <= SkDisplayEvent::kMouseUp)
{ | 106 if (kind >= SkDisplayEvent::kMouseDown && kind <= SkDisplayEvent::kMouseUp)
{ |
| 107 SkDebugf("x=\"%g\" y=\"%g\" ", SkScalarToFloat(x), SkScalarToFloat(y)); | 107 SkDebugf("x=\"%g\" y=\"%g\" ", SkScalarToFloat(x), SkScalarToFloat(y)); |
| 108 } | 108 } |
| 109 if (disable) | 109 if (disable) |
| 110 SkDebugf("disable=\"true\" "); | 110 SkDebugf("disable=\"true\" "); |
| 111 SkDebugf("/>\n"); | 111 SkDebugf("/>\n"); |
| 112 } | 112 } |
| 113 #endif | 113 #endif |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 animate->setHasEndEvent(); | 181 animate->setHasEndEvent(); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 void SkDisplayEvent::populateInput(SkAnimateMaker& maker, const SkEvent& fEvent)
{ | 185 void SkDisplayEvent::populateInput(SkAnimateMaker& maker, const SkEvent& fEvent)
{ |
| 186 const SkMetaData& meta = fEvent.getMetaData(); | 186 const SkMetaData& meta = fEvent.getMetaData(); |
| 187 SkMetaData::Iter iter(meta); | 187 SkMetaData::Iter iter(meta); |
| 188 SkMetaData::Type type; | 188 SkMetaData::Type type; |
| 189 int number; | 189 int number; |
| 190 const char* name; | 190 const char* name; |
| 191 while ((name = iter.next(&type, &number)) != NULL) { | 191 while ((name = iter.next(&type, &number)) != nullptr) { |
| 192 if (name[0] == '\0') | 192 if (name[0] == '\0') |
| 193 continue; | 193 continue; |
| 194 SkDisplayable* displayable; | 194 SkDisplayable* displayable; |
| 195 SkInput* input; | 195 SkInput* input; |
| 196 for (int index = 0; index < fChildren.count(); index++) { | 196 for (int index = 0; index < fChildren.count(); index++) { |
| 197 displayable = fChildren[index]; | 197 displayable = fChildren[index]; |
| 198 if (displayable->getType() != SkType_Input) | 198 if (displayable->getType() != SkType_Input) |
| 199 continue; | 199 continue; |
| 200 input = (SkInput*) displayable; | 200 input = (SkInput*) displayable; |
| 201 if (input->name.equals(name)) | 201 if (input->name.equals(name)) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 fMax = code; | 243 fMax = code; |
| 244 SkASSERT(count == 1 || index == SK_PROPERTY(keys)); | 244 SkASSERT(count == 1 || index == SK_PROPERTY(keys)); |
| 245 if (--count > 0) { | 245 if (--count > 0) { |
| 246 SkASSERT(*chars == '-'); | 246 SkASSERT(*chars == '-'); |
| 247 chars++; | 247 chars++; |
| 248 fMax = (SkKey) SkUTF8_NextUnichar(&chars); | 248 fMax = (SkKey) SkUTF8_NextUnichar(&chars); |
| 249 SkASSERT(fMax >= code); | 249 SkASSERT(fMax >= code); |
| 250 } | 250 } |
| 251 return true; | 251 return true; |
| 252 } | 252 } |
| OLD | NEW |