Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ class Controller(
}
}

fun changePageGap(@Suppress("UNUSED_PARAMETER") gap: Int) {
sendViewChangeNotification()
}

var rotation: Int
get() = layoutStrategy.rotation
set(rotation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ enum class OptionActions(@JvmField val key: String) {
val controller = activity.controller
controller?.changeThreshhold(newValue)
}
},

PAGE_GAP("PAGE_GAP") {
override fun doAction(activity: OrionViewerActivity, oldValue: Int, newValue: Int) {
activity.controller?.changePageGap(newValue)
}
};

open fun doAction(activity: OrionViewerActivity, oldValue: Int, newValue: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class GlobalOptions(
activity.fullScene.setDrawOffPage(isDrawOffPage)
//TODO ?
activity.view.invalidate()
} else if (PAGE_GAP == name) {
OptionActions.PAGE_GAP.doAction(activity, pageGap, pageGap)
}
}

Expand Down Expand Up @@ -241,6 +243,9 @@ class GlobalOptions(

val DRAW_PAGE_BORDER = pref("DRAW_PAGE_BORDER", true)

val pageGap: Int
get() = getIntFromStringProperty(PAGE_GAP, 2)

fun <T> subscribe(pref: Preference<T>) {
registeredPreferences.put(pref.key, pref)?.also {
errorInDebug("Pref with key ${pref.key} already registered: $pref ")
Expand All @@ -266,6 +271,8 @@ class GlobalOptions(

const val DRAW_OFF_PAGE: String = "DRAW_OFF_PAGE"

const val PAGE_GAP: String = "PAGE_GAP"

const val SHOW_ACTION_BAR: String = "SHOW_ACTION_BAR"

const val DOUBLE_TAP_ACTION: String = "DOUBLE_TAP_ACTION"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class PageLayoutManager(val controller: Controller, val scene: OrionDrawScene) {

private val analytics = controller.activity.analytics

private val pageGap: Float
get() = controller.activity.globalOptions.pageGap.toFloat().let { if (it == 0f) -1f else it }

private val handler = CoroutineExceptionHandler { _, ex ->
errorInDebug("Processing error in PageLayoutManager", ex)
analytics.error(ex)
Expand Down Expand Up @@ -302,7 +305,7 @@ class PageLayoutManager(val controller: Controller, val scene: OrionDrawScene) {
addPageInPosition(
newView,
0f,
page.layoutData.position.y - newView.layoutData.wholePageRect.height() - 2,
page.layoutData.position.y - newView.layoutData.wholePageRect.height() - pageGap,
0
)
return newView
Expand All @@ -318,7 +321,7 @@ class PageLayoutManager(val controller: Controller, val scene: OrionDrawScene) {
return existingPage
}

val pageEnd = page.pageEndY + 2
val pageEnd = page.pageEndY + pageGap
if (pageEnd < sceneHeight || addIfAbsent) {
return addPageInPosition(nextPageNum, pageEnd)
}
Expand Down Expand Up @@ -561,9 +564,11 @@ class PageLayoutManager(val controller: Controller, val scene: OrionDrawScene) {
if (RectF.intersects(rect1, rect2)) {
val intersection = RectF(rect1)
intersection.intersect(rect2)
val message =
"intersected pages ${it.first.pageNum} and ${it.second.pageNum} rects: $rect1 $rect2, intersection $intersection"
errorInDebug(message)
if (intersection.width() > 2f && intersection.height() > 2f) {
val message =
"intersected pages ${it.first.pageNum} and ${it.second.pageNum} rects: $rect1 $rect2, intersection $intersection"
errorInDebug(message)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class PageView(
canvas: Canvas,
scene: OrionDrawScene,
) {
if (scene.inScalingMode || controller.drawBorder.value) {
if (scene.inScalingMode || (controller.drawBorder.value && controller.activity.globalOptions.pageGap > 0)) {
canvas.drawRect(
layoutData.wholePageRect,
scene.borderPaint!!
Expand Down
2 changes: 2 additions & 0 deletions orion-viewer/src/main/res/values/pref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string name="pref_new_ui_summary">Application restart is required</string>
<string name="pref_renderOffPage">Draw off-page space</string>
<string name="pref_renderPageBorder">Draw page border</string>
<string name="pref_page_gap">Gap between pages</string>
<string name="pref_page_gap_desc">Spacing between pages in continuous mode (0–50 px). Set to 0 for webtoons.</string>
<string name="pref_showActionBar">Show Action Bar</string>
<string name="pref_showActionBar_desc">Show Action Bar (restart needed)</string>
<string name="pref_statusBarPosition">Status Bar Position</string>
Expand Down
11 changes: 11 additions & 0 deletions orion-viewer/src/main/res/xml/user_pref_appearance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
android:title="@string/pref_renderPageBorder"
app:iconSpaceReserved="false" />

<universe.constellation.orion.viewer.prefs.OrionEditTextPreference
android:defaultValue="2"
android:key="PAGE_GAP"
android:summary="@string/pref_page_gap_desc"
android:title="@string/pref_page_gap"
app:iconSpaceReserved="false"
app:maxValue="50"
app:minValue="0"
android:inputType="number"
app:showSeekBarValue="true" />

<CheckBoxPreference
android:defaultValue="true"
android:key="DRAW_OFF_PAGE"
Expand Down