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

Side by Side Diff: include/views/SkTextBox.h

Issue 696293005: move SkTextBox into utils (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « include/utils/SkTextBox.h ('k') | src/utils/SkTextBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10 #ifndef SkTextBox_DEFINED
11 #define SkTextBox_DEFINED
12
13 #include "SkCanvas.h"
14
15 /** \class SkTextBox
16
17 SkTextBox is a helper class for drawing 1 or more lines of text
18 within a rectangle. The textbox is positioned and clipped by its Frame.
19 The Margin rectangle controls where the text is drawn relative to
20 the Frame. Line-breaks occur inside the Margin rectangle.
21
22 Spacing is a linear equation used to compute the distance between lines
23 of text. Spacing consists of two scalars: mul and add, and the spacing
24 between lines is computed as: spacing = paint.getTextSize() * mul + add
25 */
26 class SkTextBox {
27 public:
28 SkTextBox();
29
30 enum Mode {
31 kOneLine_Mode,
32 kLineBreak_Mode,
33
34 kModeCount
35 };
36 Mode getMode() const { return (Mode)fMode; }
37 void setMode(Mode);
38
39 enum SpacingAlign {
40 kStart_SpacingAlign,
41 kCenter_SpacingAlign,
42 kEnd_SpacingAlign,
43
44 kSpacingAlignCount
45 };
46 SpacingAlign getSpacingAlign() const { return (SpacingAlign)fSpacingAlign ; }
47 void setSpacingAlign(SpacingAlign);
48
49 void getBox(SkRect*) const;
50 void setBox(const SkRect&);
51 void setBox(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) ;
52
53 void getSpacing(SkScalar* mul, SkScalar* add) const;
54 void setSpacing(SkScalar mul, SkScalar add);
55
56 void draw(SkCanvas*, const char text[], size_t len, const SkPaint&);
57
58 void setText(const char text[], size_t len, const SkPaint&);
59 void draw(SkCanvas*);
60 int countLines() const;
61 SkScalar getTextHeight() const;
62
63 private:
64 SkRect fBox;
65 SkScalar fSpacingMul, fSpacingAdd;
66 uint8_t fMode, fSpacingAlign;
67 const char* fText;
68 size_t fLen;
69 const SkPaint* fPaint;
70 };
71
72 class SkTextLineBreaker {
73 public:
74 static int CountLines(const char text[], size_t len, const SkPaint&, SkScala r width);
75 };
76
77 #endif
OLDNEW
« no previous file with comments | « include/utils/SkTextBox.h ('k') | src/utils/SkTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698