Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
Expand Down Expand Up @@ -146,7 +148,10 @@ private fun BrushLibraryMenu(
R.string.marker to StockBrushes.marker(),
R.string.pressure_pen to StockBrushes.pressurePen(),
R.string.dashed_line to StockBrushes.dashedLine(),
R.string.emoji_highlighter to StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true),
R.string.emoji_highlighter to StockBrushes.emojiHighlighter(
"emoji-heart",
showMiniEmojiTrail = true
),
)
}

Expand All @@ -166,58 +171,76 @@ private fun BrushLibraryMenu(
onClick = {},
enabled = false
)
stockBrushes.filter { it.first != R.string.emoji_highlighter }.forEach { (nameResId, brushFamily) ->
DropdownMenuItem(
text = { Text(stringResource(nameResId)) },
onClick = {
onLoadBrush(brushFamily)
expanded = false
}
)
}

stockBrushes.filter { it.first != R.string.emoji_highlighter }
.forEach { (nameResId, brushFamily) ->
DropdownMenuItem(
text = { Text(stringResource(nameResId)) },
onClick = {
onLoadBrush(brushFamily)
expanded = false
}
)
}

var showEmojiSubMenu by remember { mutableStateOf(false) }
var itemWidth by remember { mutableStateOf(0) }
var itemHeight by remember { mutableStateOf(0) }
val density = LocalDensity.current
Box(modifier = Modifier.onSizeChanged {

Box(modifier = Modifier.onSizeChanged {
itemWidth = it.width
itemHeight = it.height
}) {
DropdownMenuItem(
text = { Text(stringResource(R.string.emoji_highlighter)) },
trailingIcon = {
Text(text = if (showEmojiSubMenu) "▶" else "▼")
Icon(Icons.Default.ChevronRight, contentDescription = null)
},
onClick = { showEmojiSubMenu = true }
)
DropdownMenu(
expanded = showEmojiSubMenu,
onDismissRequest = { showEmojiSubMenu = false },
offset = DpOffset(x = density.run { itemWidth.toDp() }, y = density.run { -itemHeight.toDp() }),
offset = DpOffset(
x = density.run { itemWidth.toDp() },
y = density.run { -itemHeight.toDp() }),
properties = PopupProperties(focusable = true)
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.emoji_heart)) },
onClick = {
onLoadBrush(StockBrushes.emojiHighlighter("emoji-heart", showMiniEmojiTrail = true))
onLoadBrush(
StockBrushes.emojiHighlighter(
"emoji-heart",
showMiniEmojiTrail = true
)
)
showEmojiSubMenu = false
expanded = false
}
)
DropdownMenuItem(
text = { Text(stringResource(R.string.emoji_star)) },
onClick = {
onLoadBrush(StockBrushes.emojiHighlighter("emoji-star", showMiniEmojiTrail = true))
onLoadBrush(
StockBrushes.emojiHighlighter(
"emoji-star",
showMiniEmojiTrail = true
)
)
showEmojiSubMenu = false
expanded = false
}
)
DropdownMenuItem(
text = { Text(stringResource(R.string.emoji_poop)) },
onClick = {
onLoadBrush(StockBrushes.emojiHighlighter("emoji-poop", showMiniEmojiTrail = true))
onLoadBrush(
StockBrushes.emojiHighlighter(
"emoji-poop",
showMiniEmojiTrail = true
)
)
showEmojiSubMenu = false
expanded = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -69,6 +70,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties
import androidx.compose.ui.zIndex
import androidx.ink.brush.BrushFamily
import androidx.ink.brush.StockBrushes
Expand Down Expand Up @@ -129,8 +131,15 @@ fun MoreOptionsMenu(
Box {
DropdownMenuItem(
text = { Text(stringResource(R.string.bg_templates)) },
onClick = { onShowTemplatesMenuChange(true) },
trailingIcon = { Icon(Icons.Default.ChevronRight, contentDescription = null) },
onClick = {
onShowTemplatesMenuChange(true)
},
trailingIcon = {
Icon(
Icons.Default.ChevronRight,
contentDescription = null
)
},
modifier = Modifier.onSizeChanged { itemSize = it }
)
DropdownMenu(
Expand All @@ -144,7 +153,7 @@ fun MoreOptionsMenu(
R.string.bg_pressure_pen to StockBrushes.pressurePen(),
R.string.marker to StockBrushes.marker(),
R.string.highlighter to StockBrushes.highlighter(),
R.string.dashed_line to StockBrushes.dashedLine()
R.string.dashed_line to StockBrushes.dashedLine(),
).forEach { (title, brush) ->
DropdownMenuItem(
text = { Text(stringResource(title)) },
Expand All @@ -154,6 +163,54 @@ fun MoreOptionsMenu(
}
)
}
var showEmojiSubMenu by remember { mutableStateOf(false) }
var itemWidth by remember { mutableIntStateOf(0) }
var itemHeight by remember { mutableIntStateOf(0) }
val density = LocalDensity.current

Box(modifier = Modifier.onSizeChanged {
itemWidth = it.width
itemHeight = it.height
}) {
DropdownMenuItem(
text = { Text(stringResource(R.string.emoji_highlighter)) },
trailingIcon = {
Icon(
Icons.Default.ChevronRight,
contentDescription = null
)
},
onClick = { showEmojiSubMenu = true }
)
DropdownMenu(
expanded = showEmojiSubMenu,
onDismissRequest = { showEmojiSubMenu = false },
offset = DpOffset(
x = density.run { itemWidth.toDp() },
y = density.run { -itemHeight.toDp() }),
properties = PopupProperties(focusable = true)
) {
listOf(
R.string.emoji_heart to "emoji-heart",
R.string.emoji_star to "emoji-star",
R.string.emoji_poop to "emoji-poop",
).forEach { (title, textureId) ->
DropdownMenuItem(
text = { Text(stringResource(title)) },
onClick = {
onTemplateSelect(
StockBrushes.emojiHighlighter(
textureId,
showMiniEmojiTrail = true
)
)
onShowTemplatesMenuChange(false)
showEmojiSubMenu = false
}
)
}
}
}

if (customBrushes.isNotEmpty()) {
HorizontalDivider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ object CustomBrushes {
context.getString(R.string.graffiti) to (R.raw.graffiti to R.drawable.format_paint_24px),
context.getString(R.string.groovy) to (R.raw.groovy to R.drawable.bubble_chart_24px),
context.getString(R.string.holiday_lights) to (R.raw.holiday_lights to R.drawable.lightbulb_24px),
context.getString(R.string.jelly_wobble) to (R.raw.jelly_wobble to R.drawable.airwave_24px),
context.getString(R.string.lace) to (R.raw.lace to R.drawable.styler_24px),
context.getString(R.string.music) to (R.raw.music to R.drawable.music_note_24px),
context.getString(R.string.pressure_wave) to (R.raw.pressure_wave to R.drawable.vital_signs_24px),
context.getString(R.string.shading_pencil) to (R.raw.shading_pencil to R.drawable.stylus_pencil_24px),
context.getString(R.string.shadow) to (R.raw.shadow to R.drawable.blur_on_24px),
context.getString(R.string.twisted_yarn) to (R.raw.twisted_yarn to R.drawable.line_weight_24px),
context.getString(R.string.wet_paint) to (R.raw.wet_paint to R.drawable.water_drop_24px),
context.getString(R.string.jelly_wobble) to (R.raw.jelly_wobble to R.drawable.airwave_24px),
context.getString(R.string.pressure_wave) to (R.raw.pressure_wave to R.drawable.vital_signs_24px),
context.getString(R.string.shading_pencil) to (R.raw.shading_pencil to R.drawable.stylus_pencil_24px),
)

val loadedBrushes = brushFiles.mapNotNull { (name, pair) ->
Expand Down
Loading
Loading