Skip to content

Commit

Permalink
Join selection transitions (#30)
Browse files Browse the repository at this point in the history
* Add joining range-to-range animations

* Set cell ranges in CellMoveToCell

* Fix TickCallback

* Join move-cell-to-cell transitions

* Join move-cell-to-cell and range-to-range transitions

* Add docs

* Fix joining cell-move-to-cell transitions

* Small refactor

* Fix docs

* Generalize models

* Remove hasTransition()

* Refactor

* Fix docs
  • Loading branch information
pelmenstar1 authored Jul 13, 2023
1 parent 120ab5d commit 259c126
Show file tree
Hide file tree
Showing 12 changed files with 567 additions and 225 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ There's a description of methods of `SelectionManager` and what they are expecte
arguments. Note that, rangeEnd is **inclusive**. measureManager should be used to determine bounds of a cell.
- `updateConfiguration(measureManager)` - updates internal measurements and computation based on measureManager results
of both previousState and currentState. Change of measureManager result means that cells might be moved or resized.
- `hasTransition()` - returns whether there's a transition between previousState and currentState.
- `createTransition(measureManager, options)` - creates a transitive state between previousState and currentState. It's
only called if hasTransition() returns true.
- `options` is used to stylize the selection as selection state shouldn't contain any style-related information.
- `createTransition(measureManager, options)` - creates a transitive state between previousState and currentState

Selection renderer is responsible for drawing simple selection state or transitive state, that is created to save information about transition between two selection states. When selection is to be drawn, the canvas' matrix is translated in such way that coordinates will be relative to the grid's leftmost point on top.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import android.graphics.PointF
* **API surface of this class is not stable and new members might be added or removed.**
*/
interface CellMeasureManager {
enum class CoordinateRelativity {
VIEW,
GRID
}

/**
* Width of cell (in pixels).
*/
Expand All @@ -24,15 +29,15 @@ interface CellMeasureManager {
val roundRadius: Float

/**
* Gets x-axis value of the coordinate that specifies left corner of the cell.
* Gets x-axis value of the coordinate that specifies left corner of the cell. The coordinate is relative to the grid.
*
* @param cellIndex index of the cell, should be in range 0..41
* @throws IllegalArgumentException if [cellIndex] is out of the range 0..41
*/
fun getCellLeft(cellIndex: Int): Float

/**
* Gets y-axis value of the coordinate that specifies top corner of the cell.
* Gets y-axis value of the coordinate that specifies top corner of the cell. The coordinate is relative to the grid.
*
* @param cellIndex index of the cell, should be in range 0..41
* @throws IllegalArgumentException if [cellIndex] is out of the range 0..41
Expand All @@ -50,6 +55,7 @@ interface CellMeasureManager {

/**
* Gets points on the calendar view and cell's index nearest to the point by cell [distance]. The point is set to [outPoint].
* The coordinates of the point are relative to the grid.
*
* @param distance cell distance, expected to be non-negative
* @param outPoint the resulting point is set to this point
Expand All @@ -59,9 +65,17 @@ interface CellMeasureManager {
fun getCellAndPointByDistance(distance: Float, outPoint: PointF): Int

/**
* Gets index of a cell nearest to a point with specified coordinates. If there's no such cell, returns `-1`
* Gets 'cell distance' using a point ([x], [y]) relative to the grid.
* The [x] can be arbitrary but the [y] **must** be aligned to the row's top point.
*
* @see getCellDistance
*/
fun getCellDistanceByPoint(x: Float, y: Float): Float

/**
* Gets index of a cell nearest to a point with specified coordinates. If there's no such cell, returns `-1`.
*/
fun getCellAt(x: Float, y: Float): Int
fun getCellAt(x: Float, y: Float, relativity: CoordinateRelativity): Int

/**
* Returns the absolute value of a dimension specified by the [anchor].
Expand Down
Loading

0 comments on commit 259c126

Please sign in to comment.