feat: Custom Slider optimize
This commit is contained in:
1 parent
63327f538f
commit
cd5b66ff9e
10 files changed
+99
-182
No files matched your search
@@ -5,21 +5,15 @@ import android.graphics.Bitmap
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
@@ -29,7 +23,6 @@ import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -41,7 +34,6 @@ import androidx.compose.ui.input.pointer.PointerEventType
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -52,17 +44,15 @@ import androidx.compose.ui.window.Dialog
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import coil.request.ImageRequest
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.model.ColorPaletteMapper
|
||||
import com.hinnka.mycamera.model.ColorPaletteState
|
||||
import com.hinnka.mycamera.ui.components.ColorRecipePanel
|
||||
import com.hinnka.mycamera.ui.components.CurveChannel
|
||||
import com.hinnka.mycamera.ui.components.CustomSliderThinThumb
|
||||
import com.hinnka.mycamera.ui.components.LutSelector
|
||||
import com.hinnka.mycamera.ui.components.PaymentDialog
|
||||
import androidx.compose.material.icons.filled.Tune
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import com.hinnka.mycamera.ui.components.CustomSlider
|
||||
import me.saket.telephoto.zoomable.ZoomSpec
|
||||
import me.saket.telephoto.zoomable.coil.ZoomableAsyncImage
|
||||
import me.saket.telephoto.zoomable.rememberZoomableImageState
|
||||
@@ -385,14 +375,11 @@ fun LutSynthesisScreen(
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = layer.weight,
|
||||
onValueChange = { viewModel.updateLayerWeight(index, it) },
|
||||
onDoubleTap = { viewModel.updateLayerWeight(index, 1.0f) },
|
||||
valueRange = 0f..1f,
|
||||
thumbWidth = 3.dp,
|
||||
thumbHeight = 16.dp,
|
||||
trackHeight = 3.dp,
|
||||
activeTrackColor = Color.White,
|
||||
inactiveTrackColor = Color.Gray.copy(alpha = 0.3f),
|
||||
thumbColor = Color.White,
|
||||
|
||||
@@ -74,6 +74,7 @@ import com.hinnka.mycamera.data.AiFocusTargetMode
|
||||
import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
|
||||
import com.hinnka.mycamera.model.CameraPreset
|
||||
import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.model.EffectParams
|
||||
import com.hinnka.mycamera.raw.SpectralFilmSelection
|
||||
import com.hinnka.mycamera.ui.components.*
|
||||
import com.hinnka.mycamera.utils.OrientationObserver
|
||||
@@ -85,6 +86,7 @@ import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
import com.hinnka.mycamera.video.VideoFpsPreset
|
||||
import com.hinnka.mycamera.video.VideoLogProfile
|
||||
import com.hinnka.mycamera.video.VideoResolutionPreset
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.*
|
||||
@@ -103,6 +105,7 @@ enum class ActivePanel {
|
||||
private const val InitialPreviewTransitionDelayMillis = 150L
|
||||
private const val PreviewTransitionRevealDurationMillis = 800
|
||||
private const val RawCaptureTapDebounceMillis = 1000L
|
||||
private const val EffectsParamsSaveDebounceMillis = 250L
|
||||
private const val DefaultShutterSpeedNs = 1_000_000_000f / 60f
|
||||
private const val DefaultIso = 100f
|
||||
private const val DefaultAwbTemperature = 5000f
|
||||
@@ -174,8 +177,12 @@ fun CameraScreen(
|
||||
val currentEffectParams by viewModel.currentEffectParams.collectAsState()
|
||||
val activePresetId by viewModel.activePresetId.collectAsState()
|
||||
val customPresets by viewModel.customPresets.collectAsState()
|
||||
val mergedRecipeParams = remember(currentRecipeParams, currentEffectParams) {
|
||||
currentEffectParams.applyTo(currentRecipeParams)
|
||||
var previewEffectParamsOverride by remember { mutableStateOf<EffectParams?>(null) }
|
||||
var pendingEffectParamsToSave by remember { mutableStateOf<EffectParams?>(null) }
|
||||
var effectParamsSaveJob by remember { mutableStateOf<Job?>(null) }
|
||||
val previewEffectParams = previewEffectParamsOverride ?: currentEffectParams
|
||||
val mergedRecipeParams = remember(currentRecipeParams, previewEffectParams) {
|
||||
previewEffectParams.applyTo(currentRecipeParams)
|
||||
}
|
||||
val currentBaselineRecipeParams by viewModel.currentBaselineRecipeParams.collectAsState()
|
||||
val categoryOrder by viewModel.categoryOrder.collectAsState(emptyList())
|
||||
@@ -230,6 +237,37 @@ fun CameraScreen(
|
||||
var baselineEditLutId by remember { mutableStateOf<String?>(null) }
|
||||
var baselineEditTarget by remember { mutableStateOf<BaselineColorCorrectionTarget?>(null) }
|
||||
|
||||
fun saveEffectParamsDebounced(params: EffectParams) {
|
||||
previewEffectParamsOverride = params
|
||||
pendingEffectParamsToSave = params
|
||||
effectParamsSaveJob?.cancel()
|
||||
effectParamsSaveJob = scope.launch {
|
||||
delay(EffectsParamsSaveDebounceMillis)
|
||||
viewModel.setEffectParams(params)
|
||||
pendingEffectParamsToSave = null
|
||||
effectParamsSaveJob = null
|
||||
}
|
||||
}
|
||||
|
||||
fun flushEffectParamsSave() {
|
||||
effectParamsSaveJob?.cancel()
|
||||
effectParamsSaveJob = null
|
||||
pendingEffectParamsToSave?.let(viewModel::setEffectParams)
|
||||
pendingEffectParamsToSave = null
|
||||
}
|
||||
|
||||
LaunchedEffect(currentEffectParams) {
|
||||
if (previewEffectParamsOverride == currentEffectParams) {
|
||||
previewEffectParamsOverride = null
|
||||
}
|
||||
}
|
||||
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
flushEffectParamsSave()
|
||||
}
|
||||
}
|
||||
|
||||
// 标记相机是否已打开
|
||||
var cameraOpened by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -1566,9 +1604,12 @@ fun CameraScreen(
|
||||
|
||||
if (showEffectsSheet) {
|
||||
EffectsBottomSheet(
|
||||
currentParams = currentEffectParams,
|
||||
onParamsChange = { viewModel.setEffectParams(it) },
|
||||
onDismiss = { showEffectsSheet = false }
|
||||
currentParams = previewEffectParams,
|
||||
onParamsChange = { saveEffectParamsDebounced(it) },
|
||||
onDismiss = {
|
||||
flushEffectParamsSave()
|
||||
showEffectsSheet = false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.hinnka.mycamera.model.ColorPaletteMapper
|
||||
import com.hinnka.mycamera.model.ColorPaletteState
|
||||
import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.ui.components.ColorRecipePanel
|
||||
import com.hinnka.mycamera.ui.components.CustomSliderThinThumb
|
||||
import com.hinnka.mycamera.ui.components.CustomSlider
|
||||
import com.hinnka.mycamera.viewmodel.LutEditViewModel
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -307,7 +307,7 @@ fun LutIntensitySlider(
|
||||
)
|
||||
}
|
||||
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = intensity,
|
||||
onValueChange = onIntensityChange,
|
||||
onDoubleTap = {
|
||||
@@ -315,9 +315,6 @@ fun LutIntensitySlider(
|
||||
},
|
||||
enabled = enabled,
|
||||
valueRange = 0f..1f,
|
||||
thumbWidth = 3.dp,
|
||||
thumbHeight = 22.dp,
|
||||
trackHeight = 4.dp,
|
||||
activeTrackColor = Color.White,
|
||||
inactiveTrackColor = Color.Gray.copy(alpha = 0.5f),
|
||||
thumbColor = Color.White,
|
||||
|
||||
@@ -613,14 +613,11 @@ fun ColorRecipeSlider(
|
||||
)
|
||||
}
|
||||
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
onDoubleTap = onDoubleTap,
|
||||
valueRange = param.minValue..param.maxValue,
|
||||
thumbWidth = 3.dp,
|
||||
thumbHeight = 20.dp,
|
||||
trackHeight = 3.dp,
|
||||
activeTrackColor = getParamColor(param),
|
||||
inactiveTrackColor = Color.Gray.copy(alpha = 0.3f),
|
||||
thumbColor = Color.White,
|
||||
|
||||
@@ -9,7 +9,6 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||
@@ -46,7 +45,7 @@ fun CustomSlider(
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
|
||||
thumbRadius: Dp = 10.dp,
|
||||
thumbRadius: Dp = 8.dp,
|
||||
trackHeight: Dp = 4.dp,
|
||||
activeTrackColor: Color = Color.White,
|
||||
inactiveTrackColor: Color = Color.Gray.copy(alpha = 0.5f),
|
||||
@@ -197,136 +196,6 @@ private fun DrawScope.drawThumb(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 细长型 Thumb 的自定义 Slider
|
||||
*
|
||||
* 类似原生 Slider 的细长 Thumb 设计
|
||||
*/
|
||||
@Composable
|
||||
fun CustomSliderThinThumb(
|
||||
value: Float,
|
||||
onValueChange: (Float) -> Unit,
|
||||
onDoubleTap: (() -> Unit)? = null,
|
||||
onValueChangeFinished: (() -> Unit)? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
|
||||
thumbWidth: Dp = 3.dp,
|
||||
thumbHeight: Dp = 22.dp,
|
||||
trackHeight: Dp = 4.dp,
|
||||
activeTrackColor: Color = Color.White,
|
||||
inactiveTrackColor: Color = Color.Gray.copy(alpha = 0.5f),
|
||||
thumbColor: Color = Color.White
|
||||
) {
|
||||
var isDragging by remember { mutableStateOf(false) }
|
||||
val currentOnValueChange by rememberUpdatedState(onValueChange)
|
||||
val currentOnDoubleTap by rememberUpdatedState(onDoubleTap)
|
||||
val currentOnValueChangeFinished by rememberUpdatedState(onValueChangeFinished)
|
||||
|
||||
val density = LocalDensity.current
|
||||
val thumbWidthPx = with(density) { thumbWidth.toPx() }
|
||||
val thumbHeightPx = with(density) { thumbHeight.toPx() }
|
||||
val trackHeightPx = with(density) { trackHeight.toPx() }
|
||||
|
||||
// 确保值在范围内
|
||||
val coercedValue = value.coerceIn(valueRange.start, valueRange.endInclusive)
|
||||
|
||||
// 计算归一化的值(0-1)
|
||||
val normalizedValue = (coercedValue - valueRange.start) / (valueRange.endInclusive - valueRange.start)
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.height(thumbHeight + 4.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Canvas(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(thumbHeight)
|
||||
.horizontalSliderDragInput(
|
||||
enabled = enabled,
|
||||
key1 = valueRange,
|
||||
key2 = thumbWidthPx,
|
||||
onDragStart = { isDragging = true },
|
||||
onDragEnd = { isDragging = false; currentOnValueChangeFinished?.invoke() },
|
||||
onDragCancel = { isDragging = false; currentOnValueChangeFinished?.invoke() }
|
||||
) { positionX ->
|
||||
val trackWidth = size.width - thumbWidthPx
|
||||
val trackStart = thumbWidthPx / 2
|
||||
val x = positionX.coerceIn(trackStart, trackStart + trackWidth)
|
||||
val fraction = (x - trackStart) / trackWidth
|
||||
val newValue = valueRange.start + fraction * (valueRange.endInclusive - valueRange.start)
|
||||
currentOnValueChange(newValue.coerceIn(valueRange.start, valueRange.endInclusive))
|
||||
}
|
||||
.pointerInput(enabled, valueRange, thumbWidthPx) {
|
||||
if (!enabled) return@pointerInput
|
||||
detectTapGestures(
|
||||
onDoubleTap = {
|
||||
currentOnDoubleTap?.invoke()
|
||||
},
|
||||
onTap = { offset ->
|
||||
val trackWidth = size.width - thumbWidthPx
|
||||
val trackStart = thumbWidthPx / 2
|
||||
val x = offset.x.coerceIn(trackStart, trackStart + trackWidth)
|
||||
val fraction = (x - trackStart) / trackWidth
|
||||
val newValue = valueRange.start + fraction * (valueRange.endInclusive - valueRange.start)
|
||||
currentOnValueChange(newValue.coerceIn(valueRange.start, valueRange.endInclusive))
|
||||
currentOnValueChangeFinished?.invoke()
|
||||
}
|
||||
)
|
||||
}
|
||||
) {
|
||||
val trackWidth = size.width - thumbWidthPx
|
||||
val trackStart = thumbWidthPx / 2
|
||||
val trackEnd = trackStart + trackWidth
|
||||
val centerY = size.height / 2
|
||||
|
||||
// 绘制未激活轨道
|
||||
drawLine(
|
||||
color = if (enabled) inactiveTrackColor else inactiveTrackColor.copy(alpha = 0.3f),
|
||||
start = Offset(trackStart, centerY),
|
||||
end = Offset(trackEnd, centerY),
|
||||
strokeWidth = trackHeightPx,
|
||||
cap = StrokeCap.Round
|
||||
)
|
||||
|
||||
// 绘制激活轨道
|
||||
val activeEnd = trackStart + trackWidth * normalizedValue
|
||||
drawLine(
|
||||
color = if (enabled) activeTrackColor else activeTrackColor.copy(alpha = 0.5f),
|
||||
start = Offset(trackStart, centerY),
|
||||
end = Offset(activeEnd, centerY),
|
||||
strokeWidth = trackHeightPx,
|
||||
cap = StrokeCap.Round
|
||||
)
|
||||
|
||||
// 绘制细长型 Thumb
|
||||
val thumbX = trackStart + trackWidth * normalizedValue
|
||||
val thumbTop = centerY - thumbHeightPx / 2
|
||||
val thumbBottom = centerY + thumbHeightPx / 2
|
||||
|
||||
// 拖拽时的光晕效果
|
||||
if (isDragging && enabled) {
|
||||
drawRoundRect(
|
||||
color = thumbColor.copy(alpha = 0.2f),
|
||||
topLeft = Offset(thumbX - thumbWidthPx * 1.5f, thumbTop - 4),
|
||||
size = Size(thumbWidthPx * 3, thumbHeightPx + 8),
|
||||
cornerRadius = androidx.compose.ui.geometry.CornerRadius(thumbWidthPx * 1.5f, thumbWidthPx * 1.5f)
|
||||
)
|
||||
}
|
||||
|
||||
// 主 Thumb 矩形
|
||||
drawRoundRect(
|
||||
color = if (enabled) thumbColor else thumbColor.copy(alpha = 0.5f),
|
||||
topLeft = Offset(thumbX - thumbWidthPx / 2, thumbTop),
|
||||
size = Size(thumbWidthPx, thumbHeightPx),
|
||||
cornerRadius = androidx.compose.ui.geometry.CornerRadius(thumbWidthPx / 2, thumbWidthPx / 2)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Modifier.horizontalSliderDragInput(
|
||||
enabled: Boolean,
|
||||
key1: Any?,
|
||||
|
||||
@@ -203,7 +203,7 @@ fun EffectsPanel(
|
||||
)
|
||||
|
||||
// 3. 滑块
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = currentValue,
|
||||
onValueChange = { newValue ->
|
||||
if (abs(newValue - currentValue) > 0.05f) {
|
||||
@@ -213,15 +213,14 @@ fun EffectsPanel(
|
||||
},
|
||||
onDoubleTap = {
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onParamsChange(effect.setValue(currentParams, effect.defaultValue))
|
||||
val resetParams = effect.setValue(currentParams, effect.defaultValue)
|
||||
onParamsChange(resetParams)
|
||||
},
|
||||
valueRange = effect.minValue..effect.maxValue,
|
||||
thumbWidth = 3.dp,
|
||||
thumbHeight = 16.dp,
|
||||
trackHeight = 3.dp,
|
||||
activeTrackColor = effect.color,
|
||||
inactiveTrackColor = Color.Gray.copy(alpha = 0.2f),
|
||||
thumbColor = Color.White,
|
||||
thumbRadius = 7.dp,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 8.dp)
|
||||
|
||||
@@ -98,7 +98,7 @@ fun SliderSettingItem(
|
||||
if (shouldShowSlider) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
onValueChangeFinished = onValueChangeFinished,
|
||||
@@ -116,7 +116,7 @@ fun SliderSettingItem(
|
||||
onValueChangeFinished?.invoke()
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.IntentSenderRequest
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -68,7 +67,7 @@ import com.hinnka.mycamera.hdr.HdrGainmapStrength
|
||||
import com.hinnka.mycamera.lut.creator.AiPhotoEvaluation
|
||||
import com.hinnka.mycamera.lut.VideoLutEffect
|
||||
import com.hinnka.mycamera.ui.camera.autoRotate
|
||||
import com.hinnka.mycamera.ui.components.CustomSliderThinThumb
|
||||
import com.hinnka.mycamera.ui.components.CustomSlider
|
||||
import com.hinnka.mycamera.ui.components.PaymentDialog
|
||||
import com.hinnka.mycamera.utils.DeviceUtil
|
||||
import com.hinnka.mycamera.utils.PLog
|
||||
@@ -1246,7 +1245,7 @@ private fun HdrStrengthPanel(
|
||||
fontSize = 9.sp
|
||||
)
|
||||
}
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = strength,
|
||||
onValueChange = onStrengthChange,
|
||||
valueRange = HdrGainmapStrength.MIN..HdrGainmapStrength.MAX,
|
||||
|
||||
@@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -55,8 +54,6 @@ import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.ScrollableTabRow
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.SliderDefaults
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Tab
|
||||
@@ -102,7 +99,7 @@ import com.hinnka.mycamera.frame.FrameElementDraft
|
||||
import com.hinnka.mycamera.frame.FramePosition
|
||||
import com.hinnka.mycamera.frame.LogoType
|
||||
import com.hinnka.mycamera.frame.TextType
|
||||
import com.hinnka.mycamera.ui.components.CustomSliderThinThumb
|
||||
import com.hinnka.mycamera.ui.components.CustomSlider
|
||||
import com.hinnka.mycamera.ui.theme.AccentOrange
|
||||
import com.hinnka.mycamera.viewmodel.CameraViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -1527,7 +1524,7 @@ private fun ColorPickerDialog(
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
CustomSliderThinThumb(
|
||||
CustomSlider(
|
||||
value = alpha,
|
||||
onValueChange = { alpha = it.coerceIn(0f, 1f) },
|
||||
)
|
||||
|
||||
@@ -337,6 +337,7 @@ fun SettingsScreen(
|
||||
|
||||
var selectedTab by remember { mutableStateOf(SettingsTab.CAMERA) }
|
||||
var isRawSliderAdjusting by remember { mutableStateOf(false) }
|
||||
var isSoftwareProcessingSliderAdjusting by remember { mutableStateOf(false) }
|
||||
var mainCameraIdOptions by remember { mutableStateOf<List<String>>(emptyList()) }
|
||||
var rawExposureCompensationUi by remember { mutableStateOf(rawExposureCompensation) }
|
||||
var rawHighlightsAdjustmentUi by remember { mutableStateOf(rawHighlightsAdjustment) }
|
||||
@@ -344,6 +345,9 @@ fun SettingsScreen(
|
||||
var rawBlackPointCorrectionUi by remember { mutableStateOf(rawBlackPointCorrection) }
|
||||
var rawWhitePointCorrectionUi by remember { mutableStateOf(rawWhitePointCorrection) }
|
||||
var rawToneMappingParametersUi by remember { mutableStateOf(rawToneMappingParameters) }
|
||||
var sharpeningUi by remember { mutableStateOf(sharpening) }
|
||||
var noiseReductionUi by remember { mutableStateOf(noiseReduction) }
|
||||
var chromaNoiseReductionUi by remember { mutableStateOf(chromaNoiseReduction) }
|
||||
var aiFocusScoreThresholdUi by remember(aiFocusScoreThreshold) { mutableStateOf(aiFocusScoreThreshold) }
|
||||
var windowScreenBrightnessUi by remember { mutableStateOf(windowScreenBrightness ?: 1f) }
|
||||
var windowScreenBrightnessEnabled by remember { mutableStateOf(windowScreenBrightness != null) }
|
||||
@@ -369,6 +373,14 @@ fun SettingsScreen(
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(sharpening, noiseReduction, chromaNoiseReduction) {
|
||||
if (!isSoftwareProcessingSliderAdjusting) {
|
||||
sharpeningUi = sharpening
|
||||
noiseReductionUi = noiseReduction
|
||||
chromaNoiseReductionUi = chromaNoiseReduction
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(
|
||||
customLensIds,
|
||||
lensIdBlacklist,
|
||||
@@ -409,6 +421,13 @@ fun SettingsScreen(
|
||||
viewModel.setRawToneMappingParameters(rawToneMappingParametersUi)
|
||||
}
|
||||
|
||||
fun commitSoftwareProcessingSliderValues() {
|
||||
isSoftwareProcessingSliderAdjusting = false
|
||||
viewModel.setSharpening(sharpeningUi)
|
||||
viewModel.setNoiseReduction(noiseReductionUi)
|
||||
viewModel.setChromaNoiseReduction(chromaNoiseReductionUi)
|
||||
}
|
||||
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val coroutineScope = androidx.compose.runtime.rememberCoroutineScope()
|
||||
val isHdrSettingsSupported = remember { Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !DeviceUtil.isHarmonyOS }
|
||||
@@ -1535,10 +1554,14 @@ fun SettingsScreen(
|
||||
SliderSettingItem(
|
||||
title = stringResource(R.string.settings_sharpening),
|
||||
description = stringResource(R.string.settings_sharpening_description),
|
||||
value = sharpening,
|
||||
value = sharpeningUi,
|
||||
valueRange = 0f..1f,
|
||||
resetValue = 0f,
|
||||
onValueChange = { viewModel.setSharpening(it) }
|
||||
onValueChange = {
|
||||
isSoftwareProcessingSliderAdjusting = true
|
||||
sharpeningUi = it
|
||||
},
|
||||
onValueChangeFinished = ::commitSoftwareProcessingSliderValues
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
@@ -1546,10 +1569,14 @@ fun SettingsScreen(
|
||||
SliderSettingItem(
|
||||
title = stringResource(R.string.settings_noise_reduction),
|
||||
description = stringResource(R.string.settings_noise_reduction_description),
|
||||
value = noiseReduction,
|
||||
value = noiseReductionUi,
|
||||
valueRange = 0f..1f,
|
||||
resetValue = 0f,
|
||||
onValueChange = { viewModel.setNoiseReduction(it) }
|
||||
onValueChange = {
|
||||
isSoftwareProcessingSliderAdjusting = true
|
||||
noiseReductionUi = it
|
||||
},
|
||||
onValueChangeFinished = ::commitSoftwareProcessingSliderValues
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
@@ -1557,10 +1584,14 @@ fun SettingsScreen(
|
||||
SliderSettingItem(
|
||||
title = stringResource(R.string.settings_chroma_noise_reduction),
|
||||
description = stringResource(R.string.settings_chroma_noise_reduction_description),
|
||||
value = chromaNoiseReduction,
|
||||
value = chromaNoiseReductionUi,
|
||||
valueRange = 0f..1f,
|
||||
resetValue = 0f,
|
||||
onValueChange = { viewModel.setChromaNoiseReduction(it) }
|
||||
onValueChange = {
|
||||
isSoftwareProcessingSliderAdjusting = true
|
||||
chromaNoiseReductionUi = it
|
||||
},
|
||||
onValueChangeFinished = ::commitSoftwareProcessingSliderValues
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user