open class ZoomEngine : ZoomApi
A low level class that listens to touch events and posts zoom and pan updates. The most useful output is a Matrix that can be used to do pretty much everything, from canvas drawing to View hierarchies translations.
Users are required to:
Listener |
An interface to listen for updates in the inner matrix. This will be called typically on animation frames. interface Listener |
SimpleListener |
A simple implementation of Listener that will extract the translation and scale values from the output matrix. abstract class SimpleListener : Listener |
<init> |
Constructs an helper instance. ZoomEngine(context: Context, container: View)
Constructs an helper instance. Deprecated: use addListener to add a listener. ZoomEngine(context: Context, container: View, listener: Listener) |
containerHeight |
Returns the container height as passed to setContainerSize. val containerHeight: Float |
containerWidth |
Returns the container width as passed to setContainerSize. val containerWidth: Float |
contentHeight |
Returns the content height as passed to setContentSize. val contentHeight: Float |
contentWidth |
Returns the content width as passed to setContentSize. val contentWidth: Float |
matrix |
Returns the current matrix. This can be changed from the outside, but is not guaranteed to remain stable. val matrix: Matrix |
pan |
The current pan as an AbsolutePoint. open val pan: AbsolutePoint |
panX |
Returns the current horizontal pan value, in content absolute coordinates (that is, as if there was no zoom at all). open val panX: Float |
panY |
Returns the current vertical pan value, in content absolute coordinates (that is, as if there was no zoom at all). open val panY: Float |
realZoom |
Gets the current zoom value, including the base zoom that was eventually applied during the starting transformation, see setTransformation. This value will match the scaleX - scaleY values you get into the Matrix, and is the actual scale value of the content from its original size. open val realZoom: Float |
scaledPan |
The current pan as a ScaledPoint. open val scaledPan: ScaledPoint |
scaledPanX |
Returns the current horizontal pan value, in content scaled coordinates (that is, including the current zoom). open val scaledPanX: Float |
scaledPanY |
Returns the current vertical pan value, in content scaled coordinates (that is, including the current zoom). open val scaledPanY: Float |
zoom |
Gets the current zoom value, which can be used as a reference when calling zoomTo or zoomBy. open val zoom: Float |
addListener |
Registers a new Listener to be notified of matrix updates. fun addListener(listener: Listener): Unit |
cancelAnimations |
Cancels all currently active animations triggered by either API calls with open fun cancelAnimations(): Boolean |
clear |
Clears the current state, and stops dispatching matrix events until the view is laid out again and ZoomEngine.setContentSize is called. fun clear(): Unit |
computeHorizontalScrollOffset |
Helper for implementing View.computeHorizontalScrollOffset in custom views. fun computeHorizontalScrollOffset(): Int |
computeHorizontalScrollRange |
Helper for implementing View.computeHorizontalScrollRange in custom views. fun computeHorizontalScrollRange(): Int |
computeVerticalScrollOffset |
Helper for implementing View.computeVerticalScrollOffset in custom views. fun computeVerticalScrollOffset(): Int |
computeVerticalScrollRange |
Helper for implementing View.computeVerticalScrollRange in custom views. fun computeVerticalScrollRange(): Int |
getMaxZoom |
Get the currently allowed max zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time. open fun getMaxZoom(): Float |
getMaxZoomType |
Get the currently set max zoom type. open fun getMaxZoomType(): Int |
getMinZoom |
Get the currently allowed min zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time. open fun getMinZoom(): Float |
getMinZoomType |
Get the currently set min zoom type. open fun getMinZoomType(): Int |
moveTo |
A low level API that can animate both zoom and pan at the same time. Zoom might not be the actual matrix scale, see ZoomApi.zoom and ZoomApi.realZoom. The coordinates are referred to the content size passed in setContentSize so they do not depend on current zoom. open fun moveTo(zoom: Float, x: Float, y: Float, animate: Boolean): Unit |
moveToCenter |
Moves to the center of the content. open fun moveToCenter(zoom: Float?, animate: Boolean): Unit |
onInterceptTouchEvent |
This is required when the content is a View that has clickable hierarchies inside. If true is returned, implementors should not pass the call to super. fun onInterceptTouchEvent(ev: MotionEvent): Boolean |
onTouchEvent |
Process the given touch event. If true is returned, implementors should not pass the call to super. fun onTouchEvent(ev: MotionEvent): Boolean |
panBy |
Pans the content by the given quantity in dx-dy values. These are referred to the content size passed in setContentSize, so they do not depend on current zoom. open fun panBy(dx: Float, dy: Float, animate: Boolean): Unit |
panTo |
Pans the content until the top-left coordinates match the given x-y values. These are referred to the content size passed in setContentSize, so they do not depend on current zoom. open fun panTo(x: Float, y: Float, animate: Boolean): Unit |
realZoomTo |
Animates the actual matrix zoom to the given value. open fun realZoomTo(realZoom: Float, animate: Boolean): Unit |
removeListener |
Removes a previously registered listener. fun removeListener(listener: Listener): Unit |
setAlignment |
Sets the content alignment. Can be any of the constants defined in Alignment. The content will be aligned and forced to the specified side of the container. Defaults to ZoomApi.ALIGNMENT_DEFAULT. open fun setAlignment(alignment: Int): Unit |
setAllowFlingInOverscroll |
Controls whether fling events are allowed when the view is in an overscrolled state. open fun setAllowFlingInOverscroll(allow: Boolean): Unit |
setAnimationDuration |
Sets the duration of animations triggered by zoom and pan APIs. Defaults to ZoomEngine.DEFAULT_ANIMATION_DURATION. open fun setAnimationDuration(duration: Long): Unit |
setContainerSize |
Sets the size of the container view. Normally you don't need to call this because the size is detected from the container passed to the constructor using a global layout listener. fun setContainerSize(width: Float, height: Float, applyTransformation: Boolean = false): Unit |
setContentSize |
Notifies the helper of the content size (be it a child View, a Bitmap, or whatever else). This is needed for the helper to start working. fun fun setContentSize(width: Float, height: Float, applyTransformation: Boolean = false): Unit |
setFlingEnabled |
Controls whether fling gesture is enabled or not. open fun setFlingEnabled(enabled: Boolean): Unit |
setHorizontalPanEnabled |
Controls whether horizontal panning using gestures is enabled. open fun setHorizontalPanEnabled(enabled: Boolean): Unit |
setMaxZoom |
Which is the max zoom that should be allowed. If setOverPinchable is set to true, this can be over-pinched for a brief time. open fun setMaxZoom(maxZoom: Float, type: Int): Unit |
setMinZoom |
Which is the min zoom that should be allowed. If setOverPinchable is set to true, this can be over-pinched for a brief time. open fun setMinZoom(minZoom: Float, type: Int): Unit |
setOneFingerScrollEnabled |
Controls whether one finger scroll gesture is enabled or not. open fun setOneFingerScrollEnabled(enabled: Boolean): Unit |
setOverPanRange |
Set the OverPanRangeProvider that specifies the amount of overpan to allow. open fun setOverPanRange(provider: OverPanRangeProvider): Unit |
setOverPinchable |
Controls whether the content should be overPinchable. If it is, pinch events can change the zoom outside the safe bounds, than return to safe values. open fun setOverPinchable(overPinchable: Boolean): Unit |
setOverScrollHorizontal |
Controls whether the content should be over-scrollable horizontally. If it is, drag and fling horizontal events can scroll the content outside the safe area, then return to safe values. open fun setOverScrollHorizontal(overScroll: Boolean): Unit |
setOverScrollVertical |
Controls whether the content should be over-scrollable vertically. If it is, drag and fling vertical events can scroll the content outside the safe area, then return to safe values. open fun setOverScrollVertical(overScroll: Boolean): Unit |
setOverZoomRange |
Set the OverZoomRangeProvider that specifies the amount of overzoom to allow. open fun setOverZoomRange(provider: OverZoomRangeProvider): Unit |
setScrollEnabled |
Controls whether scroll gesture is enabled or not. open fun setScrollEnabled(enabled: Boolean): Unit |
setThreeFingersScrollEnabled |
Controls whether three fingers scroll gesture is enabled or not. open fun setThreeFingersScrollEnabled(enabled: Boolean): Unit |
setTransformation |
Sets the base transformation to be applied to the content. Defaults to ZoomApi.TRANSFORMATION_CENTER_INSIDE with Gravity.CENTER, which means that the content will be zoomed so that it fits completely inside the container. open fun setTransformation(transformation: Int, gravity: Int): Unit |
setTwoFingersScrollEnabled |
Controls whether two fingers scroll gesture is enabled or not. open fun setTwoFingersScrollEnabled(enabled: Boolean): Unit |
setVerticalPanEnabled |
Controls whether vertical panning using gestures is enabled. open fun setVerticalPanEnabled(enabled: Boolean): Unit |
setZoomEnabled |
Controls whether zoom using pinch gesture is enabled or not. open fun setZoomEnabled(enabled: Boolean): Unit |
zoomBy |
Applies the given factor to the current zoom. open fun zoomBy(zoomFactor: Float, animate: Boolean): Unit |
zoomIn |
Applies a small, animated zoom-in. Shorthand for zoomBy with factor 1.3. open fun zoomIn(): Unit |
zoomOut |
Applies a small, animated zoom-out. Shorthand for zoomBy with factor 0.7. open fun zoomOut(): Unit |
zoomTo |
Zooms to the given scale. This might not be the actual matrix zoom, see ZoomApi.zoom and ZoomApi.realZoom. open fun zoomTo(zoom: Float, animate: Boolean): Unit |
DEFAULT_ANIMATION_DURATION |
The default animation duration const val DEFAULT_ANIMATION_DURATION: Long |