| OLD | NEW |
| (Empty) |
| 1 /* libs/graphics/animator/SkDrawTextBox.cpp | |
| 2 ** | |
| 3 ** Copyright 2006, The Android Open Source Project | |
| 4 ** | |
| 5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 ** you may not use this file except in compliance with the License. | |
| 7 ** You may obtain a copy of the License at | |
| 8 ** | |
| 9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 ** | |
| 11 ** Unless required by applicable law or agreed to in writing, software | |
| 12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 ** See the License for the specific language governing permissions and | |
| 15 ** limitations under the License. | |
| 16 */ | |
| 17 | |
| 18 #include "SkDrawTextBox.h" | |
| 19 #include "SkAnimateMaker.h" | |
| 20 #include "SkCanvas.h" | |
| 21 #include "SkPaint.h" | |
| 22 | |
| 23 enum SkDrawTextBox_Properties { | |
| 24 foo = 100, | |
| 25 SK_PROPERTY(spacingAlign), | |
| 26 SK_PROPERTY(mode) | |
| 27 }; | |
| 28 | |
| 29 | |
| 30 #if SK_USE_CONDENSED_INFO == 0 | |
| 31 | |
| 32 const SkMemberInfo SkDrawTextBox::fInfo[] = { | |
| 33 SK_MEMBER_INHERITED, | |
| 34 SK_MEMBER(mode, TextBoxMode), | |
| 35 SK_MEMBER_ALIAS(spacingAdd, fSpacingAdd, Float), | |
| 36 SK_MEMBER(spacingAlign, TextBoxAlign), | |
| 37 SK_MEMBER_ALIAS(spacingMul, fSpacingMul, Float), | |
| 38 SK_MEMBER_ALIAS(text, fText, String) | |
| 39 }; | |
| 40 | |
| 41 #endif | |
| 42 | |
| 43 DEFINE_GET_MEMBER(SkDrawTextBox); | |
| 44 | |
| 45 SkDrawTextBox::SkDrawTextBox() | |
| 46 { | |
| 47 fSpacingMul = SK_Scalar1; | |
| 48 fSpacingAdd = 0; | |
| 49 spacingAlign = SkTextBox::kStart_SpacingAlign; | |
| 50 mode = SkTextBox::kLineBreak_Mode; | |
| 51 } | |
| 52 | |
| 53 #ifdef SK_DUMP_ENABLED | |
| 54 void SkDrawTextBox::dump(SkAnimateMaker* maker) | |
| 55 { | |
| 56 dumpBase(maker); | |
| 57 dumpAttrs(maker); | |
| 58 if (mode == 0) | |
| 59 SkDebugf("mode=\"oneLine\" "); | |
| 60 if (spacingAlign == 1) | |
| 61 SkDebugf("spacingAlign=\"center\" "); | |
| 62 else if (spacingAlign == 2) | |
| 63 SkDebugf("spacingAlign=\"end\" "); | |
| 64 SkDebugf("/>\n"); | |
| 65 } | |
| 66 #endif | |
| 67 | |
| 68 bool SkDrawTextBox::getProperty(int index, SkScriptValue* value) const | |
| 69 { | |
| 70 return this->INHERITED::getProperty(index, value); | |
| 71 } | |
| 72 | |
| 73 bool SkDrawTextBox::setProperty(int index, SkScriptValue& scriptValue) | |
| 74 { | |
| 75 return this->INHERITED::setProperty(index, scriptValue); | |
| 76 } | |
| 77 | |
| 78 bool SkDrawTextBox::draw(SkAnimateMaker& maker) | |
| 79 { | |
| 80 SkTextBox box; | |
| 81 box.setMode((SkTextBox::Mode) mode); | |
| 82 box.setSpacingAlign((SkTextBox::SpacingAlign) spacingAlign); | |
| 83 box.setBox(fRect); | |
| 84 box.setSpacing(fSpacingMul, fSpacingAdd); | |
| 85 SkBoundableAuto boundable(this, maker); | |
| 86 box.draw(maker.fCanvas, fText.c_str(), fText.size(), *maker.fPaint); | |
| 87 return false; | |
| 88 } | |
| 89 | |
| 90 | |
| OLD | NEW |