-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for integrating application content into the window title pane
For #23
- Loading branch information
1 parent
e2348d6
commit 0796041
Showing
10 changed files
with
838 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
demo/src/desktopMain/kotlin/org/pushingpixels/aurora/demo/svg/material/ic_chat_black_24px.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
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 ic_chat_black_24px : 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) | ||
|
||
@Suppress("UNUSED_VARIABLE", "UNUSED_VALUE", "VARIABLE_WITH_REDUNDANT_INITIALIZER", "UNNECESSARY_NOT_NULL_ASSERTION") | ||
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 | ||
if (generalPath == null) { | ||
generalPath = Path() | ||
} else { | ||
generalPath!!.reset() | ||
} | ||
generalPath?.run { | ||
moveTo(20.0f, 2.0f) | ||
lineTo(4.0f, 2.0f) | ||
cubicTo(2.9f, 2.0f, 2.01f, 2.9f, 2.01f, 4.0f) | ||
lineTo(2.0f, 22.0f) | ||
lineTo(6.0f, 18.0f) | ||
lineTo(20.0f, 18.0f) | ||
cubicTo(21.1f, 18.0f, 22.0f, 17.1f, 22.0f, 16.0f) | ||
lineTo(22.0f, 4.0f) | ||
cubicTo(22.0f, 2.9f, 21.1f, 2.0f, 20.0f, 2.0f) | ||
close() | ||
moveTo(6.0f, 9.0f) | ||
lineTo(18.0f, 9.0f) | ||
lineTo(18.0f, 11.0f) | ||
lineTo(6.0f, 11.0f) | ||
lineTo(6.0f, 9.0f) | ||
close() | ||
moveTo(14.0f, 14.0f) | ||
lineTo(6.0f, 14.0f) | ||
lineTo(6.0f, 12.0f) | ||
lineTo(14.0f, 12.0f) | ||
lineTo(14.0f, 14.0f) | ||
close() | ||
moveTo(18.0f, 8.0f) | ||
lineTo(6.0f, 8.0f) | ||
lineTo(6.0f, 6.0f) | ||
lineTo(18.0f, 6.0f) | ||
lineTo(18.0f, 8.0f) | ||
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) | ||
alphaStack.add(0, alpha) | ||
alpha *= 1.0f | ||
blendModeStack.add(0, BlendMode.SrcOver) | ||
blendMode = BlendMode.SrcOver | ||
// _0_1 | ||
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 2.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 20.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) | ||
} | ||
} | ||
} | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
...opMain/kotlin/org/pushingpixels/aurora/demo/svg/material/ic_chat_black_24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.