feat: lut / edit panel ui

This commit is contained in:
zhoubinjia committed 2026-09-04 15:14:35 +08:00
1 parent 522fa27abb
commit c773600dfa
14 files changed
+597 -703

No files matched your search

@@ -1726,13 +1726,6 @@ fun CameraScreen(
currentLutId = currentLutId,
thumbnail = viewModel.previewThumbnail,
onLutSelected = { viewModel.setLut(it) },
lutIntensity = (previewRecipeParamsOverride ?: currentRecipeParams).lutIntensity,
onLutIntensityChange = { newIntensity ->
val newParams = (previewRecipeParamsOverride ?: currentRecipeParams)
.copy(lutIntensity = newIntensity)
previewRecipeParamsOverride = newParams
viewModel.updateLutIntensity(newIntensity)
},
allPresets = allPresets,
presetModeEnabled = true,
activePresetId = activePresetId,
@@ -1768,7 +1761,7 @@ fun CameraScreen(
categoryOrder = categoryOrder,
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 6.dp)
.padding(horizontal = 6.dp, vertical = 10.dp)
)
}
}
@@ -150,7 +150,7 @@ fun LutEditBottomSheet(
)
},
imageHistogram = imageHistogram,
showLutIntensity = false,
showLutIntensity = editorTarget == LutEditorTarget.CREATIVE_GLOBAL,
currentEffects = editingParams.toEffectParams().takeIf { showEffects },
onEffectsChange = if (showEffects) {
{ effects -> onParamsUpdated(effects.applyTo(editingParams)) }
@@ -69,9 +69,8 @@ private enum class ColorPanelSection {
STYLE,
}
private enum class EffectSection {
private enum class EffectPanelSection {
LIGHT,
OPTICS,
TEXTURE,
}
@@ -146,9 +145,10 @@ fun ColorRecipePanel(
var selectedTab by remember { mutableStateOf(RecipePanelTab.CURVE) }
var selectedBasicControl by remember { mutableStateOf(BasicRecipeControl.EXPOSURE) }
var selectedColorSection by remember { mutableStateOf(ColorPanelSection.CALIBRATION) }
var selectedEffectSection by remember { mutableStateOf(EffectSection.LIGHT) }
var selectedEffectSection by remember { mutableStateOf(EffectPanelSection.LIGHT) }
var selectedLchTabIndex by remember { mutableIntStateOf(0) }
var selectedCalibrationTabIndex by remember { mutableIntStateOf(0) }
var isCurveDragging by remember { mutableStateOf(false) }
val showEffects = !hideNonBakeable || (currentEffects != null && onEffectsChange != null)
@@ -228,24 +228,19 @@ fun ColorRecipePanel(
),
)
val effectGroups = listOf(
EffectSection.LIGHT to listOf(
val advancedEffectGroups = listOf(
EffectPanelSection.LIGHT to listOf(
EffectType.FLASH,
EffectType.BLOOM,
EffectType.SOFT_LIGHT,
),
EffectSection.OPTICS to listOf(
EffectType.VIGNETTE,
EffectPanelSection.TEXTURE to listOf(
EffectType.HALATION,
EffectType.CHROMATIC_ABERRATION,
),
EffectSection.TEXTURE to listOf(
EffectType.CLARITY,
EffectType.FILM_GRAIN,
EffectType.NOISE,
EffectType.LOW_RES,
),
)
val advancedEffects = advancedEffectGroups.flatMap { it.second }
fun resetTab(tab: RecipePanelTab) {
when (tab) {
@@ -270,9 +265,13 @@ fun ColorRecipePanel(
}
RecipePanelTab.EFFECTS -> {
if (currentEffects != null && onEffectsChange != null) {
onEffectsChange(EffectParams.DEFAULT)
onEffectsChange(
advancedEffects.fold(currentEffects) { params, effect ->
effect.setValue(params, effect.defaultValue)
}
)
} else {
val effectParams = effectGroups.flatMap { it.second }.map { it.recipeParam }
val effectParams = advancedEffects.map { it.recipeParam }
onParamsChange(resetParams(currentParams, effectParams))
}
}
@@ -369,232 +368,252 @@ fun ColorRecipePanel(
Column(
modifier = modifier
.fillMaxWidth()
.clip(containerShape)
.background(Color(0xF9121316))
.border(0.5.dp, Color.White.copy(alpha = 0.08f), containerShape)
.padding(start = 14.dp, top = 12.dp, end = 14.dp, bottom = 12.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
// 最上层:滤镜强度(若启用,无边框极简单行)
// 滤镜强度独立放在透明区域,不随下方调节面板绘制黑色背景。
if (showLutIntensity) {
FlatLutIntensityRow(
intensity = currentParams.lutIntensity,
onIntensityChange = { onParamChange(RecipeParam.LUT_INTENSITY, it) },
modifier = Modifier.fillMaxWidth()
)
Box(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 14.dp, vertical = 14.dp)
) {
FlatLutIntensityRow(
intensity = currentParams.lutIntensity,
onIntensityChange = { onParamChange(RecipeParam.LUT_INTENSITY, it) },
modifier = Modifier.fillMaxWidth()
)
}
}
// 模式切换与重置栏:大圆角胶囊按钮,文字大小统一为 11.sp
Row(
Column(
modifier = Modifier
.fillMaxWidth()
.height(30.dp)
.padding(horizontal = 2.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
.clip(containerShape)
.background(
if (isCurveDragging) Color.Transparent
else Color(0xF9121316).copy(alpha = 0.95f)
)
.border(
0.5.dp,
Color.White.copy(alpha = if (isCurveDragging) 0f else 0.08f),
containerShape
)
.padding(start = 14.dp, top = 12.dp, end = 14.dp, bottom = 12.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
RecipeFlatModeToggle(
isAdvanced = showAdvanced,
onModeChange = { showAdvanced = it },
)
headerControls?.let { controls ->
Row(
modifier = Modifier
.weight(1f)
.padding(horizontal = 6.dp)
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically
) {
controls()
}
}
// 模式切换与重置栏:大圆角胶囊按钮,文字大小统一为 11.sp
Row(
modifier = Modifier
.fillMaxWidth()
.height(30.dp)
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.08f))
.clickable { resetAllParams() }
.padding(horizontal = 12.dp),
.padding(horizontal = 2.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
horizontalArrangement = Arrangement.SpaceBetween
) {
Icon(
imageVector = Icons.Default.Refresh,
contentDescription = null,
tint = Color(0xFFFFC46B),
modifier = Modifier.size(12.dp)
)
Text(
text = stringResource(R.string.color_recipe_reset_all),
color = Color.White.copy(alpha = 0.85f),
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
maxLines = 1
RecipeFlatModeToggle(
isAdvanced = showAdvanced,
onModeChange = { showAdvanced = it },
)
headerControls?.let { controls ->
Row(
modifier = Modifier
.weight(1f)
.padding(horizontal = 6.dp)
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically
) {
controls()
}
}
Row(
modifier = Modifier
.height(30.dp)
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.08f))
.clickable { resetAllParams() }
.padding(horizontal = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
Icon(
imageVector = Icons.Default.Refresh,
contentDescription = null,
tint = Color(0xFFFFC46B),
modifier = Modifier.size(12.dp)
)
Text(
text = stringResource(R.string.color_recipe_reset_all),
color = Color.White.copy(alpha = 0.85f),
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
maxLines = 1
)
}
}
}
if (!showAdvanced) {
// 基础模式:4 x 3 扁平规整矩阵(12 项参数清晰全显)
BasicRecipeGrid(
controls = basicRecipeControls,
selectedControl = selectedBasicControl,
valueFor = { control -> basicDisplayValue(control, basicRawValue(control)) },
enabledFor = { true },
onControlSelected = { selectedBasicControl = it },
onControlReset = { control ->
val defaultVal = basicDefaultRawValue(control)
setBasicRawValue(control, defaultVal)
}
)
if (!showAdvanced) {
// 基础模式:4 x 3 无边框参数矩阵,数值为主、名称为辅
BasicRecipeGrid(
controls = basicRecipeControls,
selectedControl = selectedBasicControl,
valueFor = { control -> basicDisplayValue(control, basicRawValue(control)) },
enabledFor = { true },
onControlSelected = { selectedBasicControl = it },
onControlReset = { control ->
val defaultVal = basicDefaultRawValue(control)
setBasicRawValue(control, defaultVal)
}
)
// 专属精细调参底座(带标题与大刻度尺)
BasicRecipeAdjuster(
control = selectedBasicControl,
displayValue = basicDisplayValue(
selectedBasicControl,
basicRawValue(selectedBasicControl)
),
onDisplayValueChange = { newDisplayValue ->
setBasicRawValue(
// 专属精细调参底座(带标题与大刻度尺)
BasicRecipeAdjuster(
control = selectedBasicControl,
displayValue = basicDisplayValue(
selectedBasicControl,
basicRawValue(selectedBasicControl, newDisplayValue)
)
},
onReset = {
setBasicRawValue(
selectedBasicControl,
basicDefaultRawValue(selectedBasicControl)
)
},
modifier = Modifier.fillMaxWidth()
)
basicRawValue(selectedBasicControl)
),
onDisplayValueChange = { newDisplayValue ->
setBasicRawValue(
selectedBasicControl,
basicRawValue(selectedBasicControl, newDisplayValue)
)
},
onReset = {
setBasicRawValue(
selectedBasicControl,
basicDefaultRawValue(selectedBasicControl)
)
},
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(6.dp))
} else {
// 高级模式主标签栏:曲线、色彩、效果、备注
RecipeAdvancedTabs(
tabs = tabs,
selectedTab = selectedTab,
onTabSelected = { selectedTab = it },
onTabReset = ::resetTab,
)
Spacer(modifier = Modifier.height(6.dp))
} else {
// 高级模式主标签栏:曲线、色彩、效果、备注
RecipeAdvancedTabs(
tabs = tabs,
selectedTab = selectedTab,
onTabSelected = { selectedTab = it },
onTabReset = ::resetTab,
)
Spacer(modifier = Modifier.height(4.dp))
Spacer(modifier = Modifier.height(4.dp))
when (selectedTab) {
RecipePanelTab.CURVE -> {
CurveEditorPanel(
currentParams = currentParams,
onCurveChange = onCurveChange,
imageHistogram = imageHistogram,
modifier = Modifier.fillMaxWidth()
)
}
RecipePanelTab.COLOR -> {
ColorSectionTabs(
selectedSection = selectedColorSection,
onSectionSelected = { selectedColorSection = it }
)
Spacer(modifier = Modifier.height(4.dp))
when (selectedColorSection) {
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
when (selectedTab) {
RecipePanelTab.CURVE -> {
CurveEditorPanel(
currentParams = currentParams,
onCurveChange = onCurveChange,
imageHistogram = imageHistogram,
onDragStateChange = { isDragging ->
isCurveDragging = isDragging
},
modifier = Modifier.fillMaxWidth()
)
}
RecipePanelTab.COLOR -> {
ColorSectionTabs(
selectedSection = selectedColorSection,
onSectionSelected = { selectedColorSection = it }
)
Spacer(modifier = Modifier.height(4.dp))
when (selectedColorSection) {
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
}
}
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
}
}
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
}
ColorPanelSection.GRADING -> {
ColorGradingPanel(
currentParams = currentParams,
onParamsChange = onParamsChange,
modifier = Modifier.fillMaxWidth(),
)
}
ColorPanelSection.LCH -> {
ColorRingTabs(
count = lchGroups.size,
selectedTabIndex = selectedLchTabIndex,
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
lchGroups[selectedLchTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
}
}
}
}
ColorPanelSection.GRADING -> {
ColorGradingPanel(
currentParams = currentParams,
onParamsChange = onParamsChange,
modifier = Modifier.fillMaxWidth(),
)
}
ColorPanelSection.LCH -> {
ColorRingTabs(
count = lchGroups.size,
selectedTabIndex = selectedLchTabIndex,
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
lchGroups[selectedLchTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
ColorPanelSection.STYLE -> {
val visibleParams = if (hideNonBakeable) {
colorStyleParams.filter(isBakeable)
} else {
colorStyleParams
}
}
}
ColorPanelSection.STYLE -> {
val visibleParams = if (hideNonBakeable) {
colorStyleParams.filter(isBakeable)
} else {
colorStyleParams
}
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
visibleParams.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
visibleParams.forEach { param ->
RecipeIntegerParamItem(
param = param,
value = param.getValue(currentParams),
onValueChange = { onParamChange(param, it) },
)
}
}
}
}
}
}
RecipePanelTab.EFFECTS -> {
EffectSectionTabs(
selectedSection = selectedEffectSection,
onSectionSelected = { selectedEffectSection = it }
)
Spacer(modifier = Modifier.height(4.dp))
val visibleEffects = effectGroups
.first { it.first == selectedEffectSection }
.second
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
visibleEffects.forEach { effect ->
RecipeEffectParamItem(
effect = effect,
value = getEffectRawValue(effect),
onValueChange = { setEffectRawValue(effect, it) },
)
RecipePanelTab.EFFECTS -> {
EffectPanelSectionTabs(
selectedSection = selectedEffectSection,
onSectionSelected = { selectedEffectSection = it },
)
Spacer(modifier = Modifier.height(4.dp))
val visibleEffects = advancedEffectGroups
.first { it.first == selectedEffectSection }
.second
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
visibleEffects.forEach { effect ->
RecipeEffectParamItem(
effect = effect,
value = getEffectRawValue(effect),
onValueChange = { setEffectRawValue(effect, it) },
)
}
}
}
}
RecipePanelTab.REMARKS -> {
ColorRecipeRemarksBar(
remarks = currentParams.remarks ?: "",
onRemarksChange = onRemarksChange,
modifier = Modifier.fillMaxWidth()
)
RecipePanelTab.REMARKS -> {
ColorRecipeRemarksBar(
remarks = currentParams.remarks ?: "",
onRemarksChange = onRemarksChange,
modifier = Modifier.fillMaxWidth()
)
}
}
}
}
@@ -812,12 +831,12 @@ private fun BasicRecipeGrid(
) {
Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(6.dp)
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
controls.chunked(4).forEach { rowControls ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
rowControls.forEach { control ->
BasicRecipeTile(
@@ -851,24 +870,9 @@ private fun BasicRecipeTile(
val accent = getBasicControlColor(control)
val haptic = LocalHapticFeedback.current
val tileBg = when {
isSelected -> Color(0xFF242730)
isModified -> Color(0xFF1B1D22)
else -> Color(0xFF16171B)
}
val borderColor = when {
isSelected -> accent.copy(alpha = 0.92f)
isModified -> Color.White.copy(alpha = 0.16f)
else -> Color.White.copy(alpha = 0.06f)
}
Column(
Box(
modifier = modifier
.height(54.dp)
.clip(RoundedCornerShape(8.dp))
.background(tileBg)
.border(if (isSelected) 1.2.dp else 0.5.dp, borderColor, RoundedCornerShape(8.dp))
.height(62.dp)
.pointerInput(enabled) {
if (enabled) {
detectTapGestures(
@@ -882,45 +886,54 @@ private fun BasicRecipeTile(
}
)
}
}
.padding(horizontal = 8.dp, vertical = 6.dp),
verticalArrangement = Arrangement.SpaceBetween,
},
contentAlignment = Alignment.Center,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 2.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(2.dp),
) {
Text(
text = formatBasicDisplayValue(control, value),
color = when {
!enabled -> Color.White.copy(alpha = 0.26f)
isSelected -> accent
else -> Color.White.copy(alpha = 0.92f)
},
fontSize = 18.sp,
fontWeight = FontWeight.Medium,
maxLines = 1,
)
Text(
text = stringResource(control.titleRes),
color = if (isSelected) accent else Color.White.copy(alpha = if (enabled) 0.68f else 0.28f),
fontSize = 11.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal,
color = when {
!enabled -> Color.White.copy(alpha = 0.2f)
isSelected -> accent.copy(alpha = 0.78f)
isModified -> Color.White.copy(alpha = 0.5f)
else -> Color.White.copy(alpha = 0.38f)
},
fontSize = 10.sp,
fontWeight = if (isSelected) FontWeight.Medium else FontWeight.Normal,
textAlign = TextAlign.Center,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
if (isModified && !isSelected) {
Box(
modifier = Modifier
.size(4.dp)
.clip(CircleShape)
.background(accent)
)
}
}
Text(
text = formatBasicDisplayValue(control, value),
color = when {
isSelected -> accent
isModified -> Color.White
else -> Color.White.copy(alpha = 0.35f)
},
fontSize = 15.sp,
fontWeight = FontWeight.Bold,
fontFamily = FontFamily.Monospace,
maxLines = 1,
)
if (isSelected) {
Box(
modifier = Modifier
.align(Alignment.BottomCenter)
.width(16.dp)
.height(2.dp)
.clip(CircleShape)
.background(accent.copy(alpha = 0.9f))
)
}
}
}
@@ -1342,21 +1355,19 @@ private fun ColorSectionTabs(
}
@Composable
private fun EffectSectionTabs(
selectedSection: EffectSection,
onSectionSelected: (EffectSection) -> Unit,
modifier: Modifier = Modifier
private fun EffectPanelSectionTabs(
selectedSection: EffectPanelSection,
onSectionSelected: (EffectPanelSection) -> Unit,
modifier: Modifier = Modifier,
) {
val tabs = listOf(
EffectSection.LIGHT to R.string.effects_group_light,
EffectSection.OPTICS to R.string.effects_group_optics,
EffectSection.TEXTURE to R.string.effects_group_texture,
)
RecipeSectionTabs(
tabs = tabs,
tabs = listOf(
EffectPanelSection.LIGHT to R.string.effects_group_light,
EffectPanelSection.TEXTURE to R.string.effects_group_texture,
),
selectedTab = selectedSection,
onTabSelected = onSectionSelected,
modifier = modifier
modifier = modifier,
)
}
@@ -53,6 +53,7 @@ fun CurveEditorPanel(
currentParams: ColorRecipeParams,
onCurveChange: (CurveChannel, FloatArray?) -> Unit,
imageHistogram: ImageHistogram? = null,
onDragStateChange: (Boolean) -> Unit = {},
modifier: Modifier = Modifier
) {
var activeChannel by remember { mutableStateOf(CurveChannel.MASTER) }
@@ -81,6 +82,7 @@ fun CurveEditorPanel(
curveColor = activeChannel.color,
inactiveCurves = inactiveCurves,
histogram = imageHistogram?.binsFor(activeChannel),
onDragStateChange = onDragStateChange,
onPointsChange = { newPoints ->
val arr = if (
newPoints.size <= 4 && CurveUtils.isIdentityCurve(newPoints)
@@ -159,6 +161,7 @@ private fun CurveCanvas(
curveColor: Color,
inactiveCurves: List<DisplayCurve>,
histogram: IntArray?,
onDragStateChange: (Boolean) -> Unit,
onPointsChange: (FloatArray) -> Unit,
modifier: Modifier = Modifier
) {
@@ -169,6 +172,20 @@ private fun CurveCanvas(
// 内部拖动状态;pointerInput key 使用 state 对象引用(稳定)
val controlPointsState = remember { mutableStateOf(parsePoints(points)) }
val controlPoints = controlPointsState.value
var isDragging by remember { mutableStateOf(false) }
val onDragStateChangeState by rememberUpdatedState(onDragStateChange)
fun updateDragging(dragging: Boolean) {
if (isDragging == dragging) return
isDragging = dragging
onDragStateChangeState(dragging)
}
DisposableEffect(Unit) {
onDispose {
if (isDragging) onDragStateChangeState(false)
}
}
// 普通 holder(非 Compose State),避免异步快照时序导致 LaunchedEffect 误判
val lastEmitted = remember { arrayOf(points) }
@@ -227,30 +244,41 @@ private fun CurveCanvas(
// 用相邻点夹紧代替排序,避免 index 跳变导致的抖动。
val dragIdx = nearIdx
val dragOrigin = controlPointsState.value[dragIdx]
drag@ while (true) {
val event = awaitPointerEvent()
val change = event.changes.firstOrNull { it.id == down.id }
if (change == null || !change.pressed) break@drag
change.consume()
var dragStarted = false
try {
drag@ while (true) {
val event = awaitPointerEvent()
val change = event.changes.firstOrNull { it.id == down.id }
if (change == null || !change.pressed) break@drag
change.consume()
val current = controlPointsState.value
val (rawX, ny) = curvePointAfterDrag(
origin = dragOrigin,
pointerStart = downPos,
pointerPosition = change.position,
size = size,
graphInset = graphInsetPx,
)
if (!dragStarted) {
if ((change.position - downPos).getDistance() <= 4f) continue@drag
dragStarted = true
updateDragging(true)
}
// x 轴:由相邻点边界夹紧,不排序——消除抖动
val nx = safeCoerceX(rawX, dragIdx, current)
val current = controlPointsState.value
val (rawX, ny) = curvePointAfterDrag(
origin = dragOrigin,
pointerStart = downPos,
pointerPosition = change.position,
size = size,
graphInset = graphInsetPx,
)
val updated = current.toMutableList()
updated[dragIdx] = Pair(nx, ny)
controlPointsState.value = updated
val arr = updated.toFloatArray()
lastEmitted[0] = arr
onPointsChange(arr)
// x 轴:由相邻点边界夹紧,不排序——消除抖动
val nx = safeCoerceX(rawX, dragIdx, current)
val updated = current.toMutableList()
updated[dragIdx] = Pair(nx, ny)
controlPointsState.value = updated
val arr = updated.toFloatArray()
lastEmitted[0] = arr
onPointsChange(arr)
}
} finally {
if (dragStarted) updateDragging(false)
}
} else {
// Issue 1: 点击空白区域 →
@@ -261,44 +289,49 @@ private fun CurveCanvas(
var upPos = downPos
var newPointOrigin = Pair(0f, 0f)
tap@ while (true) {
val event = awaitPointerEvent()
val change = event.changes.firstOrNull { it.id == down.id }
if (change == null || !change.pressed) {
upPos = change?.position ?: upPos
break@tap
}
change.consume()
try {
tap@ while (true) {
val event = awaitPointerEvent()
val change = event.changes.firstOrNull { it.id == down.id }
if (change == null || !change.pressed) {
upPos = change?.position ?: upPos
break@tap
}
change.consume()
if (!newPointAdded && (change.position - downPos).getDistance() > 4f) {
// 手指开始移动:在 down 位置插入新点,立即进入拖动模式
val nx0 = normalizeCurveX(downPos.x, size, graphInsetPx).coerceIn(0.001f, 0.999f)
val ny0 = normalizeCurveY(downPos.y, size, graphInsetPx)
val newPt = Pair(nx0, ny0)
val withNew = (controlPointsState.value + newPt).sortedBy { it.first }
controlPointsState.value = withNew
dragIdx = withNew.indexOf(newPt)
newPointOrigin = newPt
newPointAdded = true
}
if (!newPointAdded && (change.position - downPos).getDistance() > 4f) {
// 手指开始移动:在 down 位置插入新点,立即进入拖动模式
val nx0 = normalizeCurveX(downPos.x, size, graphInsetPx).coerceIn(0.001f, 0.999f)
val ny0 = normalizeCurveY(downPos.y, size, graphInsetPx)
val newPt = Pair(nx0, ny0)
val withNew = (controlPointsState.value + newPt).sortedBy { it.first }
controlPointsState.value = withNew
dragIdx = withNew.indexOf(newPt)
newPointOrigin = newPt
newPointAdded = true
updateDragging(true)
}
if (newPointAdded && dragIdx >= 0) {
val current = controlPointsState.value
val (rawX, ny) = curvePointAfterDrag(
origin = newPointOrigin,
pointerStart = downPos,
pointerPosition = change.position,
size = size,
graphInset = graphInsetPx,
)
val nx = safeCoerceX(rawX, dragIdx, current)
val updated = current.toMutableList()
updated[dragIdx] = Pair(nx, ny)
controlPointsState.value = updated
val arr = updated.toFloatArray()
lastEmitted[0] = arr
onPointsChange(arr)
if (newPointAdded && dragIdx >= 0) {
val current = controlPointsState.value
val (rawX, ny) = curvePointAfterDrag(
origin = newPointOrigin,
pointerStart = downPos,
pointerPosition = change.position,
size = size,
graphInset = graphInsetPx,
)
val nx = safeCoerceX(rawX, dragIdx, current)
val updated = current.toMutableList()
updated[dragIdx] = Pair(nx, ny)
controlPointsState.value = updated
val arr = updated.toFloatArray()
lastEmitted[0] = arr
onPointsChange(arr)
}
}
} finally {
if (newPointAdded) updateDragging(false)
}
// 纯点击(未拖动):在抬起位置添加点
@@ -323,7 +356,8 @@ private fun CurveCanvas(
inactiveCurves = inactiveCurves,
histogram = histogram,
canvasSize = size,
graphInset = graphInsetPx
graphInset = graphInsetPx,
drawBackground = !isDragging,
)
}
}
@@ -335,19 +369,21 @@ private fun DrawScope.drawCurveCanvas(
inactiveCurves: List<DisplayCurve>,
histogram: IntArray?,
canvasSize: Size,
graphInset: Float
graphInset: Float,
drawBackground: Boolean,
) {
val left = graphInset
val top = graphInset
val w = (canvasSize.width - graphInset * 2f).coerceAtLeast(1f)
val h = (canvasSize.height - graphInset * 2f).coerceAtLeast(1f)
// 背景
drawRect(
color = Color(0x661A1A1A),
topLeft = Offset(left, top),
size = Size(w, h)
)
if (drawBackground) {
drawRect(
color = Color(0x661A1A1A),
topLeft = Offset(left, top),
size = Size(w, h)
)
}
drawImageHistogram(
histogram = histogram,
@@ -46,6 +46,7 @@ fun CustomSlider(
onValueChange: (Float) -> Unit,
onDoubleTap: (() -> Unit)? = null,
onValueChangeFinished: (() -> Unit)? = null,
onDragStateChange: ((Boolean) -> Unit)? = null,
modifier: Modifier = Modifier,
enabled: Boolean = true,
valueRange: ClosedFloatingPointRange<Float> = 0f..1f,
@@ -60,6 +61,7 @@ fun CustomSlider(
val currentOnValueChange by rememberUpdatedState(onValueChange)
val currentOnDoubleTap by rememberUpdatedState(onDoubleTap)
val currentOnValueChangeFinished by rememberUpdatedState(onValueChangeFinished)
val currentOnDragStateChange by rememberUpdatedState(onDragStateChange)
val density = LocalDensity.current
val thumbRadiusPx = with(density) { thumbRadius.toPx() }
@@ -85,9 +87,20 @@ fun CustomSlider(
enabled = enabled,
key1 = valueRange,
key2 = thumbRadiusPx,
onDragStart = { isDragging = true },
onDragEnd = { isDragging = false; currentOnValueChangeFinished?.invoke() },
onDragCancel = { isDragging = false; currentOnValueChangeFinished?.invoke() }
onDragStart = {
isDragging = true
currentOnDragStateChange?.invoke(true)
},
onDragEnd = {
isDragging = false
currentOnDragStateChange?.invoke(false)
currentOnValueChangeFinished?.invoke()
},
onDragCancel = {
isDragging = false
currentOnDragStateChange?.invoke(false)
currentOnValueChangeFinished?.invoke()
}
) { positionX ->
val trackWidth = size.width - thumbRadiusPx * 2
val trackStart = thumbRadiusPx
@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.hinnka.mycamera.R
import com.hinnka.mycamera.model.EffectParams
import com.hinnka.mycamera.model.RecipeParam
@@ -19,8 +18,7 @@ enum class EffectType(
SOFT_LIGHT(RecipeParam.SOFT_LIGHT),
HALATION(RecipeParam.HALATION),
CHROMATIC_ABERRATION(RecipeParam.CHROMATIC_ABERRATION),
NOISE(RecipeParam.NOISE),
LOW_RES(RecipeParam.LOW_RES);
NOISE(RecipeParam.NOISE);
val defaultValue: Float
get() = recipeParam.defaultValue
@@ -36,7 +34,6 @@ enum class EffectType(
HALATION -> params.halation
CHROMATIC_ABERRATION -> params.chromaticAberration
NOISE -> params.noise
LOW_RES -> params.lowRes
}
}
@@ -52,42 +49,10 @@ enum class EffectType(
HALATION -> params.copy(halation = clamped)
CHROMATIC_ABERRATION -> params.copy(chromaticAberration = clamped)
NOISE -> params.copy(noise = clamped)
LOW_RES -> params.copy(lowRes = clamped)
}
}
}
private enum class EffectGroup {
LIGHT,
ATMOSPHERE,
TEXTURE,
}
private val effectGroups = listOf(
EffectGroup.LIGHT to listOf(
EffectType.FLASH,
EffectType.BLOOM,
EffectType.SOFT_LIGHT,
),
EffectGroup.ATMOSPHERE to listOf(
EffectType.VIGNETTE,
EffectType.HALATION,
EffectType.CHROMATIC_ABERRATION,
),
EffectGroup.TEXTURE to listOf(
EffectType.CLARITY,
EffectType.FILM_GRAIN,
EffectType.NOISE,
EffectType.LOW_RES,
),
)
private val effectGroupTabs = listOf(
EffectGroup.LIGHT to R.string.effects_group_light,
EffectGroup.ATMOSPHERE to R.string.effects_group_optics,
EffectGroup.TEXTURE to R.string.effects_group_texture,
)
/**
* 物理画面效果内容,由统一编辑面板作为“效果”参数组承载。
*/
@@ -98,30 +63,12 @@ fun EffectsPanel(
excludedEffects: Set<EffectType> = emptySet(),
modifier: Modifier = Modifier
) {
var selectedGroup by remember {
mutableStateOf(
effectGroups.firstOrNull { (_, effects) ->
effects.any { effect ->
effect.getValue(currentParams) != effect.defaultValue
}
}?.first ?: EffectGroup.LIGHT
)
}
val visibleEffects = effectGroups
.first { (group) -> group == selectedGroup }
.second
.filterNot(excludedEffects::contains)
val visibleEffects = EffectType.entries.filterNot(excludedEffects::contains)
Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
RecipeSectionTabs(
tabs = effectGroupTabs,
selectedTab = selectedGroup,
onTabSelected = { selectedGroup = it },
)
visibleEffects.forEach { effect ->
ColorRecipeSlider(
param = effect.recipeParam,
@@ -1,6 +1,6 @@
package com.hinnka.mycamera.ui.components
import androidx.compose.foundation.background
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -70,7 +69,6 @@ fun FrameSelector(
FrameItem(
name = frame.name,
isSelected = currentFrameId == frame.id,
isCustom = !frame.isBuiltIn,
onClick = { onFrameSelected(frame.id) }
)
}
@@ -85,84 +83,52 @@ private fun FrameItem(
name: String,
isSelected: Boolean,
onClick: () -> Unit,
isCustom: Boolean = false,
modifier: Modifier = Modifier
) {
val backgroundColor = if (isSelected) {
Color.White.copy(alpha = 0.2f)
} else {
Color.Transparent
}
val borderColor = animateColorAsState(
targetValue = if (isSelected) LutPanelOptionSelectedBorder else LutPanelOptionBorder,
label = "frameBorderColor"
).value
val borderColor = if (isSelected) {
Color.White
} else {
Color.White.copy(alpha = 0.2f)
}
Column(
horizontalAlignment = Alignment.CenterHorizontally,
Card(
shape = LutPanelOptionShape,
colors = CardDefaults.cardColors(
containerColor = if (isSelected) {
LutPanelOptionSelectedSurface
} else {
LutPanelOptionSurface
}
),
modifier = modifier
.width(56.dp)
.clip(RoundedCornerShape(8.dp))
.background(backgroundColor)
.size(LutPanelOptionSize)
.clip(LutPanelOptionShape)
.clickable(onClick = onClick)
.border(
width = if (isSelected) 1.5.dp else 1.dp,
color = borderColor,
shape = RoundedCornerShape(8.dp)
shape = LutPanelOptionShape
)
.clickable { onClick() }
.padding(horizontal = 4.dp, vertical = 5.dp)
) {
Box(
modifier = Modifier
.size(42.dp)
.clip(RoundedCornerShape(5.dp))
.background(if (isSelected) Color.White.copy(alpha = 0.15f) else Color.White.copy(alpha = 0.08f)),
.fillMaxSize()
.padding(horizontal = 6.dp, vertical = 5.dp),
contentAlignment = Alignment.Center
) {
Text(
text = name.take(2).uppercase(),
text = name,
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
fontSize = 10.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier
.fillMaxWidth()
.basicMarquee()
)
if (isCustom) {
Box(
modifier = Modifier
.align(Alignment.TopStart)
.background(
color = Color(0xFF4CAF50),
shape = RoundedCornerShape(bottomEnd = 4.dp)
)
.padding(horizontal = 3.dp, vertical = 1.dp)
) {
Text(
text = stringResource(R.string.custom_tag),
color = Color.White,
fontSize = 7.sp,
fontWeight = FontWeight.Bold,
lineHeight = 7.sp
)
}
}
}
Spacer(modifier = Modifier.height(4.dp))
Text(
text = name,
color = Color.White,
fontSize = 10.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier.fillMaxWidth().basicMarquee()
)
}
}
@@ -1,6 +1,7 @@
package com.hinnka.mycamera.ui.components
import android.graphics.Bitmap
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.*
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
@@ -26,7 +27,6 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
@@ -47,7 +47,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import com.hinnka.mycamera.ui.icons.AppIcons
import kotlin.math.roundToInt
private sealed class LutCategoryTab {
data object Favorite : LutCategoryTab()
@@ -64,6 +63,14 @@ private fun LutCategoryTab.stableKey(): String = when (this) {
}
private const val NONE_LUT_ITEM_KEY = "__photon_lut_selector_none__"
private val LutPanelAccent = Color(0xFFFFD700)
private val LutPanelSurface = Color.Black.copy(alpha = 0.15f)
internal val LutPanelOptionSize = 64.dp
internal val LutPanelOptionShape = RoundedCornerShape(8.dp)
internal val LutPanelOptionSurface = Color.Black.copy(alpha = 0.18f)
internal val LutPanelOptionSelectedSurface = Color.White.copy(alpha = 0.2f)
internal val LutPanelOptionBorder = Color.White.copy(alpha = 0.2f)
internal val LutPanelOptionSelectedBorder = Color.White
/**
* LUT 面板右上角的编辑入口。相机页与跨应用 LUT 面板共享同一套样式。
@@ -73,11 +80,12 @@ fun LutEditButton(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
val shape = RoundedCornerShape(12.dp)
Row(
modifier = modifier
.clip(RoundedCornerShape(14.dp))
.background(Color.White.copy(alpha = 0.15f))
.border(1.dp, Color.White.copy(alpha = 0.25f), RoundedCornerShape(14.dp))
.clip(shape)
.background(LutPanelSurface)
.border(1.dp, Color.White.copy(alpha = 0.18f), shape)
.clickable(onClick = onClick)
.padding(horizontal = 9.dp, vertical = 5.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -110,8 +118,8 @@ private fun LutPanelIconButton(
modifier = modifier
.size(26.dp)
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.15f))
.border(1.dp, Color.White.copy(alpha = 0.25f), CircleShape)
.background(LutPanelSurface)
.border(1.dp, Color.White.copy(alpha = 0.18f), CircleShape)
.clickable(onClick = onClick),
contentAlignment = Alignment.Center
) {
@@ -129,11 +137,12 @@ private fun LutPanelNewPresetButton(
onClick: () -> Unit,
modifier: Modifier = Modifier
) {
val shape = RoundedCornerShape(12.dp)
Row(
modifier = modifier
.clip(RoundedCornerShape(14.dp))
.background(Color.White.copy(alpha = 0.15f))
.border(1.dp, Color.White.copy(alpha = 0.25f), RoundedCornerShape(14.dp))
.clip(shape)
.background(LutPanelSurface)
.border(1.dp, Color.White.copy(alpha = 0.18f), shape)
.clickable(onClick = onClick)
.padding(horizontal = 9.dp, vertical = 5.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -166,8 +175,6 @@ fun LutSelector(
currentLutId: String?,
thumbnail: Bitmap?,
onLutSelected: (String?) -> Unit,
lutIntensity: Float? = null,
onLutIntensityChange: ((Float) -> Unit)? = null,
// 预设相关参数 (添加默认值以支持向后兼容)
allPresets: List<CameraPreset> = emptyList(),
presetModeEnabled: Boolean = allPresets.isNotEmpty(),
@@ -291,13 +298,14 @@ fun LutSelector(
CompositionLocalProvider(LocalTextStyle provides LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)) {
Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(4.dp)
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
// 顶栏第 1 行:当前项名称(居左)+ 操作按钮(编辑 / 新建)与设置图标(居右)
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 2.dp),
.heightIn(min = 28.dp)
.padding(horizontal = 10.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
@@ -412,8 +420,8 @@ fun LutSelector(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 2.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
.padding(horizontal = 10.dp),
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically
) {
LutSelectorModeTab(
@@ -440,149 +448,104 @@ fun LutSelector(
when (actualMode) {
LutSelectorMode.Style -> {
// 分类选择器 (小芯片样式)
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(6.dp),
contentPadding = PaddingValues(horizontal = 4.dp)
) {
items(categoryTabs, key = { it.stableKey() }) { category ->
val isSelected = selectedCategory == category
val categoryName = when (category) {
LutCategoryTab.Favorite -> favoriteText
LutCategoryTab.BuiltIn -> builtInText
LutCategoryTab.Uncategorized -> uncategorizedText
is LutCategoryTab.Category -> category.name
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
// 分类使用白色文字保证取景画面上的可读性,选中项以金色区分。
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(horizontal = 8.dp)
) {
items(categoryTabs, key = { it.stableKey() }) { category ->
val isSelected = selectedCategory == category
val categoryName = when (category) {
LutCategoryTab.Favorite -> favoriteText
LutCategoryTab.BuiltIn -> builtInText
LutCategoryTab.Uncategorized -> uncategorizedText
is LutCategoryTab.Category -> category.name
}
Text(
text = categoryName,
color = if (isSelected) LutPanelAccent else Color.White,
fontSize = 11.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null
) {
selectedCategory = category
}
.padding(horizontal = 9.dp, vertical = 3.dp)
)
}
}
Text(
text = categoryName,
color = Color.White,
fontSize = 11.sp,
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Normal,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier
.clip(CircleShape)
.background(if (isSelected) Color.White.copy(alpha = 0.2f) else Color.Transparent)
.border(
width = 1.dp,
color = if (isSelected) Color.White.copy(alpha = 0.5f) else Color.White.copy(alpha = 0.15f),
shape = CircleShape
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(horizontal = 8.dp),
state = scrollState
) {
// LUT 列表
items(filteredLuts, key = { it.id }) { lut ->
var lastManageClickTime by remember { mutableLongStateOf(0L) }
LutItem(
id = lut.id,
name = lut.getName(),
previewBitmap = thumbnail,
isSelected = activeLutId == lut.id,
isVip = lut.isVip,
isCustom = !lut.isBuiltIn,
onClick = {
if (currentLutId == lut.id) {
onEditClick?.invoke()
} else {
onLutSelected(lut.id)
}
},
onManageClick = if (onManageClick != null) {
{
val currentTime = System.currentTimeMillis()
if (currentTime - lastManageClickTime > 1000) {
lastManageClickTime = currentTime
onManageClick(lut.id)
}
}
} else null
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null
) {
selectedCategory = category
}
.padding(horizontal = 8.dp, vertical = 2.dp)
)
}
}
}
}
// 滤镜强度滑块(显示在选择的滤镜上方)
if (activeLutId != null && activeLutId != "none" && lutIntensity != null && onLutIntensityChange != null) {
Row(
LutSelectorMode.Frame -> {
FrameSelector(
availableFrames = availableFrames,
currentFrameId = currentFrameId,
onFrameSelected = requireNotNull(onFrameSelected),
modifier = Modifier
.fillMaxWidth()
.height(24.dp)
.padding(horizontal = 6.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Text(
text = stringResource(R.string.filter_intensity),
color = Color.White,
fontSize = 10.sp,
fontWeight = FontWeight.Medium,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
CustomSlider(
value = lutIntensity.coerceIn(0f, 1f),
onValueChange = onLutIntensityChange,
onDoubleTap = { onLutIntensityChange(1f) },
valueRange = 0f..1f,
activeTrackColor = Color.White,
inactiveTrackColor = Color.White.copy(alpha = 0.2f),
thumbColor = Color.White,
modifier = Modifier
.weight(1f)
.height(18.dp)
)
Text(
text = "${(lutIntensity.coerceIn(0f, 1f) * 100).roundToInt()}%",
color = Color.White,
fontSize = 11.sp,
fontFamily = FontFamily.Monospace,
fontWeight = FontWeight.Bold,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
}
.padding(vertical = 2.dp)
)
}
LazyRow(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 2.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(horizontal = 4.dp),
state = scrollState
) {
// LUT 列表
items(filteredLuts, key = { it.id }) { lut ->
var lastManageClickTime by remember { mutableLongStateOf(0L) }
LutItem(
id = lut.id,
name = lut.getName(),
previewBitmap = thumbnail,
isSelected = activeLutId == lut.id,
isVip = lut.isVip,
isCustom = !lut.isBuiltIn,
onClick = {
if (currentLutId == lut.id) {
onEditClick?.invoke()
} else {
onLutSelected(lut.id)
}
},
onManageClick = if (onManageClick != null) {
{
val currentTime = System.currentTimeMillis()
if (currentTime - lastManageClickTime > 1000) {
lastManageClickTime = currentTime
onManageClick(lut.id)
}
}
} else null
)
}
LutSelectorMode.Presets -> {
// 预设列表
PresetsPanel(
activePresetId = activePresetId,
allPresets = allPresets,
onPresetSelected = onPresetSelected,
onManagePresets = onPresetManagementClick,
modifier = Modifier.fillMaxWidth()
)
}
}
LutSelectorMode.Frame -> {
FrameSelector(
availableFrames = availableFrames,
currentFrameId = currentFrameId,
onFrameSelected = requireNotNull(onFrameSelected),
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 2.dp)
)
}
LutSelectorMode.Presets -> {
// 预设列表
PresetsPanel(
activePresetId = activePresetId,
allPresets = allPresets,
onPresetSelected = onPresetSelected,
onCreatePreset = onCreatePresetClick,
onManagePresets = onPresetManagementClick,
modifier = Modifier.fillMaxWidth()
)
}
}
}
}
}
@Composable
private fun LutSelectorModeTab(
@@ -591,14 +554,15 @@ private fun LutSelectorModeTab(
onClick: () -> Unit,
badgeText: String? = null
) {
val shape = RoundedCornerShape(12.dp)
Row(
modifier = Modifier
.clip(RoundedCornerShape(14.dp))
.background(if (isSelected) Color.White.copy(alpha = 0.18f) else Color.Transparent)
.clip(shape)
.background(if (isSelected) LutPanelAccent.copy(alpha = 0.12f) else LutPanelSurface)
.border(
width = 1.dp,
color = if (isSelected) Color.White.copy(alpha = 0.5f) else Color.White.copy(alpha = 0.15f),
shape = RoundedCornerShape(14.dp)
color = if (isSelected) LutPanelAccent.copy(alpha = 0.65f) else Color.White.copy(alpha = 0.12f),
shape = shape
)
.clickable(
interactionSource = remember { MutableInteractionSource() },
@@ -611,7 +575,7 @@ private fun LutSelectorModeTab(
) {
Text(
text = text,
color = Color.White,
color = if (isSelected) LutPanelAccent else Color.White.copy(alpha = 0.88f),
fontSize = 11.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
@@ -650,41 +614,33 @@ private fun LutItem(
modifier: Modifier = Modifier
) {
val context = LocalContext.current
val backgroundColor = if (isSelected) {
Color.White.copy(alpha = 0.2f)
} else {
Color.Transparent
}
val borderColor = if (isSelected) {
Color.White
} else {
Color.White.copy(alpha = 0.2f)
}
val itemShape = RoundedCornerShape(8.dp)
val borderColor by animateColorAsState(
targetValue = if (isSelected) LutPanelAccent else Color.White.copy(alpha = 0.15f),
label = "lutItemBorder"
)
Column(
modifier = modifier
.width(56.dp)
.clip(RoundedCornerShape(8.dp))
.background(backgroundColor)
.width(64.dp)
.aspectRatio(1f)
.clip(itemShape)
.border(
width = if (isSelected) 1.5.dp else 1.dp,
width = if (isSelected) 1.2.dp else 1.dp,
color = borderColor,
shape = RoundedCornerShape(8.dp)
shape = itemShape
)
.combinedClickable(
onClick = onClick,
onLongClick = onManageClick
)
.padding(horizontal = 4.dp, vertical = 5.dp),
),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// 预览区域
Box(
modifier = Modifier
.size(42.dp)
.clip(RoundedCornerShape(5.dp))
.fillMaxSize()
.then(
if (isNone) {
Modifier.background(Color.DarkGray)
@@ -777,21 +733,31 @@ private fun LutItem(
)
}
}
// 背景只包裹文字,不再形成覆盖缩略图宽度的底栏。
Box(
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(horizontal = 3.dp, vertical = 3.dp)
.clip(RoundedCornerShape(3.dp))
.background(Color.Black.copy(alpha = 0.5f))
.padding(horizontal = 3.dp, vertical = 1.dp)
) {
Text(
text = name,
color = if (isSelected) LutPanelAccent else Color.White,
fontSize = 9.sp,
lineHeight = 11.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier
.widthIn(max = 52.dp)
.basicMarquee()
)
}
}
Spacer(modifier = Modifier.height(4.dp))
// 名称
Text(
text = name,
color = Color.White,
fontSize = 10.sp,
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Normal,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
textAlign = TextAlign.Center,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow),
modifier = Modifier.fillMaxWidth().basicMarquee()
)
}
}
@@ -4,15 +4,12 @@ import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -41,7 +38,6 @@ fun PresetsPanel(
activePresetId: String?,
allPresets: List<CameraPreset>,
onPresetSelected: (CameraPreset?) -> Unit,
onCreatePreset: () -> Unit,
onManagePresets: () -> Unit,
modifier: Modifier = Modifier
) {
@@ -63,48 +59,11 @@ fun PresetsPanel(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
// “新建预设”卡片
Card(
shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors(containerColor = Color.Transparent),
modifier = Modifier
.width(56.dp)
.height(56.dp)
.clip(RoundedCornerShape(8.dp))
.clickable {
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
onCreatePreset()
}
.border(1.dp, Color.White.copy(alpha = 0.2f), RoundedCornerShape(8.dp))
) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Icon(
imageVector = Icons.Default.Add,
contentDescription = stringResource(R.string.preset_new),
tint = Color.White.copy(alpha = 0.85f),
modifier = Modifier.size(16.dp)
)
Spacer(modifier = Modifier.height(3.dp))
Text(
text = stringResource(R.string.preset_new),
color = Color.White,
fontSize = 10.sp,
fontWeight = FontWeight.Medium,
textAlign = TextAlign.Center,
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
}
}
// 各个预设卡片
allPresets.forEach { preset ->
val isSelected = activePresetId == preset.id
val presetBorderColor by animateColorAsState(
targetValue = if (isSelected) Color.White else Color.White.copy(alpha = 0.2f),
targetValue = if (isSelected) LutPanelOptionSelectedBorder else LutPanelOptionBorder,
label = "presetBorderColor"
)
@@ -121,14 +80,17 @@ fun PresetsPanel(
}
Card(
shape = RoundedCornerShape(8.dp),
shape = LutPanelOptionShape,
colors = CardDefaults.cardColors(
containerColor = if (isSelected) Color.White.copy(alpha = 0.2f) else Color.Transparent
containerColor = if (isSelected) {
LutPanelOptionSelectedSurface
} else {
LutPanelOptionSurface
}
),
modifier = Modifier
.width(68.dp)
.height(56.dp)
.clip(RoundedCornerShape(8.dp))
.size(LutPanelOptionSize)
.clip(LutPanelOptionShape)
.combinedClickable(
onClick = {
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
@@ -139,7 +101,7 @@ fun PresetsPanel(
onManagePresets()
}
)
.border(if (isSelected) 1.5.dp else 1.dp, presetBorderColor, RoundedCornerShape(8.dp))
.border(if (isSelected) 1.5.dp else 1.dp, presetBorderColor, LutPanelOptionShape)
) {
Column(
modifier = Modifier
@@ -470,7 +470,7 @@
<string name="recipe_param_soft_light">柔光</string>
<string name="recipe_param_hdf">HDF</string>
<string name="recipe_param_halation">光暈</string>
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
<string name="recipe_param_chromatic_aberration">色散</string>
<string name="recipe_param_noise">噪點</string>
<string name="recipe_param_low_res">低像素</string>
<string name="recipe_param_lut_intensity">LUT強度</string>
+1 -1
View File
@@ -298,7 +298,7 @@
<string name="recipe_param_soft_light">แสงนุ่ม</string>
<string name="recipe_param_hdf">HDF</string>
<string name="recipe_param_halation">แสงเรืองรอง (Halation)</string>
<string name="recipe_param_chromatic_aberration">การกระจายตัว (CA)</string>
<string name="recipe_param_chromatic_aberration">การกระจายตัว</string>
<string name="recipe_param_noise">เสียงรบกวน</string>
<string name="recipe_param_low_res">พิกเซลต่ำ</string>
<string name="recipe_param_lut_intensity">LUT</string>
+1 -1
View File
@@ -489,7 +489,7 @@
<string name="recipe_param_soft_light">柔光</string>
<string name="recipe_param_hdf">HDF</string>
<string name="recipe_param_halation">光晕</string>
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
<string name="recipe_param_chromatic_aberration">色散</string>
<string name="recipe_param_noise">噪点</string>
<string name="recipe_param_low_res">低像素</string>
<string name="recipe_param_lut_intensity">LUT强度</string>
+1 -1
View File
@@ -470,7 +470,7 @@
<string name="recipe_param_soft_light">柔光</string>
<string name="recipe_param_hdf">HDF</string>
<string name="recipe_param_halation">光暈</string>
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
<string name="recipe_param_chromatic_aberration">色散</string>
<string name="recipe_param_noise">噪點</string>
<string name="recipe_param_low_res">低像素</string>
<string name="recipe_param_lut_intensity">LUT強度</string>
+1 -1
View File
@@ -470,7 +470,7 @@
<string name="recipe_param_soft_light">柔光</string>
<string name="recipe_param_hdf">HDF</string>
<string name="recipe_param_halation">光暈</string>
<string name="recipe_param_chromatic_aberration">色散(CA)</string>
<string name="recipe_param_chromatic_aberration">色散</string>
<string name="recipe_param_noise">噪點</string>
<string name="recipe_param_low_res">低像素</string>
<string name="recipe_param_lut_intensity">LUT強度</string>