feat: integrate baseline LUT selection and editing into LUT selector UI

This commit is contained in:
Hinnka committed 2026-05-17 11:37:56 +08:00
1 parent 222b2f1d7f
commit 131ccad93a
6 files changed
+191 -148

No files matched your search

@@ -70,6 +70,7 @@ import com.hinnka.mycamera.MyCameraApplication
import com.hinnka.mycamera.R
import com.hinnka.mycamera.camera.AspectRatio
import com.hinnka.mycamera.camera.CameraState
import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.ui.components.*
import com.hinnka.mycamera.utils.OrientationObserver
@@ -133,7 +134,9 @@ fun CameraScreen(
val videoAudioInputOptions by viewModel.videoAudioInputOptions.collectAsState()
val phantomPipPreview by viewModel.phantomPipPreview.collectAsState()
val rawDcpId by viewModel.rawDcpId.collectAsState()
val jpgBaselineLutId by viewModel.jpgBaselineLutId.collectAsState()
val rawBaselineLutId by viewModel.rawBaselineLutId.collectAsState()
val phantomBaselineLutId by viewModel.phantomBaselineLutId.collectAsState()
val rawNlmNoiseFactor by viewModel.rawNlmNoiseFactor.collectAsState()
val rawExposureCompensation by viewModel.rawExposureCompensation.collectAsState()
val rawAutoExposure by viewModel.rawAutoExposure.collectAsState()
@@ -155,6 +158,8 @@ fun CameraScreen(
var previewTransitionSawPause by remember { mutableStateOf(false) }
var hasPlayedInitialPreviewTransition by remember { mutableStateOf(false) }
var rawCaptureTapLocked by remember { mutableStateOf(false) }
var baselineEditLutId by remember { mutableStateOf<String?>(null) }
var baselineEditTarget by remember { mutableStateOf<BaselineColorCorrectionTarget?>(null) }
// 标记相机是否已打开
var cameraOpened by remember { mutableStateOf(false) }
@@ -164,6 +169,16 @@ fun CameraScreen(
var selectedParameter by remember { mutableStateOf(CameraParameter.EXPOSURE_COMPENSATION) }
var showVideoParameterRuler by remember { mutableStateOf(false) }
val isXpan = state.aspectRatio == AspectRatio.XPAN
val activeBaselineTarget = when {
phantomMode -> BaselineColorCorrectionTarget.PHANTOM
useRaw && state.captureMode == CaptureMode.PHOTO && state.isRawSupported -> BaselineColorCorrectionTarget.RAW
else -> BaselineColorCorrectionTarget.JPG
}
val activeBaselineLutId = when (activeBaselineTarget) {
BaselineColorCorrectionTarget.JPG -> jpgBaselineLutId
BaselineColorCorrectionTarget.RAW -> rawBaselineLutId
BaselineColorCorrectionTarget.PHANTOM -> phantomBaselineLutId
}
val burstCapturingCount = viewModel.burstImageCount
@@ -1189,39 +1204,7 @@ fun CameraScreen(
useMFSR = useMFSR,
onMFSRToggle = {
viewModel.setUseMFSR(it)
},
selectedDcpId = rawDcpId,
availableDcps = viewModel.availableDcps,
selectedBaselineLutId = rawBaselineLutId,
onSelectBaselineLut = { viewModel.setRawBaselineLutId(it) },
onEditBaselineRecipe = { lutId ->
// Switch to filters panel and then edit recipe
activePanel = ActivePanel.FILTERS
scope.launch {
delay(100)
viewModel.setLut(lutId)
activePanel = ActivePanel.LUT_EDIT
}
},
availableLuts = viewModel.availableLutList,
thumbnail = viewModel.previewThumbnail,
rawNlmNoiseFactor = rawNlmNoiseFactor,
rawExposureCompensation = rawExposureCompensation,
rawAutoExposure = rawAutoExposure,
rawDROMode = droMode,
rawBlackPointCorrection = rawBlackPointCorrection,
rawWhitePointCorrection = rawWhitePointCorrection,
onSelectDcp = { viewModel.setRawDcpId(it) },
onImportDcp = { dcpImportLauncher.launch(arrayOf("application/octet-stream")) },
onDeleteDcp = { viewModel.deleteRawDcp(it.id) { _ -> } },
onRawNlmNoiseFactorChange = { viewModel.setRawNlmNoiseFactor(it) },
onRawExposureCompensationChange = { viewModel.setRawExposureCompensation(it) },
onRawAutoExposureChange = { viewModel.setRawAutoExposure(it) },
onRawDROModeChange = { viewModel.setDroMode(it) },
onRawBlackPointCorrectionChange = { viewModel.setRawBlackPointCorrection(it) },
onRawWhitePointCorrectionChange = { viewModel.setRawWhitePointCorrection(it) },
onAdjustmentStart = { },
onAdjustmentEnd = { }
}
)
AnimatedVisibility(
@@ -1308,6 +1291,13 @@ fun CameraScreen(
currentLutId = currentLutId,
thumbnail = viewModel.previewThumbnail,
onLutSelected = { viewModel.setLut(it) },
currentBaselineLutId = activeBaselineLutId,
baselineTarget = activeBaselineTarget,
onBaselineLutSelected = { viewModel.setBaselineLut(activeBaselineTarget, it) },
onBaselineEditClick = { lutId ->
baselineEditLutId = lutId
baselineEditTarget = activeBaselineTarget
},
onEditClick = {
activePanel = ActivePanel.LUT_EDIT
},
@@ -1332,6 +1322,21 @@ fun CameraScreen(
)
}
if (baselineEditLutId != null && baselineEditTarget != null) {
LutEditBottomSheet(
lutId = baselineEditLutId!!,
editorTarget = when (baselineEditTarget!!) {
BaselineColorCorrectionTarget.JPG -> LutEditorTarget.BASELINE_JPG
BaselineColorCorrectionTarget.RAW -> LutEditorTarget.BASELINE_RAW
BaselineColorCorrectionTarget.PHANTOM -> LutEditorTarget.BASELINE_PHANTOM
},
onDismiss = {
baselineEditLutId = null
baselineEditTarget = null
}
)
}
}
}
@@ -30,8 +30,6 @@ import com.hinnka.mycamera.camera.MeteringMode
import com.hinnka.mycamera.utils.DeviceUtil
import com.hinnka.mycamera.video.*
import com.hinnka.mycamera.video.VideoCodec
import com.hinnka.mycamera.raw.DcpInfo
import com.hinnka.mycamera.lut.LutInfo
private enum class VideoSettingPanel {
ASPECT_RATIO,
@@ -41,7 +39,7 @@ private enum class VideoSettingPanel {
MICROPHONE
}
@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class)
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun CameraTopSheet(
visible: Boolean,
@@ -77,35 +75,9 @@ fun CameraTopSheet(
onMultipleExposureToggle: (Boolean) -> Unit,
useMFSR: Boolean,
onMFSRToggle: (Boolean) -> Unit,
// RAW Edit Panel parameters
selectedDcpId: String?,
availableDcps: List<DcpInfo>,
selectedBaselineLutId: String?,
onSelectBaselineLut: (String?) -> Unit,
onEditBaselineRecipe: (String) -> Unit,
availableLuts: List<LutInfo>,
thumbnail: android.graphics.Bitmap?,
rawNlmNoiseFactor: Float,
rawExposureCompensation: Float,
rawAutoExposure: Boolean,
rawDROMode: String,
rawBlackPointCorrection: Float,
rawWhitePointCorrection: Float,
onSelectDcp: (String?) -> Unit,
onImportDcp: () -> Unit,
onDeleteDcp: (DcpInfo) -> Unit,
onRawNlmNoiseFactorChange: (Float) -> Unit,
onRawExposureCompensationChange: (Float) -> Unit,
onRawAutoExposureChange: (Boolean) -> Unit,
onRawDROModeChange: (String) -> Unit,
onRawBlackPointCorrectionChange: (Float) -> Unit,
onRawWhitePointCorrectionChange: (Float) -> Unit,
onAdjustmentStart: () -> Unit,
onAdjustmentEnd: () -> Unit,
modifier: Modifier = Modifier
) {
var expandedVideoPanel by rememberSaveable { mutableStateOf<VideoSettingPanel?>(null) }
var showRawSheet by rememberSaveable { mutableStateOf(false) }
AnimatedVisibility(
visible = visible,
enter = slideInVertically(initialOffsetY = { -it }) + fadeIn(),
@@ -174,10 +146,10 @@ fun CameraTopSheet(
)
if (isRawSupported) {
QuickSettingButton2(
QuickSettingToggle(
title = "RAW",
checked = useRaw,
onClick = { showRawSheet = true },
onCheckedChange = onRawToggle,
modifier = Modifier.weight(1f)
)
}
@@ -469,79 +441,6 @@ fun CameraTopSheet(
Spacer(Modifier.weight(1f))
}
}
if (showRawSheet) {
ModalBottomSheet(
onDismissRequest = { showRawSheet = false },
containerColor = Color(0xFF1E1E1E),
dragHandle = { BottomSheetDefaults.DragHandle(color = Color.White.copy(alpha = 0.2f)) }
) {
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.padding(horizontal = 24.dp)
.padding(bottom = 32.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = stringResource(R.string.settings_use_raw),
color = Color.White,
fontSize = 16.sp
)
Switch(
checked = useRaw,
onCheckedChange = onRawToggle,
colors = SwitchDefaults.colors(
checkedThumbColor = Color.White,
checkedTrackColor = Color(0xFFFF6B35),
uncheckedThumbColor = Color.Gray,
uncheckedTrackColor = Color.White.copy(alpha = 0.2f),
uncheckedBorderColor = Color.Transparent
)
)
}
Spacer(modifier = Modifier.height(8.dp))
com.hinnka.mycamera.ui.components.RawEditPanel(
selectedDcpId = selectedDcpId,
availableDcps = availableDcps,
selectedBaselineLutId = selectedBaselineLutId,
onSelectBaselineLut = onSelectBaselineLut,
onEditBaselineRecipe = {
showRawSheet = false
onEditBaselineRecipe(it)
},
availableLuts = availableLuts,
thumbnail = thumbnail,
rawNlmNoiseFactor = rawNlmNoiseFactor,
rawExposureCompensation = rawExposureCompensation,
rawAutoExposure = rawAutoExposure,
rawDROMode = rawDROMode,
rawBlackPointCorrection = rawBlackPointCorrection,
rawWhitePointCorrection = rawWhitePointCorrection,
onSelectDcp = onSelectDcp,
onImportDcp = onImportDcp,
onDeleteDcp = onDeleteDcp,
onRawNlmNoiseFactorChange = onRawNlmNoiseFactorChange,
onRawExposureCompensationChange = onRawExposureCompensationChange,
onRawAutoExposureChange = onRawAutoExposureChange,
onRawDROModeChange = onRawDROModeChange,
onRawBlackPointCorrectionChange = onRawBlackPointCorrectionChange,
onRawWhitePointCorrectionChange = onRawWhitePointCorrectionChange,
onAdjustmentStart = onAdjustmentStart,
onAdjustmentEnd = onAdjustmentEnd
)
}
}
}
}
@Composable
@@ -10,6 +10,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.FilterNone
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Tune
@@ -36,6 +37,7 @@ import coil.size.Size
import coil.transform.Transformation
import com.hinnka.mycamera.R
import com.hinnka.mycamera.data.ContentRepository
import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
import com.hinnka.mycamera.lut.LutInfo
import com.hinnka.mycamera.model.ColorRecipeParams
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
@@ -51,6 +53,11 @@ private sealed class LutCategoryTab {
data class Category(val name: String) : LutCategoryTab()
}
private enum class LutSelectorMode {
Style,
Baseline
}
/**
* LUT 选择器组件
*
@@ -62,6 +69,10 @@ fun LutSelector(
currentLutId: String?,
thumbnail: Bitmap?,
onLutSelected: (String?) -> Unit,
currentBaselineLutId: String? = null,
baselineTarget: BaselineColorCorrectionTarget = BaselineColorCorrectionTarget.JPG,
onBaselineLutSelected: ((String?) -> Unit)? = null,
onBaselineEditClick: ((String) -> Unit)? = null,
onEditClick: (() -> Unit)? = null,
onManageClick: ((String) -> Unit)? = null,
categoryOrder: List<String> = emptyList(),
@@ -73,6 +84,14 @@ fun LutSelector(
val favoriteText = stringResource(R.string.favorite)
val builtInText = stringResource(R.string.built_in)
val uncategorizedText = stringResource(R.string.uncategorized)
val clearBaselineText = stringResource(R.string.settings_baseline_clear)
val styleText = stringResource(R.string.lut_selector_style_tab)
val baselineText = stringResource(R.string.lut_selector_baseline_tab)
val baselineModeText = when (baselineTarget) {
BaselineColorCorrectionTarget.JPG -> stringResource(R.string.baseline_target_jpg)
BaselineColorCorrectionTarget.RAW -> stringResource(R.string.baseline_target_raw)
BaselineColorCorrectionTarget.PHANTOM -> stringResource(R.string.baseline_target_phantom)
}
// 分类逻辑
val categoryTabs = remember(availableLuts, categoryOrder, favoriteText, builtInText, uncategorizedText) {
@@ -120,9 +139,18 @@ fun LutSelector(
}
var selectedCategory by remember { mutableStateOf<LutCategoryTab>(LutCategoryTab.BuiltIn) }
var selectedMode by remember { mutableStateOf(LutSelectorMode.Style) }
val showModeTabs = onBaselineLutSelected != null
val activeLutId = if (selectedMode == LutSelectorMode.Baseline) currentBaselineLutId else currentLutId
LaunchedEffect(currentLutId, availableLuts, categoryTabs) {
val selectedLut = availableLuts.find { it.id == currentLutId }
LaunchedEffect(showModeTabs) {
if (!showModeTabs) {
selectedMode = LutSelectorMode.Style
}
}
LaunchedEffect(activeLutId, availableLuts, categoryTabs) {
val selectedLut = availableLuts.find { it.id == activeLutId }
selectedCategory = when {
selectedLut?.isFavorite == true -> LutCategoryTab.Favorite
selectedLut != null && selectedCategory.contains(selectedLut) -> selectedCategory
@@ -147,8 +175,8 @@ fun LutSelector(
val actualShowLutEditDialog = onEditClick == null && showLutEditDialogState
// 在组件首次加载时滚动到当前选中的 LUT
LaunchedEffect(currentLutId) {
currentLutId?.let { lutId ->
LaunchedEffect(activeLutId, selectedMode, filteredLuts) {
activeLutId?.let { lutId ->
val selectedIndex = filteredLuts.indexOfFirst { it.id == lutId }
if (selectedIndex >= 2) {
coroutineScope.launch {
@@ -171,6 +199,46 @@ fun LutSelector(
}
Column(modifier = modifier.fillMaxWidth()) {
if (showModeTabs) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 4.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
LutSelectorModeTab(
text = styleText,
isSelected = selectedMode == LutSelectorMode.Style,
onClick = { selectedMode = LutSelectorMode.Style }
)
LutSelectorModeTab(
text = baselineText,
isSelected = selectedMode == LutSelectorMode.Baseline,
badgeText = baselineModeText,
onClick = { selectedMode = LutSelectorMode.Baseline }
)
if (selectedMode == LutSelectorMode.Baseline && currentBaselineLutId != null) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = clearBaselineText,
tint = Color.White.copy(alpha = 0.72f),
modifier = Modifier
.size(24.dp)
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.12f))
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null
) {
onBaselineLutSelected(null)
}
.padding(5.dp)
)
}
}
}
// 分类选择器 (小芯片样式)
Row(
modifier = Modifier.fillMaxWidth().padding(bottom = 4.dp),
@@ -243,18 +311,27 @@ fun LutSelector(
id = lut.id,
name = lut.getName(),
previewBitmap = thumbnail,
isSelected = currentLutId == lut.id,
isSelected = activeLutId == lut.id,
isVip = lut.isVip,
isCustom = !lut.isBuiltIn,
recipeTarget = if (selectedMode == LutSelectorMode.Baseline) baselineTarget else null,
onClick = {
if (currentLutId == lut.id) {
if (onEditClick != null) {
onEditClick()
if (selectedMode == LutSelectorMode.Baseline) {
if (currentBaselineLutId == lut.id) {
onBaselineEditClick?.invoke(lut.id)
} else {
showLutEditDialogState = true
onBaselineLutSelected?.invoke(lut.id)
}
} else {
onLutSelected(lut.id)
if (currentLutId == lut.id) {
if (onEditClick != null) {
onEditClick()
} else {
showLutEditDialogState = true
}
} else {
onLutSelected(lut.id)
}
}
},
onManageClick = if (onManageClick != null) {
@@ -272,6 +349,52 @@ fun LutSelector(
}
}
@Composable
private fun LutSelectorModeTab(
text: String,
isSelected: Boolean,
onClick: () -> Unit,
badgeText: String? = null
) {
Row(
modifier = Modifier
.clip(RoundedCornerShape(14.dp))
.background(if (isSelected) Color.White.copy(alpha = 0.18f) else Color.Transparent)
.border(
width = 1.dp,
color = if (isSelected) Color.White.copy(alpha = 0.5f) else Color.White.copy(alpha = 0.18f),
shape = RoundedCornerShape(14.dp)
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = onClick
)
.padding(horizontal = 10.dp, vertical = 5.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
Text(
text = text,
color = if (isSelected) Color.White else Color.White.copy(alpha = 0.58f),
fontSize = 12.sp,
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium
)
if (badgeText != null) {
Text(
text = badgeText,
color = Color.Black,
fontSize = 9.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier
.clip(RoundedCornerShape(8.dp))
.background(Color(0xFFFFD700))
.padding(horizontal = 5.dp, vertical = 1.dp)
)
}
}
}
/**
* 单个 LUT 选项
*/
@@ -285,6 +408,7 @@ private fun LutItem(
isVip: Boolean,
onClick: () -> Unit,
onManageClick: (() -> Unit)? = null,
recipeTarget: BaselineColorCorrectionTarget? = null,
isNone: Boolean = false,
isCustom: Boolean = false, // 添加自定义标识参数
modifier: Modifier = Modifier
@@ -362,7 +486,7 @@ private fun LutItem(
contentRepository.lutManager.loadLut(id)
}
if (lutConfig != null) {
val colorRecipeParams = contentRepository.lutManager.loadColorRecipeParams(id)
val colorRecipeParams = contentRepository.lutManager.loadColorRecipeParams(id, recipeTarget)
return contentRepository.imageProcessor.applyLut(
bitmap = input,
lutConfig = lutConfig,
@@ -248,6 +248,11 @@
<string name="settings_baseline_dialog_description">为当前目标选择一个基准 LUT。它会在普通创意 LUT 之前应用。</string>
<string name="settings_baseline_edit_recipe">编辑配方</string>
<string name="settings_baseline_clear">清除</string>
<string name="lut_selector_style_tab">风格</string>
<string name="lut_selector_baseline_tab">基准</string>
<string name="baseline_target_jpg">JPG</string>
<string name="baseline_target_raw">RAW</string>
<string name="baseline_target_phantom">幻影</string>
<string name="settings_shutter_sound">快门声音</string>
<string name="settings_shutter_sound_description">拍照时播放快门声音</string>
<string name="settings_vibration">拍摄震动</string>
@@ -227,6 +227,11 @@
<string name="edit_name">編輯名稱</string>
<string name="name">名稱</string>
<string name="confirm">確認</string>
<string name="lut_selector_style_tab">風格</string>
<string name="lut_selector_baseline_tab">基準</string>
<string name="baseline_target_jpg">JPG</string>
<string name="baseline_target_raw">RAW</string>
<string name="baseline_target_phantom">幻影</string>
<!-- Color Recipe -->
<string name="color_recipe">色彩配方</string>
+5
View File
@@ -250,6 +250,11 @@
<string name="settings_baseline_dialog_description">Select a baseline LUT for this target. It will be applied before the regular creative LUT.</string>
<string name="settings_baseline_edit_recipe">Edit Recipe</string>
<string name="settings_baseline_clear">Clear</string>
<string name="lut_selector_style_tab">Style</string>
<string name="lut_selector_baseline_tab">Baseline</string>
<string name="baseline_target_jpg">JPG</string>
<string name="baseline_target_raw">RAW</string>
<string name="baseline_target_phantom">Phantom</string>
<string name="settings_shutter_sound">Shutter Sound</string>
<string name="settings_shutter_sound_description">Play sound when taking a photo</string>
<string name="settings_vibration">Vibration</string>