[fbreader] Center justified images
This commit is contained in:
parent
99100be8d7
commit
2457795ce8
1 changed files with 23 additions and 7 deletions
|
@ -67,11 +67,24 @@ void ZLTextArea::prepareTextLine(Style &style, const ZLTextLineInfo &info, int y
|
||||||
bool wordOccured = false;
|
bool wordOccured = false;
|
||||||
|
|
||||||
bool endsWithLineBreak = false;
|
bool endsWithLineBreak = false;
|
||||||
|
bool onlyImage = false;
|
||||||
if (info.RealStart < info.End) {
|
if (info.RealStart < info.End) {
|
||||||
ZLTextWordCursor last(info.End);
|
ZLTextWordCursor last(info.End);
|
||||||
last.previousWord();
|
last.previousWord();
|
||||||
if (last.element().kind() == ZLTextElement::LINE_BREAK_ELEMENT) {
|
while (last.element().kind() == ZLTextElement::CONTROL_ELEMENT && info.RealStart < last) {
|
||||||
endsWithLineBreak = true;
|
last.previousWord();
|
||||||
|
}
|
||||||
|
switch (last.element().kind()) {
|
||||||
|
case ZLTextElement::LINE_BREAK_ELEMENT:
|
||||||
|
endsWithLineBreak = true;
|
||||||
|
break;
|
||||||
|
case ZLTextElement::IMAGE_ELEMENT:
|
||||||
|
if (last == info.RealStart) {
|
||||||
|
onlyImage = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,13 +107,16 @@ void ZLTextArea::prepareTextLine(Style &style, const ZLTextLineInfo &info, int y
|
||||||
break;
|
break;
|
||||||
case ALIGN_LINESTART:
|
case ALIGN_LINESTART:
|
||||||
break;
|
break;
|
||||||
case ALIGN_CENTER:
|
|
||||||
x += (metrics.FullWidth - style.textStyle()->lineEndIndent(metrics, isRtl()) - info.Width) / 2;
|
|
||||||
break;
|
|
||||||
case ALIGN_JUSTIFY:
|
case ALIGN_JUSTIFY:
|
||||||
if (!endsWithLineBreak && !endOfParagraph && info.End.element().kind() != ZLTextElement::AFTER_PARAGRAPH_ELEMENT) {
|
if (!onlyImage) {
|
||||||
fullCorrection = metrics.FullWidth - style.textStyle()->lineEndIndent(metrics, isRtl()) - info.Width;
|
if (!endsWithLineBreak && !endOfParagraph && info.End.element().kind() != ZLTextElement::AFTER_PARAGRAPH_ELEMENT) {
|
||||||
|
fullCorrection = metrics.FullWidth - style.textStyle()->lineEndIndent(metrics, isRtl()) - info.Width;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
// Fall through to center "justified" images
|
||||||
|
case ALIGN_CENTER:
|
||||||
|
x += (metrics.FullWidth - style.textStyle()->lineEndIndent(metrics, isRtl()) - info.Width) / 2;
|
||||||
break;
|
break;
|
||||||
case ALIGN_UNDEFINED:
|
case ALIGN_UNDEFINED:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue