Skip to content

Commit

Permalink
Add folder icons to breadcrumb demo
Browse files Browse the repository at this point in the history
And screenshot of the demo itself for #8
  • Loading branch information
kirill-grouchnikov committed Jan 14, 2022
1 parent 520930c commit f1a5185
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 0 deletions.
Expand Up @@ -33,6 +33,7 @@ import org.pushingpixels.aurora.component.AuroraBreadcrumbBar
import org.pushingpixels.aurora.component.model.*
import org.pushingpixels.aurora.component.projection.CommandButtonPanelProjection
import org.pushingpixels.aurora.component.projection.CommandButtonProjection
import org.pushingpixels.aurora.demo.svg.material.folder_open_black_24dp
import org.pushingpixels.aurora.demo.svg.radiance_menu
import org.pushingpixels.aurora.theming.*
import org.pushingpixels.aurora.window.AuroraDecorationArea
Expand Down Expand Up @@ -111,6 +112,10 @@ fun AuroraWindowScope.BreadcrumbContent(auroraSkinDefinition: MutableState<Auror
.let { name -> name.ifEmpty { item.absolutePath } }
}

override fun getIcon(item: File?): Painter? {
return if (item?.isDirectory == true) folder_open_black_24dp() else null
}

override suspend fun getPathChoices(item: File?): List<File> {
// If our item is null, get the file system roots. Otherwise, get all files under
// this file item.
Expand Down
@@ -0,0 +1,183 @@
package org.pushingpixels.aurora.demo.svg.material

import androidx.compose.ui.geometry.*
import androidx.compose.ui.graphics.*
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.Fill
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.graphics.painter.Painter
import java.lang.ref.WeakReference
import java.util.*
import kotlin.math.min

/**
* This class has been automatically generated using
* <a href="https://github.com/kirill-grouchnikov/aurora">Aurora SVG transcoder</a>.
*/
class folder_open_black_24dp : Painter() {
@Suppress("UNUSED_VARIABLE") private var shape: Outline? = null
@Suppress("UNUSED_VARIABLE") private var generalPath: Path? = null
@Suppress("UNUSED_VARIABLE") private var brush: Brush? = null
@Suppress("UNUSED_VARIABLE") private var stroke: Stroke? = null
@Suppress("UNUSED_VARIABLE") private var clip: Shape? = null
private var alpha = 1.0f
private var blendMode = DrawScope.DefaultBlendMode
private var alphaStack = mutableListOf(1.0f)
private var blendModeStack = mutableListOf(DrawScope.DefaultBlendMode)

private fun _paint0(drawScope : DrawScope) {
var shapeText: Outline?
var generalPathText: Path? = null
var alphaText = 0.0f
var blendModeText = DrawScope.DefaultBlendMode
with(drawScope) {
//
alphaStack.add(0, alpha)
alpha *= 1.0f
blendModeStack.add(0, BlendMode.SrcOver)
blendMode = BlendMode.SrcOver
// _0
alphaStack.add(0, alpha)
alpha *= 1.0f
blendModeStack.add(0, BlendMode.SrcOver)
blendMode = BlendMode.SrcOver
// _0_0
alpha = alphaStack.removeAt(0)
blendMode = blendModeStack.removeAt(0)
alphaStack.add(0, alpha)
alpha *= 1.0f
blendModeStack.add(0, BlendMode.SrcOver)
blendMode = BlendMode.SrcOver
// _0_1
if (generalPath == null) {
generalPath = Path()
} else {
generalPath!!.reset()
}
generalPath!!.moveTo(20.0f, 6.0f)
generalPath!!.lineTo(12.0f, 6.0f)
generalPath!!.lineTo(10.0f, 4.0f)
generalPath!!.lineTo(4.0f, 4.0f)
generalPath!!.cubicTo(2.9f, 4.0f, 2.01f, 4.9f, 2.01f, 6.0f)
generalPath!!.lineTo(2.0f, 18.0f)
generalPath!!.cubicTo(2.0f, 19.1f, 2.9f, 20.0f, 4.0f, 20.0f)
generalPath!!.lineTo(20.0f, 20.0f)
generalPath!!.cubicTo(21.1f, 20.0f, 22.0f, 19.1f, 22.0f, 18.0f)
generalPath!!.lineTo(22.0f, 8.0f)
generalPath!!.cubicTo(22.0f, 6.9f, 21.1f, 6.0f, 20.0f, 6.0f)
generalPath!!.close()
generalPath!!.moveTo(20.0f, 18.0f)
generalPath!!.lineTo(4.0f, 18.0f)
generalPath!!.lineTo(4.0f, 8.0f)
generalPath!!.lineTo(20.0f, 8.0f)
generalPath!!.lineTo(20.0f, 18.0f)
generalPath!!.close()
shape = Outline.Generic(generalPath!!)
brush = SolidColor(Color(0, 0, 0, 255))
drawOutline(outline = shape!!, style=Fill, brush=brush!!, alpha=alpha, blendMode = blendMode)
alpha = alphaStack.removeAt(0)
blendMode = blendModeStack.removeAt(0)
alpha = alphaStack.removeAt(0)
blendMode = blendModeStack.removeAt(0)

}
}



private fun innerPaint(drawScope: DrawScope) {
_paint0(drawScope)


shape = null
generalPath = null
brush = null
stroke = null
clip = null
alpha = 1.0f
}

companion object {
/**
* Returns the X of the bounding box of the original SVG image.
*
* @return The X of the bounding box of the original SVG image.
*/
fun getOrigX(): Double {
return 2.0
}

/**
* Returns the Y of the bounding box of the original SVG image.
*
* @return The Y of the bounding box of the original SVG image.
*/
fun getOrigY(): Double {
return 4.0
}

/**
* Returns the width of the bounding box of the original SVG image.
*
* @return The width of the bounding box of the original SVG image.
*/
fun getOrigWidth(): Double {
return 20.0
}

/**
* Returns the height of the bounding box of the original SVG image.
*
* @return The height of the bounding box of the original SVG image.
*/
fun getOrigHeight(): Double {
return 16.0
}


}

override val intrinsicSize: Size
get() = Size.Unspecified

override fun DrawScope.onDraw() {
clipRect {
// Use the original icon bounding box and the current icon dimension to compute
// the scaling factor
val fullOrigWidth = getOrigX() + getOrigWidth()
val fullOrigHeight = getOrigY() + getOrigHeight()
val coef1 = size.width / fullOrigWidth
val coef2 = size.height / fullOrigHeight
val coef = min(coef1, coef2).toFloat()

// Use the original icon bounding box and the current icon dimension to compute
// the offset pivot for the scaling
var translateX = -getOrigX()
var translateY = -getOrigY()
if (coef1 != coef2) {
if (coef1 < coef2) {
val extraDy = ((fullOrigWidth - fullOrigHeight) / 2.0f).toFloat()
translateY += extraDy
} else {
val extraDx = ((fullOrigHeight - fullOrigWidth) / 2.0f).toFloat()
translateX += extraDx
}
}
val translateXDp = translateX.toFloat().toDp().value
val translateYDp = translateY.toFloat().toDp().value

// Create a combined scale + translate + clip transform before calling the transcoded painting instructions
withTransform({
scale(scaleX = coef, scaleY = coef, pivot = Offset.Zero)
translate(translateXDp, translateYDp)
clipRect(left = 0.0f, top = 0.0f, right = fullOrigWidth.toFloat(), bottom = fullOrigHeight.toFloat(), clipOp = ClipOp.Intersect)
}) {
innerPaint(this)
}
}
}
}

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f1a5185

Please sign in to comment.