feat: blur effect for gallery edit panel

This commit is contained in:
zhoubinjia committed 2026-11-20 11:55:22 +08:00
1 parent b2e70867af
commit fc878f22f4
7 files changed
+1170 -1007

No files matched your search

@@ -7,12 +7,15 @@ import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
@@ -38,6 +41,7 @@ import androidx.compose.ui.semantics.semantics
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
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.hinnka.mycamera.R
@@ -152,69 +156,88 @@ fun ColorGradingPanel(
)
}
GradingColorWheel(
hue = selected.hue,
amount = selected.amount,
contentDescription = selectedLabel,
onSelectionChange = { hue, amount ->
onParamsChange(currentParams.withSelection(selectedRange, hue, amount))
},
onReset = {
onParamsChange(currentParams.withSelection(selectedRange, 0f, 0f))
},
modifier = Modifier.size(184.dp),
)
BoxWithConstraints(Modifier.fillMaxWidth()) {
val wheelWidth = minOf(maxWidth * 0.44f, 160.dp)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalAlignment = Alignment.Top,
) {
Column(
modifier = Modifier.width(wheelWidth),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(7.dp),
) {
GradingColorWheel(
hue = selected.hue,
amount = selected.amount,
contentDescription = selectedLabel,
onSelectionChange = { hue, amount ->
onParamsChange(currentParams.withSelection(selectedRange, hue, amount))
},
onReset = {
onParamsChange(currentParams.withSelection(selectedRange, 0f, 0f))
},
modifier = Modifier.fillMaxWidth().aspectRatio(1f),
)
Text(
text = String.format(
java.util.Locale.getDefault(),
"%.1f · %.1f",
selected.hue.coerceIn(0f, 1f) * 10f,
selected.amount.coerceIn(0f, 1f) * 10f,
),
color = if (selected.amount > 0.001f) selectedColor else Color.White.copy(alpha = 0.48f),
fontSize = 11.sp,
fontWeight = FontWeight.SemiBold,
fontFamily = FontFamily.Monospace,
)
Text(
text = String.format(
java.util.Locale.getDefault(),
"%.1f · %.1f",
selected.hue.coerceIn(0f, 1f) * 10f,
selected.amount.coerceIn(0f, 1f) * 10f,
),
color = if (selected.amount > 0.001f) selectedColor else Color.White.copy(alpha = 0.48f),
fontSize = 11.sp,
fontWeight = FontWeight.SemiBold,
fontFamily = FontFamily.Monospace,
)
}
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(7.dp),
) {
GradingSliderControl(
label = stringResource(R.string.recipe_grading_luminance),
value = selected.luminance * 10f,
valueRange = -10f..10f,
defaultValue = 0f,
valueText = formatSignedValue(selected.luminance * 10f),
onValueChange = {
onParamsChange(
currentParams.withLuminance(selectedRange, (it / 10f).coerceIn(-1f, 1f))
)
},
)
GradingSliderRow(
label = stringResource(R.string.recipe_grading_luminance),
value = selected.luminance * 10f,
valueRange = -10f..10f,
defaultValue = 0f,
valueText = formatSignedValue(selected.luminance * 10f),
onValueChange = {
onParamsChange(
currentParams.withLuminance(selectedRange, (it / 10f).coerceIn(-1f, 1f))
)
},
)
GradingSliderRow(
label = stringResource(R.string.recipe_grading_balance),
value = currentParams.gradingBalance * 10f,
valueRange = -10f..10f,
defaultValue = 0f,
valueText = formatSignedValue(currentParams.gradingBalance * 10f),
onValueChange = {
onParamsChange(currentParams.copy(gradingBalance = (it / 10f).coerceIn(-1f, 1f)))
},
)
GradingSliderRow(
label = stringResource(R.string.recipe_grading_blending),
value = currentParams.gradingBlending * 10f,
valueRange = 0f..10f,
defaultValue = 5f,
valueText = String.format(
java.util.Locale.getDefault(),
"%.1f",
currentParams.gradingBlending.coerceIn(0f, 1f) * 10f,
),
onValueChange = {
onParamsChange(currentParams.copy(gradingBlending = (it / 10f).coerceIn(0f, 1f)))
},
)
GradingSliderControl(
label = stringResource(R.string.recipe_grading_balance),
value = currentParams.gradingBalance * 10f,
valueRange = -10f..10f,
defaultValue = 0f,
valueText = formatSignedValue(currentParams.gradingBalance * 10f),
onValueChange = {
onParamsChange(currentParams.copy(gradingBalance = (it / 10f).coerceIn(-1f, 1f)))
},
)
GradingSliderControl(
label = stringResource(R.string.recipe_grading_blending),
value = currentParams.gradingBlending * 10f,
valueRange = 0f..10f,
defaultValue = 5f,
valueText = String.format(
java.util.Locale.getDefault(),
"%.1f",
currentParams.gradingBlending.coerceIn(0f, 1f) * 10f,
),
onValueChange = {
onParamsChange(currentParams.copy(gradingBlending = (it / 10f).coerceIn(0f, 1f)))
},
)
}
}
}
}
}
@@ -248,7 +271,8 @@ private fun GradingColorWheel(
center.x + cos(markerAngle) * currentAmount * radius,
center.y + sin(markerAngle) * currentAmount * radius,
)
if ((position - markerCenter).getDistance() <= 24.dp.toPx()) {
val markerHitRadius = minOf(24.dp.toPx(), minOf(size.width, size.height) * (24f / 184f))
if ((position - markerCenter).getDistance() <= markerHitRadius) {
return
}
val dx = position.x - center.x
@@ -283,9 +307,8 @@ private fun GradingColorWheel(
sin(angle) * currentAmount * radius,
)
val pointerSelection = position - center
selectionStart = if (
(pointerSelection - currentSelection).getDistance() <= 24.dp.toPx()
) {
val markerHitRadius = minOf(24.dp.toPx(), minOf(size.width, size.height) * (24f / 184f))
selectionStart = if ((pointerSelection - currentSelection).getDistance() <= markerHitRadius) {
currentSelection
} else {
pointerSelection
@@ -317,6 +340,7 @@ private fun GradingColorWheel(
) {
val inset = 8.dp.toPx()
val diameter = minOf(size.width, size.height) - inset * 2f
if (diameter <= 0f) return@Canvas
val center = Offset(size.width / 2f, size.height / 2f)
val radius = diameter / 2f
val wheelTopLeft = Offset(center.x - radius, center.y - radius)
@@ -453,7 +477,7 @@ private fun GradingTonePreview(
}
@Composable
private fun GradingSliderRow(
private fun GradingSliderControl(
label: String,
value: Float,
valueRange: ClosedFloatingPointRange<Float>,
@@ -461,21 +485,35 @@ private fun GradingSliderRow(
valueText: String,
onValueChange: (Float) -> Unit,
) {
Row(
Column(
modifier = Modifier
.fillMaxWidth()
.height(36.dp)
.background(Color.White.copy(alpha = 0.02f), RoundedCornerShape(6.dp))
.padding(horizontal = 8.dp),
verticalAlignment = Alignment.CenterVertically,
.padding(horizontal = 8.dp, vertical = 4.dp),
verticalArrangement = Arrangement.spacedBy(2.dp),
) {
Text(
text = label,
color = Color.White.copy(alpha = 0.66f),
fontSize = 11.sp,
modifier = Modifier.size(width = 58.dp, height = 20.dp),
maxLines = 1,
)
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = label,
color = Color.White.copy(alpha = 0.66f),
fontSize = 11.sp,
modifier = Modifier.weight(1f),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
Text(
text = valueText,
color = Color.White.copy(alpha = 0.72f),
fontSize = 10.sp,
fontWeight = FontWeight.Medium,
textAlign = TextAlign.End,
fontFamily = FontFamily.Monospace,
maxLines = 1,
)
}
CustomSlider(
value = value,
onValueChange = onValueChange,
@@ -485,19 +523,6 @@ private fun GradingSliderRow(
inactiveTrackColor = Color.White.copy(alpha = 0.14f),
thumbColor = Color.White,
thumbRadius = 7.dp,
modifier = Modifier
.weight(1f)
.padding(horizontal = 8.dp),
)
Text(
text = valueText,
color = Color.White.copy(alpha = 0.72f),
fontSize = 10.sp,
fontWeight = FontWeight.Medium,
textAlign = TextAlign.End,
fontFamily = FontFamily.Monospace,
modifier = Modifier.size(width = 42.dp, height = 20.dp),
maxLines = 1,
)
}
}
@@ -132,6 +132,7 @@ fun ColorRecipePanel(
onEffectsChange: ((EffectParams) -> Unit)? = null,
headerControls: (@Composable () -> Unit)? = null,
containerShape: Shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
containerColor: Color = Color(0xF2121316),
onResetAll: (() -> Unit)? = null,
modifier: Modifier = Modifier
) {
@@ -385,13 +386,10 @@ fun ColorRecipePanel(
modifier = Modifier
.fillMaxWidth()
.clip(containerShape)
.background(
if (isCurveDragging) Color.Transparent
else Color(0xF9121316).copy(alpha = 0.95f)
)
.background(if (isCurveDragging) Color.Transparent else containerColor)
.border(
0.5.dp,
Color.White.copy(alpha = if (isCurveDragging) 0f else 0.08f),
Color.White.copy(alpha = if (isCurveDragging || containerColor == Color.Transparent) 0f else 0.08f),
containerShape
)
.padding(start = 14.dp, top = 12.dp, end = 14.dp, bottom = 12.dp),
@@ -504,8 +502,6 @@ fun ColorRecipePanel(
onTabReset = ::resetTab,
)
Spacer(modifier = Modifier.height(4.dp))
when (selectedTab) {
RecipePanelTab.CURVE -> {
CurveEditorPanel(
@@ -523,7 +519,6 @@ fun ColorRecipePanel(
selectedSection = selectedColorSection,
onSectionSelected = { selectedColorSection = it }
)
Spacer(modifier = Modifier.height(4.dp))
when (selectedColorSection) {
ColorPanelSection.CALIBRATION -> {
ColorRingTabs(
@@ -539,7 +534,6 @@ fun ColorRecipePanel(
}
}
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
calibrationGroups[selectedCalibrationTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
@@ -564,7 +558,6 @@ fun ColorRecipePanel(
onTabSelected = { selectedLchTabIndex = it },
getColor = { getLchTabColor(it) }
)
Spacer(modifier = Modifier.height(4.dp))
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
lchGroups[selectedLchTabIndex].second.forEach { param ->
RecipeIntegerParamItem(
@@ -54,27 +54,50 @@ fun CurveEditorPanel(
onCurveChange: (CurveChannel, FloatArray?) -> Unit,
imageHistogram: ImageHistogram? = null,
onDragStateChange: (Boolean) -> Unit = {},
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) {
var activeChannel by remember { mutableStateOf(CurveChannel.MASTER) }
var visibleChannels by remember { mutableStateOf(CurveChannel.entries.toSet()) }
Column(
val currentPoints = currentParams.getCurvePoints(activeChannel)
val inactiveCurves = visibleChannels
.asSequence()
.filter { it != activeChannel }
.map { channel ->
DisplayCurve(
points = currentParams.getCurvePoints(channel) ?: identityPoints(),
color = channel.color,
)
}
.toList()
Row(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(6.dp),
horizontalAlignment = Alignment.CenterHorizontally,
horizontalArrangement = Arrangement.Absolute.spacedBy(6.dp, Alignment.CenterHorizontally),
verticalAlignment = Alignment.CenterVertically,
) {
val currentPoints = currentParams.getCurvePoints(activeChannel)
val inactiveCurves = visibleChannels
.asSequence()
.filter { it != activeChannel }
.map { channel ->
DisplayCurve(
points = currentParams.getCurvePoints(channel) ?: identityPoints(),
color = channel.color,
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
CurveChannel.entries.forEach { channel ->
CurveChannelButton(
channel = channel,
isVisible = channel in visibleChannels,
isActive = activeChannel == channel,
onClick = {
when {
channel !in visibleChannels -> {
visibleChannels = visibleChannels + channel
activeChannel = channel
}
activeChannel != channel -> activeChannel = channel
visibleChannels.size > 1 -> {
visibleChannels = visibleChannels - channel
activeChannel = visibleChannels.first()
}
}
},
)
}
.toList()
}
key(activeChannel) {
CurveCanvas(
@@ -93,60 +116,41 @@ fun CurveEditorPanel(
}
onCurveChange(activeChannel, arr)
},
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.widthIn(max = 288.dp)
.fillMaxWidth(),
)
}
}
}
// 参考移动端修图应用,通道放到大画布下方,不再挤占横向编辑空间。
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
) {
CurveChannel.entries.forEach { channel ->
val isVisible = channel in visibleChannels
val isActive = activeChannel == channel
Box(
modifier = Modifier
.size(40.dp)
.clip(RoundedCornerShape(8.dp))
.background(
when {
isActive -> channel.color.copy(alpha = 0.28f)
isVisible -> channel.color.copy(alpha = 0.12f)
else -> Color.Transparent
}
)
.clickable {
when {
!isVisible -> {
visibleChannels = visibleChannels + channel
activeChannel = channel
}
!isActive -> activeChannel = channel
visibleChannels.size > 1 -> {
visibleChannels = visibleChannels - channel
activeChannel = visibleChannels.first()
}
}
},
contentAlignment = Alignment.Center,
) {
Text(
text = channel.label,
color = if (isVisible) {
channel.color
} else {
channel.color.copy(alpha = 0.45f)
},
fontSize = 12.sp,
fontWeight = if (isActive) FontWeight.Bold else FontWeight.Normal,
)
@Composable
private fun CurveChannelButton(
channel: CurveChannel,
isVisible: Boolean,
isActive: Boolean,
onClick: () -> Unit,
) {
Box(
modifier = Modifier
.size(40.dp)
.clip(RoundedCornerShape(8.dp))
.background(
when {
isActive -> channel.color.copy(alpha = 0.28f)
isVisible -> channel.color.copy(alpha = 0.12f)
else -> Color.Transparent
}
}
}
)
.clickable(onClick = onClick),
contentAlignment = Alignment.Center,
) {
Text(
text = channel.label,
color = if (isVisible) channel.color else channel.color.copy(alpha = 0.45f),
fontSize = 12.sp,
fontWeight = if (isActive) FontWeight.Bold else FontWeight.Normal,
)
}
}
@@ -167,7 +171,7 @@ private fun CurveCanvas(
) {
val density = LocalDensity.current
val hitThresholdPx = with(density) { 30.dp.toPx() }
val graphInsetPx = with(density) { 16.dp.toPx() }
val graphInsetPx = with(density) { 10.dp.toPx() }
// 内部拖动状态;pointerInput key 使用 state 对象引用(稳定)
val controlPointsState = remember { mutableStateOf(parsePoints(points)) }
@@ -202,7 +206,7 @@ private fun CurveCanvas(
var lastTapTime by remember { mutableLongStateOf(0L) }
var lastTapIndex by remember { mutableIntStateOf(-1) }
Box(modifier = modifier.padding(vertical = 4.dp)) {
Box(modifier = modifier) {
Canvas(
modifier = Modifier
.fillMaxWidth()
@@ -58,7 +58,7 @@ import kotlin.math.floor
* glass node is only re-rendered when its backdrop or geometry changes, not when panel content does.
*
* Capability tiers: API 33+ full lens + highlight; API 31-32 vibrancy with a flat rim;
* API 30 an opaque fallback color without backdrop capture.
* API 30 a fallback tint without backdrop capture.
*/
@Immutable
data class LiquidGlassStyle(
@@ -148,14 +148,14 @@ fun LiquidGlassSurface(
val backdropPosition = backdrop.positionInRoot
val backdropSize = backdrop.size
if (!BACKDROP_SUPPORTED) {
if (!BACKDROP_SUPPORTED || !positionInRoot.isSpecified || !backdropPosition.isSpecified ||
backdropSize == IntSize.Zero
) {
return@drawWithCache onDrawBehind {
clipRect { drawPath(outline, style.fallbackColor) }
}
}
if (!positionInRoot.isSpecified || !backdropPosition.isSpecified ||
backdropSize == IntSize.Zero || width <= 0f || height <= 0f
) {
if (width <= 0f || height <= 0f) {
return@drawWithCache onDrawBehind {}
}
@@ -172,7 +172,9 @@ fun LiquidGlassSurface(
ceil(captureRect.bottom).toInt() - layerOffset.y,
)
if (layerSize.width <= 0 || layerSize.height <= 0) {
return@drawWithCache onDrawBehind {}
return@drawWithCache onDrawBehind {
clipRect { drawPath(outline, style.fallbackColor) }
}
}
val glassLayer = obtainGraphicsLayer().apply {
@@ -249,7 +251,9 @@ private fun glassEffect(
} else {
vibrancy
}
if (shaders == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return blur
if (refractionAmount == 0f || refractionHeight == 0f || shaders == null ||
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
) return blur
return shaders.lensEffect(blur, shapeOffset, shapeWidth, shapeHeight, radius, bottomRadius,
refractionHeight, refractionAmount)
}
@@ -198,6 +198,7 @@ fun LutSelector(
presetThumbnailInput: com.hinnka.mycamera.lut.PresetThumbnailInput? = null,
onEditPreset: ((String) -> Unit)? = null,
presetLookActive: Boolean = false,
showHorizontalHeader: Boolean = true,
) {
val favoriteText = stringResource(R.string.favorite)
val uncategorizedText = stringResource(R.string.uncategorized)
@@ -522,112 +523,114 @@ fun LutSelector(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
headerContent?.invoke()
// 顶栏第 1 行:当前项名称(居左)+ 操作按钮(编辑 / 新建)与设置图标(居右)
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 28.dp)
.padding(horizontal = 10.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
when (actualMode) {
LutSelectorMode.Style -> {
val currentLut = availableLuts.find { it.id == activeLutId }
val currentName = if (activeLutId == null || activeLutId == "none") {
stringResource(R.string.none)
} else {
currentLut?.getName() ?: ""
}
Text(
text = currentName,
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
if (editActiveLut != null) {
LutEditButton(onClick = editActiveLut)
if (showHorizontalHeader) {
// 顶栏第 1 行:当前项名称(居左)+ 操作按钮(编辑 / 新建)与设置图标(居右)
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 28.dp)
.padding(horizontal = 10.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
when (actualMode) {
LutSelectorMode.Style -> {
val currentLut = availableLuts.find { it.id == activeLutId }
val currentName = if (activeLutId == null || activeLutId == "none") {
stringResource(R.string.none)
} else {
currentLut?.getName() ?: ""
}
Text(
text = currentName,
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
if (onManageClick != null) {
var lastClickTime by remember { mutableLongStateOf(0L) }
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
if (editActiveLut != null) {
LutEditButton(onClick = editActiveLut)
}
if (onManageClick != null) {
var lastClickTime by remember { mutableLongStateOf(0L) }
LutPanelIconButton(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings_filter_management),
onClick = {
val currentTime = System.currentTimeMillis()
if (currentTime - lastClickTime > 1000) {
lastClickTime = currentTime
onManageClick(activeLutId ?: "")
}
}
)
}
}
}
LutSelectorMode.Frame -> {
val currentFrame = availableFrames.find { it.id == currentFrameId }
val currentName = if (currentFrameId == null) stringResource(R.string.none) else (currentFrame?.name ?: "")
Text(
text = currentName,
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
if (onFrameManagementClick != null) {
LutPanelIconButton(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings_filter_management),
onClick = {
val currentTime = System.currentTimeMillis()
if (currentTime - lastClickTime > 1000) {
lastClickTime = currentTime
onManageClick(activeLutId ?: "")
}
}
contentDescription = stringResource(R.string.settings_frame_management),
onClick = onFrameManagementClick
)
}
}
}
LutSelectorMode.Frame -> {
val currentFrame = availableFrames.find { it.id == currentFrameId }
val currentName = if (currentFrameId == null) stringResource(R.string.none) else (currentFrame?.name ?: "")
Text(
text = currentName,
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
if (onFrameManagementClick != null) {
LutPanelIconButton(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings_frame_management),
onClick = onFrameManagementClick
)
}
}
LutSelectorMode.Presets -> {
val currentPreset = activePreset
val currentName = currentPreset?.let { presetDisplayName(it) }.orEmpty()
Text(
text = if (currentPreset != null && activePresetModified) {
"$currentName*"
} else {
currentName
},
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
LutPanelPresetActionButton(
text = stringResource(if (activePresetModified) R.string.preset_save_as else R.string.preset_new),
onClick = onCreatePresetClick
LutSelectorMode.Presets -> {
val currentPreset = activePreset
val currentName = currentPreset?.let { presetDisplayName(it) }.orEmpty()
Text(
text = if (currentPreset != null && activePresetModified) {
"$currentName*"
} else {
currentName
},
color = Color.White,
fontSize = 13.sp,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f).padding(end = 8.dp).basicMarquee(),
style = LocalTextStyle.current.copy(shadow = ViewfinderTextShadow)
)
LutPanelIconButton(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings_preset_management),
onClick = onPresetManagementClick
)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp)
) {
LutPanelPresetActionButton(
text = stringResource(if (activePresetModified) R.string.preset_save_as else R.string.preset_new),
onClick = onCreatePresetClick
)
LutPanelIconButton(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings_preset_management),
onClick = onPresetManagementClick
)
}
}
}
}
@@ -52,7 +52,6 @@ import com.hinnka.mycamera.raw.SpectralFilmSelection
import com.hinnka.mycamera.raw.SpectralFilmUiInfo
import com.hinnka.mycamera.raw.fotufilm.FotufilmDocument
import kotlin.math.roundToInt
import com.hinnka.mycamera.ui.settings.DropdownSettingItem
import com.hinnka.mycamera.ui.icons.AppIcons
enum class RawEditPanelContentMode {
@@ -150,6 +149,7 @@ fun RawEditPanel(
contentMode: RawEditPanelContentMode = RawEditPanelContentMode.FULL,
hncsFilmCurveMode: HncsFilmCurveMode = HncsFilmCurveMode.Standard,
onHncsFilmCurveModeChange: (HncsFilmCurveMode) -> Unit = {},
compactLayout: Boolean = false,
modifier: Modifier = Modifier
) {
Column(
@@ -207,62 +207,85 @@ fun RawEditPanel(
)
if (contentMode == RawEditPanelContentMode.FULL) {
SliderSettingItem(
title = stringResource(R.string.settings_raw_exposure_compensation),
value = rawExposureCompensation,
valueRange = MeteringSystem.RAW_EXPOSURE_MIN_EV..MeteringSystem.RAW_EXPOSURE_MAX_EV,
resetValue = 0f,
onResetValue = onRawExposureCompensationReset,
onValueChange = {
onAdjustmentStart()
onRawExposureCompensationChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_highlights_adjustment),
value = rawHighlightsAdjustment,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawHighlightsAdjustmentChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_shadows_adjustment),
value = rawShadowsAdjustment,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawShadowsAdjustmentChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_blacks_adjustment),
value = rawBlackPointCorrection,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawBlackPointCorrectionChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_whites_adjustment),
value = rawWhitePointCorrection,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawWhitePointCorrectionChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
var lightAdjustmentsExpanded by remember { mutableStateOf(false) }
if (compactLayout) {
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 48.dp)
.clickable(role = Role.Button) {
lightAdjustmentsExpanded = !lightAdjustmentsExpanded
}
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(stringResource(R.string.recipe_tab_light), color = Color.White, fontSize = 16.sp)
Icon(
imageVector = if (lightAdjustmentsExpanded) AppIcons.ExpandLess else AppIcons.ExpandMore,
contentDescription = null,
tint = Color.White.copy(alpha = 0.6f),
)
}
}
if (!compactLayout || lightAdjustmentsExpanded) {
SliderSettingItem(
title = stringResource(R.string.settings_raw_exposure_compensation),
value = rawExposureCompensation,
valueRange = MeteringSystem.RAW_EXPOSURE_MIN_EV..MeteringSystem.RAW_EXPOSURE_MAX_EV,
resetValue = 0f,
onResetValue = onRawExposureCompensationReset,
onValueChange = {
onAdjustmentStart()
onRawExposureCompensationChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_highlights_adjustment),
value = rawHighlightsAdjustment,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawHighlightsAdjustmentChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_shadows_adjustment),
value = rawShadowsAdjustment,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawShadowsAdjustmentChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_blacks_adjustment),
value = rawBlackPointCorrection,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawBlackPointCorrectionChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
SliderSettingItem(
title = stringResource(R.string.settings_raw_whites_adjustment),
value = rawWhitePointCorrection,
valueRange = -1f..1f,
resetValue = 0f,
onValueChange = {
onAdjustmentStart()
onRawWhitePointCorrectionChange(it)
},
onValueChangeFinished = onAdjustmentEnd
)
}
if (showDngMetadataControls) {
RawDngMetadataCorrectionSettings(
rawBlackLevelMode = rawBlackLevelMode,
@@ -274,7 +297,8 @@ fun RawEditPanel(
onRawCustomBlackLevelChange = onRawCustomBlackLevelChange,
onRawWhiteLevelModeChange = onRawWhiteLevelModeChange,
onRawCustomWhiteLevelChange = onRawCustomWhiteLevelChange,
onRawCfaCorrectionModeChange = onRawCfaCorrectionModeChange
onRawCfaCorrectionModeChange = onRawCfaCorrectionModeChange,
useDropdowns = compactLayout,
)
}
}
@@ -542,6 +566,7 @@ fun RawDngMetadataCorrectionSettings(
onRawWhiteLevelModeChange: (String) -> Unit,
onRawCustomWhiteLevelChange: (Float) -> Unit,
onRawCfaCorrectionModeChange: (String) -> Unit,
useDropdowns: Boolean = false,
modifier: Modifier = Modifier
) {
Column(modifier = modifier.fillMaxWidth()) {
@@ -558,7 +583,8 @@ fun RawDngMetadataCorrectionSettings(
"Custom" to stringResource(R.string.settings_black_level_custom)
),
currentLevel = rawBlackLevelMode,
onLevelSelected = onRawBlackLevelModeChange
onLevelSelected = onRawBlackLevelModeChange,
useDropdown = useDropdowns,
)
if (rawBlackLevelMode == "Custom") {
RawNumberInputSetting(
@@ -579,7 +605,8 @@ fun RawDngMetadataCorrectionSettings(
RawWhiteLevelCorrection.MODE_CUSTOM to stringResource(R.string.settings_white_level_custom)
),
currentLevel = rawWhiteLevelMode,
onLevelSelected = onRawWhiteLevelModeChange
onLevelSelected = onRawWhiteLevelModeChange,
useDropdown = useDropdowns,
)
if (rawWhiteLevelMode == RawWhiteLevelCorrection.MODE_CUSTOM) {
RawNumberInputSetting(
@@ -607,7 +634,8 @@ fun RawDngMetadataCorrectionSettings(
RawCfaCorrection.MODE_8X8_BGGR to stringResource(R.string.settings_cfa_correction_8x8_bggr)
),
currentLevel = rawCfaCorrectionMode,
onLevelSelected = onRawCfaCorrectionModeChange
onLevelSelected = onRawCfaCorrectionModeChange,
useDropdown = useDropdowns,
)
}
}
@@ -810,8 +838,13 @@ private fun RawChoiceSetting(
levels: List<Pair<String, String>>,
currentLevel: String,
onLevelSelected: (String) -> Unit,
useDropdown: Boolean = false,
modifier: Modifier = Modifier
) {
if (useDropdown) {
RawChoiceDropdown(title, description, levels, currentLevel, onLevelSelected, modifier)
return
}
Column(
modifier = modifier
.fillMaxWidth()
@@ -860,6 +893,55 @@ private fun RawChoiceSetting(
}
}
@Composable
private fun RawChoiceDropdown(
title: String,
description: String,
levels: List<Pair<String, String>>,
currentLevel: String,
onLevelSelected: (String) -> Unit,
modifier: Modifier = Modifier,
) {
var expanded by remember { mutableStateOf(false) }
Row(
modifier = modifier
.fillMaxWidth()
.clickable(role = Role.Button) { expanded = true }
.padding(vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
Text(title, color = Color.White, fontSize = 16.sp)
Text(description, color = Color.White.copy(alpha = 0.6f), fontSize = 13.sp, lineHeight = 18.sp)
Text(
text = levels.firstOrNull { (level, _) -> level == currentLevel }?.second ?: currentLevel,
color = AccentColor,
fontSize = 14.sp,
)
}
Spacer(Modifier.width(16.dp))
Box {
Icon(AppIcons.ExpandMore, contentDescription = null, tint = Color.White.copy(alpha = 0.6f))
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier.heightIn(max = 320.dp),
containerColor = Color(0xFF2C2C2E),
) {
levels.forEach { (level, label) ->
DropdownMenuItem(
text = { Text(label, color = if (level == currentLevel) AccentColor else Color.White) },
onClick = {
expanded = false
onLevelSelected(level)
},
)
}
}
}
}
}
@Composable
private fun RawNumberInputSetting(
title: String,
@@ -2109,13 +2191,11 @@ fun RawBaselineColorCorrectionBottomSheet(
availableLuts: List<LutInfo>,
thumbnail: Bitmap?,
title: String = stringResource(R.string.settings_baseline_raw_title),
containerColor: Color? = null,
onSelectLut: (String?) -> Unit,
onEditRecipe: ((String) -> Unit)? = null,
onDismiss: () -> Unit
) {
AppModalBottomSheet(
containerColor = containerColor,
style = AppSheetStyle.Translucent,
onDismissRequest = onDismiss,
dragHandle = { BottomSheetDefaults.DragHandle(color = Color.White.copy(alpha = 0.2f)) }
File diff suppressed because it is too large. Load diff