ParagraphLayout: Don't ignore the given drawing offset.
This commit is contained in:
parent
f1a08c0848
commit
8e8d1b55d3
@ -255,7 +255,7 @@ ParagraphLayout::Draw(BView* view, const BPoint& offset)
|
|||||||
int lineCount = fLineInfos.CountItems();
|
int lineCount = fLineInfos.CountItems();
|
||||||
for (int i = 0; i < lineCount; i++) {
|
for (int i = 0; i < lineCount; i++) {
|
||||||
const LineInfo& line = fLineInfos.ItemAtFast(i);
|
const LineInfo& line = fLineInfos.ItemAtFast(i);
|
||||||
_DrawLine(view, line);
|
_DrawLine(view, offset, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,8 +283,10 @@ ParagraphLayout::_Init()
|
|||||||
void
|
void
|
||||||
ParagraphLayout::_ValidateLayout()
|
ParagraphLayout::_ValidateLayout()
|
||||||
{
|
{
|
||||||
if (!fLayoutValid)
|
if (!fLayoutValid) {
|
||||||
_Layout();
|
_Layout();
|
||||||
|
fLayoutValid = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -674,27 +676,28 @@ ParagraphLayout::_IncludeStyleInLine(LineInfo& line,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParagraphLayout::_DrawLine(BView* view, const LineInfo& line) const
|
ParagraphLayout::_DrawLine(BView* view, const BPoint& offset,
|
||||||
|
const LineInfo& line) const
|
||||||
{
|
{
|
||||||
int textOffset = line.textOffset;
|
int textOffset = line.textOffset;
|
||||||
int spanCount = line.layoutedSpans.CountItems();
|
int spanCount = line.layoutedSpans.CountItems();
|
||||||
for (int i = 0; i < spanCount; i++) {
|
for (int i = 0; i < spanCount; i++) {
|
||||||
const TextSpan& span = line.layoutedSpans.ItemAtFast(i);
|
const TextSpan& span = line.layoutedSpans.ItemAtFast(i);
|
||||||
_DrawSpan(view, span, textOffset);
|
_DrawSpan(view, offset, span, textOffset);
|
||||||
textOffset += span.CharCount();
|
textOffset += span.CharCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ParagraphLayout::_DrawSpan(BView* view, const TextSpan& span,
|
ParagraphLayout::_DrawSpan(BView* view, BPoint offset,
|
||||||
int32 textOffset) const
|
const TextSpan& span, int32 textOffset) const
|
||||||
{
|
{
|
||||||
const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset);
|
const GlyphInfo& glyph = fGlyphInfos.ItemAtFast(textOffset);
|
||||||
const LineInfo& line = fLineInfos.ItemAtFast(glyph.lineIndex);
|
const LineInfo& line = fLineInfos.ItemAtFast(glyph.lineIndex);
|
||||||
|
|
||||||
float x = glyph.x;
|
offset.x += glyph.x;
|
||||||
float y = line.y + line.maxAscent;
|
offset.y += line.y + line.maxAscent;
|
||||||
|
|
||||||
const CharacterStyle& style = span.Style();
|
const CharacterStyle& style = span.Style();
|
||||||
|
|
||||||
@ -708,7 +711,7 @@ ParagraphLayout::_DrawSpan(BView* view, const TextSpan& span,
|
|||||||
delta.space = line.extraWhiteSpacing;
|
delta.space = line.extraWhiteSpacing;
|
||||||
|
|
||||||
// TODO: Fix in app_server: First glyph should not be shifted by delta.
|
// TODO: Fix in app_server: First glyph should not be shifted by delta.
|
||||||
x -= delta.nonspace;
|
offset.x -= delta.nonspace;
|
||||||
|
|
||||||
view->DrawString(span.Text(), BPoint(x, y), &delta);
|
view->DrawString(span.Text(), offset, &delta);
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,8 @@ public:
|
|||||||
virtual ~ParagraphLayout();
|
virtual ~ParagraphLayout();
|
||||||
|
|
||||||
void SetParagraph(const Paragraph& paragraph);
|
void SetParagraph(const Paragraph& paragraph);
|
||||||
|
const ParagraphStyle& Style() const
|
||||||
|
{ return fParagraphStyle; }
|
||||||
|
|
||||||
void SetWidth(float width);
|
void SetWidth(float width);
|
||||||
float Width() const
|
float Width() const
|
||||||
@ -205,9 +207,10 @@ private:
|
|||||||
void _IncludeStyleInLine(LineInfo& line,
|
void _IncludeStyleInLine(LineInfo& line,
|
||||||
const CharacterStyle& style);
|
const CharacterStyle& style);
|
||||||
|
|
||||||
void _DrawLine(BView* view,
|
void _DrawLine(BView* view, const BPoint& offset,
|
||||||
const LineInfo& line) const;
|
const LineInfo& line) const;
|
||||||
void _DrawSpan(BView* view, const TextSpan& span,
|
void _DrawSpan(BView* view, BPoint offset,
|
||||||
|
const TextSpan& span,
|
||||||
int32 textOffset) const;
|
int32 textOffset) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -221,4 +224,8 @@ private:
|
|||||||
LineInfoList fLineInfos;
|
LineInfoList fLineInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef BReference<ParagraphLayout> ParagraphLayoutRef;
|
||||||
|
|
||||||
|
|
||||||
#endif // PARAGRAPH_LAYOUT_H
|
#endif // PARAGRAPH_LAYOUT_H
|
||||||
|
Loading…
Reference in New Issue
Block a user