|
@@ -17,7 +17,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import com.ys.imageProcess.R
|
|
|
import com.ys.imageProcess.ui.theme.Blue
|
|
|
-import com.ys.imageProcess.ui.work.ImageAction.*
|
|
|
+import com.ys.imageProcess.ui.work.ViewAction.*
|
|
|
|
|
|
/**
|
|
|
* 操作类型
|
|
@@ -28,8 +28,8 @@ import com.ys.imageProcess.ui.work.ImageAction.*
|
|
|
* @property ShowWidth 显示宽
|
|
|
* @property ShowContour 显示轮廓
|
|
|
*/
|
|
|
-enum class ImageAction {
|
|
|
- Back, ZoomIn, ZoomOut, FitScreen, ShowContour, ShowLength, ShowWidth;
|
|
|
+enum class ViewAction {
|
|
|
+ Back, ZoomIn, ZoomOut, FitScreen, ShowContour, ShowLength, ShowWidth, ToEdit;
|
|
|
|
|
|
fun icon(): Int {
|
|
|
return when (this) {
|
|
@@ -40,6 +40,7 @@ enum class ImageAction {
|
|
|
ShowContour -> R.drawable.show_contour
|
|
|
ShowLength -> R.drawable.show_length
|
|
|
ShowWidth -> R.drawable.show_width2
|
|
|
+ ToEdit -> R.drawable.edit_path2
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -53,17 +54,17 @@ data class ImageState(
|
|
|
)
|
|
|
|
|
|
@Composable
|
|
|
-fun ToolView(
|
|
|
+fun ViewToolBar(
|
|
|
modifier: Modifier = Modifier,
|
|
|
state: ImageState = ImageState(),
|
|
|
- action: (ImageAction) -> Unit
|
|
|
+ action: (ViewAction) -> Unit
|
|
|
) {
|
|
|
Row(
|
|
|
modifier.background(Color.LightGray),
|
|
|
horizontalArrangement = Arrangement.SpaceEvenly,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
|
- ImageAction.entries.forEach { it ->
|
|
|
+ ViewAction.entries.forEach { it ->
|
|
|
val enabled: Boolean = when (it) {
|
|
|
FitScreen -> !state.isFitScreen
|
|
|
else -> true
|
|
@@ -77,6 +78,7 @@ fun ToolView(
|
|
|
ShowContour -> if (state.showContour) Blue else Color.DarkGray
|
|
|
ShowLength -> if (state.showLength) Blue else Color.DarkGray
|
|
|
ShowWidth -> if (state.showWidth) Blue else Color.DarkGray
|
|
|
+ ToEdit -> Color.DarkGray
|
|
|
}
|
|
|
|
|
|
Button(
|
|
@@ -103,7 +105,7 @@ fun ToolView(
|
|
|
@Preview(device = "id:pixel_tablet")
|
|
|
@Composable
|
|
|
private fun ToolPreview() {
|
|
|
- ToolView {}
|
|
|
+ ViewToolBar {}
|
|
|
}
|
|
|
|
|
|
const val zoomStep = 1.5f
|