ProCraft for Android: An Android native painting app written in Rust
Rust
fix: landscape layouts, surround grid and private layers
Josh48c65688a797
diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.ktindex 1c706bf..373972a 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasSurfaceView.kt@@ -309,6 +309,7 @@ class CanvasSurfaceView(context: Context, private val vm: CanvasViewModel) : Sur}private fun remember(width: Int, height: Int, rotation: Int) {+ vm.session?.let { placeGrid(it, width, height, rotation) }vm.screenCentre = Offset(width / 2f, height / 2f)windowWidth = widthwindowHeight = height@@ -317,6 +318,23 @@ class CanvasSurfaceView(context: Context, private val vm: CanvasViewModel) : SurwindowRotation = rotation}+ /**+ * The surround's grid is fixed to the glass as the canvas is: its 1 pt lines lie every 16 pt+ * from the panel's own top-left corner in its natural orientation, so in the window a line's+ * middle is half a point in from whichever corner that is.+ */+ private fun placeGrid(s: CanvasSession, width: Int, height: Int, rotation: Int) {+ val half = 0.5f * resources.displayMetrics.density+ val (nw, nh) = if (rotation % 2 == 0) width.toFloat() to height.toFloat() else height.toFloat() to width.toFloat()+ val (x, y) = when (rotation) {+ Surface.ROTATION_90 -> half to nw - half+ Surface.ROTATION_180 -> nw - half to nh - half+ Surface.ROTATION_270 -> nh - half to half+ else -> half to half+ }+ s.setGridOrigin(x, y)+ }+/*** The display turned from rotation [from] to [to]: the view turns the other way, so the canvas* stays where it was on the glass while the bars turn upright.diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.ktindex 6d765f9..c22418e 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/canvas/CanvasViewModel.kt@@ -1682,6 +1682,9 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {/** Gesture controls is open. */var gestureControlsOpen by mutableStateOf(false)+ /** The page Gesture controls was last on: it opens there again. */+ var gesturePage by mutableStateOf(GesturePurpose.EYEDROPPER)+/** Canvas information is open. */var canvasInfoOpen by mutableStateOf(false)@@ -1858,7 +1861,9 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {closePanels()if (guide?.on != true) s.setGuideOn(true)val d = density- guide = s.guideEditBegin(GUIDE_FIT_SIDE_DP * d, GUIDE_FIT_TOP_DP * d, windowSize.x - GUIDE_FIT_SIDE_DP * d, windowSize.y - GUIDE_FIT_BOTTOM_DP * d)+ // fitted between a fifth of the screen's height above and below (either way up), 40 in from the sides+ val band = windowSize.y * GUIDE_FIT_BAND+ guide = s.guideEditBegin(GUIDE_FIT_SIDE_DP * d, band, windowSize.x - GUIDE_FIT_SIDE_DP * d, windowSize.y - band)guideEditing = truerefreshView()}@@ -1947,9 +1952,11 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {if (cut != null) showNotice("Layer cut")}- fun paste() {+ /** What was cut or copied, on a new layer; a [private] one is left out of the gallery's thumbnail. */+ fun paste(private: Boolean = false) {val image = clipboard ?: return- if (session?.paste(image) == null) message = noRoom()+ val s = session+ if ((if (private) s?.pastePrivate(image) else s?.paste(image)) == null) message = noRoom()closePanels()refresh()if (panel == Panel.LAYERS) refreshThumbnails()@@ -2117,8 +2124,11 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {refresh()}- /** A photo or picture file comes in as a new layer, fitted to the canvas, ready to transform. */- fun insertPicture(uri: android.net.Uri) {+ /**+ * A photo or picture file comes in as a new layer, fitted to the canvas, ready to transform; a+ * [private] one is left out of the gallery's thumbnail.+ */+ fun insertPicture(uri: android.net.Uri, private: Boolean = false) {val s = session ?: returnclosePanels()viewModelScope.launch {@@ -2127,7 +2137,7 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {message = "This picture can't be opened."return@launch}- if (s.insertImage(image) != null) {+ if (s.insertImage(image, private) != null) {refresh()toggleTransform()} else {@@ -3761,7 +3771,15 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {?.playSoundEffect(android.media.AudioManager.FX_KEY_CLICK)}+ /** The library's brush swiped open to its buttons ("set-index"), if one is. */+ var swipedBrush by mutableStateOf<String?>(null)+fun toggle(p: Panel) {+ // with a brush swiped open, its button only closes the swipe+ if (p == Panel.BRUSHES && panel == Panel.BRUSHES && swipedBrush != null) {+ swipedBrush = null+ return+ }feedback()endQuickShape()if (transforming) endTransform(true)@@ -3773,6 +3791,12 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {fun closePanels() {panel = Panel.NONE+ swipedBrush = null+ }++ /** A tap outside the open panel closes it; with a brush swiped open, only the swipe. */+ fun tapOutsidePanel() {+ if (panel == Panel.BRUSHES && swipedBrush != null) swipedBrush = null else closePanels()}/** Closes the open panel by fading it away, as picking something that takes the screen does. */@@ -5206,8 +5230,7 @@ class CanvasViewModel(app: Application) : AndroidViewModel(app) {const val SELECTION_VISIBILITY = "selection_visibility"/** The guide editor fits the canvas this far in from the window's sides, top and bottom (points). */const val GUIDE_FIT_SIDE_DP = 40f- const val GUIDE_FIT_TOP_DP = 226f- const val GUIDE_FIT_BOTTOM_DP = 228f+ const val GUIDE_FIT_BAND = 0.2f/** The largest side a picture brought in is decoded at (pixels). */const val MAX_PICTURE = 4096/** How long a stroke is held still to snap (milliseconds), how still (points), and how near a handle a touch takes it. */diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ActionsPanel.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ActionsPanel.ktindex 1206a8a..9305aa7 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ActionsPanel.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ActionsPanel.kt@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.fillMaxHeightimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.height@@ -42,6 +43,7 @@ import androidx.compose.runtime.LaunchedEffectimport androidx.compose.foundation.borderimport androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.draw.clip+import androidx.compose.ui.draw.clipToBoundsimport androidx.compose.ui.draw.drawBehindimport androidx.compose.ui.geometry.CornerRadiusimport androidx.compose.ui.geometry.Offset@@ -65,7 +67,14 @@ private val ActionsWidth = 390.dp/** One row of the actions panel. Rows whose features are still to come show dimmed. */private sealed interface ActionRow-private class Act(val label: String, val value: String? = null, val onClick: (() -> Unit)? = null) : ActionRow+/** A button row; with a [private] label, a swipe to the left shows a second button doing it privately. */+private class Act(+ val label: String,+ val value: String? = null,+ val private: String? = null,+ val onPrivate: (() -> Unit)? = null,+ val onClick: (() -> Unit)? = null,+) : ActionRow/** A switch row; [fixed] is a setting shown as it is, its name not dimmed. */private class Toggle(val label: String, val checked: Boolean, val fixed: Boolean = false, val onChange: ((Boolean) -> Unit)? = null) : ActionRow@@ -139,11 +148,13 @@ fun ActionsPanel(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier)if (file != null) shareFile(context, file, if (jpeg) "image/jpeg" else "image/png") else dialog = "Share" to "The picture could not be exported."}}+ // whether the picture being picked or taken goes on a private layer+ var privately by remember { mutableStateOf(false) }val pickPhoto = androidx.activity.compose.rememberLauncherForActivityResult(androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia()) { uri ->- uri?.let { vm.insertPicture(it) }+ uri?.let { vm.insertPicture(it, privately) }}val pickFile = androidx.activity.compose.rememberLauncherForActivityResult(androidx.activity.result.contract.ActivityResultContracts.OpenDocument()) { uri ->- uri?.let { vm.insertPicture(it) }+ uri?.let { vm.insertPicture(it, privately) }}// the camera writes its picture to a file of ours, which goes in like a photoval photo = remember {@@ -151,7 +162,19 @@ fun ActionsPanel(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier)FileProvider.getUriForFile(context, context.packageName + ".files", File(dir, "camera.jpg"))}val takePhoto = androidx.activity.compose.rememberLauncherForActivityResult(androidx.activity.result.contract.ActivityResultContracts.TakePicture()) { taken ->- if (taken) vm.insertPicture(photo)+ if (taken) vm.insertPicture(photo, privately)+ }+ fun file(private: Boolean) {+ privately = private+ pickFile.launch(arrayOf("image/*"))+ }+ fun photoFrom(private: Boolean) {+ privately = private+ pickPhoto.launch(androidx.activity.result.PickVisualMediaRequest(androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageOnly))+ }+ fun camera(private: Boolean) {+ privately = private+ runCatching { takePhoto.launch(photo) }.onFailure { dialog = "Take a photo" to "No camera app is available." }}val model = vm.modelOpenval tabs = if (model) ModelTabs else Tabs@@ -160,16 +183,25 @@ fun ActionsPanel(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier)takePhoto = { runCatching { takePhoto.launch(photo) }.onFailure { dialog = "Take a photo" to "No camera app is available." } },) else when (shownTab) {0 -> listOf(+ // swiped to the left, the first three and Paste put what they bring on a private layerlistOf(- Act("Insert a file") { pickFile.launch(arrayOf("image/*")) },- Act("Insert a photo") {- pickPhoto.launch(androidx.activity.result.PickVisualMediaRequest(androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageOnly))- },- Act("Take a photo") { runCatching { takePhoto.launch(photo) }.onFailure { dialog = "Take a photo" to "No camera app is available." } },+ Act("Insert a file", private = "Insert a private file", onPrivate = { file(true) }) { file(false) },+ Act("Insert a photo", private = "Insert a private photo", onPrivate = { photoFrom(true) }) { photoFrom(false) },+ Act("Take a photo", private = "Take a private photo", onPrivate = { camera(true) }) { camera(false) },Act("Add text") { vm.addText() },),// Paste is grey until something has been cut or copied- listOf(Act("Cut") { vm.cutLayer() }, Act("Copy") { vm.copyLayer() }, Act("Copy canvas") { vm.copyCanvas() }, Act("Paste", onClick = if (vm.canPaste) ({ vm.paste() }) else null)),+ listOf(+ Act("Cut") { vm.cutLayer() },+ Act("Copy") { vm.copyLayer() },+ Act("Copy canvas") { vm.copyCanvas() },+ Act(+ "Paste",+ private = "Paste Private",+ onPrivate = if (vm.canPaste) ({ vm.paste(private = true) }) else null,+ onClick = if (vm.canPaste) ({ vm.paste() }) else null,+ ),+ ),)1 -> listOf(listOf(Act("Crop & Resize") { vm.beginCrop() }),@@ -562,8 +594,70 @@ private fun SlideRow(row: Slide) {}}+/** How far a row with a private action slides open, that action's button and its look. */+private val PrivateSlide = 248.dp+private val PrivateWidth = 245.dp+private val PrivateFill = Color(0xFF454545)+private val PrivateInk = Color(0xFFA8A8A8)++/**+ * A row that a swipe to the left slides open, its private action's button coming in from the+ * right; let go past halfway it stays open. A tap on the row closes it again.+ */+@Composable+private fun PrivateSwipe(row: Act, content: @Composable () -> Unit) {+ val scope = rememberCoroutineScope()+ val slide = remember { androidx.compose.animation.core.Animatable(0f) }+ val full = with(androidx.compose.ui.platform.LocalDensity.current) { PrivateSlide.toPx() }+ fun settle(open: Boolean) {+ scope.launch { slide.animateTo(if (open) full else 0f, Motion.swipeSettle()) }+ }+ Box(+ Modifier.fillMaxWidth().height(44.dp).clipToBounds()+ .pointerInput(Unit) {+ detectHorizontalDragGestures(+ onDragEnd = { settle(slide.value > full / 2f) },+ onDragCancel = { settle(false) },+ ) { c, dx ->+ c.consume()+ scope.launch { slide.snapTo((slide.value - dx).coerceIn(0f, full)) }+ }+ },+ ) {+ Box(Modifier.fillMaxSize().graphicsLayer { translationX = -slide.value }) { content() }+ if (slide.value > 0f) {+ Box(Modifier.matchParentSize().clickable(remember { androidx.compose.foundation.interaction.MutableInteractionSource() }, indication = null) { settle(false) })+ Box(+ Modifier.align(Alignment.CenterEnd).width(PrivateWidth).fillMaxHeight()+ .graphicsLayer { translationX = full - slide.value }+ .clip(RoundedCornerShape(13.dp)).background(PrivateFill)+ .then(+ row.onPrivate?.let { act ->+ Modifier.clickable {+ scope.launch { slide.snapTo(0f) }+ act()+ }+ } ?: Modifier,+ ),+ contentAlignment = Alignment.Center,+ ) {+ Text(row.private.orEmpty(), color = if (row.onPrivate != null) PrivateInk else Pc.ActionsDisabled, fontSize = 17.sp, maxLines = 1)+ }+ }+ }+}+@Composableprivate fun ActionRowView(row: ActionRow) {+ if (row is Act && row.private != null) {+ PrivateSwipe(row) { ActionRowContent(row) }+ } else {+ ActionRowContent(row)+ }+}++@Composable+private fun ActionRowContent(row: ActionRow) {val enabled = when (row) {is Act -> row.onClick != nullis Toggle -> row.onChange != nulldiff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AdjustmentsUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AdjustmentsUi.ktindex 1696d68..b18a335 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AdjustmentsUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AdjustmentsUi.kt@@ -26,6 +26,8 @@ import androidx.compose.material3.Iconimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.rememberimport androidx.compose.runtime.setValueimport androidx.compose.foundation.gestures.detectDragGesturesimport androidx.compose.foundation.gestures.detectTapGestures@@ -144,17 +146,36 @@ private fun Adjustment.icon() = when (this) {Adjustment.CLONE -> PcIcons.AdjustClone}+/**+ * Whether the adjustment toolbars lay their sliders side by side: on a screen wider than tall, as+ * the reference does in landscape (upright they stack).+ */+@Composable+private fun widePanels(): Boolean {+ val screen = androidx.compose.ui.platform.LocalConfiguration.current+ return screen.screenWidthDp > screen.screenHeightDp+}+/** The floating panel of hue, saturation and brightness, each 0..100% with 50% leaving the layer as it was. */@Composablefun HsbPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {- Column(- modifier.offset(y = (-25).dp).size(532.dp, 220.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(horizontal = 26.dp, vertical = 16.dp),- verticalArrangement = Arrangement.spacedBy(8.dp),- ) {- val (h, s, b) = Triple(vm.hue50, vm.saturation50, vm.brightness50)- HsbRow("Hue", h, Brush.horizontalGradient(HUE_STOPS.map { Color(it) }), { Color.hsv((it * 360f) % 360f, 1f, 1f) }) { vm.setHsb(it, s, b) }- HsbRow("Saturation", s, Brush.horizontalGradient(listOf(Color(0xFF808080), Color(0xFFFF0000))), { lerp(Color(0xFF808080), Color.Red, it) }) { vm.setHsb(h, it, b) }- HsbRow("Brightness", b, Brush.horizontalGradient(listOf(Color.Black, Color.White)), { lerp(Color.Black, Color.White, it) }) { vm.setHsb(h, s, it) }+ val (h, s, b) = Triple(vm.hue50, vm.saturation50, vm.brightness50)+ val rows: @Composable (Modifier) -> Unit = { m ->+ HsbRow("Hue", h, Brush.horizontalGradient(HUE_STOPS.map { Color(it) }), { Color.hsv((it * 360f) % 360f, 1f, 1f) }, m) { vm.setHsb(it, s, b) }+ HsbRow("Saturation", s, Brush.horizontalGradient(listOf(Color(0xFF808080), Color(0xFFFF0000))), { lerp(Color(0xFF808080), Color.Red, it) }, m) { vm.setHsb(h, it, b) }+ HsbRow("Brightness", b, Brush.horizontalGradient(listOf(Color.Black, Color.White)), { lerp(Color.Black, Color.White, it) }, m) { vm.setHsb(h, s, it) }+ }+ if (widePanels()) {+ // side by side, 301 wide and 13 apart+ Row(+ modifier.offset(y = (-25).dp).size(961.dp, 95.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(start = 16.dp, end = 16.dp, top = 24.dp, bottom = 16.dp),+ horizontalArrangement = Arrangement.spacedBy(13.dp),+ ) { rows(Modifier.weight(1f)) }+ } else {+ Column(+ modifier.offset(y = (-25).dp).size(532.dp, 220.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(horizontal = 26.dp, vertical = 16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) { rows(Modifier.fillMaxWidth()) }}}@@ -162,9 +183,9 @@ private val HUE_STOPS = listOf(0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0/** A labelled slider over a coloured track, its knob taking the track's colour where it sits. */@Composable-private fun HsbRow(label: String, value: Float, track: Brush, knobColor: (Float) -> Color, onChange: (Float) -> Unit) {+private fun HsbRow(label: String, value: Float, track: Brush, knobColor: (Float) -> Color, modifier: Modifier, onChange: (Float) -> Unit) {val change by rememberUpdatedState(onChange)- Column(Modifier.fillMaxWidth().height(55.dp)) {+ Column(modifier.height(55.dp)) {Row(Modifier.fillMaxWidth().padding(top = 6.dp)) {Text(label, color = HsbLabel, fontSize = 16.sp, maxLines = 1, modifier = Modifier.weight(1f))Text("${(value * 100).roundToInt()}%", color = HsbValue, fontSize = 16.sp, maxLines = 1)@@ -198,25 +219,49 @@ private val PanelButton = Color(0xFF303030)private val PanelButtonText = Color(0xFFA6A6A6)private val GridLine = Color(0xFF8A8A8A)-/** The colour balance panel: three sliders between opposite colours, for the tone chosen below them. */+private val BALANCE_PAIRS = listOf(+ Triple("Cyan", "Red", listOf(Color(0xFF00FFFF), Color(0xFF808080), Color(0xFFFF0000))),+ Triple("Magenta", "Green", listOf(Color(0xFFFF00FF), Color(0xFF808080), Color(0xFF00FF00))),+ Triple("Yellow", "Blue", listOf(Color(0xFFFFFF00), Color(0xFF808080), Color(0xFF0000FF))),+)++private val BALANCE_TONES = listOf("Shadows", "Midtones", "Highlights")++/**+ * The colour balance panel: three sliders between opposite colours, for the tone chosen below them+ * (side by side on a wide screen, the tones then in the menu of the "•••" button after them).+ */@Composablefun ColorBalancePanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {+ val tone = vm.balanceTone+ if (widePanels()) {+ Row(+ modifier.offset(y = (-25).dp).size(903.dp, 95.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(start = 16.dp, top = 24.dp, bottom = 16.dp),+ horizontalArrangement = Arrangement.spacedBy(19.dp),+ ) {+ BALANCE_PAIRS.forEachIndexed { k, (left, right, colours) ->+ BalanceRow(left, right, vm.balance[tone * 3 + k], Brush.horizontalGradient(colours), Modifier.width(251.dp)) { vm.setBalance(k, it) }+ }+ MoreButton("Color Balance") {+ OptionsGroup {+ BALANCE_TONES.forEachIndexed { i, name ->+ OptionsChoice(name, tone == i, 40.dp, first = i == 0) { vm.chooseBalanceTone(i) }+ }+ }+ }+ }+ return+ }Column(modifier.offset(y = (-25).dp).size(532.dp, 272.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(horizontal = 26.dp, vertical = 16.dp),verticalArrangement = Arrangement.spacedBy(8.dp),) {- val tone = vm.balanceTone- val pairs = listOf(- Triple("Cyan", "Red", listOf(Color(0xFF00FFFF), Color(0xFF808080), Color(0xFFFF0000))),- Triple("Magenta", "Green", listOf(Color(0xFFFF00FF), Color(0xFF808080), Color(0xFF00FF00))),- Triple("Yellow", "Blue", listOf(Color(0xFFFFFF00), Color(0xFF808080), Color(0xFF0000FF))),- )- pairs.forEachIndexed { k, (left, right, colours) ->+ BALANCE_PAIRS.forEachIndexed { k, (left, right, colours) ->val value = vm.balance[tone * 3 + k]- BalanceRow(left, right, value, Brush.horizontalGradient(colours)) { vm.setBalance(k, it) }+ BalanceRow(left, right, value, Brush.horizontalGradient(colours), Modifier.fillMaxWidth()) { vm.setBalance(k, it) }}Row(Modifier.fillMaxWidth().padding(top = 4.dp), horizontalArrangement = Arrangement.spacedBy(7.dp)) {- listOf("Shadows", "Midtones", "Highlights").forEachIndexed { i, name ->+ BALANCE_TONES.forEachIndexed { i, name ->val chosen = tone == iBox(Modifier.weight(1f).height(40.dp).clip(RoundedCornerShape(20.dp)).background(if (chosen) Pc.Accent else PanelButton).tap { vm.chooseBalanceTone(i) },@@ -231,9 +276,9 @@ fun ColorBalancePanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {/** A slider between two named colours, its middle leaving the colour as it was. */@Composable-private fun BalanceRow(left: String, right: String, value: Float, track: Brush, onChange: (Float) -> Unit) {+private fun BalanceRow(left: String, right: String, value: Float, track: Brush, modifier: Modifier, onChange: (Float) -> Unit) {val change by rememberUpdatedState(onChange)- Column(Modifier.fillMaxWidth().height(55.dp)) {+ Column(modifier.height(55.dp)) {Row(Modifier.fillMaxWidth().padding(top = 6.dp)) {Text(left, color = MenuText, fontSize = 16.sp, maxLines = 1, modifier = Modifier.weight(1f))Text(right, color = HsbValue, fontSize = 16.sp, maxLines = 1)@@ -324,7 +369,9 @@ private val CurveNode = Color(0xFF0171EA)@Composablefun GradientMapPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {val editing = vm.gradientEditing- Column(modifier.offset(y = (-25).dp).size(544.dp, 159.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(horizontal = 14.dp, vertical = 12.dp)) {+ // wider on a wide screen, showing more of the library+ val width = if (widePanels()) 835.dp else 544.dp+ Column(modifier.offset(y = (-25).dp).size(width, 159.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(horizontal = 14.dp, vertical = 12.dp)) {Row(Modifier.fillMaxWidth().height(40.dp), verticalAlignment = Alignment.CenterVertically) {Text(if (editing != null) "Gradient Map" else "Gradient Library", color = MenuText, fontSize = 20.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.weight(1f).padding(start = 14.dp))if (editing != null) {@@ -601,6 +648,108 @@ private val LIQUIFY_NAMES = listOf(/** The liquify panel: the brush's size, pressure, distortion and momentum; its way, adjust and reset. */@Composablefun LiquifyPanel(vm: CanvasViewModel, screenWidth: Dp, screenHeight: Dp, modifier: Modifier = Modifier) {+ val wide = widePanels()+ if (wide) LiquifyWide(vm, modifier) else LiquifyUpright(vm, modifier)+ // the way's list and the adjust slider open over the panel's buttons+ val panelLeft = (screenWidth - 654.dp) / 2+ val buttonsTop = if (wide) screenHeight - 25.dp - 162.dp + 28.dp else screenHeight - 25.dp - 16.dp - 40.dp+ when (vm.liquifyPopup) {+ 1 -> if (!wide) {+ val centre = panelLeft + 16.dp + (654.dp - 32.dp - 16.dp) / 6+ val left = (centre - 130.dp).coerceIn(0.dp, screenWidth - 260.dp)+ MenuPopover(centre - left, left, buttonsTop) {+ MenuTitle("Liquify Mode")+ Spacer(Modifier.height(10.dp))+ Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)).background(MenuGroup)) {+ LIQUIFY_NAMES.forEachIndexed { i, (kind, label) ->+ if (i > 0) Box(Modifier.fillMaxWidth().height(1.dp).background(MenuLine))+ val chosen = vm.liquifyKind == kind+ Row(+ Modifier.fillMaxWidth().height(44.dp).background(if (chosen) Pc.Accent else Color.Transparent).tap { vm.chooseLiquifyKind(kind) }.padding(start = 16.dp, end = 14.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ MenuLabel(label, if (chosen) Color.White else MenuText, Modifier.weight(1f))+ if (chosen) Icon(PcIcons.MenuTick, contentDescription = null, tint = Color.White, modifier = Modifier.size(29.dp))+ }+ }+ }+ }+ }+ 2 -> {+ // over the Adjust button: the middle one upright, the ninth of the row when wide+ val centre = if (wide) (screenWidth - 1093.dp) / 2 + 86.dp + 94.dp * 8 + 37.5.dp else screenWidth / 2+ val left = (centre - 130.dp).coerceIn(0.dp, screenWidth - 260.dp)+ MenuPopover(centre - left, left, buttonsTop) {+ MenuTitle("Adjust")+ Spacer(Modifier.height(4.dp))+ Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)).background(MenuGroup).padding(vertical = 8.dp)) {+ SliderRow("Amount", vm.liquifyAmount, "${(vm.liquifyAmount * 100).roundToInt()}%") { vm.changeLiquifyAmount(it) }+ }+ }+ }+ }+}++private val LiquifyIcons = mapOf(+ LiquifyKind.PUSH to { PcIcons.LiquifyPush },+ LiquifyKind.TWIRL_RIGHT to { PcIcons.LiquifyTwirlRight },+ LiquifyKind.TWIRL_LEFT to { PcIcons.LiquifyTwirlLeft },+ LiquifyKind.PINCH to { PcIcons.LiquifyPinch },+ LiquifyKind.EXPAND to { PcIcons.LiquifyExpand },+ LiquifyKind.CRYSTALS to { PcIcons.LiquifyCrystals },+ LiquifyKind.EDGE to { PcIcons.LiquifyEdge },+ LiquifyKind.RECONSTRUCT to { PcIcons.LiquifyReconstruct },+)+private val LiquifyIdle = Color(0xFFAAAAAA)+private val LiquifyLabel = Color(0xFFA3A3A3)+private val LiquifyDim = Color(0xFF575757)++/**+ * Liquify on a wide screen (1093 x 162): its ways, Adjust and Reset as a row of icon buttons (75+ * wide, 94 apart; the chosen way's icon blue), and the four sliders side by side under them.+ */+@Composable+private fun LiquifyWide(vm: CanvasViewModel, modifier: Modifier) {+ val percent = { v: Float, none: String? -> if (v >= 1f) "Max" else if (v <= 0f && none != null) none else "${(v * 100).roundToInt()}%" }+ Column(+ modifier.offset(y = (-25).dp).size(1093.dp, 162.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(start = 16.dp, end = 16.dp, top = 28.dp),+ horizontalAlignment = Alignment.CenterHorizontally,+ ) {+ val canAdjust = vm.liquified+ Row(Modifier.height(60.dp), horizontalArrangement = Arrangement.spacedBy(19.dp)) {+ for ((kind, label) in LIQUIFY_NAMES) {+ val chosen = vm.liquifyKind == kind+ LiquifyButton(LiquifyIcons[kind]?.invoke() ?: PcIcons.AdjustLiquify, label, if (chosen) Pc.Accent else LiquifyIdle, LiquifyLabel, 24.dp) { vm.chooseLiquifyKind(kind) }+ }+ val ink = if (canAdjust) LiquifyIdle else LiquifyDim+ val words = if (canAdjust) LiquifyLabel else LiquifyDim+ LiquifyButton(PcIcons.AdjustKnob, "Adjust", ink, words, 39.5.dp, canAdjust) { vm.liquifyPopup = if (vm.liquifyPopup == 2) 0 else 2 }+ LiquifyButton(PcIcons.PieReset, "Reset", ink, words, 23.dp, canAdjust) { vm.resetLiquify() }+ }+ Spacer(Modifier.height(8.dp))+ Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(11.dp)) {+ Box(Modifier.weight(1f)) { SliderRow("Size", vm.liquifySize, percent(vm.liquifySize, null)) { vm.liquifySize = it } }+ Box(Modifier.weight(1f)) { SliderRow("Pressure", vm.liquifyPressure, percent(vm.liquifyPressure, null)) { vm.liquifyPressure = it } }+ Box(Modifier.weight(1f)) { SliderRow("Distortion", vm.liquifyDistortion, percent(vm.liquifyDistortion, "None")) { vm.liquifyDistortion = it } }+ Box(Modifier.weight(1f)) { SliderRow("Momentum", vm.liquifyMomentum, percent(vm.liquifyMomentum, "None")) { vm.liquifyMomentum = it } }+ }+ }+}++/** One of wide Liquify's buttons: its icon ([iconSize] across, centred 9 down) over its name. */+@Composable+private fun LiquifyButton(icon: androidx.compose.ui.graphics.vector.ImageVector, label: String, ink: Color, words: Color, iconSize: Dp, enabled: Boolean = true, onClick: () -> Unit) {+ Box(Modifier.size(75.dp, 60.dp).then(if (enabled) Modifier.tap(onClick = onClick) else Modifier)) {+ Box(Modifier.align(Alignment.TopCenter).offset(y = 9.dp - 12.dp).size(24.dp), contentAlignment = Alignment.Center) {+ Icon(icon, contentDescription = label, tint = ink, modifier = Modifier.requiredSize(iconSize))+ }+ Text(label, color = words, fontSize = 13.sp, maxLines = 1, modifier = Modifier.align(Alignment.TopCenter).padding(top = 22.dp))+ }+}++/** Liquify upright: two rows of two sliders, then the way, Adjust and Reset. */+@Composable+private fun LiquifyUpright(vm: CanvasViewModel, modifier: Modifier) {Column(modifier.offset(y = (-25).dp).size(654.dp, 200.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(16.dp),verticalArrangement = Arrangement.SpaceBetween,@@ -646,42 +795,6 @@ fun LiquifyPanel(vm: CanvasViewModel, screenWidth: Dp, screenHeight: Dp, modifie}}}- // the way's list and the adjust slider open over the panel's buttons- val panelLeft = (screenWidth - 654.dp) / 2- val buttonsTop = screenHeight - 25.dp - 16.dp - 40.dp- when (vm.liquifyPopup) {- 1 -> {- val centre = panelLeft + 16.dp + (654.dp - 32.dp - 16.dp) / 6- val left = (centre - 130.dp).coerceIn(0.dp, screenWidth - 260.dp)- MenuPopover(centre - left, left, buttonsTop) {- MenuTitle("Liquify Mode")- Spacer(Modifier.height(10.dp))- Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)).background(MenuGroup)) {- LIQUIFY_NAMES.forEachIndexed { i, (kind, label) ->- if (i > 0) Box(Modifier.fillMaxWidth().height(1.dp).background(MenuLine))- val chosen = vm.liquifyKind == kind- Row(- Modifier.fillMaxWidth().height(44.dp).background(if (chosen) Pc.Accent else Color.Transparent).tap { vm.chooseLiquifyKind(kind) }.padding(start = 16.dp, end = 14.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- MenuLabel(label, if (chosen) Color.White else MenuText, Modifier.weight(1f))- if (chosen) Icon(PcIcons.MenuTick, contentDescription = null, tint = Color.White, modifier = Modifier.size(29.dp))- }- }- }- }- }- 2 -> {- val centre = screenWidth / 2- MenuPopover(130.dp, centre - 130.dp, buttonsTop) {- MenuTitle("Adjust")- Spacer(Modifier.height(4.dp))- Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)).background(MenuGroup).padding(vertical = 8.dp)) {- SliderRow("Amount", vm.liquifyAmount, "${(vm.liquifyAmount * 100).roundToInt()}%") { vm.changeLiquifyAmount(it) }- }- }- }- }}private val ModesFill = Color(0xFF7B7B7B)@@ -738,8 +851,9 @@ private val GLITCH_KINDS = listOf(/** The glitch toolbar: its four kinds above the kind's sliders, two to a row. */@Composablefun GlitchPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {+ val wide = widePanels()Column(- modifier.offset(y = (-25).dp).size(640.dp, 167.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(top = 8.dp),+ modifier.offset(y = (-25).dp).size(if (wide) 973.dp else 640.dp, if (wide) 120.dp else 167.dp).clip(RoundedCornerShape(33.dp)).background(HsbPanelFill).padding(top = 8.dp),horizontalAlignment = Alignment.CenterHorizontally,) {KindsSwitch(466.dp, GLITCH_KINDS.map { (kind, label, width) -> Kind(kind.icon(), label, width) }, GLITCH_KINDS.indexOfFirst { it.first == vm.glitchKind }) {@@ -752,6 +866,18 @@ fun GlitchPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {}val values = vm.glitchValues[vm.glitchKind].orEmpty()Spacer(Modifier.height(12.dp))+ // on a wide screen all in one row, 19 apart+ if (wide) {+ val each = (941.dp - 19.dp * (names.size - 1)) / names.size+ Row(Modifier.width(941.dp).height(54.dp), horizontalArrangement = Arrangement.spacedBy(19.dp)) {+ for (k in names.indices) {+ val both = vm.glitchKind == GlitchKind.DIVERGE && k < 3+ val v = values.getOrElse(k) { 0f }+ OptionSlider(names[k], v, "${(v * 100).roundToInt()}%", each, both) { vm.setGlitchValue(k, it) }+ }+ }+ return@Column+ }for (row in names.indices.chunked(2)) {Row(Modifier.width(608.dp).height(54.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {for (k in row) {@@ -808,14 +934,23 @@ internal fun shown(v: Float, max: Boolean = false) = when {else -> "${(v * 100).roundToInt()}%"}-/** A labelled toolbar slider [width] wide: [both] ways runs −1..1 with its fill from the middle, else 0..1. */+/**+ * A labelled toolbar slider [width] wide: [both] ways runs −1..1 with its fill from the middle, else+ * 0..1. A [chip] value sits on a rounded chip (one that can be typed).+ */@Composable-internal fun OptionSlider(label: String, value: Float, shown: String, width: Dp, both: Boolean = false, labelColor: Color = HsbLabel, onChange: (Float) -> Unit) {+internal fun OptionSlider(label: String, value: Float, shown: String, width: Dp, both: Boolean = false, labelColor: Color = HsbLabel, chip: Boolean = false, onChange: (Float) -> Unit) {val change by rememberUpdatedState(onChange)Column(Modifier.width(width).height(54.dp)) {Row(Modifier.fillMaxWidth().padding(start = 10.dp, end = 15.dp, top = 6.dp)) {Text(label, color = labelColor, fontSize = 16.sp, maxLines = 1, modifier = Modifier.weight(1f))- Text(shown, color = HsbValue, fontSize = 16.sp, maxLines = 1)+ if (chip) {+ Box(Modifier.offset(x = 8.dp, y = (-4).dp).clip(RoundedCornerShape(14.dp)).background(ValueChip).padding(horizontal = 12.dp, vertical = 3.dp)) {+ Text(shown, color = HsbValue, fontSize = 16.sp, maxLines = 1)+ }+ } else {+ Text(shown, color = HsbValue, fontSize = 16.sp, maxLines = 1)+ }}Box(Modifier.fillMaxWidth().height(24.dp).padding(start = 10.dp, end = 11.dp).pointerInput(both) {@@ -852,6 +987,7 @@ internal fun OptionSlider(label: String, value: Float, shown: String, width: Dp,}private val ModesText = Color(0xFFD0D0D0)+private val ValueChip = Color(0xFF2A2A2A)private fun GlitchKind.icon() = when (this) {GlitchKind.ARTIFACT -> PcIcons.GlitchArtifact@@ -863,11 +999,41 @@ private fun GlitchKind.icon() = when (this) {/** The noise toolbar: its three kinds, scale, octaves and turbulence, single or multi channel, added or not. */@Composablefun NoisePanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {- OptionsPanel(532.dp, 292.dp, modifier, 10.dp) {- val kinds = listOf(NoiseKind.CLOUDS, NoiseKind.BILLOWS, NoiseKind.RIDGES)+ val kinds = listOf(NoiseKind.CLOUDS, NoiseKind.BILLOWS, NoiseKind.RIDGES)+ val switch: @Composable () -> Unit = {KindsSwitch(472.dp, listOf(Kind(PcIcons.NoiseClouds, "Clouds", 149.dp), Kind(PcIcons.NoiseBillows, "Billows", 149.dp), Kind(PcIcons.NoiseRidges, "Ridges", 148.dp)), kinds.indexOf(vm.noiseKind)) {vm.chooseNoiseKind(kinds[it])}+ }+ if (widePanels()) {+ // the sliders side by side, single or multi channel and additive in the "•••" menu+ OptionsPanel(903.dp, 113.dp, modifier, 8.dp) {+ switch()+ Spacer(Modifier.height(8.dp))+ Row(Modifier.fillMaxWidth().padding(start = 16.dp), horizontalArrangement = Arrangement.spacedBy(19.dp)) {+ OptionSlider("Scale", vm.noiseScale, shown(vm.noiseScale), 251.dp, labelColor = ModesText) { vm.setNoiseValue(0, it) }+ OptionSlider("Octaves", vm.noiseOctaves, shown(vm.noiseOctaves), 251.dp, labelColor = ModesText) { vm.setNoiseValue(1, it) }+ OptionSlider("Turbulence", vm.noiseTurbulence, shown(vm.noiseTurbulence), 251.dp, labelColor = ModesText) { vm.setNoiseValue(2, it) }+ MoreButton("Channel") {+ OptionsGroup {+ Row(Modifier.fillMaxWidth().height(44.dp).padding(start = 12.dp, end = 8.dp), verticalAlignment = Alignment.CenterVertically) {+ Text("Additive", color = MenuText, fontSize = 17.sp, maxLines = 1, modifier = Modifier.weight(1f))+ Box(Modifier.tap { vm.toggleNoiseAdded() }) { Switch(vm.noiseAdded, enabled = true) }+ }+ }+ Spacer(Modifier.height(12.dp))+ OptionsGroup {+ for ((i, pair) in listOf(false to "Single", true to "Multi").withIndex()) {+ OptionsChoice(pair.second, vm.noiseMulti == pair.first, 44.dp, first = i == 0) { vm.chooseNoiseMulti(pair.first) }+ }+ }+ }+ }+ }+ return+ }+ OptionsPanel(532.dp, 292.dp, modifier, 10.dp) {+ switch()Spacer(Modifier.height(8.dp))Column(Modifier.width(500.dp), verticalArrangement = Arrangement.spacedBy(8.5.dp)) {OptionSlider("Scale", vm.noiseScale, shown(vm.noiseScale), 500.dp, labelColor = ModesText) { vm.setNoiseValue(0, it) }@@ -899,6 +1065,17 @@ private val NoiseButton = Color(0xFF1E1E1E)/** The bloom toolbar: transition, size and burn. */@Composablefun BloomPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {+ if (widePanels()) {+ // side by side, 301 wide and 39 apart+ OptionsPanel(1013.dp, 95.dp, modifier, 24.dp) {+ Row(Modifier.width(981.dp), horizontalArrangement = Arrangement.spacedBy(39.dp)) {+ OptionSlider("Transition", vm.bloomTransition, shown(vm.bloomTransition, max = true), 301.dp) { vm.setBloomValue(0, it) }+ OptionSlider("Size", vm.bloomSize, shown(vm.bloomSize, max = true), 301.dp) { vm.setBloomValue(1, it) }+ OptionSlider("Burn", vm.bloomBurn, shown(vm.bloomBurn, max = true), 301.dp) { vm.setBloomValue(2, it) }+ }+ }+ return+ }OptionsPanel(532.dp, 220.dp, modifier, 24.dp) {Column(Modifier.width(500.dp), verticalArrangement = Arrangement.spacedBy(8.5.dp)) {OptionSlider("Transition", vm.bloomTransition, shown(vm.bloomTransition, max = true), 500.dp) { vm.setBloomValue(0, it) }@@ -908,6 +1085,64 @@ fun BloomPanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {}}+private val MoreFill = Color(0xFF1C1C1C)+private val MoreEdge = Color(0xFF3A3A3A)+private val MoreDots = Color(0xFF9A9A9A)+private val OptionsMenuFill = Color(0xF2262626)+private val OptionsGroupFill = Color(0xFF1B1B1B)+private val OptionsLine = Color(0xFF2E2E2E)++/**+ * A toolbar's "•••" button (41 × 40, 3 lower than the sliders' top): it opens a small menu over+ * it, [title] above the [content], 16 above the button; a tap outside closes it.+ */+@Composable+private fun MoreButton(title: String, content: @Composable androidx.compose.foundation.layout.ColumnScope.(close: () -> Unit) -> Unit) {+ var open by remember { mutableStateOf(false) }+ Box(+ Modifier.padding(top = 3.dp).size(41.dp, 40.dp).clip(androidx.compose.foundation.shape.CircleShape).background(MoreFill)+ .border(1.dp, MoreEdge, androidx.compose.foundation.shape.CircleShape).tap { open = !open },+ contentAlignment = Alignment.Center,+ ) {+ Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {+ repeat(3) { Box(Modifier.size(6.dp).clip(androidx.compose.foundation.shape.CircleShape).background(MoreDots)) }+ }+ if (open) {+ val lift = with(androidx.compose.ui.platform.LocalDensity.current) { (40.dp + 16.dp).roundToPx() }+ androidx.compose.ui.window.Popup(+ alignment = Alignment.BottomCenter,+ offset = androidx.compose.ui.unit.IntOffset(0, -lift),+ onDismissRequest = { open = false },+ properties = androidx.compose.ui.window.PopupProperties(focusable = true),+ ) {+ Column(Modifier.width(260.dp).clip(RoundedCornerShape(26.dp)).background(OptionsMenuFill).padding(start = 10.dp, end = 10.dp, bottom = 10.dp)) {+ Text(title, color = MenuText, fontSize = 22.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.padding(start = 12.dp, top = 16.dp, bottom = 16.dp))+ content { open = false }+ }+ }+ }+ }+}++/** Rows in a rounded group of an options menu. */+@Composable+private fun OptionsGroup(rows: @Composable androidx.compose.foundation.layout.ColumnScope.() -> Unit) {+ Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(16.dp)).background(OptionsGroupFill), content = rows)+}++/** One choice of an options menu: blue with a tick when [chosen], a line above all but the [first]. */+@Composable+private fun OptionsChoice(label: String, chosen: Boolean, height: Dp, first: Boolean, onChoose: () -> Unit) {+ if (!first) Box(Modifier.fillMaxWidth().height(1.dp).background(OptionsLine))+ Row(+ Modifier.fillMaxWidth().height(height).background(if (chosen) Pc.Accent else Color.Transparent).tap(onClick = onChoose).padding(start = 12.dp, end = 14.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Text(label, color = if (chosen) Color.White else MenuText, fontSize = 17.sp, maxLines = 1, modifier = Modifier.weight(1f))+ if (chosen) Icon(PcIcons.Tick, contentDescription = null, tint = Color.White, modifier = Modifier.size(20.dp))+ }+}+/** The halftone toolbar: full colour, screen print or newspaper. */@Composablefun HalftonePanel(vm: CanvasViewModel, modifier: Modifier = Modifier) {diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AnimationUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AnimationUi.ktindex c5845b0..b31e827 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AnimationUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AnimationUi.kt@@ -51,11 +51,12 @@ import io.github.artcraftandroid.procraft.canvas.CanvasViewModelimport io.github.artcraftandroid.procraft.core.AnimationPlaybackimport kotlin.math.roundToInt-private val BarWidth = 446.dp+/** The bar is 657 wide on a wide screen, 446 upright; the timeline 12 in from each side. */+private val WideBarWidth = 657.dp+private val UprightBarWidth = 446.dpprivate val BarHeight = 96.dpprivate val BarGap = 25.dp-private val FrameWidth = 27.dp-private val FramePitch = 28.dp+private val FrameHeight = 40.dpprivate val BarFill get() = if (Pc.light) Color(0xFFE4E4E4) else Color(0xFF2A2A2A)private val TrackFill get() = if (Pc.light) Color(0xFFD0D0D0) else Color(0xFF474747)private val TrackEdge get() = if (Pc.light) Color(0xFFBDBDBD) else Color(0xFF5C5C5C)@@ -69,17 +70,19 @@ private const val MAX_ONION = 12@Composablefun BoxScope.AnimationBar(vm: CanvasViewModel) {if (vm.animation == null) return+ val screen = androidx.compose.ui.platform.LocalConfiguration.current+ val barWidth = if (screen.screenWidthDp > screen.screenHeightDp) WideBarWidth else UprightBarWidthBox(Modifier.align(Alignment.BottomCenter).fillMaxWidth()) {// where Settings' middle is along the bar, for the arrow of its popovervar settingsAt by remember { mutableStateOf(281.5.dp) }val density = LocalDensity.currentColumn(Modifier.align(Alignment.BottomCenter)) {if (vm.animationSettingsOpen) {- DownPopover(290.dp, 145.dp, Modifier.offset(x = (settingsAt - 145.dp).coerceIn(0.dp, BarWidth - 290.dp))) { AnimationSettingsPage(vm) }+ DownPopover(290.dp, 145.dp, Modifier.offset(x = (settingsAt - 145.dp).coerceIn(0.dp, barWidth - 290.dp))) { AnimationSettingsPage(vm) }} else if (vm.frameOptionsOpen) {- DownPopover(268.dp, 134.dp, Modifier.offset(x = BarWidth / 2 - 134.dp)) { FrameOptionsPage(vm) }+ DownPopover(268.dp, 134.dp, Modifier.offset(x = barWidth / 2 - 134.dp)) { FrameOptionsPage(vm) }}- Box(Modifier.padding(bottom = BarGap).size(BarWidth, BarHeight).clip(RoundedCornerShape(30.dp)).background(BarFill)) {+ Box(Modifier.padding(bottom = BarGap).size(barWidth, BarHeight).clip(RoundedCornerShape(30.dp)).background(BarFill)) {val pages = vm.animation?.pages == trueRow(Modifier.fillMaxWidth().padding(start = 26.dp, end = 26.dp, top = 8.dp).height(30.dp), verticalAlignment = Alignment.CenterVertically) {Text(@@ -97,7 +100,7 @@ fun BoxScope.AnimationBar(vm: CanvasViewModel) {Spacer(Modifier.width(23.dp))BarText(if (pages) "New Page" else "Add Frame", Modifier) { vm.addFrame() }}- Timeline(vm, Modifier.offset(x = 12.dp, y = 42.dp))+ Timeline(vm, barWidth - 24.dp, Modifier.offset(x = 12.dp, y = 42.dp))}}}@@ -110,18 +113,24 @@ private fun BarText(label: String, modifier: Modifier, onClick: () -> Unit) {}}-/** The frames in a rounded track, the current (or played) one in the middle with a blue line under it. */+/**+ * The frames in a rounded track [width] wide, the current (or played) one in the middle with a+ * blue line under it; each frame's card is 40 tall and as wide as the canvas's shape makes it.+ */@Composable-private fun Timeline(vm: CanvasViewModel, modifier: Modifier) {+private fun Timeline(vm: CanvasViewModel, width: Dp, modifier: Modifier) {val frames = vm.animationFramesval focus = vm.playingFrame ?: vm.currentFrame ?: 0- val width = 422.dp+ val (cw, ch) = vm.canvasSize()+ val aspect = if (cw > 0 && ch > 0) (cw.toFloat() / ch).coerceIn(0.25f, 2f) else 0.66f+ val frameWidth = FrameHeight * aspect + 1.dp+ val pitch = frameWidth + 1.dpBox(modifier.size(width, 44.dp).clip(RoundedCornerShape(18.dp)).background(TrackFill).border(1.dp, TrackEdge, RoundedCornerShape(18.dp))) {frames.forEachIndexed { i, id ->- val x = width / 2 - FrameWidth / 2 + FramePitch * (i - focus)- if (x > -FrameWidth && x < width) {+ val x = width / 2 - frameWidth / 2 + pitch * (i - focus)+ if (x > -frameWidth && x < width) {Box(- Modifier.offset(x = x, y = 2.dp).size(FrameWidth, 40.dp).clip(RoundedCornerShape(6.dp)).background(Color.White)+ Modifier.offset(x = x, y = 2.dp).size(frameWidth, FrameHeight).clip(RoundedCornerShape(6.dp)).background(Color.White).border(1.dp, Color(0xFF9A9A9A), RoundedCornerShape(6.dp)).clickable { vm.tapFrame(i) },) {vm.frameThumbnails[id]?.let { Image(it, contentDescription = "Frame ${i + 1}", contentScale = ContentScale.Fit, modifier = Modifier.fillMaxSize().padding(2.dp)) }diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AppRoot.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AppRoot.ktindex 0a32c15..6c34b4d 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AppRoot.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/AppRoot.kt@@ -71,7 +71,7 @@ fun AppRoot(vm: CanvasViewModel) {if (vm.selecting) SelectionOverlay(vm, Pc.BarHeight)if (vm.panel != Panel.NONE) {// a tap outside an open panel closes it (and does not paint)- Box(Modifier.fillMaxSize().pointerInput(Unit) { detectTapGestures { vm.closePanels() } })+ Box(Modifier.fillMaxSize().pointerInput(Unit) { detectTapGestures { vm.tapOutsidePanel() } })}vm.picking?.let { pick ->Loupe(pick, CanvasSpace.color(vm.colorRgb()))@@ -116,7 +116,8 @@ fun AppRoot(vm: CanvasViewModel) {TopBar(vm, Modifier.align(Alignment.TopCenter).then(up).then(fade))// a mode taking the screen slides it off its edge, and back when it endsandroidx.compose.animation.AnimatedVisibility(- vm.showSideBar && !vm.transforming && !vm.selecting && !vm.guideEditing && !vm.lightingStudioOpen && vm.cropRect == null && (vm.adjustment == null || vm.adjustPencil),+ vm.showSideBar && !vm.transforming && !vm.selecting && !vm.guideEditing && !vm.lightingStudioOpen && vm.cropRect == null && vm.textInfo == null &&+ (vm.adjustment == null || vm.adjustPencil),Modifier.align(if (vm.rightHanded) Alignment.TopEnd else Alignment.TopStart).offset(y = maxHeight * Pc.SIDE_BAR_CENTRE - Pc.SideBarHeight / 2),enter = Motion.sideBarIn(vm.rightHanded),exit = Motion.sideBarOut(vm.rightHanded),@@ -165,9 +166,9 @@ fun AppRoot(vm: CanvasViewModel) {}Panel.COLOR -> ColorPanel(vm, place.arrowX, maxHeight, at)Panel.BRUSHES -> BrushLibrary(vm, place.arrowX, at.height(maxHeight - Pc.BarHeight - 25.dp))- // ending 25 above the screen's edge, its rows scrolling (as measured)+ // ending 25 above the screen's edge, their rows scrolling (as measured)Panel.ACTIONS -> ActionsPanel(vm, place.arrowX, at.heightIn(max = maxHeight - Pc.BarHeight - 25.dp))- Panel.ADJUSTMENTS -> AdjustmentsPanel(vm, place.arrowX, at.heightIn(max = maxHeight - Pc.BarHeight - Pc.PopoverGap))+ Panel.ADJUSTMENTS -> AdjustmentsPanel(vm, place.arrowX, at.heightIn(max = maxHeight - Pc.BarHeight - 25.dp))Panel.NONE -> Unit}}diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/BrushLibrary.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/BrushLibrary.ktindex 474136b..d655918 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/BrushLibrary.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/BrushLibrary.kt@@ -236,7 +236,6 @@ fun BrushLibrary(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier)var setMenu by remember { mutableStateOf<Int?>(null) }// the set menu's icon grid is openvar iconPicker by remember { mutableStateOf(false) }- var swiped by remember { mutableStateOf<String?>(null) }// the search: what is typed, and whether the field is in usevar query by remember { mutableStateOf("") }var searching by remember { mutableStateOf(false) }@@ -447,8 +446,8 @@ fun BrushLibrary(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier)LaunchedEffect(key, preview == null) { if (preview == null) vm.loadPreview(b) }Box(Modifier.animateItem(Motion.rowFade(), Motion.rowMove(), Motion.rowFade())) {SwipeBrush(- open = swiped == key,- onOpen = { swiped = if (it) key else null },+ open = vm.swipedBrush == key,+ onOpen = { vm.swipedBrush = if (it) key else null },onShare = { share(b) },onDuplicate = { vm.duplicateBrush(b) },onDelete = { deleting = "Delete this brush?" to { vm.deleteBrush(b) } },@@ -459,7 +458,7 @@ fun BrushLibrary(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier).pointerInput(key) {detectDragGesturesAfterLongPress(onDragStart = { at ->- swiped = null+ vm.swipedBrush = nullval top = brushBounds[key]?.topLeft ?: Offset.Zerograb = atdragAt = top + at@@ -476,7 +475,11 @@ fun BrushLibrary(vm: CanvasViewModel, arrowX: Dp, modifier: Modifier = Modifier).clip(RoundedCornerShape(12.dp)).background(if (selected) Pc.RowSelected else Color.Transparent).clickable {- swiped = null+ // with a brush swiped open, a tap only closes it+ if (vm.swipedBrush != null) {+ vm.swipedBrush = null+ return@clickable+ }// a highlighted brush opens in the studiovm.chooseBrush(b)if (selected) vm.openStudio()diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CanvasInfoUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CanvasInfoUi.ktindex cf69655..b284f08 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CanvasInfoUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CanvasInfoUi.kt@@ -13,6 +13,7 @@ import androidx.compose.foundation.clickableimport androidx.compose.foundation.gestures.awaitEachGestureimport androidx.compose.foundation.gestures.awaitFirstDownimport androidx.compose.foundation.gestures.detectTapGestures+import androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Row@@ -85,6 +86,35 @@ private val CapsuleEdge = Color(0xFF373737)private val DoneBlue = Color(0xFF0190FF)private val CardCorner = 25.dp+/** Where a wide screen's page starts and ends, beside the pages' card. */+private val WideContentStart = 358.dp+private val WideContentEnd = 28.dp+private val CardEdge = Color(0xFF373737)+private val PageInk = Color(0xFF797979)++/** The pages by icon and name on a card headed "Canvas Info" (a wide screen's), as the brush studio's. */+@Composable+private fun InfoPagesCard(page: Int, onPage: (Int) -> Unit) {+ val shape = RoundedCornerShape(20.dp)+ Column(Modifier.padding(start = 10.dp, top = 10.dp, bottom = 10.dp).width(320.dp).fillMaxHeight().clip(shape).background(RailFill).border(1.dp, CardEdge, shape)) {+ Text("Canvas Info", color = Ink, fontSize = 24.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.padding(start = 24.dp, top = 19.dp))+ Column(Modifier.padding(start = 8.dp, end = 8.dp, top = 17.dp), verticalArrangement = Arrangement.spacedBy(3.dp)) {+ InfoTabs.forEachIndexed { i, tab ->+ val chosen = i == page+ Row(+ Modifier.fillMaxWidth().height(53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { onPage(i) },+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Box(Modifier.width(60.dp), contentAlignment = Alignment.Center) {+ Icon(tab.icon, contentDescription = null, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(tab.size))+ }+ Text(tab.label, color = if (chosen) Color.White else PageInk, fontSize = 17.sp, maxLines = 1)+ }+ }+ }+ }+}+/** A page of the rail: its name, and its icon shown [size] across (each its own). */private class InfoTab(val label: String, val icon: ImageVector, val size: Dp)@@ -152,28 +182,39 @@ fun CanvasInfo(vm: CanvasViewModel) {close()}BackHandler { close() }+ // on a wide screen the pages are named on a card, the page and the name to its right+ val screen = androidx.compose.ui.platform.LocalConfiguration.current+ val wide = screen.screenWidthDp > screen.screenHeightDpBox(Modifier.fillMaxSize().background(ScreenFill).pointerInput(Unit) { detectTapGestures { } }) {- // the rail of pages- Column(Modifier.width(81.dp).fillMaxHeight().background(RailFill).padding(start = 8.dp, top = 46.dp)) {- InfoTabs.forEachIndexed { i, tab ->- val chosen = i == page- Box(- Modifier.size(65.dp, 53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { page = i },- contentAlignment = Alignment.Center,- ) {- Icon(tab.icon, contentDescription = tab.label, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(tab.size))+ if (wide) {+ InfoPagesCard(page) { page = it }+ } else {+ // the rail of pages+ Column(Modifier.width(81.dp).fillMaxHeight().background(RailFill).padding(start = 8.dp, top = 46.dp)) {+ InfoTabs.forEachIndexed { i, tab ->+ val chosen = i == page+ Box(+ Modifier.size(65.dp, 53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { page = i },+ contentAlignment = Alignment.Center,+ ) {+ Icon(tab.icon, contentDescription = tab.label, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(tab.size))+ }+ Spacer(Modifier.height(3.dp))}- Spacer(Modifier.height(3.dp))}}- // the name, Cancel and Done+ // the name (centred over the page when wide), Cancel and DoneBasicTextField(name,{ name = it.take(256) },singleLine = true,- textStyle = TextStyle(color = Ink, fontSize = 18.sp, fontWeight = FontWeight.Bold),+ textStyle = TextStyle(color = Ink, fontSize = 18.sp, fontWeight = FontWeight.Bold, textAlign = if (wide) androidx.compose.ui.text.style.TextAlign.Center else androidx.compose.ui.text.style.TextAlign.Start),cursorBrush = SolidColor(Color.White),- modifier = Modifier.offset(x = 101.dp, y = 30.dp).width(400.dp),+ modifier = if (wide) {+ Modifier.padding(start = WideContentStart, end = WideContentEnd).offset(y = 30.dp).fillMaxWidth()+ } else {+ Modifier.offset(x = 101.dp, y = 30.dp).width(400.dp)+ },)Row(Modifier.align(Alignment.TopEnd).padding(top = 20.dp, end = 20.dp), verticalAlignment = Alignment.CenterVertically) {// Cancel, with Import before it on the colour profile page@@ -186,7 +227,7 @@ fun CanvasInfo(vm: CanvasViewModel) {Icon(PcIcons.DoneTick, contentDescription = "Done", tint = Color.White, modifier = Modifier.requiredSize(40.dp))}}- Column(Modifier.padding(start = 105.dp, end = 24.dp, top = 100.dp).verticalScroll(rememberScrollState())) {+ Column(Modifier.padding(start = if (wide) WideContentStart else 105.dp, end = if (wide) WideContentEnd else 24.dp, top = 100.dp).verticalScroll(rememberScrollState())) {when (page) {0 -> {AboutCard(photo, author, { author = it.take(256) }, { pick.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) }, signature)diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Chrome.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Chrome.ktindex 17543b8..712ce32 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Chrome.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Chrome.kt@@ -363,13 +363,23 @@ fun BrushSlider(value: Float, onChange: (Float) -> Unit, modifier: Modifier = Moval thumb = Size(Pc.ThumbWidth.toPx(), Pc.ThumbHeight.toPx())val at = Offset((size.width - thumb.width) / 2f, inset + (size.height - thumb.height - inset * 2) * (1f - value))val knob = RoundRect(at.x, at.y, at.x + thumb.width, at.y + thumb.height, CornerRadius(thumb.height / 2f))- // the track has a window where the thumb is, so the thumb shows over the bar alone+ // the track has a window where the thumb is, so the thumb shows over the bar alone;+ // a lighter rim runs round it+ val corner = Pc.SliderCorner.toPx()+ val rim = Pc.SliderRimWidth.toPx()+ val inside = RoundRect(rim, rim, size.width - rim, size.height - rim, CornerRadius(corner - rim))val track = Path().apply {fillType = PathFillType.EvenOdd- addRoundRect(RoundRect(0f, 0f, size.width, size.height, CornerRadius(Pc.SliderCorner.toPx())))+ addRoundRect(inside)addRoundRect(knob)}drawPath(track, Pc.SliderTrack)+ val ring = Path().apply {+ fillType = PathFillType.EvenOdd+ addRoundRect(RoundRect(0f, 0f, size.width, size.height, CornerRadius(corner)))+ addRoundRect(inside)+ }+ drawPath(ring, Pc.SliderRim)// the notches: short bars across the track; on one, the thumb shows a blue barval bar = Size(NotchWidth.toPx(), NotchHeight.toPx())val travel = size.height - thumb.height - inset * 2diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ColorPanel.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ColorPanel.ktindex 9ce4e02..421fe5e 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ColorPanel.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/ColorPanel.kt@@ -334,7 +334,7 @@ private fun Classic(c: ColorPick, compact: Boolean = false, square: Dp = 344.dp)val pure = hsvColor(c.hue, 1f, 1f)SliderRow(huePosition(SliderHues, c.hue), SliderHues.map { hsvColor(it / 360f, 1f, 1f) }) { c.setHsv(hueAt(SliderHues, it), c.saturation, c.brightness) }SliderRow(c.saturation, listOf(Pc.SaturationGrey, pure)) { c.setHsv(c.hue, it, c.brightness) }- SliderRow(c.brightness, listOf(Color.Black, hsvColor(c.hue, c.saturation, 1f))) { c.setHsv(c.hue, c.saturation, it) }+ SliderRow(c.brightness, BrightnessTrack) { c.setHsv(c.hue, c.saturation, it) }}}@@ -480,6 +480,9 @@ private fun SaturationBrightness(c: ColorPick, compact: Boolean, height: Dp = 34}}+/** A brightness slider runs from black to white whatever the colour, its knob grey at the value. */+private val BrightnessTrack = listOf(Color.Black, Color.White)+/*** A 36-tall slider row: a 4-dp track through [colours] and a pill showing the colour under it.* Touching anywhere on the row moves the pill there.@@ -618,7 +621,7 @@ private fun Harmony(vm: CanvasViewModel, c: ColorPick, compact: Boolean = false,},)Box(Modifier.padding(start = if (compact) 10.dp else 20.dp, end = if (compact) 10.dp else 20.dp, top = if (compact) 8.dp else if (short) 10.dp else 31.dp)) {- SliderRow(hsv[2], listOf(Color.Black, rgbColor(p3HsvToRgb(hsv[0], hsv[1], 1f)))) { c.setRgb(p3HsvToRgb(state[0], state[1], it)) }+ SliderRow(hsv[2], BrightnessTrack) { c.setRgb(p3HsvToRgb(state[0], state[1], it)) }}}}@@ -888,7 +891,7 @@ private fun Value(c: ColorPick, compact: Boolean = false, short: Boolean = falseValueRow("S", c.saturation, listOf(Pc.SaturationGrey, hsvColor(c.hue, 1f, 1f)), "${(c.saturation * 100f).roundToInt()}%") {c.setHsv(c.hue, it, c.brightness)}- ValueRow("B", c.brightness, listOf(Color.Black, hsvColor(c.hue, c.saturation, 1f)), "${(c.brightness * 100f).roundToInt()}%") {+ ValueRow("B", c.brightness, BrightnessTrack, "${(c.brightness * 100f).roundToInt()}%") {c.setHsv(c.hue, c.saturation, it)}}@@ -920,7 +923,7 @@ private fun InkValue(c: ColorPick, inks: Inks) {ValueRow("S", c.saturation, listOf(Pc.SaturationGrey, hsvColor(c.hue, 1f, 1f)), "${(c.saturation * 100f).roundToInt()}%") {c.setHsv(c.hue, it, c.brightness)}- ValueRow("B", c.brightness, listOf(Color.Black, hsvColor(c.hue, c.saturation, 1f)), "${(c.brightness * 100f).roundToInt()}%") {+ ValueRow("B", c.brightness, BrightnessTrack, "${(c.brightness * 100f).roundToInt()}%") {c.setHsv(c.hue, c.saturation, it)}}@@ -974,7 +977,7 @@ private fun CompactValue(c: ColorPick) {CompactValueRow("S", c.saturation, listOf(Pc.SaturationGrey, hsvColor(c.hue, 1f, 1f)), "${(c.saturation * 100f).roundToInt()}%") {c.setHsv(c.hue, it, c.brightness)}- CompactValueRow("B", c.brightness, listOf(Color.Black, hsvColor(c.hue, c.saturation, 1f)), "${(c.brightness * 100f).roundToInt()}%") {+ CompactValueRow("B", c.brightness, BrightnessTrack, "${(c.brightness * 100f).roundToInt()}%") {c.setHsv(c.hue, c.saturation, it)}}diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CustomCanvasUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CustomCanvasUi.ktindex d73be2a..e74a387 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CustomCanvasUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/CustomCanvasUi.kt@@ -173,10 +173,20 @@ fun CustomCanvasScreen(vm: CanvasViewModel, onMade: () -> Unit) {}}// the name, Cancel and Done+ // on a wide screen centred over the page, upright from its left+ val wide = maxWidth > maxHeightBasicTextField(name, { name = it.take(64) }, singleLine = true,- textStyle = TextStyle(color = Ink, fontSize = 22.sp, fontWeight = FontWeight.Bold), cursorBrush = SolidColor(Color.White),- modifier = Modifier.offset(x = 394.dp, y = 28.dp).width(maxWidth - 394.dp - 160.dp),+ textStyle = TextStyle(+ color = Ink, fontSize = 22.sp, fontWeight = FontWeight.Bold,+ textAlign = if (wide) androidx.compose.ui.text.style.TextAlign.Center else androidx.compose.ui.text.style.TextAlign.Start,+ ),+ cursorBrush = SolidColor(Color.White),+ modifier = if (wide) {+ Modifier.padding(start = 372.dp, end = 32.dp).offset(y = 28.dp).fillMaxWidth()+ } else {+ Modifier.offset(x = 394.dp, y = 28.dp).width(maxWidth - 394.dp - 160.dp)+ },)Row(Modifier.align(Alignment.TopEnd).padding(top = 20.dp, end = 20.dp), verticalAlignment = Alignment.CenterVertically) {// Cancel, and Import beside it on the colour profile page@@ -252,6 +262,7 @@ fun CustomCanvasScreen(vm: CanvasViewModel, onMade: () -> Unit) {if (section == 0 && field != null) {Keypad(Modifier.align(Alignment.BottomCenter),+ wide,unit,onUnit = {commit()@@ -350,37 +361,48 @@ private fun SwitchLine(label: String, on: Boolean, onChange: (Boolean) -> Unit)}}-/** The keypad: units on the left, the digits, and Backspace, Next and Done on the right. */+/**+ * The keypad: units on the left, the digits, and Backspace, Next and Done on the right. Upright its+ * keys are 120 x 71 (8 apart down) in a 342 panel; on a [wide] screen 150 x 87.5 (9 apart) in a+ * 457 one, the rows from 47 below its top.+ */@Composable-private fun Keypad(modifier: Modifier, unit: SizeUnit, onUnit: (SizeUnit) -> Unit, onKey: (String) -> Unit, onNext: () -> Unit, onDone: () -> Unit) {- Box(modifier.fillMaxWidth().height(342.dp).background(KeypadFill), contentAlignment = Alignment.Center) {+private fun Keypad(modifier: Modifier, wide: Boolean, unit: SizeUnit, onUnit: (SizeUnit) -> Unit, onKey: (String) -> Unit, onNext: () -> Unit, onDone: () -> Unit) {+ val w = if (wide) 150.dp else 120.dp+ val h = if (wide) 87.5.dp else 71.dp+ val down = if (wide) 9.dp else 8.dp+ val across = 9.dp+ Box(+ modifier.fillMaxWidth().height(if (wide) 457.dp else 342.dp).background(KeypadFill).padding(top = if (wide) 47.dp else 0.dp),+ contentAlignment = if (wide) Alignment.TopCenter else Alignment.Center,+ ) {Row(horizontalArrangement = Arrangement.spacedBy(30.dp)) {- Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ Column(verticalArrangement = Arrangement.spacedBy(down)) {for (u in listOf(SizeUnit.MILLIMETERS, SizeUnit.CENTIMETERS, SizeUnit.INCHES, SizeUnit.PIXELS)) {- Key(u.label, if (u == unit) UnitChosen else KeyFill, if (u == unit) Color(0xFF1F1F1F) else Ink, 15.sp) { onUnit(u) }+ Key(u.label, if (u == unit) UnitChosen else KeyFill, if (u == unit) Color(0xFF1F1F1F) else Ink, 15.sp, w, h) { onUnit(u) }}}- Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ Column(verticalArrangement = Arrangement.spacedBy(down)) {for (row in listOf(listOf("7", "8", "9"), listOf("4", "5", "6"), listOf("1", "2", "3"))) {- Row(horizontalArrangement = Arrangement.spacedBy(9.dp)) { for (k in row) Key(k, DigitFill, Ink, 26.sp) { onKey(k) } }+ Row(horizontalArrangement = Arrangement.spacedBy(across)) { for (k in row) Key(k, DigitFill, Ink, 26.sp, w, h) { onKey(k) } }}- Row(horizontalArrangement = Arrangement.spacedBy(9.dp)) {- Key("0", DigitFill, Ink, 26.sp, width = 249) { onKey("0") }- Key(".", DigitFill, Ink, 26.sp) { onKey(".") }+ Row(horizontalArrangement = Arrangement.spacedBy(across)) {+ Key("0", DigitFill, Ink, 26.sp, w * 2 + across, h) { onKey("0") }+ Key(".", DigitFill, Ink, 26.sp, w, h) { onKey(".") }}}- Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {- Key("Backspace", KeyFill, Ink, 15.sp) { onKey("⌫") }- Key("Next", KeyFill, Ink, 15.sp) { onNext() }- Key("Done", KeyFill, Ink, 15.sp, height = 150) { onDone() }+ Column(verticalArrangement = Arrangement.spacedBy(down)) {+ Key("Backspace", KeyFill, Ink, 15.sp, w, h) { onKey("⌫") }+ Key("Next", KeyFill, Ink, 15.sp, w, h) { onNext() }+ Key("Done", KeyFill, Ink, 15.sp, w, h * 2 + down) { onDone() }}}}}@Composable-private fun Key(label: String, fill: Color, ink: Color, size: androidx.compose.ui.unit.TextUnit, width: Int = 120, height: Int = 71, onClick: () -> Unit) {- Box(Modifier.size(width.dp, height.dp).clip(RoundedCornerShape(8.dp)).background(fill).clickable(onClick = onClick), contentAlignment = Alignment.Center) {+private fun Key(label: String, fill: Color, ink: Color, size: androidx.compose.ui.unit.TextUnit, width: Dp, height: Dp, onClick: () -> Unit) {+ Box(Modifier.size(width, height).clip(RoundedCornerShape(8.dp)).background(fill).clickable(onClick = onClick), contentAlignment = Alignment.Center) {Text(label, color = ink, fontSize = size)}}diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.ktindex 147ca81..f8af25a 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GalleryScreen.kt@@ -99,8 +99,6 @@ import kotlin.math.roundToIntimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.delayimport kotlinx.coroutines.withContext-import kotlin.math.max-import kotlin.math.min/*** A gallery cell's sizes: its pitch both ways (the screen's width over the columns, three upright@@ -167,10 +165,22 @@ fun GalleryScreen(vm: CanvasViewModel) {)Column(Modifier.fillMaxSize().then(if (blur > 0.dp) Modifier.blur(blur) else Modifier)) {if (selecting) {+ val screen = androidx.compose.ui.platform.LocalConfiguration.currentSelectHeader(title = vm.openStack?.name ?: "ProCraft",- any = selected.isNotEmpty(),+ count = selected.size,+ wide = screen.screenWidthDp > screen.screenHeightDp,+ canStack = vm.openStack == null,+ onStack = {+ vm.stackArtworks(picked())+ endSelecting()+ },+ onPreview = { previewing = picked() },onShare = { sharing = GalleryShare(picked(), null) },+ onDuplicate = {+ picked().forEach(vm::duplicateArtwork)+ endSelecting()+ },onDelete = { deletingSelected = true },onMore = { moreOpen = !moreOpen },onDone = ::endSelecting,@@ -575,21 +585,48 @@ private fun GalleryHeader(stack: String?, onBack: () -> Unit, onSelect: () -> Un}}+/** One of Select's buttons: its label, width, whether it can act now, and what it does. */+private class SelectAction(val label: String, val width: Dp, val enabled: Boolean, val onClick: () -> Unit)+/**- * Select's title row: Share, Delete and More (dimmed until an artwork is picked), and the blue- * round button that ends selecting.+ * Select's title row: upright, Share, Delete and More; on a wide screen Stack, Preview, Share,+ * Duplicate and Delete side by side ([wide]). Each is dimmed until it can act on the [count]+ * picked artworks (Stack on two or more; More always opens, its rows greyed). Then the blue round+ * button that ends selecting.*/@Composable-private fun SelectHeader(title: String, any: Boolean, onShare: () -> Unit, onDelete: () -> Unit, onMore: () -> Unit, onDone: () -> Unit) {+private fun SelectHeader(+ title: String,+ count: Int,+ wide: Boolean,+ canStack: Boolean,+ onStack: () -> Unit,+ onPreview: () -> Unit,+ onShare: () -> Unit,+ onDuplicate: () -> Unit,+ onDelete: () -> Unit,+ onMore: () -> Unit,+ onDone: () -> Unit,+) {+ val any = count > 0+ val actions = if (wide) {+ listOf(+ SelectAction("Stack", 65.dp, canStack && count >= 2, onStack),+ SelectAction("Preview", 80.dp, any, onPreview),+ SelectAction("Share", 65.dp, any, onShare),+ SelectAction("Duplicate", 91.dp, any, onDuplicate),+ SelectAction("Delete", 70.dp, any, onDelete),+ )+ } else {+ listOf(SelectAction("Share", 65.dp, any, onShare), SelectAction("Delete", 70.dp, any, onDelete), SelectAction("More", 61.dp, true, onMore))+ }Box(Modifier.fillMaxWidth().height(55.dp)) {Text(title, color = Pc.GalleryTitle, fontSize = 36.sp, fontWeight = FontWeight.Bold, modifier = Modifier.padding(start = 32.dp, top = 11.dp))Row(Modifier.align(Alignment.TopEnd).padding(top = 10.dp, end = 20.dp), verticalAlignment = Alignment.CenterVertically) {Row(Modifier.height(45.dp).clip(CircleShape).background(Pc.Capsule).border(1.dp, Pc.CapsuleEdge, CircleShape), verticalAlignment = Alignment.CenterVertically) {- // More opens with nothing picked too (its rows greyed then)- for ((label, width, action) in listOf(Triple("Share", 65.dp, onShare), Triple("Delete", 70.dp, onDelete), Triple("More", 61.dp, onMore))) {- val enabled = any || label == "More"- Box(Modifier.width(width).height(45.dp).clickable(enabled = enabled, onClick = action), contentAlignment = Alignment.Center) {- Text(label, color = if (enabled) Pc.GalleryTitle else Pc.GallerySize, fontSize = 16.sp)+ for (a in actions) {+ Box(Modifier.width(a.width).height(45.dp).clickable(enabled = a.enabled, onClick = a.onClick), contentAlignment = Alignment.Center) {+ Text(a.label, color = if (a.enabled) Pc.GalleryTitle else Pc.GallerySize, fontSize = 16.sp)}}}@@ -757,7 +794,12 @@ private fun formatsPlace(from: androidx.compose.ui.geometry.Rect?, screenWidth:val arrowAt = (centreY - top).coerceIn(Pc.PopoverCorner + Pc.ArrowHeight, FormatsHeight - Pc.PopoverCorner - Pc.ArrowHeight)val total = FormatsWidth + Pc.ArrowHeightval y = arrowAt / FormatsHeight- return if (from.right.dp + gap + total <= screenWidth - 2.dp) {+ // on the side of the pill with more room (right of a pill left of the middle), the other if+ // that side is too narrow+ val roomRight = screenWidth - 2.dp - from.right.dp - gap+ val roomLeft = from.left.dp - gap - 2.dp+ val right = if (roomRight >= roomLeft) roomRight >= total || roomLeft < total else roomLeft < total && roomRight >= total+ return if (right) {FormatsPlace(from.right.dp + gap, top, ArrowSide.LEFT, arrowAt, androidx.compose.ui.graphics.TransformOrigin(0f, y))} else {FormatsPlace((from.left.dp - gap - total).coerceAtLeast(2.dp), top, ArrowSide.RIGHT, arrowAt, androidx.compose.ui.graphics.TransformOrigin(1f, y))@@ -917,8 +959,9 @@ private fun NewCanvasPanel(onPick: (CanvasPreset) -> Unit,onScreenSize: (Int, Int) -> Unit,) {+ // the screen as it is turned now (2560 x 1600 in landscape, 1600 x 2560 upright)val root = LocalView.current.rootView- val (sw, sh) = min(root.width, root.height).coerceAtLeast(1) to max(root.width, root.height).coerceAtLeast(1)+ val (sw, sh) = root.width.coerceAtLeast(1) to root.height.coerceAtLeast(1)// the row swiped open, if one isvar opened by remember { mutableStateOf<Int?>(null) }Popover(NewCanvasWidth, arrowX, modifier, fill = Pc.LightPanel, corner = 32.dp) {diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GestureControlsUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GestureControlsUi.ktindex d704ba7..45afc96 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GestureControlsUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GestureControlsUi.kt@@ -5,6 +5,8 @@ import androidx.compose.foundation.backgroundimport androidx.compose.foundation.clickableimport androidx.compose.foundation.gestures.detectHorizontalDragGesturesimport androidx.compose.foundation.gestures.detectTapGestures+import androidx.compose.foundation.border+import androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Row@@ -61,6 +63,38 @@ private val TrackOff = Color(0xFF1D1D1D)private val KnobOff = Color(0xFF333333)private val DoneBlue = Color(0xFF0190FF)+/** Where a wide screen's page starts and ends, beside the card of what gestures can do. */+private val WideContentStart = 358.dp+private val WideContentEnd = 28.dp+private val CardEdge = Color(0xFF373737)+private val PageInk = Color(0xFF797979)++/** What gestures can do, by icon and name on a card headed "Gesture controls" (a wide screen's). */+@Composable+private fun GesturePagesCard(page: GesturePurpose, onPage: (GesturePurpose) -> Unit) {+ val shape = RoundedCornerShape(20.dp)+ Column(Modifier.padding(start = 10.dp, top = 10.dp, bottom = 10.dp).width(320.dp).fillMaxHeight().clip(shape).background(RailFill).border(1.dp, CardEdge, shape)) {+ Text("Gesture controls", color = Ink, fontSize = 24.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.padding(start = 24.dp, top = 19.dp))+ Column(+ Modifier.verticalScroll(rememberScrollState()).padding(start = 8.dp, end = 8.dp, top = 17.dp, bottom = 8.dp),+ verticalArrangement = Arrangement.spacedBy(3.dp),+ ) {+ for (p in GesturePurpose.entries) {+ val chosen = p == page+ Row(+ Modifier.fillMaxWidth().height(53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { onPage(p) },+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Box(Modifier.width(54.dp), contentAlignment = Alignment.Center) {+ Icon(icon(p), contentDescription = null, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(37.dp))+ }+ Text(p.title, color = if (chosen) Color.White else PageInk, fontSize = 17.sp, maxLines = 1)+ }+ }+ }+ }+}+private fun icon(p: GesturePurpose): ImageVector = when (p) {GesturePurpose.SMUDGE -> PcIcons.SmudgeGesturePurpose.ERASE -> PcIcons.Erase@@ -82,32 +116,47 @@ private fun icon(p: GesturePurpose): ImageVector = when (p) {*/@Composablefun GestureControls(vm: CanvasViewModel) {- var page by remember { mutableStateOf(GesturePurpose.EYEDROPPER) }+ // it opens on the page it was last on+ var page by vm::gesturePagevar resetting by remember { mutableStateOf(false) }val settings = vm.gesturesBackHandler { vm.gestureControlsOpen = false }+ // on a wide screen what gestures can do is named on a card, the page and its title to its right+ val screen = androidx.compose.ui.platform.LocalConfiguration.current+ val wide = screen.screenWidthDp > screen.screenHeightDpBox(Modifier.fillMaxSize().background(ScreenFill).pointerInput(Unit) { detectTapGestures { } }) {- Column(Modifier.width(81.dp).fillMaxHeight().background(RailFill).verticalScroll(rememberScrollState()).padding(start = 8.dp, top = 46.dp, bottom = 20.dp)) {- for (p in GesturePurpose.entries) {- val chosen = p == page- Box(- Modifier.size(65.dp, 53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { page = p },- contentAlignment = Alignment.Center,- ) {- // each drawn in a padded frame, fitted 37 across- Icon(icon(p), contentDescription = p.title, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(37.dp))+ if (wide) {+ GesturePagesCard(page) { page = it }+ } else {+ Column(Modifier.width(81.dp).fillMaxHeight().background(RailFill).verticalScroll(rememberScrollState()).padding(start = 8.dp, top = 46.dp, bottom = 20.dp)) {+ for (p in GesturePurpose.entries) {+ val chosen = p == page+ Box(+ Modifier.size(65.dp, 53.dp).clip(CircleShape).background(if (chosen) Pc.Accent else Color.Transparent).clickable { page = p },+ contentAlignment = Alignment.Center,+ ) {+ // each drawn in a padded frame, fitted 37 across+ Icon(icon(p), contentDescription = p.title, tint = if (chosen) Color.White else RailIdle, modifier = Modifier.requiredSize(37.dp))+ }+ Spacer(Modifier.height(3.dp))}- Spacer(Modifier.height(3.dp))}}- Text(page.heading, color = Ink, fontSize = 20.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.offset(x = 101.dp, y = 28.dp))+ if (wide) {+ Text(+ page.heading, color = Ink, fontSize = 20.sp, fontWeight = FontWeight.Bold, maxLines = 1, textAlign = androidx.compose.ui.text.style.TextAlign.Center,+ modifier = Modifier.padding(start = WideContentStart, end = WideContentEnd).offset(y = 28.dp).fillMaxWidth(),+ )+ } else {+ Text(page.heading, color = Ink, fontSize = 20.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.offset(x = 101.dp, y = 28.dp))+ }Box(Modifier.align(Alignment.TopEnd).padding(top = 20.dp, end = 20.dp).size(44.dp, 45.dp).clip(CircleShape).background(DoneBlue).clickable { vm.gestureControlsOpen = false },contentAlignment = Alignment.Center,) {Icon(PcIcons.DoneTick, contentDescription = "Done", tint = Color.White, modifier = Modifier.requiredSize(40.dp))}- Column(Modifier.padding(start = 105.dp, end = 24.dp, top = 100.dp).verticalScroll(rememberScrollState())) {+ Column(Modifier.padding(start = if (wide) WideContentStart else 105.dp, end = if (wide) WideContentEnd else 24.dp, top = 100.dp).verticalScroll(rememberScrollState())) {Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(25.dp)).background(CardFill)) {val options = GestureOptions[page].orEmpty()options.forEachIndexed { i, o ->diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GuideUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GuideUi.ktindex f0bea8a..533ee6c 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GuideUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/GuideUi.kt@@ -179,10 +179,41 @@ private fun GuideType.icon() = when (this) {GuideType.SYMMETRY -> PcIcons.GuideSymmetry}-/** The guide editor's toolbar: the four kinds, then the kind's look and assisted drawing. */+/**+ * The guide editor's toolbar: the four kinds, then the kind's look and assisted drawing (on a wide+ * screen the whole width less 8 each side, the sliders in one row and the switch at the end).+ */@Composableprivate fun GuideToolbar(vm: CanvasViewModel, modifier: Modifier) {val g = vm.guide ?: return+ val screen = androidx.compose.ui.platform.LocalConfiguration.current+ if (screen.screenWidthDp > screen.screenHeightDp) {+ OptionsPanel(screen.screenWidthDp.dp - 16.dp, 137.dp, modifier, 16.dp) {+ KindsSwitch(546.dp, GUIDE_KINDS.map { (k, label, w) -> Kind(k.icon(), label, w) }, GUIDE_KINDS.indexOfFirst { it.first == g.kind }) {+ vm.chooseGuideKind(GUIDE_KINDS[it].first)+ }+ Spacer(Modifier.height(16.dp))+ Row(Modifier.fillMaxWidth().height(54.dp).padding(start = 16.dp, end = 22.dp), horizontalArrangement = Arrangement.spacedBy(19.dp), verticalAlignment = Alignment.CenterVertically) {+ OptionSlider("Opacity", g.opacity, shown(g.opacity, max = true), 257.dp) { vm.setGuideLook(opacity = it) }+ OptionSlider("Thickness", g.thickness, shown(g.thickness, max = true), 257.dp) { vm.setGuideLook(thickness = it) }+ when (g.kind) {+ GuideType.GRID, GuideType.ISOMETRIC ->+ OptionSlider("Grid size", sizeToSlider(g.size), "${g.size.roundToInt()}px", 257.dp, chip = true) { vm.setGuideLook(size = sliderToSize(it)) }+ GuideType.SYMMETRY -> Box(+ Modifier.size(257.dp, 40.dp).clip(RoundedCornerShape(20.dp)).background(Color(0xFF303030)).tap { vm.symmetryOptionsOpen = !vm.symmetryOptionsOpen },+ contentAlignment = Alignment.Center,+ ) {+ Text("Options", color = Color(0xFFD0D0D0), fontSize = 15.sp, maxLines = 1)+ }+ GuideType.PERSPECTIVE -> Unit+ }+ Spacer(Modifier.weight(1f))+ Text("Assisted Drawing", color = Color(0xFFD0D0D0), fontSize = 15.sp, maxLines = 1)+ Box(Modifier.tap { vm.setGuideAssisted(!g.assisted) }) { Switch(g.assisted, enabled = true) }+ }+ }+ return+ }OptionsPanel(652.dp, 199.dp, modifier, 16.dp) {KindsSwitch(546.dp, GUIDE_KINDS.map { (k, label, w) -> Kind(k.icon(), label, w) }, GUIDE_KINDS.indexOfFirst { it.first == g.kind }) {vm.chooseGuideKind(GUIDE_KINDS[it].first)@@ -196,7 +227,7 @@ private fun GuideToolbar(vm: CanvasViewModel, modifier: Modifier) {Row(Modifier.width(620.dp).height(54.dp), horizontalArrangement = Arrangement.spacedBy(20.dp), verticalAlignment = Alignment.CenterVertically) {when (g.kind) {GuideType.GRID, GuideType.ISOMETRIC -> {- OptionSlider("Grid size", sizeToSlider(g.size), "${g.size.roundToInt()}px", 300.dp) { vm.setGuideLook(size = sliderToSize(it)) }+ OptionSlider("Grid size", sizeToSlider(g.size), "${g.size.roundToInt()}px", 300.dp, chip = true) { vm.setGuideLook(size = sliderToSize(it)) }AssistedSwitch(vm, g.assisted)}GuideType.PERSPECTIVE -> AssistedSwitch(vm, g.assisted)@@ -224,9 +255,11 @@ private fun AssistedSwitch(vm: CanvasViewModel, on: Boolean) {private fun SymmetryOptions(vm: CanvasViewModel, screenWidth: androidx.compose.ui.unit.Dp, screenHeight: androidx.compose.ui.unit.Dp) {val g = vm.guide ?: returnif (!vm.symmetryOptionsOpen || g.kind != GuideType.SYMMETRY) return- val toolbarLeft = (screenWidth - 652.dp) / 2- // over the Options button, its arrow at the button's middle- MenuPopover(150.dp, toolbarLeft + 16.dp, screenHeight - 98.dp) {+ // over the Options button, its arrow at the button's middle: the third of the row when wide+ val wide = screenWidth > screenHeight+ val buttonMiddle = if (wide) 8.dp + 16.dp + (257.dp + 19.dp) * 2 + 128.5.dp else (screenWidth - 652.dp) / 2 + 16.dp + 150.dp+ val left = (buttonMiddle - 150.dp).coerceIn(0.dp, screenWidth - 300.dp)+ MenuPopover(buttonMiddle - left, left, if (wide) screenHeight - 89.dp else screenHeight - 98.dp) {MenuTitle("Guide Options")Spacer(Modifier.height(10.dp))Column(Modifier.fillMaxWidth().clip(RoundedCornerShape(13.dp)).background(MenuGroup)) {diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Icons.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Icons.ktindex 2c84275..81da5a6 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Icons.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Icons.kt@@ -513,6 +513,16 @@ object PcIcons {val AdjustGlitch by lazy { shape("adjustglitch", 32f, "M10.9 21.3C9.8 21 8.9 20.2 8.6 19.1C8.5 18.8 8.5 18.5 8.5 17.8C8.5 16.8 8.5 16.8 8.7 16.8C8.8 16.8 11.5 16.6 14.6 16.3C21.7 15.8 20.9 15.9 20.9 15.5C20.9 15.3 20.9 15.2 20.9 15.2C20.9 15.2 18.1 14.9 14.8 14.6C11.5 14.3 8.7 14.1 8.6 14.1C8.5 14.1 8.4 12.1 8.6 11.4C8.9 10.3 9.8 9.4 10.9 9.1C11.4 9 17.9 9 18.5 9.1C19.6 9.3 20.5 10.2 20.8 11.4C20.9 11.7 20.9 12.2 20.9 13.5C20.9 15.2 20.9 15.2 21.2 15.2C21.3 15.2 22.2 15.3 23.1 15.4C24.1 15.5 24.8 15.6 24.9 15.6C24.9 15.6 24.2 15.6 23.3 15.7C22.5 15.8 21.6 15.8 21.4 15.9L20.9 15.9L20.9 17.4C20.9 18.8 20.9 19 20.8 19.3C20.4 20.3 19.8 20.9 18.8 21.3C18.4 21.4 11.5 21.5 10.9 21.3z") }val AdjustHalftone by lazy { shape("adjusthalftone", 32f, "M16.9 23.8C16.8 23.7 16.7 23.6 16.7 23.5C16.7 23.3 17 23 17.2 23C17.4 23 17.7 23.3 17.7 23.5C17.7 23.9 17.2 24.1 16.9 23.8zM14.5 22.9C13.9 22.5 14 21.7 14.6 21.4C15.2 21.2 15.8 21.5 15.7 22.2C15.7 22.8 15.1 23.2 14.5 22.9zM18.5 22.1C17.9 21.8 17.8 21.2 18.2 20.7C18.9 20.1 20 21 19.5 21.7C19.3 22.1 18.8 22.3 18.5 22.1zM12.5 21.3C11.6 21 11.8 19.6 12.8 19.6C13.7 19.6 13.9 20.9 13 21.2C12.8 21.3 12.7 21.3 12.5 21.3zM22.3 20.9C22.1 20.6 22.2 20.2 22.6 20.2C22.7 20.2 22.8 20.2 22.9 20.3C23.1 20.6 22.9 21 22.6 21C22.5 21 22.4 20.9 22.3 20.9zM16.1 20.6C15.7 20.4 15.5 19.9 15.7 19.5C15.8 19.2 15.7 18.9 15.4 18.8C15.1 18.7 15.1 18.7 14.8 18.9C14 19.5 13.1 18.9 13.4 17.9C13.5 17.4 13.1 17.1 12.8 17.4C12.2 18.1 11.2 17.6 11.2 16.8C11.2 16.1 11.7 15.8 12.6 16C12.9 16.1 13.3 15.4 13 15.2C12.6 14.8 12.7 14 13.2 13.7C13.4 13.6 13.8 13.6 14.2 13.7C14.5 13.8 14.7 13.3 14.4 13C13.9 12.3 14.3 11.5 15.1 11.5C15.7 11.5 16.2 12.1 15.9 12.7C15.8 13 15.9 13.2 16.2 13.3C16.4 13.4 16.5 13.4 16.8 13.2C16.9 13 17.1 12.9 17.2 12.9C17.6 12.8 17.8 12.5 17.8 11.9C17.8 11.1 18 10.8 18.6 10.8C19.5 10.7 19.7 11.8 19 12.3C18.5 12.6 18.5 12.7 18.4 13.4C18.4 13.7 18.3 14.1 18.2 14.2C18.1 14.4 18.1 14.6 18.2 14.8C18.4 14.9 18.8 14.9 18.9 14.8C19.1 14.5 19.7 14.4 20 14.6C20.9 15.2 20.2 16.6 19.2 16.2C19.1 16.2 18.9 16.1 18.9 16.2C18 16.5 19.2 18.3 20.3 18.3C20.5 18.3 20.6 18.4 20.8 18.6C21.4 19.1 21 19.9 20.2 19.9C19.8 19.9 19.4 19.6 19.4 19.3C19.4 18.9 18.8 18.4 18.2 18.3C17.2 18.2 16.7 18.7 17.2 19.2C17.8 20 17 21.1 16.1 20.6zM10 19.5C9.4 19.1 9.7 18.3 10.3 18.3C10.9 18.3 11.2 19 10.8 19.4C10.6 19.6 10.2 19.7 10 19.5zM16.3 18.2C17 17.9 16.8 16.9 16 16.9C15.3 16.9 15.1 17.9 15.8 18.2C16 18.3 16 18.3 16.3 18.2zM21.4 17.6C20.6 17.2 20.7 16.1 21.5 15.9C22 15.8 22.5 16 22.6 16.5C22.9 17.2 22.1 17.9 21.4 17.6zM14.7 16.9C15.3 16.2 14.4 15.4 13.8 15.9C13.3 16.3 13.6 17.1 14.3 17.1C14.5 17.1 14.6 17 14.7 16.9zM17.5 16.3C18.2 16 18 15 17.3 15C16.5 15 16.3 15.9 17 16.3C17.3 16.4 17.3 16.4 17.5 16.3zM9.4 15.8C8.9 15.6 8.9 14.9 9.4 14.6C10.2 14.3 10.7 15.5 9.9 15.8C9.7 16 9.7 16 9.4 15.8zM16 14.9C16.4 14.5 16.1 13.8 15.5 13.8C15.3 13.8 15.2 13.9 15 14C14.4 14.6 15.3 15.5 16 14.9zM22.7 14.8C22.5 14.6 22.5 14.5 22.6 14.3C22.8 13.8 23.5 14 23.5 14.5C23.5 14.9 23 15.1 22.7 14.8zM10.9 13.7C10.5 13.6 10.2 13.1 10.4 12.7C10.6 12 11.6 11.9 11.9 12.6C12.2 13.2 11.6 14 10.9 13.7zM20.9 13.7C20 13.5 20.1 12.1 21.1 12.1C22 12.1 22.2 13.5 21.3 13.7C21.1 13.8 21.1 13.8 20.9 13.7zM12.3 11.5C11.8 11.2 11.8 10.5 12.2 10.2C12.8 9.5 13.8 10.2 13.5 11.1C13.3 11.5 12.7 11.7 12.3 11.5zM16.1 10.7C15.6 10.5 15.5 9.8 15.8 9.4C16.2 8.8 17.3 9.1 17.2 9.9C17.2 10.5 16.7 10.9 16.1 10.7zM20 9.4C19.9 9.2 19.9 9 20 8.8C20.2 8.6 20.3 8.6 20.5 8.8C20.8 9.2 20.4 9.6 20 9.4zM14 8.5C13.9 8.4 13.9 8.3 13.9 8.3C14 8 14.4 7.9 14.6 8.2C14.7 8.6 14.2 8.9 14 8.5z") }val AdjustChromatic by lazy { shape("adjustchromatic", 32f, "M9.6 19.6C7 16.3 7.1 16.4 7.1 16C7.1 15.6 7 15.7 9.6 12.4L11.9 9.5L12.9 9.5C13.6 9.5 13.8 9.5 13.8 9.6C13.8 9.6 12.7 11 11.4 12.6C9 15.6 9 15.6 9 16C9.1 16.4 8.9 16.2 12.7 21C13.1 21.6 13.6 22.1 13.7 22.3C13.8 22.5 13.8 22.5 12.9 22.5L11.9 22.5L9.6 19.6zM18.2 22.4C18.2 22.4 19.3 21.1 20.5 19.5C23 16.4 23 16.4 23 16C23 15.6 23 15.6 20.5 12.5C19.3 10.9 18.2 9.6 18.2 9.6C18.2 9.5 18.6 9.5 19.1 9.5L20.1 9.5L21.1 10.7C25.1 15.8 24.9 15.6 24.9 16C24.9 16.4 25.1 16.2 21.1 21.3L20.1 22.5L19.1 22.5C18.6 22.5 18.2 22.5 18.2 22.4zM13.7 19.6C10.8 15.9 10.9 16.1 11.3 15.6C11.5 15.2 15.9 9.6 16 9.6C16.1 9.6 20.8 15.6 20.8 15.8C20.9 15.9 20.9 16.1 20.8 16.2C20.8 16.4 16.1 22.4 16 22.4C16 22.4 14.9 21.1 13.7 19.6z") }+ // Liquify's ways, drawn for the toolbar's row on a wide screen (24 frames): a bow pushed right,+ // spirals each way, four lobes drawn together, a square bulging out, a star, a hexagon, steps+ val LiquifyPush by lazy { filled("liquifypush", "M3 5C10 5.5 17.5 8.5 21 12C17.5 15.5 10 18.5 3 19C7 16.5 9 14.5 9 12C9 9.5 7 7.5 3 5Z") }+ val LiquifyTwirlRight by lazy { filled("liquifytwirlright", "M13.74 2.15A10 10 0 1 1 2.15 10.26A1.30 1.30 0 0 1 4.71 10.72A7.4 7.4 0 1 0 13.28 4.71A1.30 1.30 0 0 1 13.74 2.15ZM9.80 16.25A5.6 5.6 0 1 1 17.45 14.20A1.20 1.20 0 0 1 15.37 13.00A3.2 3.2 0 1 0 11.00 14.17A1.20 1.20 0 0 1 9.80 16.25Z") }+ val LiquifyTwirlLeft by lazy { filled("liquifytwirlleft", "M10.26 2.15A10 10 0 1 0 21.85 10.26A1.30 1.30 0 0 0 19.29 10.72A7.4 7.4 0 1 1 10.72 4.71A1.30 1.30 0 0 0 10.26 2.15ZM14.20 16.25A5.6 5.6 0 1 0 6.55 14.20A1.20 1.20 0 0 0 8.63 13.00A3.2 3.2 0 1 1 13.00 14.17A1.20 1.20 0 0 0 14.20 16.25Z") }+ val LiquifyPinch by lazy { filled("liquifypinch", "M3.4 8a4.6 4.6 0 1 0 9.2 0a4.6 4.6 0 1 0 -9.2 0ZM11.4 8a4.6 4.6 0 1 0 9.2 0a4.6 4.6 0 1 0 -9.2 0ZM3.4 16a4.6 4.6 0 1 0 9.2 0a4.6 4.6 0 1 0 -9.2 0ZM11.4 16a4.6 4.6 0 1 0 9.2 0a4.6 4.6 0 1 0 -9.2 0ZM9 9H15V15H9Z") }+ val LiquifyExpand by lazy { filled("liquifyexpand", "M5 3.5Q12 6.5 19 3.5Q20.5 3.5 20.5 5Q17.5 12 20.5 19Q20.5 20.5 19 20.5Q12 17.5 5 20.5Q3.5 20.5 3.5 19Q6.5 12 3.5 5Q3.5 3.5 5 3.5Z") }+ val LiquifyCrystals by lazy { filled("liquifycrystals", "M12.00 1.50L13.38 8.67L19.42 4.58L15.33 10.62L22.50 12.00L15.33 13.38L19.42 19.42L13.38 15.33L12.00 22.50L10.62 15.33L4.58 19.42L8.67 13.38L1.50 12.00L8.67 10.62L4.58 4.58L10.62 8.67Z") }+ val LiquifyEdge by lazy { filled("liquifyedge", "M12.00 2.00L20.66 7.00L20.66 17.00L12.00 22.00L3.34 17.00L3.34 7.00Z") }+ val LiquifyReconstruct by lazy { filled("liquifyreconstruct", "M3 15h4v4H3zM8.5 11h4v8h-4zM14 7h4v12h-4zM19.5 3h2v16h-2z") }val AdjustLiquify by lazy { shape("adjustliquify", 32f, "M21.6 22.3C23.9 18.9 23.8 15 21.4 12.5C19.6 10.6 17 10.1 15 11.3C14.1 11.8 13.3 12.8 13.2 13.6C13.1 14.4 13.7 14.5 14.1 13.7C14.9 11.9 17.6 11.5 19.4 12.9C22 15 21.2 19.6 18 21.2C17 21.7 16.5 21.8 15.2 21.8C13.1 21.8 11.8 21.2 10.4 19.9C7.2 16.9 7.2 11.9 10.4 8.7C11 8 11 8.1 10.5 8.8C8.5 11.7 8.3 15.1 10 17.7C12.1 20.7 16.1 21.3 18.3 18.8C18.8 18.2 19.1 17.1 18.8 16.8C18.5 16.7 18.3 16.8 18.1 17.3C17.1 19.3 14.1 19.6 12.3 17.7C10.4 15.6 11 11.9 13.4 10.3C17.9 7.2 23.9 10.7 24.1 16.3C24.2 18.7 23.4 20.8 21.7 22.4L21.2 22.9L21.6 22.3z") }val AdjustClone by lazy { shape("adjustclone", 32f, "M12.1 20.9C7.6 20 6.5 14.3 10.3 11.8C12.4 10.5 15.3 10.9 16.8 12.8C19.2 15.7 17.8 19.9 14.2 20.9C13.7 21 12.6 21 12.1 20.9zM18.8 20.7C20.7 17.8 20.5 14.1 18.2 11.5L17.9 11.1L18.4 11C20.7 10.8 22.9 12.2 23.6 14.5C23.9 15.3 23.9 16.8 23.6 17.6C22.9 19.6 21.2 20.8 19.1 21C18.5 21 18.5 21 18.8 20.7z") }val Disclose by lazy { shape("disclose", 32f, "M12.5 19.1C12.2 18.9 9 15.4 8.7 14.8C8.3 14 8.6 12.9 9.5 12.5C9.8 12.3 9.8 12.3 13.3 12.3C17.2 12.3 16.9 12.3 17.4 12.8C17.9 13.3 18.1 14.1 17.8 14.8C17.6 15.1 14.4 18.8 14 19C13.6 19.3 13 19.3 12.5 19.1z") }@@ -623,6 +633,9 @@ object PcIcons {private fun solid(name: String, vararg paths: String): ImageVector = icon(name, *paths.map { Part(it, 1.2f, true) }.toTypedArray())+ /** A shape filled where its parts overlap too, in a 24 frame. */+ private fun filled(name: String, d: String): ImageVector = icon(name, Part(d, 0f, true))+private fun outline(name: String, width: Float, vararg paths: String): ImageVector = icon(name, *paths.map { Part(it, width, false) }.toTypedArray())/** A filled shape drawn in a [frame] unit square (the frame it is shown in, padding and all). */diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/LayersPanel.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/LayersPanel.ktindex 83a6420..bbd55b7 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/LayersPanel.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/LayersPanel.kt@@ -614,13 +614,18 @@ private fun LayerRow(else -> 0.dp}Box(Modifier.padding(start = 4.dp).offset(y = shift)) { Thumb(vm, l, thumbShape) }- if (subtitle == null) {- LockedName(l, ink, name, Modifier.weight(1f))- } else {- // a model's layer shared by its texture set's meshes says so under its name- Column(Modifier.weight(1f)) {- LockedName(l, ink, name, Modifier)- Text(subtitle, color = ink, fontSize = 13.sp, maxLines = 1, modifier = Modifier.padding(start = 29.dp))+ // what the layer is, under its name (which stays in the middle): the reference layer, a+ // private one, a model's layer shared by its texture set's meshes+ val tag = when {+ l.reference -> subtitle?.let { "$it Reference" } ?: "Reference"+ subtitle != null -> subtitle+ l.private -> "Private"+ else -> null+ }+ Box(Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.CenterStart) {+ LockedName(l, ink, name, Modifier)+ if (tag != null) {+ Text(tag, color = ink, fontSize = 13.sp, maxLines = 1, modifier = Modifier.offset(y = 17.5.dp).padding(start = 29.dp))}}// a model's layer: the button that shows its channels, blue while one of them is painteddiff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/TextUi.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/TextUi.ktindex 8a78919..a1de498 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/TextUi.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/TextUi.kt@@ -102,6 +102,9 @@ fun BoxScope.TextEditor(vm: CanvasViewModel) {vm.endText(true)return@awaitEachGesture}+ // a touch on the text brings the keyboard back if it was put away+ focus.requestFocus()+ keyboard?.show()var last = down.positionwhile (true) {val c = awaitPointerEvent().changes.firstOrNull { it.id == down.id } ?: break@@ -120,8 +123,10 @@ fun BoxScope.TextEditor(vm: CanvasViewModel) {keyboard?.show()}}+ // the bar rides on the keyboard: put away, it goes with it+ val keyboardUp = WindowInsets.ime.getBottom(androidx.compose.ui.platform.LocalDensity.current) > 0Column(Modifier.align(Alignment.BottomCenter).fillMaxWidth().windowInsetsPadding(WindowInsets.ime)) {- if (vm.textStyleOpen) TextStyleSheet(vm, info) else TextBar(vm)+ if (vm.textStyleOpen) TextStyleSheet(vm, info) else if (keyboardUp) TextBar(vm)}}diff --git a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Theme.kt b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Theme.ktindex 21887ed..15c5e35 100644--- a/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Theme.kt+++ b/apps/procraft-android/android/app/src/main/java/io/github/artcraftandroid/procraft/ui/Theme.kt@@ -138,6 +138,10 @@ object Pc {// over white); the thumbs opaque (#a6a6a6 over white and over the dark surround alike)val SideBar: Color get() = pick(0xE7171717, 0xF2E8E8E8)val SliderTrack: Color get() = pick(0xC93E3E3E, 0xFFEDEDED)+ // a lighter rim round each track, more of what is behind showing through it (#5a5a5a over the+ // dark surround, #969696 over white)+ val SliderRim: Color get() = pick(0xB96E6E6E, 0xFFEDEDED)+ val SliderRimWidth = 0.8.dpval SliderThumb: Color get() = pick(0xFFA6A6A6, 0xFFF8F8F8)val SideGlyph: Color get() = pick(0xFF969696, 0xFF646464)val SideGlyphDisabled: Color get() = pick(0x1AFFFFFF, 0x33000000)diff --git a/apps/procraft-android/src/clipboard.rs b/apps/procraft-android/src/clipboard.rsindex f61aab1..37f369e 100644--- a/apps/procraft-android/src/clipboard.rs+++ b/apps/procraft-android/src/clipboard.rs@@ -98,12 +98,18 @@ impl CanvasSession {/// A new layer above the current one holding `image` where it was copied from (centred when/// it is another size); returns its id.pub fn paste(&self, image: ThumbnailImage) -> Option<u64> {- self.add_picture(&image, false)+ self.add_picture(&image, false, false)+ }++ /// As [`paste`](Self::paste), on a private layer: one the gallery's thumbnail leaves out.+ pub fn paste_private(&self, image: ThumbnailImage) -> Option<u64> {+ self.add_picture(&image, false, true)}/// A new layer above the current one holding `image` (a photo or file, straight RGBA8),- /// centred and scaled down to fit; returns its id.- pub fn insert_image(&self, image: ThumbnailImage) -> Option<u64> {+ /// centred and scaled down to fit (on a private layer, one the gallery's thumbnail leaves+ /// out, if `private`); returns its id.+ pub fn insert_image(&self, image: ThumbnailImage, private: bool) -> Option<u64> {let mut premultiplied = image;for px in premultiplied.rgba.as_chunks_mut::<4>().0 {let a = u16::from(px[3]);@@ -111,7 +117,7 @@ impl CanvasSession {*c = ((u16::from(*c) * a + 127) / 255) as u8;}}- self.add_picture(&premultiplied, true)+ self.add_picture(&premultiplied, true, private)}/// Mirrors every layer of the canvas, left to right or (not `horizontal`) top to bottom, as@@ -137,13 +143,21 @@ impl CanvasSession {}impl CanvasSession {- fn add_picture(&self, image: &ThumbnailImage, fit: bool) -> Option<u64> {+ fn add_picture(&self, image: &ThumbnailImage, fit: bool, private: bool) -> Option<u64> {let (w, h) = {let st = self.shared.lock();(st.doc.width(), st.doc.height())};let pixels = placed(image, w, h, fit)?;- let id = self.add_layer();+ let id = self+ .change("new layer", |d| {+ d.has_room(1).then(|| {+ let id = d.add_layer();+ d.set_private(id, private);+ id.0+ })+ })+ .unwrap_or(0);let mut guard = self.shared.lock();let st = &mut *guard;if !st.doc.has_room(1) {diff --git a/apps/procraft-android/src/layers.rs b/apps/procraft-android/src/layers.rsindex 3ac1a1f..a529ded 100644--- a/apps/procraft-android/src/layers.rs+++ b/apps/procraft-android/src/layers.rs@@ -20,6 +20,8 @@ pub struct LayerInfo {/// Picked to act on together with the current layer.pub picked: bool,pub reference: bool,+ /// Left out of the gallery's thumbnail (put in by a private insert or paste).+ pub private: bool,pub kind: LayerType,/// A mask's layer, or the group a layer is in.pub parent: Option<u64>,@@ -170,6 +172,7 @@ impl CanvasSession {current: l.id == current,picked: st.doc.is_picked(l.id),reference: l.reference,+ private: l.private,kind: match l.kind {LayerKind::Paint => LayerType::Paint,LayerKind::Group => LayerType::Group,diff --git a/apps/procraft-android/src/lib.rs b/apps/procraft-android/src/lib.rsindex 6ae926f..01bcea1 100644--- a/apps/procraft-android/src/lib.rs+++ b/apps/procraft-android/src/lib.rs@@ -53,13 +53,16 @@ use procraft_gpu::{Canvas, Gpu, StrokeStyle, StrokeTool};#[cfg_attr(not(target_os = "android"), allow(dead_code))]pub(crate) const SURROUND: [f32; 3] = [37.0 / 255.0, 37.0 / 255.0, 37.0 / 255.0];-/// The grid over the surround: its line colour (sRGB), and its spacing, line width and top (the-/// bar's height), in interface points.+/// The grid over the surround: its line colour (sRGB), and its spacing, line width (a point, its+/// edges smoothed a third of a pixel out on a 2x screen) and top (the bar's height, none under+/// it), in interface points. It is fixed to the glass: see [`CanvasSession::set_grid_origin`].#[cfg_attr(not(target_os = "android"), allow(dead_code))]-pub(crate) const GRID_LINE: [f32; 3] = [40.0 / 255.0, 40.0 / 255.0, 40.0 / 255.0];+pub(crate) const GRID_LINE: [f32; 3] = [46.0 / 255.0, 46.0 / 255.0, 46.0 / 255.0];#[cfg_attr(not(target_os = "android"), allow(dead_code))]pub(crate) const GRID_SPACING_PT: f32 = 16.0;#[cfg_attr(not(target_os = "android"), allow(dead_code))]+pub(crate) const GRID_WIDTH_PT: f32 = 4.0 / 3.0;+#[cfg_attr(not(target_os = "android"), allow(dead_code))]pub(crate) const GRID_TOP_PT: f32 = 44.0;/// The bands over what is not selected: their period across the window and drift (points, points@@ -290,6 +293,9 @@ pub(crate) struct State {pub(crate) error: Option<String>,/// Window pixels per interface point.pub(crate) display_scale: f32,+ /// Where the middle of one of the surround grid's lines is, across and down (window pixels);+ /// none given, half a point in from the top-left corner.+ grid_origin: Option<[f32; 2]>,/// The document before a continuous change (a slider drag) began.pending_doc: Option<Document>,/// What undo calls that change.@@ -360,10 +366,25 @@ pub(crate) struct State {/// Where the stroke began (canvas pixels), for assisted drawing; the guide and view as the/// guide editor opened.assist_from: Option<Vec2>,- guide_before: Option<(procraft_engine::guide::Guide, Option<View>)>,+ pub(crate) guide_before: Option<(procraft_engine::guide::Guide, Option<View>)>,}impl State {+ /// The surround's grid in window pixels, shifted by `by` (where the window's corner lands on+ /// the target).+ #[cfg_attr(not(target_os = "android"), allow(dead_code))]+ pub(crate) fn surround_grid(&self, by: Vec2) -> procraft_gpu::SurroundGrid {+ let s = self.display_scale;+ let [x, y] = self.grid_origin.unwrap_or([0.5 * s, 0.5 * s]);+ procraft_gpu::SurroundGrid {+ spacing: GRID_SPACING_PT * s,+ origin: [x + by.x, y + by.y],+ top: GRID_TOP_PT * s + by.y,+ width: GRID_WIDTH_PT * s,+ color: GRID_LINE,+ }+ }+/// The whole canvas fitted in the window, clear of the insets, turned by the right angle the/// view is nearest (fitting straightens a turned canvas, but keeps it on its side if it is).pub(crate) fn fitted_view(&self) -> View {@@ -678,6 +699,7 @@ impl CanvasSession {frame_interval_ms: 0.0,error: None,display_scale: 2.0,+ grid_origin: None,pending_doc: None,pending_name: None,info: project::ArtworkInfo {@@ -991,6 +1013,17 @@ impl CanvasSession {}}+ /// The surround's grid is fixed to the glass as the canvas is: its lines run from the panel's+ /// own corner, so the window gives where the middle of one of them lands (window pixels) as+ /// the display turns.+ pub fn set_grid_origin(&self, x: f32, y: f32) {+ if x.is_finite() && y.is_finite() {+ let mut st = self.shared.lock();+ st.grid_origin = Some([x, y]);+ self.shared.frame(&mut st);+ }+ }+/// Fits the whole canvas in the window again, at once.pub fn fit_view(&self) {let mut st = self.shared.lock();diff --git a/apps/procraft-android/src/pick.rs b/apps/procraft-android/src/pick.rsindex 4c2c78f..77adad5 100644--- a/apps/procraft-android/src/pick.rs+++ b/apps/procraft-android/src/pick.rs@@ -1,9 +1,9 @@//! The eyedropper: what is shown around a window point, and the canvas colour under it.use procraft_engine::geom::{Affine, Vec2};-use procraft_gpu::{SurroundGrid, Target, read_texture, wgpu};+use procraft_gpu::{Target, read_texture, wgpu};-use crate::{CanvasSession, GRID_LINE, GRID_SPACING_PT, GRID_TOP_PT, SURROUND};+use crate::{CanvasSession, SURROUND};/// What the eyedropper sees.#[derive(Clone, Debug, uniffi::Record)]@@ -25,6 +25,9 @@ impl CanvasSession {let mut guard = self.shared.lock();let st = &mut *guard;let view = st.view?;+ // the window shifted so that the point lands in the middle of the small target+ let corner = Vec2::new(x - side as f32 / 2.0, y - side as f32 / 2.0);+ let grid = st.surround_grid(Vec2::ZERO - corner);let (Some(canvas), Some(gpu)) = (st.canvas.as_mut(), st.gpu.as_ref()) else { return None };let format = wgpu::TextureFormat::Rgba8Unorm;let texture = gpu.device.create_texture(&wgpu::TextureDescriptor {@@ -38,16 +41,7 @@ impl CanvasSession {view_formats: &[],});let target_view = texture.create_view(&Default::default());- // the window shifted so that the point lands in the middle of the small target- let corner = Vec2::new(x - side as f32 / 2.0, y - side as f32 / 2.0);let to_screen = view.to_screen().then(Affine::translate(Vec2::ZERO - corner));- let s = st.display_scale;- let grid = SurroundGrid {- spacing: GRID_SPACING_PT * s,- origin: [-corner.x, GRID_TOP_PT * s - corner.y],- width: s,- color: GRID_LINE,- };canvas.render(gpu,&mut st.doc,diff --git a/apps/procraft-android/src/project.rs b/apps/procraft-android/src/project.rsindex 73e92ee..e38d73a 100644--- a/apps/procraft-android/src/project.rs+++ b/apps/procraft-android/src/project.rs@@ -143,8 +143,15 @@ impl crate::State {name: self.name.clone(),document: self.doc.clone(),info: self.info.clone(),- // as shown, or as it opened if it hasn't been shown- view: self.view.as_ref().and_then(|v| SavedView::of(v, self.window_size)).or(self.saved_view),+ // as shown (while the guide editor is open, as it was before it), or as it opened if it+ // hasn't been shown+ view: self+ .guide_before+ .as_ref()+ .map_or(self.view, |(_, before)| *before)+ .as_ref()+ .and_then(|v| SavedView::of(v, self.window_size))+ .or(self.saved_view),model: model.as_ref().map(|m| m.saved.clone()),};let mut layers = Vec::new();@@ -155,7 +162,13 @@ impl crate::State {let rgba = canvas.read_layer(gpu, layer.id).map_err(|e| file_error("reading a layer", e))?;layers.push((layer.id, rgba));}- composite = Some(canvas.read_composite(gpu).map_err(|e| file_error("reading the picture", e))?);+ // for the gallery's thumbnail: private layers left out+ let private = self.doc.private_layers();+ composite = Some(+ canvas+ .read_composite_without(gpu, &mut self.doc, &private)+ .map_err(|e| file_error("reading the picture", e))?,+ );} else {// not shown yet: what was opened is still what there islayers = self.pending_pixels.clone();@@ -407,8 +420,11 @@ impl CanvasSession {let (Some(canvas), Some(gpu)) = (st.canvas.as_mut(), st.gpu.as_ref()) else {return Err(file_error("reading the picture", "the canvas is not shown yet"));};- canvas.render(gpu, &mut st.doc, None);- let composite = canvas.read_composite(gpu).map_err(|e| file_error("reading the picture", e))?;+ // the file's preview leaves private layers out+ let private = st.doc.private_layers();+ let composite = canvas+ .read_composite_without(gpu, &mut st.doc, &private)+ .map_err(|e| file_error("reading the picture", e))?;let mut pixels = std::collections::HashMap::new();for l in st.doc.layers() {if l.kind != LayerKind::Group {diff --git a/apps/procraft-android/src/render.rs b/apps/procraft-android/src/render.rsindex f9a1e07..4906e05 100644--- a/apps/procraft-android/src/render.rs+++ b/apps/procraft-android/src/render.rs@@ -4,14 +4,15 @@ use std::sync::Arc;use std::time::{Duration, Instant};use ndk::native_window::NativeWindow;+use procraft_engine::geom::Vec2;use procraft_engine::profile::Profile;use procraft_engine::view::View;-use procraft_gpu::{Backdrop, Gpu, SelectionLook, Stripes, SurroundGrid, Target, wgpu};+use procraft_gpu::{Backdrop, Gpu, SelectionLook, Stripes, Target, wgpu};use crate::selection::SelectionDisplay;use crate::{- BACKDROP_SIGMA_PT, GRID_LINE, GRID_SPACING_PT, GRID_TOP_PT, SELECTION_FILL, SELECTION_TINT, STRIPE_COVERAGE,- STRIPE_PERIOD_PT, STRIPE_SPEED_PT, SURROUND, Shared,+ BACKDROP_SIGMA_PT, SELECTION_FILL, SELECTION_TINT, STRIPE_COVERAGE, STRIPE_PERIOD_PT, STRIPE_SPEED_PT, SURROUND,+ Shared,};pub(crate) fn run(shared: Arc<Shared>, window: NativeWindow) {@@ -109,6 +110,7 @@ pub(crate) fn run(shared: Arc<Shared>, window: NativeWindow) {st.needs_frame = true;}let to_screen = st.view.map(|v| v.to_screen());+ let grid = st.surround_grid(Vec2::ZERO);// a model is drawn in place of the flat canvasif st.scene_shown() {let convert = colours_to(st.doc.profile, screen);@@ -117,12 +119,6 @@ pub(crate) fn run(shared: Arc<Shared>, window: NativeWindow) {} else if let (Some(canvas), Some(gpu), Some(to_screen)) = (st.canvas.as_mut(), st.gpu.as_ref(), to_screen){let s = st.display_scale;- let grid = SurroundGrid {- spacing: GRID_SPACING_PT * s,- origin: [0.0, GRID_TOP_PT * s],- width: s,- color: GRID_LINE,- };// the bands over what is not selected drift, so they keep drawinglet look = canvas.has_selection().then(|| match st.selection_display {SelectionDisplay::Stripes => {diff --git a/apps/procraft-android/src/scene3d.rs b/apps/procraft-android/src/scene3d.rsindex 9d0abf7..77326f6 100644--- a/apps/procraft-android/src/scene3d.rs+++ b/apps/procraft-android/src/scene3d.rs@@ -1765,6 +1765,7 @@ impl State {}}self.carry_stroke();+ let grid = self.surround_grid(Vec2::ZERO);let (Some(gpu), Some(scene)) = (self.gpu.as_ref(), self.scene.as_mut()) else { return };// a new environment: prefiltered now, shown behind the model unless that's turned offif let (Some(view), Some(panorama)) = (scene.view.as_mut(), scene.environment.take()) {@@ -1780,13 +1781,7 @@ impl State {}let Some(view) = scene.view.as_mut() else { return };view.set_convert(convert);- let d = self.display_scale;- view.set_grid(Some(procraft_gpu::SurroundGrid {- spacing: crate::GRID_SPACING_PT * d,- origin: [0.0, crate::GRID_TOP_PT * d],- width: d,- color: crate::GRID_LINE,- }));+ view.set_grid(Some(grid));let mut encoder = gpu.device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("3D view") });// each set's texture, its smaller levels made again when its picture has changed (the// current part's colour is the session's own unless a channel is painted on)diff --git a/apps/procraft-android/src/tests.rs b/apps/procraft-android/src/tests.rsindex 0582805..48a22d3 100644--- a/apps/procraft-android/src/tests.rs+++ b/apps/procraft-android/src/tests.rs@@ -921,11 +921,35 @@ fn copy_cut_paste_and_flip() {assert_eq!(pixel(&s, 20, 50), [255, 255, 255, 255]);// a photo comes in as straight colour, premultipliedlet photo = crate::layers::ThumbnailImage { width: 2, height: 2, rgba: [255, 0, 0, 128].repeat(4) };- assert!(s.insert_image(photo).is_some());+ assert!(s.insert_image(photo, false).is_some());let canvas = s.copy_canvas().unwrap();assert_eq!(canvas.rgba.len(), 100 * 100 * 4);}+#[test]+fn a_private_picture_shows_on_the_canvas_but_not_in_the_thumbnail() {+ let Some(s) = session(100, 100) else { return };+ let photo = crate::layers::ThumbnailImage { width: 100, height: 100, rgba: [255, 0, 0, 255].repeat(100 * 100) };+ let id = s.insert_image(photo, true).unwrap();+ assert!(s.layers().iter().any(|l| l.id == id && l.private));+ assert_eq!(pixel(&s, 50, 50), [255, 0, 0, 255]);+ let dir = std::env::temp_dir().join(format!("procraft-private-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&dir);+ s.save(dir.to_string_lossy().into_owned()).unwrap();+ let png = std::fs::read(dir.join("thumbnail.png")).unwrap();+ let (w, h, rgba) = crate::brush_files::thumbnail_pixels(&png).unwrap();+ let middle = ((h / 2 * w + w / 2) * 4) as usize;+ assert_eq!(&rgba[middle..middle + 3], &[255, 255, 255], "the thumbnail shows the white background");+ // the canvas itself still shows it, and a paste can be private too+ assert_eq!(pixel(&s, 50, 50), [255, 0, 0, 255]);+ let copied = s.copy_layer().unwrap();+ let pasted = s.paste_private(copied).unwrap();+ assert!(s.layers().iter().any(|l| l.id == pasted && l.private));+ s.undo();+ assert!(s.layers().iter().all(|l| l.id != pasted));+ let _ = std::fs::remove_dir_all(&dir);+}+#[test]fn the_drawing_guide_mirrors_and_assists_strokes() {use crate::guide::{GuideType, SymmetryType};diff --git a/crates/engine/src/document.rs b/crates/engine/src/document.rsindex 6c5e59c..b5667e3 100644--- a/crates/engine/src/document.rs+++ b/crates/engine/src/document.rs@@ -276,6 +276,10 @@ pub struct Layer {/// A text layer's text, until its pixels are changed some other way.#[serde(default)]pub text: Option<LayerText>,+ /// Left out of the gallery's thumbnail and the file's preview (put in by a private insert or+ /// paste).+ #[serde(default)]+ pub private: bool,}/// Largest canvas edge, pixels.@@ -775,6 +779,7 @@ impl Document {parent,collapsed: false,text: None,+ private: false,}}@@ -1178,6 +1183,15 @@ impl Document {self.layer_mut(id).map(|l| l.visible = visible).is_some()}+ pub fn set_private(&mut self, id: LayerId, private: bool) -> bool {+ self.layer_mut(id).map(|l| l.private = private).is_some()+ }++ /// The layers the gallery's thumbnail leaves out (see [`Layer::private`]).+ pub fn private_layers(&self) -> Vec<LayerId> {+ self.layers.iter().filter(|l| l.private).map(|l| l.id).collect()+ }+pub fn set_opacity(&mut self, id: LayerId, opacity: f32) -> bool {let o = if opacity.is_finite() { opacity.clamp(0.0, 1.0) } else { return false };self.layer_mut(id).map(|l| l.opacity = o).is_some()diff --git a/crates/engine/src/native.rs b/crates/engine/src/native.rsindex 1f6da9c..fe43ecc 100644--- a/crates/engine/src/native.rs+++ b/crates/engine/src/native.rs@@ -256,6 +256,7 @@ fn add_item(parent,collapsed: item.bool("isCollapsed").unwrap_or(false),text: None,+ private: false,});}_ => {@@ -283,6 +284,7 @@ fn add_item(parent,collapsed: false,text: None,+ private: item.bool("private").unwrap_or(false),});if !uuid.is_empty() {pixels.push((lid, canvas.pixels(&uuid, 4, 0)?));@@ -304,6 +306,7 @@ fn add_item(parent: Some(lid),collapsed: false,text: None,+ private: false,});if let Some(m) = mask.string("UUID") {// a mask stores only the tiles painted on: the rest shows the layer@@ -548,6 +551,7 @@ fn write_item(locked: ml.locked,clipped: false,alpha_lock: false,+ private: false,};Some(layer_record(b, doc_ref, &mask_uuid, None, rec, w, h))});@@ -561,6 +565,7 @@ fn write_item(locked: l.locked,clipped: l.clipped,alpha_lock: l.alpha_lock,+ private: l.private,};let r = layer_record(b, doc_ref, &uuid, mask, rec, w, h);if id == doc.current() {@@ -583,6 +588,8 @@ struct LayerRecord<'a> {locked: bool,clipped: bool,alpha_lock: bool,+ /// Left out of the file's preview.+ private: bool,}impl LayerRecord<'_> {@@ -597,6 +604,7 @@ impl LayerRecord<'_> {locked: false,clipped: false,alpha_lock: false,+ private: false,}}}@@ -650,7 +658,7 @@ fn layer_record(("opacity", Value::Real(f64::from(r.opacity))),("perspectiveAssisted", Value::Bool(false)),("preserve", Value::Bool(r.alpha_lock)),- ("private", Value::Bool(false)),+ ("private", Value::Bool(r.private)),("sizeHeight", Value::Int(i64::from(h))),("sizeWidth", Value::Int(i64::from(w))),("text", Builder::null()),@@ -771,6 +779,7 @@ mod tests {let top = doc.add_layer();doc.rename(top, "Ink");doc.set_clipped(top, true);+ doc.set_private(top, true);let mask = doc.add_mask(base).unwrap();doc.background = [0.2, 0.4, 0.6];let mut pixels = HashMap::new();@@ -807,7 +816,8 @@ mod tests {assert_eq!(kinds, [(LayerKind::Paint, "Sketch"), (LayerKind::Mask, "Layer Mask"), (LayerKind::Paint, "Ink")]);let sk = d.layers().first().unwrap();assert_eq!((sk.blend, sk.opacity), (BlendMode::Multiply, 0.75));- assert!(d.layers().get(2).unwrap().clipped);+ assert!(d.layers().get(2).unwrap().clipped && d.layers().get(2).unwrap().private);+ assert!(!d.layers().first().unwrap().private);let px = |i: usize| &back.pixels.iter().find(|(id, _)| *id == d.layers().get(i).unwrap().id).unwrap().1;assert_eq!(px(0), &sketch);assert_eq!(px(1), &grey);diff --git a/crates/gpu/src/canvas.rs b/crates/gpu/src/canvas.rsindex 8b1d9d6..acd1db0 100644--- a/crates/gpu/src/canvas.rs+++ b/crates/gpu/src/canvas.rs@@ -375,12 +375,14 @@ struct SelectionGpu {bind: wgpu::BindGroup,}-/// Grid lines around the canvas, fixed to the target: `width` pixels wide, every `spacing` pixels-/// across and down from `origin` (none above it), in `color` (sRGB 0..1).+/// Grid lines around the canvas, fixed to the target: `width` pixels wide (their edges smoothed),+/// every `spacing` pixels across and down from one whose middle is at `origin`, none above `top`,+/// in `color` (sRGB 0..1).#[derive(Clone, Copy, Debug, PartialEq)]pub struct SurroundGrid {pub spacing: f32,pub origin: [f32; 2],+ pub top: f32,pub width: f32,pub color: [f32; 3],}@@ -637,6 +639,7 @@ struct TransformUniform {struct SurroundUniform {v0: [f32; 4],v1: [f32; 4],+ v2: [f32; 4],}const STROKE_NONE: u32 = 0;@@ -3749,6 +3752,7 @@ impl Canvas {let offset = uniforms.push(&SurroundUniform {v0: [g.spacing, g.origin[0], g.origin[1], g.width],v1: [g.color[0], g.color[1], g.color[2], if srgb { 1.0 } else { 0.0 }],+ v2: [target.surround[0], target.surround[1], target.surround[2], g.top],});(&*pipeline, offset)});@@ -4248,6 +4252,30 @@ impl Canvas {read_texture(gpu, &self.composite[0], self.width, self.height)}+ /// The composite's pixels as they would be without the layers `left_out` (the gallery's+ /// thumbnail leaves private layers out); the canvas's own composite is made again after.+ pub fn read_composite_without(+ &mut self,+ gpu: &Gpu,+ doc: &mut Document,+ left_out: &[LayerId],+ ) -> Result<Vec<u8>, GpuError> {+ self.render(gpu, doc, None);+ if left_out.is_empty() {+ return self.read_composite(gpu);+ }+ let mut shown = doc.clone();+ for &id in left_out {+ shown.set_visible(id, false);+ }+ self.invalidate();+ self.render(gpu, &mut shown, None);+ let read = self.read_composite(gpu);+ self.invalidate();+ self.render(gpu, doc, None);+ read+ }+/// A layer's pixels (premultiplied RGBA8). Waits for the GPU.pub fn read_layer(&self, gpu: &Gpu, id: LayerId) -> Result<Vec<u8>, GpuError> {let layer = self.layers.get(&id).ok_or_else(|| GpuError::Readback(format!("no layer {id:?}")))?;diff --git a/crates/gpu/src/scene.rs b/crates/gpu/src/scene.rsindex 20ebcb1..175fce8 100644--- a/crates/gpu/src/scene.rs+++ b/crates/gpu/src/scene.rs@@ -278,6 +278,7 @@ struct GridDraw {struct GridUniform {v0: [f32; 4],v1: [f32; 4],+ v2: [f32; 4],}impl GridDraw {@@ -1246,6 +1247,7 @@ impl MeshView {let u = GridUniform {v0: [g.spacing, g.origin[0], g.origin[1], g.width],v1: [g.color[0], g.color[1], g.color[2], srgb],+ v2: [clear[0] as f32, clear[1] as f32, clear[2] as f32, g.top],};gpu.queue.write_buffer(&draw.buffer, 0, bytemuck::bytes_of(&u));Some(&*draw)diff --git a/crates/gpu/src/shaders/surround.wgsl b/crates/gpu/src/shaders/surround.wgslindex 4025f25..4438db3 100644--- a/crates/gpu/src/shaders/surround.wgsl+++ b/crates/gpu/src/shaders/surround.wgsl@@ -1,10 +1,12 @@-// Grid lines over the colour around the canvas, fixed to the window.+// Grid lines over the colour around the canvas.struct SurroundUniform {- // (spacing, origin x, origin y, line width), in target pixels+ // (spacing, a line's middle across and down, line width), in target pixelsv0: vec4<f32>,// (line colour, 1 when the target encodes sRGB itself)v1: vec4<f32>,+ // (the colour under the lines, the top above which there are none)+ v2: vec4<f32>,}@group(0) @binding(0) var<uniform> su: SurroundUniform;@@ -23,14 +25,20 @@ fn srgb_to_linear(c: vec3<f32>) -> vec3<f32> {@fragmentfn fs_surround(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {+ if (pos.y < su.v2.w) {+ discard;+ }let p = pos.xy - su.v0.yz;let s = su.v0.x;- // how far this pixel's centre is from the nearest line across and down- let d = abs(p - round(p / s) * s);- if (p.y < 0.0 || min(d.x, d.y) >= su.v0.w * 0.5) {+ // how far this pixel's centre is from the nearest line across and down, and how much of the+ // pixel that line covers+ let d = min(abs(p - round(p / s) * s).x, abs(p - round(p / s) * s).y);+ let w = su.v0.w;+ let cover = clamp(min(w, w * 0.5 + 0.5 - d), 0.0, 1.0);+ if (cover <= 0.0) {discard;}- var rgb = su.v1.rgb;+ var rgb = mix(su.v2.rgb, su.v1.rgb, cover);if (su.v1.w > 0.5) {rgb = srgb_to_linear(rgb);}diff --git a/crates/gpu/tests/canvas.rs b/crates/gpu/tests/canvas.rsindex c1b4b7c..6d55d0a 100644--- a/crates/gpu/tests/canvas.rs+++ b/crates/gpu/tests/canvas.rs@@ -215,7 +215,7 @@ fn the_surround_grid_is_fixed_to_the_target() {let view = target.create_view(&Default::default());// a tiny canvas in the top-left corner, the rest surround with a line every 20 px from y = 10let to_screen = View::fit((10, 10), (10, 10)).to_screen();- let grid = SurroundGrid { spacing: 20.0, origin: [0.0, 10.0], width: 2.0, color: [1.0, 0.0, 0.0] };+ let grid = SurroundGrid { spacing: 20.0, origin: [0.0, 10.0], top: 10.0, width: 2.0, color: [1.0, 0.0, 0.0] };canvas.render(&gpu,&mut doc,@@ -238,6 +238,33 @@ fn the_surround_grid_is_fixed_to_the_target() {assert_eq!(pixel(&px, 100, 50, 45), [51, 51, 51, 255], "between lines");assert_eq!(pixel(&px, 100, 50, 5), [51, 51, 51, 255], "above the origin");assert_eq!(pixel(&px, 100, 5, 5), [255, 255, 255, 255], "the canvas covers the grid");+ // a line wider than its pixels smooths into the ones beside it+ let grid = SurroundGrid { spacing: 20.0, origin: [41.0, 0.0], top: 0.0, width: 8.0 / 3.0, color: [1.0, 0.0, 0.0] };+ canvas.render(+ &gpu,+ &mut doc,+ Some(Target {+ view: &view,+ format,+ size: (100, 100),+ to_screen,+ surround: [0.2, 0.2, 0.2],+ grid: Some(grid),+ selection: None,+ backdrop: None,+ convert: None,+ lut: None,+ }),+ );+ let px = read(&gpu, &target, 100, 100);+ assert_eq!(pixel(&px, 100, 40, 50), [255, 0, 0, 255]);+ assert_eq!(pixel(&px, 100, 41, 50), [255, 0, 0, 255]);+ for x in [39, 42] {+ let side = pixel(&px, 100, x, 50);+ // a third of the way from the surround (51) to the line+ assert!((side[0] as i32 - 119).abs() <= 2 && (side[1] as i32 - 34).abs() <= 2, "{x}: {side:?}");+ }+ assert_eq!(pixel(&px, 100, 43, 50), [51, 51, 51, 255]);}#[test]diff --git a/crates/gpu/tests/mesh.rs b/crates/gpu/tests/mesh.rsindex 1048ea6..ebb84e6 100644--- a/crates/gpu/tests/mesh.rs+++ b/crates/gpu/tests/mesh.rs@@ -387,6 +387,7 @@ fn without_its_environment_the_model_stands_on_the_surround_grid() {view.set_grid(Some(procraft_gpu::SurroundGrid {spacing: 8.0,origin: [0.0, 4.0],+ top: 4.0,width: 2.0,color: [0.5, 0.5, 0.5],}));