Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join selection transitions #30

Merged
merged 13 commits into from
Jul 13, 2023
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