Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
fix: let PDF toolbar controls overflow glass surfaces
Chethan616625da2670efb
diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.ktindex fd6268a..b80ae61 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/ViewerGlass.kt@@ -8,6 +8,7 @@ import androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.CompositingStrategyimport androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.drawOutlineimport androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.unit.Dpimport androidx.compose.ui.unit.dp@@ -49,7 +50,10 @@ fun Modifier.viewerGlass(shape: () -> Shape = { ViewerGlassShape },// Off for surfaces that must NOT cast a drop shadow — e.g. the onboarding page-1 book, whose// shadow otherwise snapped in the moment the assembled book reached full opacity.- withShadow: Boolean = true+ withShadow: Boolean = true,+ // Panels sometimes host animated/scrolling controls that intentionally float beyond the glass+ // silhouette. The default preserves the original safe behavior for the rest of the app.+ clipContent: Boolean = true): Modifier = drawBackdrop(backdrop = backdrop,shape = shape,@@ -59,7 +63,12 @@ fun Modifier.viewerGlass(lens(12f.dp.toPx(), 24f.dp.toPx())},shadow = if (withShadow) ({ com.kyant.backdrop.shadow.Shadow.Default }) else null,- onDrawSurface = { drawRect(color) }+ clipContent = clipContent,+ onDrawSurface = {+ // When content is allowed to overflow, draw the tint as the glass outline instead of a+ // rectangular wash. This keeps the material rounded while its controls remain un-clipped.+ drawOutline(shape().createOutline(size, layoutDirection, this), color)+ })/**diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.ktindex fe74414..da334f2 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerBottomToolbar.kt@@ -266,7 +266,7 @@ internal fun PdfViewerBottomToolbar(translationY = (1f - reveal) * 8.dp.toPx()}.graphicsLayer { scaleX = toolCompress; transformOrigin = TransformOrigin(0f, 0.5f) }- .viewerGlass(backdrop, glass).padding(12.dp),+ .viewerGlass(backdrop, glass, clipContent = false).padding(12.dp),verticalArrangement = Arrangement.spacedBy(12.dp)) {Row(@@ -459,7 +459,7 @@ internal fun PdfViewerBottomToolbar(// ── Export feedback row ────────────────────────────────────────────if (exportError != null || exportMessage != null || isExporting) {Row(- Modifier.fillMaxWidth().viewerGlass(backdrop, glass).padding(12.dp),+ Modifier.fillMaxWidth().viewerGlass(backdrop, glass, clipContent = false).padding(12.dp),horizontalArrangement = Arrangement.SpaceBetween,verticalAlignment = Alignment.CenterVertically) {@@ -520,7 +520,7 @@ internal fun PdfViewerBottomToolbar(Modifier.fillMaxWidth().graphicsLayer { scaleX = toolCompress; transformOrigin = TransformOrigin(0f, 0.5f) }- .viewerGlass(backdrop, pillGlass)+ .viewerGlass(backdrop, pillGlass, clipContent = false).padding(horizontal = 16.dp, vertical = 16.dp),horizontalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterHorizontally),verticalAlignment = Alignment.CenterVertically@@ -536,7 +536,7 @@ internal fun PdfViewerBottomToolbar(Modifier.fillMaxWidth().graphicsLayer { scaleX = toolCompress; transformOrigin = TransformOrigin(0f, 0.5f) }- .viewerGlass(backdrop, pillGlass)+ .viewerGlass(backdrop, pillGlass, clipContent = false)// Clip to the capsule's own curve and soften the ends. See [carouselEdges]// for why the padding has to come after the scroll, not before it..carouselEdges(wordScroll)@@ -573,7 +573,7 @@ internal fun PdfViewerBottomToolbar(Modifier.fillMaxWidth().graphicsLayer { scaleX = toolCompress; transformOrigin = TransformOrigin(0f, 0.5f) }- .viewerGlass(backdrop, pillGlass)+ .viewerGlass(backdrop, pillGlass, clipContent = false)// The chips are meant to disappear behind the capsule's curved ends. Without// this the scroll viewport clipped them with a straight vertical line inset// from the curve. See [carouselEdges] — the padding order is load-bearing.diff --git a/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.kt b/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.ktindex d91d6ad..20167bd 100644--- a/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.kt+++ b/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.kt@@ -51,7 +51,8 @@ fun Modifier.drawPlainBackdrop(onDrawBehind: (DrawScope.() -> Unit)? = null,onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,onDrawSurface: (DrawScope.() -> Unit)? = null,- onDrawFront: (DrawScope.() -> Unit)? = null+ onDrawFront: (DrawScope.() -> Unit)? = null,+ clipContent: Boolean = true): Modifier {val shapeProvider = ShapeProvider(shape)return this@@ -72,7 +73,8 @@ fun Modifier.drawPlainBackdrop(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent))}@@ -89,7 +91,8 @@ fun Modifier.drawBackdrop(onDrawBehind: (DrawScope.() -> Unit)? = null,onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,onDrawSurface: (DrawScope.() -> Unit)? = null,- onDrawFront: (DrawScope.() -> Unit)? = null+ onDrawFront: (DrawScope.() -> Unit)? = null,+ clipContent: Boolean = true): Modifier {val shapeProvider = ShapeProvider(shape)return this@@ -140,7 +143,8 @@ fun Modifier.drawBackdrop(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent))}@@ -154,7 +158,8 @@ private class DrawBackdropElement(val onDrawBehind: (DrawScope.() -> Unit)?,val onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,val onDrawSurface: (DrawScope.() -> Unit)?,- val onDrawFront: (DrawScope.() -> Unit)?+ val onDrawFront: (DrawScope.() -> Unit)?,+ val clipContent: Boolean) : ModifierNodeElement<DrawBackdropNode>() {override fun create(): DrawBackdropNode {@@ -167,7 +172,8 @@ private class DrawBackdropElement(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent)}@@ -184,6 +190,7 @@ private class DrawBackdropElement(node.onDrawBackdrop = onDrawBackdropnode.onDrawSurface = onDrawSurfacenode.onDrawFront = onDrawFront+ node.clipContent = clipContentnode.invalidateDrawCache()}@@ -198,6 +205,7 @@ private class DrawBackdropElement(properties["onDrawBackdrop"] = onDrawBackdropproperties["onDrawSurface"] = onDrawSurfaceproperties["onDrawFront"] = onDrawFront+ properties["clipContent"] = clipContent}override fun equals(other: Any?): Boolean {@@ -213,6 +221,7 @@ private class DrawBackdropElement(if (onDrawBackdrop != other.onDrawBackdrop) return falseif (onDrawSurface != other.onDrawSurface) return falseif (onDrawFront != other.onDrawFront) return false+ if (clipContent != other.clipContent) return falsereturn true}@@ -227,6 +236,7 @@ private class DrawBackdropElement(result = 31 * result + onDrawBackdrop.hashCode()result = 31 * result + (onDrawSurface?.hashCode() ?: 0)result = 31 * result + (onDrawFront?.hashCode() ?: 0)+ result = 31 * result + clipContent.hashCode()return result}}@@ -240,7 +250,8 @@ private class DrawBackdropNode(var onDrawBehind: (DrawScope.() -> Unit)?,var onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,var onDrawSurface: (DrawScope.() -> Unit)?,- var onDrawFront: (DrawScope.() -> Unit)?+ var onDrawFront: (DrawScope.() -> Unit)?,+ var clipContent: Boolean) : LayoutModifierNode, DrawModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, Modifier.Node() {private val effectScope =@@ -252,7 +263,7 @@ private class DrawBackdropNode(private var graphicsLayer: GraphicsLayer? = nullprivate val layoutLayerBlock: GraphicsLayerScope.() -> Unit = {- clip = true+ clip = clipContentshape = shapeProvider.shapecompositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen}diff --git a/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt b/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.ktindex 60b79a1..c349c83 100644--- a/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt+++ b/backdrop/src/main/java/com/kyant/backdrop/DrawBackdropModifier.kt@@ -57,7 +57,8 @@ fun Modifier.drawPlainBackdrop(onDrawBehind: (DrawScope.() -> Unit)? = null,onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,onDrawSurface: (DrawScope.() -> Unit)? = null,- onDrawFront: (DrawScope.() -> Unit)? = null+ onDrawFront: (DrawScope.() -> Unit)? = null,+ clipContent: Boolean = true): Modifier {val shapeProvider = ShapeProvider(shape)return this@@ -78,7 +79,8 @@ fun Modifier.drawPlainBackdrop(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent))}@@ -95,7 +97,8 @@ fun Modifier.drawBackdrop(onDrawBehind: (DrawScope.() -> Unit)? = null,onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,onDrawSurface: (DrawScope.() -> Unit)? = null,- onDrawFront: (DrawScope.() -> Unit)? = null+ onDrawFront: (DrawScope.() -> Unit)? = null,+ clipContent: Boolean = true): Modifier {val shapeProvider = ShapeProvider(shape)return this@@ -146,7 +149,8 @@ fun Modifier.drawBackdrop(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent))}@@ -160,7 +164,8 @@ private class DrawBackdropElement(val onDrawBehind: (DrawScope.() -> Unit)?,val onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,val onDrawSurface: (DrawScope.() -> Unit)?,- val onDrawFront: (DrawScope.() -> Unit)?+ val onDrawFront: (DrawScope.() -> Unit)?,+ val clipContent: Boolean) : ModifierNodeElement<DrawBackdropNode>() {override fun create(): DrawBackdropNode {@@ -173,7 +178,8 @@ private class DrawBackdropElement(onDrawBehind = onDrawBehind,onDrawBackdrop = onDrawBackdrop,onDrawSurface = onDrawSurface,- onDrawFront = onDrawFront+ onDrawFront = onDrawFront,+ clipContent = clipContent)}@@ -187,6 +193,7 @@ private class DrawBackdropElement(node.onDrawBackdrop = onDrawBackdropnode.onDrawSurface = onDrawSurfacenode.onDrawFront = onDrawFront+ node.clipContent = clipContentnode.invalidateDrawCache()}@@ -201,6 +208,7 @@ private class DrawBackdropElement(properties["onDrawBackdrop"] = onDrawBackdropproperties["onDrawSurface"] = onDrawSurfaceproperties["onDrawFront"] = onDrawFront+ properties["clipContent"] = clipContent}override fun equals(other: Any?): Boolean {@@ -216,6 +224,7 @@ private class DrawBackdropElement(if (onDrawBackdrop != other.onDrawBackdrop) return falseif (onDrawSurface != other.onDrawSurface) return falseif (onDrawFront != other.onDrawFront) return false+ if (clipContent != other.clipContent) return falsereturn true}@@ -230,6 +239,7 @@ private class DrawBackdropElement(result = 31 * result + onDrawBackdrop.hashCode()result = 31 * result + (onDrawSurface?.hashCode() ?: 0)result = 31 * result + (onDrawFront?.hashCode() ?: 0)+ result = 31 * result + clipContent.hashCode()return result}}@@ -243,7 +253,8 @@ private class DrawBackdropNode(var onDrawBehind: (DrawScope.() -> Unit)?,var onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,var onDrawSurface: (DrawScope.() -> Unit)?,- var onDrawFront: (DrawScope.() -> Unit)?+ var onDrawFront: (DrawScope.() -> Unit)?,+ var clipContent: Boolean) : LayoutModifierNode, DrawModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, Modifier.Node() {private val effectScope =@@ -255,7 +266,7 @@ private class DrawBackdropNode(private var graphicsLayer: GraphicsLayer? = nullprivate val layoutLayerBlock: GraphicsLayerScope.() -> Unit = {- clip = true+ clip = clipContentshape = shapeProvider.shapecompositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen}