mirror of
https://github.com/gedoor/legado.git
synced 2025-01-07 03:06:58 +08:00
优化单图模式下标题的显示位置居中 (#4485)
* 当图片格式设置为single时,图片居中显示。 * 优化单图模式下标题的显示位置优化了标题威之居中
This commit is contained in:
parent
21d689ef2f
commit
ae3341e2b6
@ -194,6 +194,7 @@ class TextChapterLayout(
|
||||
titlePaint,
|
||||
titlePaintTextHeight,
|
||||
titlePaintFontMetrics,
|
||||
book.getImageStyle(),
|
||||
isTitle = true,
|
||||
emptyContent = contents.isEmpty(),
|
||||
isVolumeTitle = bookChapter.isVolume
|
||||
@ -231,6 +232,7 @@ class TextChapterLayout(
|
||||
contentPaint,
|
||||
contentPaintTextHeight,
|
||||
contentPaintFontMetrics,
|
||||
book.getImageStyle(),
|
||||
srcList = srcList
|
||||
).let {
|
||||
absStartX = it.first
|
||||
@ -250,7 +252,8 @@ class TextChapterLayout(
|
||||
text,
|
||||
contentPaint,
|
||||
contentPaintTextHeight,
|
||||
contentPaintFontMetrics
|
||||
contentPaintFontMetrics,
|
||||
book.getImageStyle()
|
||||
).let {
|
||||
absStartX = it.first
|
||||
durY = it.second
|
||||
@ -278,7 +281,8 @@ class TextChapterLayout(
|
||||
if (AppConfig.enableReview) text + ChapterProvider.reviewChar else text,
|
||||
contentPaint,
|
||||
contentPaintTextHeight,
|
||||
contentPaintFontMetrics
|
||||
contentPaintFontMetrics,
|
||||
book.getImageStyle()
|
||||
).let {
|
||||
absStartX = it.first
|
||||
durY = it.second
|
||||
@ -443,6 +447,7 @@ class TextChapterLayout(
|
||||
textPaint: TextPaint,
|
||||
textHeight: Float,
|
||||
fontMetrics: Paint.FontMetrics,
|
||||
imageStyle: String?,
|
||||
isTitle: Boolean = false,
|
||||
emptyContent: Boolean = false,
|
||||
isVolumeTitle: Boolean = false,
|
||||
@ -487,8 +492,31 @@ class TextChapterLayout(
|
||||
}
|
||||
}
|
||||
|
||||
isTitle && textPages.isEmpty() && pendingTextPage.lines.isEmpty() ->
|
||||
y + titleTopSpacing
|
||||
isTitle && textPages.isEmpty() && pendingTextPage.lines.isEmpty() -> {
|
||||
when (imageStyle?.uppercase(Locale.ROOT)) {
|
||||
Book.imgStyleSingle -> {
|
||||
val textPage = pendingTextPage
|
||||
if (textPage.lineSize == 0) {
|
||||
val ty = (visibleHeight - layout.lineCount * textHeight) / 2
|
||||
if (ty > titleTopSpacing) ty else titleTopSpacing.toFloat()
|
||||
} else {
|
||||
var textLayoutHeight = layout.lineCount * textHeight
|
||||
val fistLine = textPage.getLine(0)
|
||||
if (fistLine.lineTop < textLayoutHeight + titleTopSpacing) {
|
||||
textLayoutHeight = fistLine.lineTop - titleTopSpacing
|
||||
}
|
||||
textPage.lines.forEach {
|
||||
it.lineTop -= textLayoutHeight
|
||||
it.lineBase -= textLayoutHeight
|
||||
it.lineBottom -= textLayoutHeight
|
||||
}
|
||||
y - textLayoutHeight
|
||||
}
|
||||
}
|
||||
|
||||
else -> y + titleTopSpacing
|
||||
}
|
||||
}
|
||||
|
||||
else -> y
|
||||
}
|
||||
@ -539,7 +567,7 @@ class TextChapterLayout(
|
||||
//标题x轴居中
|
||||
val startX = if (
|
||||
isTitle &&
|
||||
(ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle)
|
||||
(ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle || imageStyle == "SINGLE")
|
||||
) {
|
||||
(visibleWidth - desiredWidth) / 2
|
||||
} else {
|
||||
@ -554,7 +582,7 @@ class TextChapterLayout(
|
||||
else -> {
|
||||
if (
|
||||
isTitle &&
|
||||
(ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle)
|
||||
(ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle || imageStyle == "SINGLE")
|
||||
) {
|
||||
//标题居中
|
||||
val startX = (visibleWidth - desiredWidth) / 2
|
||||
|
Loading…
Reference in New Issue
Block a user