forked from upstream-mirrors/quik
Fix swiping for hue bar
This commit is contained in:
@@ -79,14 +79,15 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
|
|
||||||
var hueThumbX = 0f
|
var hueThumbX = 0f
|
||||||
|
|
||||||
hueBackground.setOnTouchListener { _, event ->
|
hueGroup.setOnTouchListener { _, event ->
|
||||||
|
setupBounds()
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
hueThumbX = event.x - event.rawX
|
hueThumbX = event.x - event.rawX
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
hueThumb.x = (event.rawX + hueThumbX + hueThumb.width / 2).within(0f, width - hueThumb.width.toFloat())
|
hueThumb.x = (event.rawX + hueThumbX + hueThumb.width / 2).within(min, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> return@setOnTouchListener false
|
else -> return@setOnTouchListener false
|
||||||
@@ -94,8 +95,8 @@ class HSVPickerView @JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
hueBackground.clipToOutline = true
|
hueTrack.clipToOutline = true
|
||||||
hueBackground.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
hueTrack.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupBounds() {
|
private fun setupBounds() {
|
||||||
|
|||||||
@@ -52,18 +52,21 @@
|
|||||||
tools:tint="@color/tools_theme" />
|
tools:tint="@color/tools_theme" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:id="@+id/hueGroup"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingEnd="24dp"
|
||||||
|
android:paddingStart="24dp"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="@id/saturation"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="@id/saturation"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/saturation">
|
app:layout_constraintTop_toBottomOf="@id/saturation">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/hueBackground"
|
android:id="@+id/hueTrack"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
|||||||
Reference in New Issue
Block a user