Skip to content

Commit

Permalink
handle bar density fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Snd-R committed Jan 8, 2025
1 parent cc4d724 commit 96edb74
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ android.useAndroidX=true

#MPP
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.incremental.wasm=true
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import io.github.snd_r.komelia.color.repository.ColorCurvePresetRepository
import io.github.snd_r.komelia.ui.color.view.curvePointSize
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -240,7 +239,7 @@ class CurvesState(

val currentPoints = controlPoints.value
val selectedIndex = currentPoints.indexOfFirst {
Rect(it.toOffset(), curvePointSize * density * 1.3f).contains(position)
Rect(it.toOffset(), curvePointSize * density * 2.0f).contains(position)
}
if (selectedIndex != -1) {
selectedPoint.value = SelectedPoint(index = selectedIndex, isMoving = true, isRemoved = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class LevelsState(
val inputHandleBarState = HandleBarState(
coroutineScope = coroutineScope,
normalizedPointPositions = inputPointsPositions,
density = density,
onPositionChange = { index, newValue ->
presetsState.deselectCurrent()
val levelsState = currentLevels.value
Expand All @@ -136,6 +137,7 @@ class LevelsState(
coroutineScope = coroutineScope,
normalizedPointPositions = combine(lowOutputPosition, highOutputPosition) { low, high -> listOf(low, high) }
.stateIn(coroutineScope, SharingStarted.Eagerly, emptyList()),
density = density,
onPositionChange = { index, newValue ->
presetsState.deselectCurrent()
val levelsState = currentLevels.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.ArrowUpward
Expand Down Expand Up @@ -37,6 +38,7 @@ import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import io.github.snd_r.komelia.color.ColorChannel
import io.github.snd_r.komelia.color.ColorChannel.BLUE
Expand Down Expand Up @@ -80,6 +82,7 @@ fun NumberFieldWithIncrements(
},
enabled = value != null,
label = { Text(label) },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
modifier = Modifier.widthIn(max = 90.dp)
)
Column {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import kotlin.math.sqrt
class HandleBarState(
coroutineScope: CoroutineScope,
normalizedPointPositions: StateFlow<List<Float>>,
val density: StateFlow<Density>,
private val onPositionChange: (index: Int, newValue: Float) -> Unit,
) {
val hoverPointerIcon = MutableStateFlow(PointerIcon.Default)
private val canvasSize = MutableStateFlow(Size.Zero)
private val density = MutableStateFlow(Density(1f, 1f))
private val selectedPointIndex = MutableStateFlow<Int?>(null)
private val canvasPoints = normalizedPointPositions.combine(canvasSize) { points, size ->
points.map { it.toCanvasX(size) }
Expand Down Expand Up @@ -93,8 +93,8 @@ class HandleBarState(

private fun trianglePath(x: Float, density: Density): Path {
val path = Path()
val side = handleBarSize
val height = side * density.density * (sqrt(3f) / 2)
val side = handleBarSize * density.density
val height = side * (sqrt(3f) / 2)
path.moveTo(x, 0f)
path.lineTo(x + side / 2, height)
path.lineTo(x - side / 2, height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ object AndroidSharedLibrariesLoader {
"gobject-2.0",
"gio-2.0",
"lcms2",
"exif",
"de265",
"dav1d",
"expat",
Expand Down

0 comments on commit 96edb74

Please sign in to comment.