feat: color edit ui

This commit is contained in:
zhoubinjia committed 2026-07-28 18:44:37 +08:00
1 parent 3e65dc4111
commit 4488ce8ed2
23 files changed
+849 -980

No files matched your search

@@ -103,11 +103,9 @@ import com.hinnka.mycamera.model.ColorPaletteMapper
import com.hinnka.mycamera.model.ColorPaletteState
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.ui.camera.LutIntensitySlider
import com.hinnka.mycamera.ui.components.ColorRecipePanel
import com.hinnka.mycamera.ui.components.CurveChannel
import com.hinnka.mycamera.ui.components.EffectsPanel
import com.hinnka.mycamera.ui.components.LutSelectorWithRecipeAction
import com.hinnka.mycamera.ui.components.LutSelector
import com.hinnka.mycamera.ui.icons.AppIcons
import com.hinnka.mycamera.utils.PLog
import kotlinx.coroutines.CancellationException
@@ -207,7 +205,6 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
private var expanded by mutableStateOf(false)
private var showFilterPicker by mutableStateOf(false)
private var showRecipeEditor by mutableStateOf(false)
private var showEffectsEditor by mutableStateOf(false)
private var floatingWindowYBeforeEditor: Int? = null
private val contentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
@@ -918,7 +915,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
}
private fun updateWindowParams(hidden: Boolean) {
val editorVisible = showRecipeEditor || showEffectsEditor
val editorVisible = showRecipeEditor
if (hidden) {
windowParams.width = 1
windowParams.height = 1
@@ -1001,7 +998,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
}
}
if (!showRecipeEditor && !showEffectsEditor) {
if (!showRecipeEditor) {
Row(
modifier = Modifier
.padding(4.dp)
@@ -1106,34 +1103,26 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
composeView?.let { windowManager.updateViewLayout(it, windowParams) }
}
LutSelectorWithRecipeAction(
availableLuts = availableLuts,
currentLutId = currentLutId,
thumbnail = processingInfo?.thumbnail?.takeIf { !it.isRecycled },
onLutSelected = { lutId ->
scope.launch {
userPreferencesRepository.saveLutConfig(lutId)
syncScreenCaptureRenderConfig(lutId)
closeFilterPicker()
}
},
onEditRecipeClick = if (currentLutId != null) {
{
showRecipeEditor = true
updateWindowParams(false)
composeView?.let { windowManager.updateViewLayout(it, windowParams) }
}
} else null,
onEditEffectClick = {
showEffectsEditor = true
updateWindowParams(false)
composeView?.let { windowManager.updateViewLayout(it, windowParams) }
},
categoryOrder = categoryOrder,
Column(
modifier = Modifier
.fillMaxWidth()
.padding(top = 32.dp)
)
) {
LutSelector(
availableLuts = availableLuts,
currentLutId = currentLutId,
thumbnail = processingInfo?.thumbnail?.takeIf { !it.isRecycled },
onLutSelected = { lutId ->
scope.launch {
userPreferencesRepository.saveLutConfig(lutId)
syncScreenCaptureRenderConfig(lutId)
closeFilterPicker()
}
},
categoryOrder = categoryOrder,
modifier = Modifier.fillMaxWidth()
)
}
Row(
modifier = Modifier
@@ -1182,6 +1171,35 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
}
}
Box(
modifier = Modifier.width(48.dp),
contentAlignment = Alignment.Center
) {
IconButton(
onClick = {
if (currentLutId != null) {
showRecipeEditor = true
updateWindowParams(false)
composeView?.let {
windowManager.updateViewLayout(it, windowParams)
}
}
},
enabled = currentLutId != null,
modifier = Modifier.size(48.dp)
) {
Icon(
imageVector = AppIcons.Tune,
contentDescription = stringResource(R.string.edit),
tint = if (currentLutId != null) {
Color.White
} else {
Color.White.copy(alpha = 0.3f)
}
)
}
}
Box(
modifier = Modifier.width(48.dp),
contentAlignment = Alignment.Center
@@ -1252,9 +1270,10 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
}
LaunchedEffect(editingLutId) {
val params = ContentRepository.getInstance(context)
.lutManager
.loadColorRecipeParams(editingLutId)
val params = recipePreviewParams
?: ContentRepository.getInstance(context)
.lutManager
.loadColorRecipeParams(editingLutId)
editingParams = params
paletteState = ColorPaletteState(
x = params.paletteX,
@@ -1270,15 +1289,9 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
.padding(horizontal = 12.dp, vertical = 8.dp)
) {
PhantomEditorHeader(
title = stringResource(R.string.color_recipe),
title = stringResource(R.string.edit),
onClose = { closeRecipeEditor() }
)
LutIntensitySlider(
intensity = editingParams.lutIntensity,
onIntensityChange = {
updateRecipeParams(editingParams.copy(lutIntensity = it))
}
)
ColorRecipePanel(
currentParams = editingParams,
paletteState = paletteState,
@@ -1316,38 +1329,14 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
}
)
},
modifier = Modifier.fillMaxWidth()
)
}
}
if (showEffectsEditor) {
fun closeEffectsEditor() {
showEffectsEditor = false
scope.launch {
syncScreenCaptureRenderConfig(currentLutId)
updateWindowParams(false)
composeView?.let { windowManager.updateViewLayout(it, windowParams) }
}
}
Column(
modifier = Modifier
.fillMaxWidth()
.background(Color.Black.copy(alpha = 0.88f))
.padding(horizontal = 12.dp, vertical = 8.dp)
) {
PhantomEditorHeader(
title = stringResource(R.string.effects_title),
onClose = { closeEffectsEditor() }
)
EffectsPanel(
currentParams = currentEffectParams,
onParamsChange = { effects ->
showLutIntensity = true,
currentEffects = currentEffectParams,
onEffectsChange = { effects ->
scope.launch {
userPreferencesRepository.saveActiveEffectParams(effects)
syncScreenCaptureRenderConfig(
lutId = currentLutId,
creativeRecipeParamsOverride = editingParams,
effectParamsOverride = effects
)
}
@@ -1441,7 +1430,6 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
expanded = false
showFilterPicker = false
showRecipeEditor = false
showEffectsEditor = false
floatingWindowYBeforeEditor = null
}
}
@@ -94,7 +94,7 @@ enum class ActivePanel {
NONE,
SETTINGS,
FILTERS,
LUT_EDIT,
EDIT,
PRESETS
}
@@ -320,6 +320,12 @@ fun CameraScreen(
}
}
LaunchedEffect(currentRecipeParams) {
if (previewRecipeParamsOverride?.isSameAs(currentRecipeParams) == true) {
previewRecipeParamsOverride = null
}
}
DisposableEffect(Unit) {
onDispose {
flushEffectParamsSave()
@@ -342,7 +348,6 @@ fun CameraScreen(
// UI State
var activePanel by remember { mutableStateOf(ActivePanel.NONE) }
var showEffectsSheet by remember { mutableStateOf(false) }
var selectedParameter by remember { mutableStateOf(CameraParameter.EXPOSURE_COMPENSATION) }
var showVideoParameterRuler by remember { mutableStateOf(false) }
val isXpan = state.aspectRatio == AspectRatio.XPAN
@@ -1033,7 +1038,8 @@ fun CameraScreen(
baselineLut = viewModel.currentBaselineLutConfig,
currentLut = viewModel.currentLutConfig,
baselineColorRecipeParams = currentBaselineRecipeParams,
colorRecipeParams = previewRecipeParamsOverride ?: mergedRecipeParams,
colorRecipeParams = previewRecipeParamsOverride?.let(previewEffectParams::applyTo)
?: mergedRecipeParams,
focusPoint = state.focusPoint,
focusPointSource = state.focusPointSource,
isFocusLocked = state.isFocusLocked,
@@ -1668,7 +1674,7 @@ fun CameraScreen(
.clip(RoundedCornerShape(16.dp))
.background(Color.White.copy(alpha = 0.15f))
.clickable {
activePanel = ActivePanel.LUT_EDIT
activePanel = ActivePanel.EDIT
}
.padding(horizontal = 12.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -1676,21 +1682,17 @@ fun CameraScreen(
) {
Icon(
imageVector = AppIcons.Tune,
contentDescription = stringResource(R.string.color_recipe),
contentDescription = stringResource(R.string.edit),
tint = Color(0xFFFFD700), // Gold color to match VIP/Premium feel
modifier = Modifier.size(14.dp)
)
Text(
text = stringResource(R.string.color_recipe),
text = stringResource(R.string.edit),
color = Color.White,
fontSize = 11.sp,
fontWeight = FontWeight.Medium
)
}
EffectsActionChip(
onClick = { showEffectsSheet = true }
)
}
}
@@ -1722,7 +1724,7 @@ fun CameraScreen(
},
onPresetManagementClick = onPresetManagementClick,
onEditClick = {
activePanel = ActivePanel.LUT_EDIT
activePanel = ActivePanel.EDIT
},
onManageClick = { lutId ->
activePanel = ActivePanel.NONE
@@ -1734,11 +1736,15 @@ fun CameraScreen(
}
}
if (activePanel == ActivePanel.LUT_EDIT) {
if (activePanel == ActivePanel.EDIT) {
LutEditBottomSheet(
lutId = currentLutId,
initialParams = previewRecipeParamsOverride ?: currentRecipeParams,
onParamsPreviewChange = { previewRecipeParamsOverride = it },
effectParams = previewEffectParams,
onEffectParamsChange = { saveEffectParamsDebounced(it) },
onDismiss = {
flushEffectParamsSave()
previewRecipeParamsOverride = null
viewModel.refreshActivePresetMatch()
activePanel = ActivePanel.FILTERS
@@ -1746,17 +1752,6 @@ fun CameraScreen(
)
}
if (showEffectsSheet) {
EffectsBottomSheet(
currentParams = previewEffectParams,
onParamsChange = { saveEffectParamsDebounced(it) },
onDismiss = {
flushEffectParamsSave()
showEffectsSheet = false
}
)
}
if (baselineEditLutId != null && baselineEditTarget != null) {
LutEditBottomSheet(
lutId = baselineEditLutId!!,
@@ -1,40 +1,26 @@
package com.hinnka.mycamera.ui.camera
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.hinnka.mycamera.R
import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
import com.hinnka.mycamera.model.ColorPaletteMapper
import com.hinnka.mycamera.model.ColorPaletteState
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.ui.components.ColorRecipePanel
import com.hinnka.mycamera.ui.components.CustomSlider
import com.hinnka.mycamera.ui.components.ImageHistogram
import com.hinnka.mycamera.viewmodel.LutEditViewModel
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
enum class RecipeScope { LUT_GLOBAL, PHOTO_LOCAL }
enum class LutEditorTarget(val baselineTarget: BaselineColorCorrectionTarget? = null) {
CREATIVE_GLOBAL(),
BASELINE_JPG(BaselineColorCorrectionTarget.JPG),
@@ -43,12 +29,7 @@ enum class LutEditorTarget(val baselineTarget: BaselineColorCorrectionTarget? =
}
/**
* LUT编辑底部弹窗
*
* 当 photoRecipeParams 非 null 时,说明这张照片已有独立配方覆盖。
* onPhotoParamsChange 提供后会在顶部显示 scope 切换,允许用户选择:
* - LUT 默认:修改 LUT 全局配方(原有行为)
* - 仅此照片:修改照片级覆盖,不影响 LUT
* LUT 色彩配方编辑底部弹窗。物理效果参数存在时,与色彩调整显示在同一编辑面板中。
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -58,10 +39,8 @@ fun LutEditBottomSheet(
initialParams: ColorRecipeParams? = null,
onParamsPreviewChange: ((ColorRecipeParams) -> Unit)? = null,
imageHistogram: ImageHistogram? = null,
// 照片级配方相关(为 null 则隐藏 scope 切换,保持纯 LUT 编辑模式)
photoRecipeParams: ColorRecipeParams? = null,
onPhotoParamsChange: ((ColorRecipeParams?) -> Unit)? = null,
defaultScope: RecipeScope = RecipeScope.LUT_GLOBAL,
effectParams: EffectParams? = null,
onEffectParamsChange: ((EffectParams) -> Unit)? = null,
editorTarget: LutEditorTarget = LutEditorTarget.CREATIVE_GLOBAL,
containerColor: Color = Color.Black.copy(alpha = 0.8f),
modifier: Modifier = Modifier
@@ -70,20 +49,13 @@ fun LutEditBottomSheet(
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val coroutineScope = rememberCoroutineScope()
val showScopeToggle = onPhotoParamsChange != null
var currentScope by remember { mutableStateOf(defaultScope) }
var editingParams by remember { mutableStateOf(ColorRecipeParams.DEFAULT) }
var paletteState by remember { mutableStateOf(ColorPaletteState.DEFAULT) }
var saveJob by remember { mutableStateOf<Job?>(null) }
var hasPendingLutSave by remember { mutableStateOf(false) }
val openingInitialParams = remember(lutId) { initialParams }
// 切换 scope 时加载对应的参数
suspend fun loadParamsForScope(scope: RecipeScope, lutParams: ColorRecipeParams) {
val params = when (scope) {
RecipeScope.LUT_GLOBAL -> lutParams
RecipeScope.PHOTO_LOCAL -> photoRecipeParams ?: lutParams
}
fun loadParams(params: ColorRecipeParams) {
editingParams = params
paletteState = ColorPaletteState(
x = params.paletteX,
@@ -93,36 +65,44 @@ fun LutEditBottomSheet(
}
fun scheduleLutSave(params: ColorRecipeParams) {
hasPendingLutSave = true
saveJob?.cancel()
saveJob = coroutineScope.launch {
delay(250)
lutEditViewModel.saveLutColorRecipe(lutId, params, editorTarget.baselineTarget)
hasPendingLutSave = false
}
}
fun flushLutSave() {
if (!hasPendingLutSave) return
saveJob?.cancel()
saveJob = null
hasPendingLutSave = false
lutEditViewModel.saveLutColorRecipe(lutId, editingParams, editorTarget.baselineTarget)
}
fun onParamsUpdated(newParams: ColorRecipeParams) {
editingParams = newParams
onParamsPreviewChange?.invoke(newParams)
when (currentScope) {
RecipeScope.LUT_GLOBAL -> scheduleLutSave(newParams)
RecipeScope.PHOTO_LOCAL -> onPhotoParamsChange?.invoke(newParams)
}
scheduleLutSave(newParams)
}
// 初始加载
LaunchedEffect(lutId) {
val lutParams = openingInitialParams ?: lutEditViewModel.getColorRecipe(lutId, editorTarget.baselineTarget)
loadParamsForScope(currentScope, lutParams)
loadParams(lutParams)
}
DisposableEffect(lutId, editorTarget) {
onDispose {
flushLutSave()
}
}
ModalBottomSheet(
onDismissRequest = {
if (currentScope == RecipeScope.LUT_GLOBAL) flushLutSave()
flushLutSave()
onDismiss()
},
sheetState = sheetState,
@@ -135,101 +115,6 @@ fun LutEditBottomSheet(
.fillMaxWidth()
.navigationBarsPadding()
) {
// Scope 切换(仅在 gallery 编辑模式下显示)
if (showScopeToggle) {
SingleChoiceSegmentedButtonRow(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp)
) {
RecipeScope.entries.forEachIndexed { index, scope ->
SegmentedButton(
selected = currentScope == scope,
onClick = {
if (currentScope != scope) {
// 切换前先把当前 scope 的未提交 LUT 改动 flush 掉
if (currentScope == RecipeScope.LUT_GLOBAL) flushLutSave()
currentScope = scope
if (scope == RecipeScope.LUT_GLOBAL) {
onPhotoParamsChange.invoke(null)
}
coroutineScope.launch {
val lutParams = lutEditViewModel.getColorRecipe(lutId, editorTarget.baselineTarget)
loadParamsForScope(scope, lutParams)
// 切换后预览也跟着刷新
onParamsPreviewChange?.invoke(editingParams)
}
}
},
shape = SegmentedButtonDefaults.itemShape(
index = index,
count = RecipeScope.entries.size
),
colors = SegmentedButtonDefaults.colors(
activeContainerColor = Color(0x882A2A2A),
activeContentColor = Color.White,
inactiveContainerColor = Color.Transparent,
inactiveContentColor = Color.White.copy(alpha = 0.5f),
activeBorderColor = Color.White.copy(alpha = 0.3f),
inactiveBorderColor = Color.White.copy(alpha = 0.15f)
)
) {
Text(
text = when (scope) {
RecipeScope.LUT_GLOBAL -> stringResource(R.string.recipe_scope_lut)
RecipeScope.PHOTO_LOCAL -> stringResource(R.string.recipe_scope_photo)
},
fontSize = 12.sp
)
}
}
}
// 仅此照片模式下的提示 + 重置按钮
if (currentScope == RecipeScope.PHOTO_LOCAL) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.recipe_scope_photo_hint),
color = Color.White.copy(alpha = 0.4f),
fontSize = 10.sp
)
if (photoRecipeParams != null) {
Text(
text = stringResource(R.string.recipe_scope_photo_reset),
color = Color(0xFFFF9800).copy(alpha = 0.8f),
fontSize = 10.sp,
modifier = Modifier
.clip(RoundedCornerShape(4.dp))
.clickable {
onPhotoParamsChange.invoke(null)
coroutineScope.launch {
val lutParams = lutEditViewModel.getColorRecipe(lutId, editorTarget.baselineTarget)
loadParamsForScope(RecipeScope.PHOTO_LOCAL, lutParams)
onParamsPreviewChange?.invoke(editingParams)
}
}
.padding(horizontal = 6.dp, vertical = 2.dp)
)
}
}
} else {
Spacer(modifier = Modifier.height(8.dp))
}
}
LutIntensitySlider(
intensity = editingParams.lutIntensity,
onIntensityChange = {
onParamsUpdated(editingParams.copy(lutIntensity = it))
}
)
ColorRecipePanel(
currentParams = editingParams,
paletteState = paletteState,
@@ -267,61 +152,11 @@ fun LutEditBottomSheet(
)
},
imageHistogram = imageHistogram,
showLutIntensity = editorTarget == LutEditorTarget.CREATIVE_GLOBAL,
currentEffects = effectParams,
onEffectsChange = onEffectParamsChange,
modifier = Modifier.fillMaxWidth()
)
}
}
}
/**
* LUT 强度滑块组件
*/
@Composable
fun LutIntensitySlider(
intensity: Float,
onIntensityChange: (Float) -> Unit,
enabled: Boolean = true,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp).padding(bottom = 8.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.filter_intensity),
color = if (enabled) Color.White else Color.Gray,
fontSize = 12.sp,
lineHeight = 14.sp
)
Text(
text = "${(intensity * 100).toInt()}%",
color = if (enabled) Color.White else Color.Gray,
fontSize = 10.sp,
lineHeight = 14.sp,
fontWeight = FontWeight.Bold
)
}
CustomSlider(
value = intensity,
onValueChange = onIntensityChange,
onDoubleTap = {
if (enabled) onIntensityChange(1.0f)
},
enabled = enabled,
valueRange = 0f..1f,
activeTrackColor = Color.White,
inactiveTrackColor = Color.Gray.copy(alpha = 0.5f),
thumbColor = Color.White,
modifier = Modifier.fillMaxWidth()
)
}
}
@@ -5,10 +5,8 @@ import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberUpdatedState
@@ -141,17 +139,6 @@ fun ColorRecipePalettePanel(
}
}
Spacer(modifier = Modifier.height(8.dp))
PaletteDensitySlider(
value = paletteState.density,
onValueChange = {
currentOnPaletteStateChange.value(
currentPaletteState.value.copy(density = it)
)
},
modifier = Modifier.padding(horizontal = 8.dp)
)
}
}
@@ -177,82 +164,3 @@ private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawPaletteGrid(siz
}
}
}
@Composable
private fun PaletteDensitySlider(
value: Float,
onValueChange: (Float) -> Unit,
modifier: Modifier = Modifier
) {
Column(modifier = modifier.fillMaxWidth()) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(28.dp)
) {
Canvas(modifier = Modifier.matchParentSize()) {
val trackHeight = 14.dp.toPx()
val thumbRadius = trackHeight * 0.62f
val top = (size.height - trackHeight) * 0.5f
val corner = CornerRadius(trackHeight / 2f, trackHeight / 2f)
val thumbTravelWidth = (size.width - thumbRadius * 2f).coerceAtLeast(1f)
drawRoundRect(
brush = Brush.horizontalGradient(
listOf(
Color(0xFF5BC1FF),
Color(0xFFDFD3B0),
Color(0xFFFFB064),
Color(0xFFF0526A)
)
),
topLeft = Offset(0f, top),
size = Size(size.width, trackHeight),
cornerRadius = corner
)
drawRoundRect(
color = Color.Black.copy(alpha = 0.18f),
topLeft = Offset(0f, top),
size = Size(size.width, trackHeight),
cornerRadius = corner,
style = Stroke(width = 1.dp.toPx())
)
val thumbX = thumbRadius + value.coerceIn(0f, 1f) * thumbTravelWidth
val center = Offset(thumbX, size.height / 2f)
drawCircle(
color = Color.White,
radius = thumbRadius,
center = center
)
drawCircle(
color = Color(0xFFE95A78),
radius = thumbRadius,
center = center,
style = Stroke(width = 2.dp.toPx())
)
}
Box(
modifier = Modifier
.matchParentSize()
.pointerInput(Unit) {
detectTapGestures { offset ->
val trackHeight = 14.dp.toPx()
val thumbRadius = trackHeight * 0.62f
val width = (size.width.toFloat() - thumbRadius * 2f).coerceAtLeast(1f)
onValueChange(((offset.x - thumbRadius) / width).coerceIn(0f, 1f))
}
}
.pointerInput(Unit) {
detectDragGestures { change, _ ->
change.consume()
val trackHeight = 14.dp.toPx()
val thumbRadius = trackHeight * 0.62f
val width = (size.width.toFloat() - thumbRadius * 2f).coerceAtLeast(1f)
onValueChange(((change.position.x - thumbRadius) / width).coerceIn(0f, 1f))
}
}
)
}
}
}
@@ -1,14 +1,11 @@
package com.hinnka.mycamera.ui.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
@@ -23,6 +20,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.res.stringResource
@@ -34,12 +32,30 @@ import androidx.compose.ui.text.input.ImeAction
import com.hinnka.mycamera.R
import com.hinnka.mycamera.model.ColorPaletteState
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.model.RecipeParam
private enum class RecipePanelTab {
PALETTE,
LIGHT,
CURVE,
COLOR,
TEXTURE,
LENS,
EFFECTS,
REMARKS,
}
private enum class ColorPanelSection {
BASIC,
CALIBRATION,
LCH,
}
/**
* 色彩配方控制面板
*
* 使用顶部 Tab 切换不同参数组
* 色彩调整与物理效果共用同一组一级菜单。校准和 LCH 收纳在颜色的二级菜单中。
*/
@Composable
fun ColorRecipePanel(
@@ -52,6 +68,10 @@ fun ColorRecipePanel(
onCurveChange: (CurveChannel, FloatArray?) -> Unit = { _, _ -> },
imageHistogram: ImageHistogram? = null,
hideNonBakeable: Boolean = true,
showLutIntensity: Boolean = false,
currentEffects: EffectParams? = null,
onEffectsChange: ((EffectParams) -> Unit)? = null,
optionControls: (@Composable () -> Unit)? = null,
modifier: Modifier = Modifier
) {
val isBakeable: (RecipeParam) -> Boolean = { param ->
@@ -66,46 +86,42 @@ fun ColorRecipePanel(
param != RecipeParam.LOW_RES
}
var selectedTabIndex by remember { mutableIntStateOf(0) }
var selectedTab by remember { mutableStateOf(RecipePanelTab.PALETTE) }
var selectedColorSection by remember { mutableStateOf(ColorPanelSection.BASIC) }
var selectedLchTabIndex by remember { mutableIntStateOf(0) }
var selectedCalibrationTabIndex by remember { mutableIntStateOf(0) }
var isExpanded by remember { mutableStateOf(true) }
val showEffects = currentEffects != null && onEffectsChange != null
val tabs = listOf(
R.string.recipe_tab_palette, // 0
R.string.recipe_tab_light, // 1
R.string.recipe_tab_curve, // 2 (曲线)
R.string.recipe_tab_color, // 3
R.string.recipe_tab_calibration, // 4
R.string.recipe_tab_lch, // 5
R.string.recipe_tab_texture, // 6
R.string.recipe_tab_lens, // 7
R.string.recipe_tab_remarks, // 8
)
val parameterGroups = listOf(
emptyList(), // 0 palette
listOf( // 1 light
val tabs = buildList {
add(RecipePanelTab.PALETTE to R.string.recipe_tab_palette)
add(RecipePanelTab.LIGHT to R.string.recipe_tab_light)
add(RecipePanelTab.CURVE to R.string.recipe_tab_curve)
add(RecipePanelTab.COLOR to R.string.recipe_tab_color)
add(RecipePanelTab.TEXTURE to R.string.recipe_tab_texture)
if (!hideNonBakeable) add(RecipePanelTab.LENS to R.string.recipe_tab_lens)
if (showEffects) add(RecipePanelTab.EFFECTS to R.string.effects_title)
if (!hideNonBakeable) add(RecipePanelTab.REMARKS to R.string.recipe_tab_remarks)
}
val parameterGroups = mapOf(
RecipePanelTab.LIGHT to listOf(
RecipeParam.EXPOSURE,
RecipeParam.CONTRAST,
RecipeParam.HIGHLIGHTS,
RecipeParam.SHADOWS,
),
emptyList(), // 2 curve (handled specially)
listOf( // 3 color
RecipePanelTab.COLOR to listOf(
RecipeParam.SATURATION,
RecipeParam.TEMPERATURE,
RecipeParam.TINT,
RecipeParam.COLOR
),
emptyList(), // 4 calibration (handled specially)
emptyList(), // 5 lch (handled specially)
listOf( // 6 texture
RecipePanelTab.TEXTURE to listOf(
RecipeParam.VIGNETTE,
RecipeParam.FILM_GRAIN,
RecipeParam.FADE,
RecipeParam.BLEACH_BYPASS,
),
listOf( // 7 lens
RecipePanelTab.LENS to listOf(
RecipeParam.HALATION,
RecipeParam.CHROMATIC_ABERRATION,
RecipeParam.NOISE,
@@ -174,9 +190,9 @@ fun ColorRecipePanel(
),
)
fun resetTab(tabIndex: Int) {
when (tabIndex) {
0 -> {
fun resetTab(tab: RecipePanelTab) {
when (tab) {
RecipePanelTab.PALETTE -> {
val defaultPaletteState = ColorPaletteState.DEFAULT
onParamsChange(
currentParams.copy(
@@ -186,7 +202,7 @@ fun ColorRecipePanel(
)
)
}
2 -> onParamsChange(
RecipePanelTab.CURVE -> onParamsChange(
currentParams.copy(
masterCurvePoints = null,
redCurvePoints = null,
@@ -194,11 +210,18 @@ fun ColorRecipePanel(
blueCurvePoints = null
)
)
4 -> onParamsChange(resetParams(currentParams, calibrationGroups.flatMap { it.second }))
5 -> onParamsChange(resetParams(currentParams, lchGroups.flatMap { it.second }))
8 -> Unit
RecipePanelTab.COLOR -> onParamsChange(
resetParams(
currentParams,
parameterGroups[RecipePanelTab.COLOR].orEmpty() +
calibrationGroups.flatMap { it.second } +
lchGroups.flatMap { it.second }
)
)
RecipePanelTab.EFFECTS -> onEffectsChange?.invoke(EffectParams.DEFAULT)
RecipePanelTab.REMARKS -> Unit
else -> {
val allParams = parameterGroups.getOrNull(tabIndex).orEmpty()
val allParams = parameterGroups[tab].orEmpty()
val params = if (hideNonBakeable) allParams.filter(isBakeable) else allParams
if (params.isNotEmpty()) {
onParamsChange(resetParams(currentParams, params))
@@ -210,13 +233,18 @@ fun ColorRecipePanel(
fun resetAllParams() {
if (!hideNonBakeable) {
onParamsChange(ColorRecipeParams.DEFAULT)
onEffectsChange?.invoke(EffectParams.DEFAULT)
return
}
val defaultPaletteState = ColorPaletteState.DEFAULT
val visibleParams = parameterGroups
.values
.flatten()
.filter(isBakeable) + calibrationGroups.flatMap { it.second } + lchGroups.flatMap { it.second }
.filter(isBakeable) +
calibrationGroups.flatMap { it.second } +
lchGroups.flatMap { it.second } +
if (showLutIntensity) listOf(RecipeParam.LUT_INTENSITY) else emptyList()
onParamsChange(
resetParams(
currentParams.copy(
@@ -231,218 +259,307 @@ fun ColorRecipePanel(
visibleParams
)
)
onEffectsChange?.invoke(EffectParams.DEFAULT)
}
Column(
modifier = modifier
.fillMaxWidth()
) {
val sectionBackgroundColor = Color.Transparent
// 当前选中的内容
AnimatedVisibility(isExpanded) {
Box(
Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
if (showLutIntensity) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
contentAlignment = Alignment.TopCenter
.clip(RoundedCornerShape(10.dp))
.background(sectionBackgroundColor)
) {
if (selectedTabIndex < parameterGroups.size) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
when (selectedTabIndex) {
0 -> {
// 调色盘
ColorRecipePalettePanel(
paletteState = paletteState,
onPaletteStateChange = onPaletteStateChange,
modifier = Modifier.fillMaxWidth()
)
}
2 -> {
// 曲线编辑器
CurveEditorPanel(
currentParams = currentParams,
onCurveChange = onCurveChange,
imageHistogram = imageHistogram,
modifier = Modifier.fillMaxWidth()
)
}
4 -> {
// Calibration 颜色校准
ColorRingTabs(
count = calibrationGroups.size,
selectedTabIndex = selectedCalibrationTabIndex,
onTabSelected = { selectedCalibrationTabIndex = it },
getColor = { index ->
when (index) {
0 -> Color(0xFFE53935) // Red
1 -> Color(0xFF43A047) // Green
2 -> Color(0xFF1E88E5) // Blue
else -> Color.White
}
}
)
Spacer(modifier = Modifier.height(6.dp))
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
key(param) {
ColorRecipeSlider(
param = param,
value = param.getValue(currentParams),
onValueChange = { newValue ->
onParamChange(param, newValue)
},
onDoubleTap = {
onParamChange(param, param.defaultValue)
}
)
}
}
}
5 -> {
// LCH 颜色混合
ColorRingTabs(
count = lchGroups.size,
selectedTabIndex = selectedLchTabIndex,
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
Spacer(modifier = Modifier.height(6.dp))
lchGroups[selectedLchTabIndex].second.forEach { param ->
key(param) {
ColorRecipeSlider(
param = param,
value = param.getValue(currentParams),
onValueChange = { newValue ->
onParamChange(param, newValue)
},
onDoubleTap = {
onParamChange(param, param.defaultValue)
}
)
}
}
}
else -> {
val allParams = parameterGroups.getOrNull(selectedTabIndex).orEmpty()
val visibleParams = remember(selectedTabIndex, hideNonBakeable) {
if (hideNonBakeable) {
allParams.filter(isBakeable)
} else {
allParams
}
}
visibleParams.forEach { param ->
key(param) {
ColorRecipeSlider(
param = param,
value = param.getValue(currentParams),
onValueChange = { newValue ->
onParamChange(param, newValue)
},
onDoubleTap = {
onParamChange(param, param.defaultValue)
}
)
}
}
}
}
LutIntensitySlider(
intensity = currentParams.lutIntensity,
onIntensityChange = {
onParamChange(RecipeParam.LUT_INTENSITY, it)
}
} else {
// 备注 Tab
ColorRecipeRemarksBar(
remarks = currentParams.remarks ?: "",
onRemarksChange = onRemarksChange,
modifier = Modifier.fillMaxWidth()
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
// 自定义 Tab 选择器 (Pill style)
Box(
modifier = Modifier
.fillMaxWidth()
.height(56.dp)
.background(Color.Black)
.padding(8.dp)
) {
Row(
modifier = Modifier.fillMaxSize(),
verticalAlignment = Alignment.CenterVertically
) {
Row(
modifier = Modifier
.weight(1f)
.fillMaxHeight()
.horizontalScroll(rememberScrollState())
) {
tabs.forEachIndexed { index, title ->
if (hideNonBakeable && (title == R.string.recipe_tab_lens || title == R.string.recipe_tab_remarks)) {
return@forEachIndexed
}
val isSelected = selectedTabIndex == index && isExpanded
val backgroundColor by animateColorAsState(
if (isSelected) Color.White.copy(alpha = 0.2f) else Color.Transparent,
label = "tabBackground"
)
Box(
modifier = Modifier
.widthIn(min = 48.dp)
.fillMaxHeight()
.clip(RoundedCornerShape(4.dp))
.background(backgroundColor)
.pointerInput(index, currentParams) {
detectTapGestures(
onTap = {
selectedTabIndex = index
isExpanded = true
},
onDoubleTap = {
selectedTabIndex = index
isExpanded = true
resetTab(index)
}
)
},
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(title),
fontSize = 11.sp,
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,
color = if (isSelected) Color.White else Color.White.copy(alpha = 0.6f),
modifier = Modifier.padding(horizontal = 4.dp)
)
}
}
}
Icon(
imageVector = Icons.Default.Refresh,
contentDescription = stringResource(R.string.color_recipe_reset_all),
tint = Color.White.copy(alpha = 0.72f),
modifier = Modifier
.padding(start = 8.dp)
.size(32.dp)
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.12f))
.clickable { resetAllParams() }
.padding(7.dp)
)
}
}
Spacer(modifier = Modifier.height(8.dp).background(Color.Black))
optionControls?.let { controls ->
Column(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(10.dp))
.background(sectionBackgroundColor)
) {
controls()
}
}
Column(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(10.dp))
.background(sectionBackgroundColor)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 12.dp, top = 9.dp, end = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.edit),
color = Color.White.copy(alpha = 0.82f),
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
modifier = Modifier.weight(1f)
)
Row(
modifier = Modifier
.height(28.dp)
.clip(RoundedCornerShape(14.dp))
.background(Color.White.copy(alpha = 0.1f))
.clickable { resetAllParams() }
.padding(horizontal = 9.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
imageVector = Icons.Default.Refresh,
contentDescription = null,
tint = Color.White.copy(alpha = 0.78f),
modifier = Modifier.size(14.dp)
)
Text(
text = stringResource(R.string.color_recipe_reset_all),
color = Color.White.copy(alpha = 0.78f),
fontSize = 9.sp,
fontWeight = FontWeight.Medium,
maxLines = 1
)
}
}
Row(
modifier = Modifier
.fillMaxWidth()
.height(42.dp)
.padding(horizontal = 8.dp, vertical = 3.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
tabs.forEach { (tab, title) ->
val isSelected = selectedTab == tab
val backgroundColor by animateColorAsState(
if (isSelected) Color.White.copy(alpha = 0.18f) else Color.Transparent,
label = "tabBackground"
)
Box(
modifier = Modifier
.weight(1f)
.fillMaxHeight()
.clip(RoundedCornerShape(6.dp))
.background(backgroundColor)
.pointerInput(tab, currentParams, currentEffects) {
detectTapGestures(
onTap = {
selectedTab = tab
},
onDoubleTap = {
selectedTab = tab
resetTab(tab)
}
)
},
contentAlignment = Alignment.Center
) {
Text(
text = stringResource(title),
fontSize = if (tabs.size > 6) 9.sp else 10.sp,
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,
color = if (isSelected) Color.White else Color.White.copy(alpha = 0.58f),
textAlign = TextAlign.Center,
maxLines = 1,
softWrap = false,
overflow = TextOverflow.Clip,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 1.dp)
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
Box(
modifier = Modifier
.fillMaxWidth()
.padding(start = 10.dp, end = 10.dp, bottom = 10.dp),
contentAlignment = Alignment.TopCenter
) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
when (selectedTab) {
RecipePanelTab.PALETTE -> {
ColorRecipePalettePanel(
paletteState = paletteState,
onPaletteStateChange = onPaletteStateChange,
modifier = Modifier.fillMaxWidth()
)
}
RecipePanelTab.CURVE -> {
CurveEditorPanel(
currentParams = currentParams,
onCurveChange = onCurveChange,
imageHistogram = imageHistogram,
modifier = Modifier.fillMaxWidth()
)
}
RecipePanelTab.COLOR -> {
ColorSectionTabs(
selectedSection = selectedColorSection,
onSectionSelected = { selectedColorSection = it }
)
when (selectedColorSection) {
ColorPanelSection.BASIC -> {
parameterGroups[RecipePanelTab.COLOR].orEmpty().forEach { param ->
RecipeParamSlider(
param = param,
currentParams = currentParams,
onParamChange = onParamChange
)
}
}
ColorPanelSection.CALIBRATION -> {
ColorRingTabs(
count = calibrationGroups.size,
selectedTabIndex = selectedCalibrationTabIndex,
onTabSelected = { selectedCalibrationTabIndex = it },
getColor = { index ->
when (index) {
0 -> Color(0xFFE53935)
1 -> Color(0xFF43A047)
2 -> Color(0xFF1E88E5)
else -> Color.White
}
}
)
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
RecipeParamSlider(
param = param,
currentParams = currentParams,
onParamChange = onParamChange
)
}
}
ColorPanelSection.LCH -> {
ColorRingTabs(
count = lchGroups.size,
selectedTabIndex = selectedLchTabIndex,
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
lchGroups[selectedLchTabIndex].second.forEach { param ->
RecipeParamSlider(
param = param,
currentParams = currentParams,
onParamChange = onParamChange
)
}
}
}
}
RecipePanelTab.EFFECTS -> {
if (currentEffects != null && onEffectsChange != null) {
EffectsPanel(
currentParams = currentEffects,
onParamsChange = onEffectsChange,
modifier = Modifier.fillMaxWidth()
)
}
}
RecipePanelTab.REMARKS -> {
ColorRecipeRemarksBar(
remarks = currentParams.remarks ?: "",
onRemarksChange = onRemarksChange,
modifier = Modifier.fillMaxWidth()
)
}
else -> {
val allParams = parameterGroups[selectedTab].orEmpty()
val visibleParams = if (hideNonBakeable) {
allParams.filter(isBakeable)
} else {
allParams
}
visibleParams.forEach { param ->
RecipeParamSlider(
param = param,
currentParams = currentParams,
onParamChange = onParamChange
)
}
}
}
}
}
}
}
}
@Composable
private fun ColorSectionTabs(
selectedSection: ColorPanelSection,
onSectionSelected: (ColorPanelSection) -> Unit,
modifier: Modifier = Modifier
) {
val tabs = listOf(
ColorPanelSection.BASIC to R.string.recipe_color_basic,
ColorPanelSection.CALIBRATION to R.string.recipe_tab_calibration,
ColorPanelSection.LCH to R.string.recipe_tab_lch,
)
Row(
modifier = modifier
.fillMaxWidth()
.background(Color.White.copy(alpha = 0.04f), RoundedCornerShape(8.dp))
.padding(3.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
tabs.forEach { (section, title) ->
val selected = section == selectedSection
Text(
text = stringResource(title),
color = if (selected) Color.White else Color.White.copy(alpha = 0.5f),
fontSize = 11.sp,
fontWeight = if (selected) FontWeight.Bold else FontWeight.Normal,
textAlign = TextAlign.Center,
modifier = Modifier
.weight(1f)
.clip(RoundedCornerShape(6.dp))
.background(if (selected) Color.White.copy(alpha = 0.14f) else Color.Transparent)
.clickable { onSectionSelected(section) }
.padding(vertical = 7.dp)
)
}
}
}
@Composable
private fun RecipeParamSlider(
param: RecipeParam,
currentParams: ColorRecipeParams,
onParamChange: (RecipeParam, Float) -> Unit
) {
key(param) {
ColorRecipeSlider(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
onDoubleTap = { onParamChange(param, param.defaultValue) }
)
}
}
@@ -1,17 +1,9 @@
package com.hinnka.mycamera.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -28,7 +20,6 @@ import androidx.compose.ui.unit.sp
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.model.RecipeParam
import kotlin.math.abs
import com.hinnka.mycamera.ui.icons.AppIcons
enum class EffectType(
val recipeParam: RecipeParam,
@@ -74,66 +65,8 @@ enum class EffectType(
}
}
@Composable
fun EffectsActionChip(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier
.clip(RoundedCornerShape(16.dp))
.background(
Color(0xFF00FFCC).copy(alpha = 0.15f)
)
.clickable(onClick = onClick)
.padding(horizontal = 12.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
imageVector = AppIcons.Layers,
contentDescription = stringResource(com.hinnka.mycamera.R.string.effects_title),
tint = Color(0xFF00FFCC),
modifier = Modifier.size(14.dp)
)
Text(
text = stringResource(com.hinnka.mycamera.R.string.effects_title),
color = Color.White,
fontSize = 11.sp,
fontWeight = FontWeight.Medium
)
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EffectsBottomSheet(
currentParams: EffectParams,
onParamsChange: (EffectParams) -> Unit,
onDismiss: () -> Unit,
modifier: Modifier = Modifier,
containerColor: Color = Color.Black.copy(alpha = 0.86f)
) {
ModalBottomSheet(
onDismissRequest = onDismiss,
containerColor = containerColor,
scrimColor = Color.Transparent,
dragHandle = { BottomSheetDefaults.DragHandle(color = Color.White.copy(alpha = 0.2f)) },
modifier = modifier
) {
EffectsPanel(
currentParams = currentParams,
onParamsChange = onParamsChange,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
.navigationBarsPadding()
)
}
}
/**
* 独立的物理画面效果控制面板
* 物理画面效果内容,由统一编辑面板作为“效果”参数组承载。
*/
@Composable
fun EffectsPanel(
@@ -146,13 +79,10 @@ fun EffectsPanel(
Column(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.weight(1f, fill = false)
.verticalScroll(rememberScrollState()),
.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
EffectType.entries.forEach { effect ->
@@ -0,0 +1,69 @@
package com.hinnka.mycamera.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.hinnka.mycamera.R
/**
* 编辑面板中的滤镜强度控制。
*/
@Composable
fun LutIntensitySlider(
intensity: Float,
onIntensityChange: (Float) -> Unit,
enabled: Boolean = true,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 6.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.filter_intensity),
color = if (enabled) Color.White else Color.Gray,
fontSize = 12.sp,
lineHeight = 14.sp
)
Text(
text = "${(intensity * 100).toInt()}%",
color = if (enabled) Color.White else Color.Gray,
fontSize = 10.sp,
lineHeight = 14.sp,
fontWeight = FontWeight.Bold
)
}
CustomSlider(
value = intensity,
onValueChange = onIntensityChange,
onDoubleTap = {
if (enabled) onIntensityChange(1f)
},
enabled = enabled,
valueRange = 0f..1f,
activeTrackColor = Color.White,
inactiveTrackColor = Color.Gray.copy(alpha = 0.5f),
thumbColor = Color.White,
modifier = Modifier.fillMaxWidth()
)
}
}
@@ -37,105 +37,11 @@ import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
import com.hinnka.mycamera.lut.LutInfo
import com.hinnka.mycamera.model.CameraPreset
import com.hinnka.mycamera.model.LutSelectorMode
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import com.hinnka.mycamera.ui.icons.AppIcons
@Composable
fun LutSelectorWithRecipeAction(
availableLuts: List<LutInfo>,
currentLutId: String?,
thumbnail: Bitmap?,
onLutSelected: (String?) -> Unit,
onEditRecipeClick: (() -> Unit)?,
onEditEffectClick: (() -> Unit)?,
modifier: Modifier = Modifier,
recipeIsCustomized: Boolean = false,
onManageClick: ((String) -> Unit)? = null,
categoryOrder: List<String> = emptyList()
) {
val selectedLutName = availableLuts.find { it.id == currentLutId }?.getName().orEmpty()
Column(modifier = modifier.fillMaxWidth()) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Column(verticalArrangement = Arrangement.spacedBy(2.dp), modifier = Modifier.weight(1f)) {
Text(
text = stringResource(R.string.filter).uppercase(),
color = Color.White.copy(alpha = 0.4f),
fontSize = 10.sp,
fontWeight = FontWeight.Bold,
letterSpacing = 1.sp
)
Text(
text = if (selectedLutName.isEmpty()) stringResource(R.string.none) else selectedLutName,
color = Color.White,
fontSize = 16.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.basicMarquee()
)
}
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
if (onEditRecipeClick != null) {
Row(
modifier = Modifier
.clip(RoundedCornerShape(16.dp))
.background(
if (recipeIsCustomized) Color(0xFFFF9800).copy(alpha = 0.15f)
else Color.White.copy(alpha = 0.1f)
)
.clickable { onEditRecipeClick() }
.padding(horizontal = 10.dp, vertical = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
imageVector = AppIcons.Tune,
contentDescription = null,
tint = if (recipeIsCustomized) Color(0xFFFF9800) else Color(0xFFFFD700),
modifier = Modifier.size(14.dp)
)
Text(
text = stringResource(R.string.color_recipe),
color = Color.White,
fontSize = 11.sp,
fontWeight = FontWeight.Medium
)
}
}
if (onEditEffectClick != null) {
EffectsActionChip(
onClick = { onEditEffectClick() }
)
}
}
}
Spacer(modifier = Modifier.height(8.dp))
LutSelector(
availableLuts = availableLuts,
currentLutId = currentLutId,
thumbnail = thumbnail,
onLutSelected = onLutSelected,
onEditClick = onEditRecipeClick,
onManageClick = onManageClick,
categoryOrder = categoryOrder
)
}
}
private sealed class LutCategoryTab {
data object Favorite : LutCategoryTab()
data object BuiltIn : LutCategoryTab()
@@ -178,7 +84,6 @@ fun LutSelector(
) {
val scrollState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
var showLutEditDialogState by remember { mutableStateOf(false) }
val favoriteText = stringResource(R.string.favorite)
val builtInText = stringResource(R.string.built_in)
val uncategorizedText = stringResource(R.string.uncategorized)
@@ -258,8 +163,6 @@ fun LutSelector(
}
}
val actualShowLutEditDialog = onEditClick == null && showLutEditDialogState
// 在组件首次加载时滚动到当前选中的 LUT
LaunchedEffect(activeLutId, actualMode, filteredLuts) {
if (actualMode == LutSelectorMode.Style) {
@@ -274,16 +177,6 @@ fun LutSelector(
}
}
// 全局 LUT 编辑底部弹窗
if (actualShowLutEditDialog && currentLutId != null) {
LutEditBottomSheet(
lutId = currentLutId,
onDismiss = {
showLutEditDialogState = false
}
)
}
Column(modifier = modifier.fillMaxWidth()) {
if (allPresets.isNotEmpty()) {
Row(
@@ -384,11 +277,7 @@ fun LutSelector(
isCustom = !lut.isBuiltIn,
onClick = {
if (currentLutId == lut.id) {
if (onEditClick != null) {
onEditClick()
} else {
showLutEditDialogState = true
}
onEditClick?.invoke()
} else {
onLutSelected(lut.id)
}
@@ -592,30 +481,6 @@ private fun LutItem(
)
}
if (isSelected) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Black.copy(alpha = 0.3f)),
contentAlignment = Alignment.Center
) {
Box(
modifier = Modifier
.size(24.dp)
.background(Color.White.copy(alpha = 0.2f), CircleShape)
.border(1.dp, Color.White.copy(alpha = 0.5f), CircleShape),
contentAlignment = Alignment.Center
) {
Icon(
imageVector = AppIcons.Tune,
contentDescription = stringResource(R.string.edit),
tint = Color.White,
modifier = Modifier.size(14.dp)
)
}
}
}
if (isVip) {
Box(
modifier = Modifier
@@ -53,6 +53,8 @@ import me.saket.telephoto.zoomable.coil.ZoomableAsyncImage
import me.saket.telephoto.zoomable.rememberZoomableImageState
import me.saket.telephoto.zoomable.rememberZoomableState
import com.hinnka.mycamera.gallery.MediaData
import com.hinnka.mycamera.model.ColorPaletteMapper
import com.hinnka.mycamera.model.ColorPaletteState
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.toEffectParams
import com.hinnka.mycamera.raw.SpectralFilmSelection
@@ -60,7 +62,6 @@ import com.hinnka.mycamera.raw.SpectralFilmTuning
import com.hinnka.mycamera.raw.HncsProfileManager
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
import com.hinnka.mycamera.ui.camera.LutEditorTarget
import com.hinnka.mycamera.ui.camera.RecipeScope
import com.hinnka.mycamera.ui.components.*
import com.hinnka.mycamera.ui.components.RawEditPanel
import com.hinnka.mycamera.ui.components.RawBaselineColorCorrectionBottomSheet
@@ -94,11 +95,16 @@ import com.hinnka.mycamera.ui.components.RawEditPanelContentMode
import me.saket.telephoto.zoomable.DoubleClickToZoomListener
import com.hinnka.mycamera.ui.icons.AppIcons
private const val EDIT_TAB_LUT = 0
private const val EDIT_TAB_ADJUSTMENTS = 1
private const val EDIT_TAB_DETAIL = 2
private const val EDIT_TAB_RAW = 3
private const val EDIT_TAB_CROP = 4
private data class PreviewRenderSignature(
val photoId: String,
val refreshKey: Long,
val editLutId: String?,
val previewRecipeParamsOverride: ColorRecipeParams?,
val editPhotoRecipeParams: ColorRecipeParams?,
val editLutRecipeParams: ColorRecipeParams?,
val editLutConfig: Any?,
@@ -172,14 +178,11 @@ fun GalleryEditScreen(
var isSaving by remember { mutableStateOf(false) }
var isLoadingPreview by remember { mutableStateOf(false) }
val lutScrollState = rememberLazyListState()
val frameScrollState = rememberLazyListState()
var showLutEditDialog by remember { mutableStateOf(false) }
var showBaselineLutEditSheet by remember { mutableStateOf(false) }
var baselineLutEditId by remember { mutableStateOf<String?>(null) }
var showRawBaselineLutSelectorSheet by remember { mutableStateOf(false) }
var previewRecipeParamsOverride by remember(editLutId) { mutableStateOf<ColorRecipeParams?>(null) }
var showEffectsSheet by remember { mutableStateOf(false) }
var syncAdjustmentsToLut by remember(editLutId) { mutableStateOf(false) }
BackHandler {
viewModel.exitEditMode()
@@ -246,15 +249,13 @@ fun GalleryEditScreen(
var showOrigin by remember { mutableStateOf(false) }
// 编辑标签页状态
var editTab by remember { mutableIntStateOf(0) } // 0: 滤镜/边框, 1: 细节处理, 2: RAW, 3: 裁剪
var editTab by remember { mutableIntStateOf(EDIT_TAB_LUT) }
var showControls by remember { mutableStateOf(true) }
var isZoomed by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
val refreshKey = editSourcePhoto?.id?.let { viewModel.photoRefreshKeys[it] } ?: 0L
val isBaselineLutEditSheetVisible = showBaselineLutEditSheet && baselineLutEditId != null
val isLutEditSheetVisible = (showLutEditDialog || showEffectsSheet) && editLutId != null
val shouldShowEditControls = showControls &&
!isLutEditSheetVisible &&
!isBaselineLutEditSheetVisible &&
!showRawBaselineLutSelectorSheet
@@ -263,7 +264,7 @@ fun GalleryEditScreen(
)
var previewRenderRequestId by remember { mutableLongStateOf(0L) }
val shouldCalculateImageHistogram =
(showLutEditDialog && editLutId != null) || isBaselineLutEditSheetVisible
(editTab == EDIT_TAB_ADJUSTMENTS && editLutId != null) || isBaselineLutEditSheetVisible
fun currentPreviewSignature(fast: Boolean = false): PreviewRenderSignature? {
val photo = editSourcePhoto ?: return null
@@ -272,7 +273,6 @@ fun GalleryEditScreen(
photoId = photo.id,
refreshKey = refreshKey,
editLutId = editLutId,
previewRecipeParamsOverride = previewRecipeParamsOverride,
editPhotoRecipeParams = editPhotoRecipeParams,
editLutRecipeParams = editLutRecipeParams,
editLutConfig = editLutConfig,
@@ -327,8 +327,7 @@ fun GalleryEditScreen(
photo,
useGlobalEdit = true,
showOrigin = showOrigin,
ignoreCrop = editTab == 3,
recipeParamsOverride = previewRecipeParamsOverride,
ignoreCrop = editTab == EDIT_TAB_CROP,
maxEdge = maxEdge
)
}
@@ -435,15 +434,6 @@ fun GalleryEditScreen(
}
}
LaunchedEffect(editLutId) {
editLutId?.let { lutId ->
val selectedIndex = availableLuts.indexOfFirst { it.id == lutId }
if (selectedIndex >= 2) {
lutScrollState.animateScrollToItem(selectedIndex - 2)
}
}
}
LaunchedEffect(editFrameId) {
editFrameId?.let { lutId ->
val selectedIndex = availableFrames.indexOfFirst { it.id == lutId }
@@ -705,7 +695,7 @@ fun GalleryEditScreen(
if (!isMultiTouch && !isMoved) {
if (upEvent != null) {
// 快速点击:切换控制区域显隐,或者调整景深焦点
if (editTab == 1 && viewModel.editComputationalAperture.value != null && previewBitmap != null) {
if (editTab == EDIT_TAB_DETAIL && viewModel.editComputationalAperture.value != null && previewBitmap != null) {
val tapPosition = upEvent.changes[0].position
val boxWidth = size.width.toFloat()
val boxHeight = size.height.toFloat()
@@ -758,10 +748,10 @@ fun GalleryEditScreen(
VideoEditPlayer(
photo = currentPhoto,
lutConfig = editLutConfig,
recipeParams = if (showOrigin) null else (previewRecipeParamsOverride ?: editPhotoRecipeParams ?: editLutRecipeParams),
recipeParams = if (showOrigin) null else (editPhotoRecipeParams ?: editLutRecipeParams),
modifier = Modifier.fillMaxSize()
)
} else if (editTab == 3 && previewBitmap != null) {
} else if (editTab == EDIT_TAB_CROP && previewBitmap != null) {
CropOverlay(
bitmap = previewBitmap,
cropRect = editCropRect ?: android.graphics.RectF(0f, 0f, 1f, 1f),
@@ -773,7 +763,7 @@ fun GalleryEditScreen(
} else {
ZoomableEditImage(
previewBitmap = previewBitmap,
isLutEditing = isLutEditSheetVisible || isBaselineLutEditSheetVisible,
isLutEditing = editTab == EDIT_TAB_ADJUSTMENTS || isBaselineLutEditSheetVisible,
contentDescription = stringResource(R.string.edit),
onZoomChange = {
isZoomed = it
@@ -905,78 +895,54 @@ fun GalleryEditScreen(
) {
// 标签页切换
Row(
modifier = Modifier.fillMaxWidth().padding(top = 16.dp),
modifier = Modifier
.fillMaxWidth()
.horizontalScroll(rememberScrollState())
.padding(top = 16.dp),
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
TabItem(
title = stringResource(R.string.filter) + " & " + stringResource(R.string.frame),
isSelected = editTab == 0,
onClick = { editTab = 0 }
isSelected = editTab == EDIT_TAB_LUT,
onClick = { editTab = EDIT_TAB_LUT }
)
TabItem(
title = stringResource(R.string.edit),
isSelected = editTab == EDIT_TAB_ADJUSTMENTS,
onClick = { editTab = EDIT_TAB_ADJUSTMENTS }
)
TabItem(
title = stringResource(R.string.recipe_tab_post),
isSelected = editTab == 1,
onClick = { editTab = 1 }
isSelected = editTab == EDIT_TAB_DETAIL,
onClick = { editTab = EDIT_TAB_DETAIL }
)
if (isRaw) {
TabItem(
title = "RAW",
isSelected = editTab == 2,
onClick = { editTab = 2 }
isSelected = editTab == EDIT_TAB_RAW,
onClick = { editTab = EDIT_TAB_RAW }
)
}
if (!currentPhoto.isVideo) {
TabItem(
title = stringResource(R.string.crop),
isSelected = editTab == 3,
onClick = { editTab = 3 }
isSelected = editTab == EDIT_TAB_CROP,
onClick = { editTab = EDIT_TAB_CROP }
)
}
}
Column(modifier = Modifier.heightIn(max = 550.dp).verticalScroll(rememberScrollState())) {
when (editTab) {
0 -> {
if (currentPhoto.isMotionPhoto) {
val applyEffectsToVideo by viewModel.editApplyEffectsToVideo.collectAsState()
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 12.dp, bottom = 4.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = applyEffectsToVideo,
onCheckedChange = { viewModel.setApplyEffectsToVideo(it) },
colors = CheckboxDefaults.colors(
checkedColor = AccentOrange,
uncheckedColor = Color.White.copy(alpha = 0.6f),
checkmarkColor = Color.Black
)
)
Spacer(modifier = Modifier.width(8.dp))
Text(
text = stringResource(R.string.edit_embedded_video_simultaneously),
color = Color.White,
fontSize = 14.sp
)
}
}
EDIT_TAB_LUT -> {
Spacer(modifier = Modifier.height(16.dp))
LutSelectorWithRecipeAction(
LutSelector(
availableLuts = viewModel.availableLuts,
currentLutId = editLutId,
thumbnail = thumbnailBitmap,
onLutSelected = { viewModel.setEditLut(it) },
onEditRecipeClick = if (editLutId != null) {
{ showLutEditDialog = true }
} else null,
onEditEffectClick = if (editLutId != null) {
{ showEffectsSheet = true }
} else null,
recipeIsCustomized = editPhotoRecipeParams != null,
onManageClick = { onFilterManagementClick(it) },
categoryOrder = categoryOrder
categoryOrder = categoryOrder,
modifier = Modifier.fillMaxWidth()
)
if (!currentPhoto.isVideo) {
@@ -1060,7 +1026,171 @@ fun GalleryEditScreen(
}
}
}
1 -> {
EDIT_TAB_ADJUSTMENTS -> {
Spacer(modifier = Modifier.height(6.dp))
if (editLutId == null) {
Text(
text = stringResource(R.string.edit_select_lut_hint),
color = Color.White.copy(alpha = 0.55f),
fontSize = 13.sp,
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp, vertical = 28.dp)
)
} else {
val effectiveRecipe = editPhotoRecipeParams ?: editLutRecipeParams
val paletteState = ColorPaletteState(
x = effectiveRecipe.paletteX,
y = effectiveRecipe.paletteY,
density = effectiveRecipe.paletteDensity
).normalized()
val applyEffectsToVideo by viewModel.editApplyEffectsToVideo.collectAsState()
ColorRecipePanel(
currentParams = effectiveRecipe,
paletteState = paletteState,
onPaletteStateChange = { state ->
viewModel.setPhotoRecipeParams(
ColorPaletteMapper.updatePaletteState(
effectiveRecipe,
state.normalized()
),
syncToCurrentLut = syncAdjustmentsToLut
)
},
onParamChange = { param, value ->
viewModel.setPhotoRecipeParams(
param.setValue(effectiveRecipe, value),
syncToCurrentLut = syncAdjustmentsToLut
)
},
onParamsChange = { params ->
viewModel.setPhotoRecipeParams(
params,
syncToCurrentLut = syncAdjustmentsToLut
)
},
onRemarksChange = { remarks ->
viewModel.setPhotoRecipeParams(
effectiveRecipe.copy(remarks = remarks),
syncToCurrentLut = syncAdjustmentsToLut
)
},
onCurveChange = { channel, points ->
val updated = when (channel) {
CurveChannel.MASTER -> effectiveRecipe.copy(masterCurvePoints = points)
CurveChannel.RED -> effectiveRecipe.copy(redCurvePoints = points)
CurveChannel.GREEN -> effectiveRecipe.copy(greenCurvePoints = points)
CurveChannel.BLUE -> effectiveRecipe.copy(blueCurvePoints = points)
}
viewModel.setPhotoRecipeParams(
updated,
syncToCurrentLut = syncAdjustmentsToLut
)
},
imageHistogram = imageHistogram,
showLutIntensity = true,
currentEffects = effectiveRecipe.toEffectParams(),
onEffectsChange = { effects ->
val latestRecipe = viewModel.editPhotoRecipeParams.value
?: viewModel.editLutRecipeParams.value
viewModel.setPhotoRecipeParams(
effects.applyTo(latestRecipe),
syncToCurrentLut = syncAdjustmentsToLut
)
},
optionControls = {
Column(modifier = Modifier.fillMaxWidth()) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 7.dp),
verticalAlignment = Alignment.CenterVertically
) {
Column(
modifier = Modifier
.weight(1f)
.padding(end = 10.dp)
) {
Text(
text = stringResource(R.string.edit_sync_lut_recipe),
color = Color.White,
fontSize = 12.sp,
fontWeight = FontWeight.Medium
)
Text(
text = stringResource(
R.string.edit_sync_lut_recipe_description
),
color = Color.White.copy(alpha = 0.48f),
fontSize = 9.sp,
lineHeight = 12.sp
)
}
Switch(
checked = syncAdjustmentsToLut,
onCheckedChange = { enabled ->
syncAdjustmentsToLut = enabled
if (enabled) {
viewModel.setPhotoRecipeParams(
effectiveRecipe,
syncToCurrentLut = true
)
}
},
colors = SwitchDefaults.colors(
checkedThumbColor = Color.Black,
checkedTrackColor = AccentOrange,
uncheckedThumbColor = Color.White.copy(alpha = 0.75f),
uncheckedTrackColor = Color.White.copy(alpha = 0.16f),
uncheckedBorderColor = Color.White.copy(alpha = 0.3f)
)
)
}
if (currentPhoto.isMotionPhoto) {
HorizontalDivider(
color = Color.White.copy(alpha = 0.08f)
)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(
R.string.edit_embedded_video_simultaneously
),
color = Color.White,
fontSize = 12.sp,
modifier = Modifier
.weight(1f)
.padding(end = 10.dp)
)
Switch(
checked = applyEffectsToVideo,
onCheckedChange = {
viewModel.setApplyEffectsToVideo(it)
},
colors = SwitchDefaults.colors(
checkedThumbColor = Color.Black,
checkedTrackColor = AccentOrange,
uncheckedThumbColor = Color.White.copy(alpha = 0.75f),
uncheckedTrackColor = Color.White.copy(alpha = 0.16f),
uncheckedBorderColor = Color.White.copy(alpha = 0.3f)
)
)
}
}
}
},
modifier = Modifier.fillMaxWidth()
)
}
}
EDIT_TAB_DETAIL -> {
Spacer(modifier = Modifier.height(16.dp))
if (!currentPhoto.isVideo) {
val isDnCNNDenoising by viewModel.isAiDenoising.collectAsState()
@@ -1169,7 +1299,7 @@ fun GalleryEditScreen(
}
)
}
2 -> {
EDIT_TAB_RAW -> {
RawEditPanel(
selectedDcpId = editRawDcpId,
availableDcps = availableDcps,
@@ -1348,7 +1478,7 @@ fun GalleryEditScreen(
}
)
}
3 -> {
EDIT_TAB_CROP -> {
if (!currentPhoto.isVideo) {
// 裁剪编辑
val availablePhotoAspectRatios by cameraViewModel.availablePhotoAspectRatios.collectAsState()
@@ -1376,38 +1506,6 @@ fun GalleryEditScreen(
}
}
if (showEffectsSheet) {
val currentRecipe = previewRecipeParamsOverride ?: editPhotoRecipeParams ?: editLutRecipeParams
val currentEffectParams = currentRecipe.toEffectParams()
EffectsBottomSheet(
currentParams = currentEffectParams,
onParamsChange = { newParams ->
viewModel.setPhotoEffectParams(newParams, currentRecipe)
},
onDismiss = { showEffectsSheet = false },
containerColor = Color(0x151A1A1A)
)
}
if (showLutEditDialog && editLutId != null) {
LutEditBottomSheet(
lutId = editLutId!!,
initialParams = previewRecipeParamsOverride ?: editPhotoRecipeParams ?: editLutRecipeParams,
onParamsPreviewChange = {
previewRecipeParamsOverride = it
},
imageHistogram = imageHistogram,
onDismiss = {
previewRecipeParamsOverride = null
showLutEditDialog = false
},
photoRecipeParams = editPhotoRecipeParams,
onPhotoParamsChange = { viewModel.setPhotoRecipeParams(it) },
defaultScope = RecipeScope.PHOTO_LOCAL,
containerColor = Color(0x151A1A1A)
)
}
if (isBaselineLutEditSheetVisible) {
LutEditBottomSheet(
lutId = baselineLutEditId!!,
@@ -29,14 +29,13 @@ import com.hinnka.mycamera.model.ColorPaletteState
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.ui.components.ColorRecipePanel
import com.hinnka.mycamera.ui.components.LutSelectorWithRecipeAction
import com.hinnka.mycamera.ui.components.LutSelector
import com.hinnka.mycamera.ui.components.CurveChannel
import com.hinnka.mycamera.raw.HncsFilmCurveMode
import com.hinnka.mycamera.raw.RawProfileToneMapMode
import com.hinnka.mycamera.raw.RawRenderingEngine
import com.hinnka.mycamera.raw.HncsProfileManager
import com.hinnka.mycamera.raw.SpectralFilmUiInfo
import com.hinnka.mycamera.ui.components.EffectsBottomSheet
import com.hinnka.mycamera.ui.components.FrameSelector
import com.hinnka.mycamera.ui.components.RawBaselineColorCorrectionSelector
import com.hinnka.mycamera.ui.components.RawDcpSelector
@@ -128,8 +127,7 @@ fun PresetEditorScreen(
var expandSettings by remember { mutableStateOf(false) }
var expandQuickRaw by remember { mutableStateOf(false) }
var expandBaseline by remember { mutableStateOf(false) }
var showColorRecipeSheet by remember { mutableStateOf(false) }
var showEffectsSheet by remember { mutableStateOf(false) }
var showEditSheet by remember { mutableStateOf(false) }
var baselineRecipeEditLutId by remember { mutableStateOf<String?>(null) }
var baselineRecipeEditorTarget by remember { mutableStateOf<LutEditorTarget?>(null) }
@@ -244,18 +242,32 @@ fun PresetEditorScreen(
}
SettingsSection(title = stringResource(R.string.filter), isExpandable = false) {
LutSelectorWithRecipeAction(
LutSelector(
availableLuts = availableLuts,
currentLutId = selectedLutId,
thumbnail = null,
onLutSelected = { selectedLutId = it },
onEditRecipeClick = { showColorRecipeSheet = true },
onEditEffectClick = { showEffectsSheet = true },
recipeIsCustomized = !colorRecipe.isDefault(),
modifier = Modifier.fillMaxWidth()
)
}
SettingsSection(title = stringResource(R.string.edit), isExpandable = false) {
OutlinedButton(
onClick = { showEditSheet = true },
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.White),
border = androidx.compose.foundation.BorderStroke(
1.dp,
Color.White.copy(alpha = 0.18f)
)
) {
Text(
text = stringResource(R.string.edit_color_and_effects),
fontSize = 13.sp
)
}
}
SettingsSection(title = stringResource(R.string.settings_section_frame), isExpandable = false) {
FrameSelector(
availableFrames = availableFrames,
@@ -316,9 +328,9 @@ fun PresetEditorScreen(
}
if (showColorRecipeSheet) {
if (showEditSheet) {
ModalBottomSheet(
onDismissRequest = { showColorRecipeSheet = false },
onDismissRequest = { showEditSheet = false },
containerColor = Color.Black.copy(alpha = 0.86f),
scrimColor = Color.Transparent,
dragHandle = { BottomSheetDefaults.DragHandle(color = Color.White.copy(alpha = 0.2f)) }
@@ -357,6 +369,9 @@ fun PresetEditorScreen(
}
},
hideNonBakeable = true,
showLutIntensity = true,
currentEffects = effects,
onEffectsChange = { effects = it },
modifier = Modifier
.fillMaxWidth()
.navigationBarsPadding()
@@ -364,14 +379,6 @@ fun PresetEditorScreen(
}
}
if (showEffectsSheet) {
EffectsBottomSheet(
currentParams = effects,
onParamsChange = { effects = it },
onDismiss = { showEffectsSheet = false }
)
}
val editBaselineRecipe: (String, LutEditorTarget) -> Unit = { lutId, target ->
baselineRecipeEditLutId = lutId
baselineRecipeEditorTarget = target
@@ -34,7 +34,6 @@ import com.hinnka.mycamera.lut.exportVideoWithEffects
import com.hinnka.mycamera.lut.isVideoTransformerExportSupported
import com.hinnka.mycamera.lut.creator.OpenAIApiClient
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.raw.DcpInfo
import com.hinnka.mycamera.raw.HncsFilmCurveMode
import com.hinnka.mycamera.raw.HncsRenderIntent
@@ -255,6 +254,9 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
var editPhotoRecipeParams = MutableStateFlow<ColorRecipeParams?>(null)
private set
private var editLutRecipeSyncJob: Job? = null
private var pendingEditLutRecipeSync: Pair<String, ColorRecipeParams>? = null
var editLutConfig: LutConfig? by mutableStateOf(null)
private set
@@ -2086,6 +2088,9 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
* 退出编辑模式
*/
fun exitEditMode() {
viewModelScope.launch {
flushPendingEditLutRecipeSync()
}
isEditing = false
editLutId.value = null
editLutConfig = null
@@ -2126,13 +2131,29 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
/**
* 设置照片级别的色彩配方覆盖(null = 清除覆盖,跟随 LUT 默认)
*/
fun setPhotoRecipeParams(params: ColorRecipeParams?) {
fun setPhotoRecipeParams(
params: ColorRecipeParams?,
syncToCurrentLut: Boolean = false
) {
editPhotoRecipeParams.value = params
if (syncToCurrentLut && params != null) {
val lutId = editLutId.value ?: return
pendingEditLutRecipeSync = lutId to params
editLutRecipeSyncJob?.cancel()
editLutRecipeSyncJob = viewModelScope.launch {
delay(250)
editLutRecipeSyncJob = null
flushPendingEditLutRecipeSync()
}
}
}
fun setPhotoEffectParams(params: EffectParams, baseRecipeOverride: ColorRecipeParams? = null) {
val baseRecipe = baseRecipeOverride ?: editPhotoRecipeParams.value ?: editLutRecipeParams.value
editPhotoRecipeParams.value = params.applyTo(baseRecipe)
private suspend fun flushPendingEditLutRecipeSync() {
editLutRecipeSyncJob?.cancel()
editLutRecipeSyncJob = null
val (lutId, params) = pendingEditLutRecipeSync ?: return
pendingEditLutRecipeSync = null
contentRepository.lutManager.saveColorRecipeParams(lutId, params)
}
/**
@@ -3074,6 +3095,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
viewModelScope.launch {
try {
flushPendingEditLutRecipeSync()
val context = getApplication<Application>()
val wasSystemPhoto = selectedTab == GalleryTab.SYSTEM
@@ -402,11 +402,11 @@
<!-- Color Recipe -->
<string name="color_recipe">色彩配方</string>
<string name="effects_title">效果</string>
<string name="recipe_scope_lut">LUT 預設</string>
<string name="recipe_scope_photo">僅此相片</string>
<string name="recipe_scope_photo_reset">還原 LUT 預設</string>
<string name="color_recipe_reset_all">重置所有參數</string>
<string name="recipe_scope_photo_hint">調整僅作用于這張相片</string>
<string name="color_recipe_reset_all">重置</string>
<string name="edit_sync_lut_recipe">同時更新目前 LUT</string>
<string name="edit_sync_lut_recipe_description">色彩、效果與濾鏡強度都會同時寫入目前 LUT。</string>
<string name="edit_select_lut_hint">請先選擇一個 LUT,再調整色彩與效果。</string>
<string name="edit_color_and_effects">調整色彩與效果</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">曝光</string>
@@ -468,6 +468,7 @@
<!-- Color Recipe Tabs -->
<string name="recipe_tab_color">色彩</string>
<string name="recipe_color_basic">基礎</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">亮度</string>
<string name="recipe_tab_curve">曲線</string>
@@ -481,7 +482,7 @@
<string name="recipe_lch_blue">藍</string>
<string name="recipe_lch_purple">紫</string>
<string name="recipe_lch_magenta">品紅</string>
<string name="recipe_tab_texture">效果</string>
<string name="recipe_tab_texture">質感</string>
<string name="recipe_tab_lens">氛圍</string>
<string name="recipe_tab_post">細節</string>
<string name="recipe_tab_remarks">備注</string>
+5
View File
@@ -167,7 +167,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">Aktuelle LUT ebenfalls aktualisieren</string>
<string name="edit_sync_lut_recipe_description">Farbe, Effekte und LUT-Intensität werden auch in der ausgewählten LUT gespeichert.</string>
<string name="edit_select_lut_hint">Wähle zuerst eine LUT aus, um Farbe und Effekte anzupassen.</string>
<string name="edit_color_and_effects">Farbe und Effekte anpassen</string>
<string name="recipe_tab_color">Farbe</string>
<string name="recipe_color_basic">Grundlagen</string>
<string name="recipe_tab_light">Licht</string>
<string name="recipe_tab_texture">Textur</string>
<string name="recipe_tab_post">Entwicklung</string>
+5
View File
@@ -167,7 +167,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">Mettre aussi à jour la LUT actuelle</string>
<string name="edit_sync_lut_recipe_description">La couleur, les effets et l’intensité LUT sont aussi enregistrés dans la LUT sélectionnée.</string>
<string name="edit_select_lut_hint">Sélectionnez d’abord une LUT pour régler la couleur et les effets.</string>
<string name="edit_color_and_effects">Régler la couleur et les effets</string>
<string name="recipe_tab_color">Couleur</string>
<string name="recipe_color_basic">Base</string>
<string name="recipe_tab_light">Lumière</string>
<string name="recipe_tab_texture">Texture</string>
<string name="recipe_tab_post">Développement</string>
+5
View File
@@ -167,7 +167,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">Perbarui juga LUT saat ini</string>
<string name="edit_sync_lut_recipe_description">Warna, efek, dan intensitas LUT juga disimpan ke LUT yang dipilih.</string>
<string name="edit_select_lut_hint">Pilih LUT sebelum menyesuaikan warna dan efek.</string>
<string name="edit_color_and_effects">Sesuaikan warna dan efek</string>
<string name="recipe_tab_color">Warna</string>
<string name="recipe_color_basic">Dasar</string>
<string name="recipe_tab_light">Cahaya</string>
<string name="recipe_tab_texture">Tekstur</string>
<string name="recipe_tab_post">Pasca</string>
+5
View File
@@ -167,7 +167,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">現在の LUT も更新</string>
<string name="edit_sync_lut_recipe_description">カラー、エフェクト、LUT 強度も選択中の LUT に保存します。</string>
<string name="edit_select_lut_hint">カラーとエフェクトを調整する前に LUT を選択してください。</string>
<string name="edit_color_and_effects">カラーとエフェクトを調整</string>
<string name="recipe_tab_color">カラー</string>
<string name="recipe_color_basic">基本</string>
<string name="recipe_tab_light">ライト</string>
<string name="recipe_tab_texture">テクスチャ</string>
<string name="recipe_tab_post">現像</string>
+5
View File
@@ -168,7 +168,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">현재 LUT도 업데이트</string>
<string name="edit_sync_lut_recipe_description">색상, 효과, LUT 강도도 선택한 LUT에 저장합니다.</string>
<string name="edit_select_lut_hint">색상과 효과를 조정하기 전에 LUT를 선택하세요.</string>
<string name="edit_color_and_effects">색상 및 효과 조정</string>
<string name="recipe_tab_color">색상</string>
<string name="recipe_color_basic">기본</string>
<string name="recipe_tab_light">빛</string>
<string name="recipe_tab_texture">질감</string>
<string name="recipe_tab_post">후보정</string>
@@ -168,7 +168,12 @@
<string name="recipe_param_lut_intensity">LUT</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">Atualizar também a LUT atual</string>
<string name="edit_sync_lut_recipe_description">Cor, efeitos e intensidade da LUT também são salvos na LUT selecionada.</string>
<string name="edit_select_lut_hint">Selecione uma LUT antes de ajustar cor e efeitos.</string>
<string name="edit_color_and_effects">Ajustar cor e efeitos</string>
<string name="recipe_tab_color">Cor</string>
<string name="recipe_color_basic">Básico</string>
<string name="recipe_tab_light">Luz</string>
<string name="recipe_tab_texture">Textura</string>
<string name="recipe_tab_post">Pós</string>
+5 -5
View File
@@ -288,11 +288,6 @@
<!-- Color Recipe -->
<string name="color_recipe">สูตรสี (Color Recipe)</string>
<string name="effects_title">ผล</string>
<string name="recipe_scope_lut">ค่าเริ่มต้นของ LUT</string>
<string name="recipe_scope_photo">เฉพาะรูปนี้เท่านั้น</string>
<string name="recipe_scope_photo_reset">คืนค่าเริ่มต้น LUT</string>
<string name="color_recipe_reset_all">รีเซ็ตพารามิเตอร์ทั้งหมด</string>
<string name="recipe_scope_photo_hint">การปรับเปลี่ยนมีผลกับรูปภาพนี้เท่านั้น</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">การรับแสง</string>
@@ -353,7 +348,12 @@
<string name="recipe_param_primary_blue_lightness">ความสว่างของสีหลักสีน้ำเงิน</string>
<!-- Color Recipe Tabs -->
<string name="edit_sync_lut_recipe">อัปเดต LUT ปัจจุบันด้วย</string>
<string name="edit_sync_lut_recipe_description">สี เอฟเฟกต์ และความเข้ม LUT จะบันทึกไปยัง LUT ที่เลือกด้วย</string>
<string name="edit_select_lut_hint">เลือก LUT ก่อนปรับสีและเอฟเฟกต์</string>
<string name="edit_color_and_effects">ปรับสีและเอฟเฟกต์</string>
<string name="recipe_tab_color">สี</string>
<string name="recipe_color_basic">พื้นฐาน</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">แสง</string>
<string name="recipe_tab_curve">เส้นโค้ง</string>
+7 -6
View File
@@ -402,11 +402,11 @@
<!-- Color Recipe -->
<string name="color_recipe">色彩配方</string>
<string name="effects_title">效果</string>
<string name="recipe_scope_lut">LUT 默认</string>
<string name="recipe_scope_photo">仅此照片</string>
<string name="recipe_scope_photo_reset">恢复 LUT 默认</string>
<string name="color_recipe_reset_all">重置所有参数</string>
<string name="recipe_scope_photo_hint">调整仅作用于这张照片</string>
<string name="color_recipe_reset_all">重置</string>
<string name="edit_sync_lut_recipe">同时更新当前 LUT</string>
<string name="edit_sync_lut_recipe_description">色彩、效果和滤镜强度都会同时写入当前 LUT。</string>
<string name="edit_select_lut_hint">请先选择一个 LUT,再调整色彩与效果。</string>
<string name="edit_color_and_effects">调整色彩与效果</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">曝光</string>
@@ -468,6 +468,7 @@
<!-- Color Recipe Tabs -->
<string name="recipe_tab_color">颜色</string>
<string name="recipe_color_basic">基础</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">亮度</string>
<string name="recipe_tab_curve">曲线</string>
@@ -481,7 +482,7 @@
<string name="recipe_lch_blue">蓝</string>
<string name="recipe_lch_purple">紫</string>
<string name="recipe_lch_magenta">品红</string>
<string name="recipe_tab_texture">效果</string>
<string name="recipe_tab_texture">质感</string>
<string name="recipe_tab_lens">氛围</string>
<string name="recipe_tab_post">细节</string>
<string name="recipe_tab_remarks">备注</string>
+7 -6
View File
@@ -402,11 +402,11 @@
<!-- Color Recipe -->
<string name="color_recipe">色彩配方</string>
<string name="effects_title">效果</string>
<string name="recipe_scope_lut">LUT 預設</string>
<string name="recipe_scope_photo">僅此相片</string>
<string name="recipe_scope_photo_reset">還原 LUT 預設</string>
<string name="color_recipe_reset_all">重置所有參數</string>
<string name="recipe_scope_photo_hint">調整僅作用于這張相片</string>
<string name="color_recipe_reset_all">重置</string>
<string name="edit_sync_lut_recipe">同時更新目前 LUT</string>
<string name="edit_sync_lut_recipe_description">色彩、效果與濾鏡強度都會同時寫入目前 LUT。</string>
<string name="edit_select_lut_hint">請先選擇一個 LUT,再調整色彩與效果。</string>
<string name="edit_color_and_effects">調整色彩與效果</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">曝光</string>
@@ -468,6 +468,7 @@
<!-- Color Recipe Tabs -->
<string name="recipe_tab_color">色彩</string>
<string name="recipe_color_basic">基礎</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">亮度</string>
<string name="recipe_tab_curve">曲線</string>
@@ -481,7 +482,7 @@
<string name="recipe_lch_blue">藍</string>
<string name="recipe_lch_purple">紫</string>
<string name="recipe_lch_magenta">品紅</string>
<string name="recipe_tab_texture">效果</string>
<string name="recipe_tab_texture">質感</string>
<string name="recipe_tab_lens">氛圍</string>
<string name="recipe_tab_post">細節</string>
<string name="recipe_tab_remarks">備注</string>
+7 -6
View File
@@ -402,11 +402,11 @@
<!-- Color Recipe -->
<string name="color_recipe">色彩配方</string>
<string name="effects_title">效果</string>
<string name="recipe_scope_lut">LUT 預設</string>
<string name="recipe_scope_photo">僅此相片</string>
<string name="recipe_scope_photo_reset">還原 LUT 預設</string>
<string name="color_recipe_reset_all">重置所有參數</string>
<string name="recipe_scope_photo_hint">調整僅作用于這張相片</string>
<string name="color_recipe_reset_all">重置</string>
<string name="edit_sync_lut_recipe">同時更新目前 LUT</string>
<string name="edit_sync_lut_recipe_description">色彩、效果與濾鏡強度都會同時寫入目前 LUT。</string>
<string name="edit_select_lut_hint">請先選擇一個 LUT,再調整色彩與效果。</string>
<string name="edit_color_and_effects">調整色彩與效果</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">曝光</string>
@@ -468,6 +468,7 @@
<!-- Color Recipe Tabs -->
<string name="recipe_tab_color">色彩</string>
<string name="recipe_color_basic">基礎</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">亮度</string>
<string name="recipe_tab_curve">曲線</string>
@@ -481,7 +482,7 @@
<string name="recipe_lch_blue">藍</string>
<string name="recipe_lch_purple">紫</string>
<string name="recipe_lch_magenta">品紅</string>
<string name="recipe_tab_texture">效果</string>
<string name="recipe_tab_texture">質感</string>
<string name="recipe_tab_lens">氛圍</string>
<string name="recipe_tab_post">細節</string>
<string name="recipe_tab_remarks">備注</string>
+6 -5
View File
@@ -407,11 +407,11 @@
<!-- Color Recipe -->
<string name="color_recipe">Color Recipe</string>
<string name="effects_title">Effects</string>
<string name="recipe_scope_lut">LUT Default</string>
<string name="recipe_scope_photo">This Photo</string>
<string name="recipe_scope_photo_reset">Reset to LUT Default</string>
<string name="color_recipe_reset_all">Reset all parameters</string>
<string name="recipe_scope_photo_hint">Adjustments apply to this photo only</string>
<string name="color_recipe_reset_all">Reset</string>
<string name="edit_sync_lut_recipe">Update current LUT too</string>
<string name="edit_sync_lut_recipe_description">Color, effects, and LUT intensity are also saved to the selected LUT.</string>
<string name="edit_select_lut_hint">Select a LUT before adjusting color and effects.</string>
<string name="edit_color_and_effects">Adjust color and effects</string>
<!-- Color Recipe Parameters -->
<string name="recipe_param_exposure">Exposure</string>
@@ -473,6 +473,7 @@
<!-- Color Recipe Tabs -->
<string name="recipe_tab_color">Color</string>
<string name="recipe_color_basic">Basic</string>
<string name="recipe_tab_lch">LCH</string>
<string name="recipe_tab_light">Light</string>
<string name="recipe_tab_curve">Curve</string>