pull/43/head^2
kunfei 5 years ago
parent edd6d3b2d4
commit 9e4cdcd702
  1. 33
      app/src/main/java/io/legado/app/ui/widget/page/curl/CurlRenderer.kt
  2. 8
      app/src/main/java/io/legado/app/ui/widget/page/curl/CurlView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/widget/page/delegate/SimulationPageDelegate.kt

@ -67,10 +67,6 @@ class CurlRenderer(private val mObserver: Observer) : GLSurfaceView.Renderer {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT) gl.glClear(GL10.GL_COLOR_BUFFER_BIT)
gl.glLoadIdentity() gl.glLoadIdentity()
if (USE_PERSPECTIVE_PROJECTION) {
gl.glTranslatef(0f, 0f, -6f)
}
for (i in mCurlMeshes.indices) { for (i in mCurlMeshes.indices) {
mCurlMeshes[i].onDrawFrame(gl) mCurlMeshes[i].onDrawFrame(gl)
} }
@ -90,14 +86,10 @@ class CurlRenderer(private val mObserver: Observer) : GLSurfaceView.Renderer {
gl.glMatrixMode(GL10.GL_PROJECTION) gl.glMatrixMode(GL10.GL_PROJECTION)
gl.glLoadIdentity() gl.glLoadIdentity()
if (USE_PERSPECTIVE_PROJECTION) {
GLU.gluPerspective(gl, 20f, width.toFloat() / height, .1f, 100f)
} else {
GLU.gluOrtho2D( GLU.gluOrtho2D(
gl, mViewRect.left, mViewRect.right, gl, mViewRect.left, mViewRect.right,
mViewRect.bottom, mViewRect.top mViewRect.bottom, mViewRect.top
) )
}
gl.glMatrixMode(GL10.GL_MODELVIEW) gl.glMatrixMode(GL10.GL_MODELVIEW)
gl.glLoadIdentity() gl.glLoadIdentity()
@ -124,29 +116,6 @@ class CurlRenderer(private val mObserver: Observer) : GLSurfaceView.Renderer {
mCurlMeshes.remove(mesh) mCurlMeshes.remove(mesh)
} }
/**
* Change background/clear color.
*/
fun setBackgroundColor(color: Int) {
mBackgroundColor = color
}
/**
* Set margins or padding. Note: margins are proportional. Meaning a value
* of .1f will produce a 10% margin.
*/
@Synchronized
fun setMargins(
left: Float, top: Float, right: Float,
bottom: Float
) {
mMargins.left = left
mMargins.top = top
mMargins.right = right
mMargins.bottom = bottom
updatePageRects()
}
/** /**
* Sets visible page count to one or two. Should be either SHOW_ONE_PAGE or * Sets visible page count to one or two. Should be either SHOW_ONE_PAGE or
* SHOW_TWO_PAGES. * SHOW_TWO_PAGES.
@ -242,7 +211,5 @@ class CurlRenderer(private val mObserver: Observer) : GLSurfaceView.Renderer {
// Constants for changing view mode. // Constants for changing view mode.
const val SHOW_ONE_PAGE = 1 const val SHOW_ONE_PAGE = 1
const val SHOW_TWO_PAGES = 2 const val SHOW_TWO_PAGES = 2
// Set to true for checking quickly how perspective projection looks.
private const val USE_PERSPECTIVE_PROJECTION = false
} }
} }

@ -410,14 +410,6 @@ class CurlView : GLSurfaceView, View.OnTouchListener, CurlRenderer.Observer {
mEnableTouchPressure = enableTouchPressure mEnableTouchPressure = enableTouchPressure
} }
/**
* Set margins (or padding). Note: margins are proportional. Meaning a value
* of .1f will produce a 10% margin.
*/
fun setMargins(left: Float, top: Float, right: Float, bottom: Float) {
mRenderer.setMargins(left, top, right, bottom)
}
/** /**
* Setter for whether left side page is rendered. This is useful mostly for * Setter for whether left side page is rendered. This is useful mostly for
* situations where right (main) page is aligned to left side of screen and * situations where right (main) page is aligned to left side of screen and

@ -56,7 +56,6 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
private inner class SizeChangedObserver : CurlView.SizeChangedObserver { private inner class SizeChangedObserver : CurlView.SizeChangedObserver {
override fun onSizeChanged(width: Int, height: Int) { override fun onSizeChanged(width: Int, height: Int) {
pageView.curlView?.setViewMode(CurlView.SHOW_ONE_PAGE) pageView.curlView?.setViewMode(CurlView.SHOW_ONE_PAGE)
pageView.curlView?.setMargins(0f, 0f, 0f, 0f)
} }
} }
} }
Loading…
Cancel
Save