Browse Source

Fixed gif.

pull/15/head
Roman Sedaikin 4 years ago
parent
commit
64fe3de689
  1. 41
      tutorials/Tray_Notifications_MenuBar/TrayNotifierMenuBar.md
  2. BIN
      tutorials/Tray_Notifications_MenuBar/notifier.gif
  3. BIN
      tutorials/Tray_Notifications_MenuBar/tray.gif

41
tutorials/Tray_Notifications_MenuBar/TrayNotifierMenuBar.md

@ -31,10 +31,12 @@ import java.awt.image.BufferedImage
fun main() {
val count = mutableStateOf(0)
Window {
Window(
icon = getMyAppIcon()
) {
onActive {
val tray = Tray().apply {
icon(getMyAppIcon())
icon(getTrayIcon())
menu(
MenuItem(
name = "Increment value",
@ -72,6 +74,20 @@ fun main() {
}
fun getMyAppIcon() : BufferedImage {
val size = 256
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB)
val graphics = image.createGraphics()
graphics.setColor(Color.green)
graphics.fillOval(size / 4, 0, size / 2, size)
graphics.setColor(Color.blue)
graphics.fillOval(0, size / 4, size, size / 2)
graphics.setColor(Color.red)
graphics.fillOval(size / 4, size / 4, size / 2, size / 2)
graphics.dispose()
return image
}
fun getTrayIcon() : BufferedImage {
val size = 256
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB)
val graphics = image.createGraphics()
@ -98,11 +114,16 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.Text
import androidx.compose.material.Button
import androidx.compose.ui.window.Notifier
import java.awt.Color
import java.awt.Graphics2D
import java.awt.image.BufferedImage
fun main() {
val message = "Some message!"
val notifier = Notifier()
Window {
Window(
icon = getMyAppIcon()
) {
Column {
Button(onClick = { notifier.notify("Notification.", message) }) {
Text(text = "Notify")
@ -116,6 +137,20 @@ fun main() {
}
}
}
fun getMyAppIcon() : BufferedImage {
val size = 256
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB)
val graphics = image.createGraphics()
graphics.setColor(Color.green)
graphics.fillOval(size / 4, 0, size / 2, size)
graphics.setColor(Color.blue)
graphics.fillOval(0, size / 4, size, size / 2)
graphics.setColor(Color.red)
graphics.fillOval(size / 4, size / 4, size / 2, size / 2)
graphics.dispose()
return image
}
```
![Notifier](notifier.gif)

BIN
tutorials/Tray_Notifications_MenuBar/notifier.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.3 MiB

BIN
tutorials/Tray_Notifications_MenuBar/tray.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

After

Width:  |  Height:  |  Size: 6.5 MiB

Loading…
Cancel
Save