https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose-desktop
  • m

    Mitchell Syer

    08/14/2021, 9:59 PM
    Hi, I need some advice on how to migrate some code made with the 0.4.x and below Window API to the new API. I have a custom clickable modifier that takes a click event, gets the x and the y of the click event inside the window, and compares it to the LocalAppWindow.current width and height so that it gives me a % value of where it was clicked. I cant find a good way to do this in the new Window Api, as LocalAppWindow was deprecated.
    ✅ 1
    i
    • 2
    • 3
  • z

    Zach Klippenstein (he/him) [MOD]

    08/15/2021, 6:27 AM
    I’ve been playing around with building a TouchBar API for Compose for Desktop. It’s only a very rough proof of concept, but it was fun to figure out. There’s demo videos and code snippets, as well as a link to the whole repo, in this twitter thread. https://twitter.com/zachklipp/status/1426790034988945413?s=20
    🆒 2
    :kotlin-intensifies: 13
    💯 4
    c
    t
    • 3
    • 2
  • j

    John Dumais

    08/15/2021, 9:57 AM
    Exploring the use of compose desktop for a project I'm working on. Would like it to be a menu bar app on macos and a system tray app in Windows. Are there any examples / tutorials available? Thanks
    ✅ 1
    c
    a
    e
    • 4
    • 18
  • c

    Christian Babsek

    08/15/2021, 1:42 PM
    Hello, I have a question. I have seen that some of the built-in components in Compose are inline functions. When is it a good idea to make own composable functions inline, when hot?
    👀 4
    d
    • 2
    • 1
  • k

    kevindmoore

    08/16/2021, 3:25 PM
    How do you handle string resources in desktop?
    d
    m
    a
    • 4
    • 6
  • r

    Rajashekar

    08/17/2021, 5:23 PM
    Does compose for desktop support ConstraintLayout as of now?
    🇳🇴 4
    j
    m
    • 3
    • 2
  • k

    kevindmoore

    08/17/2021, 7:16 PM
    Is it possible to share Compose code between Desktop and Android? Examples?
    k
    c
    +3
    • 6
    • 23
  • r

    rnett

    08/17/2021, 8:59 PM
    I'm getting key events twice when I trigger a recomposition in
    onPreviewKeyEvent
    , is this a known issue? ✅ I just needed to only respond to key down events
    a
    • 2
    • 4
  • l

    Lukas K-G

    08/20/2021, 9:50 AM
    Is there a way to open e.g. a
    Dialog
    from the
    onClick
    of a
    MenuItem
    ? Problem is that the
    onClick
    is not a composable function. 🤔
    ✅ 1
    d
    l
    y
    • 4
    • 6
  • a

    Andre Classen

    08/20/2021, 1:32 PM
    Any suggestions how to hunt
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: pending composition has not been applied
    exception ?
    i
    • 2
    • 4
  • r

    Rajashekar

    08/20/2021, 6:32 PM
    I'm trying to understand how to make layouts responsive when resizing. I'm trying to build this spotify look-a-like for desktop, all I have is nested Columns, Rows, Boxes and no support for constraint layout yet. In second image, when I try to resize to small window size, it lays views almost on top of each other instead of hiding the complete bottom player. Am I missing anything ?
    b
    c
    • 3
    • 2
  • t

    Tristan B.

    08/20/2021, 7:11 PM
    I tried to add keyboard shortcuts to the Menu Item of my MenuBar but it didn't work. It seems that the functionality is not implemented yet. Is there a workaround?
    i
    • 2
    • 2
  • s

    Siva Nimmala

    08/20/2021, 9:03 PM
    Hi, I'm using Jetpack Compose for desktop application. How to choose folder (folder pick) ? please help me with a snippet of code
    c
    i
    • 3
    • 4
  • d

    darkmoon_uk

    08/20/2021, 11:34 PM
    ⚠️ Developing with Compose for Multiplatform? (e.g. Desktop + Android) You may have encountered a long-standing bug, that default parameters in
    expect
    /
    actual
    do not play nice with the Compose compiler - meaning you can't use default parameters values at all! This is a major bug/limitation, since
    @Composable
    functions often rely on many default parameters to have a usable API. Please consider voting here.
    ✅ 6
    o
    • 2
    • 2
  • t

    theapache64

    08/21/2021, 6:20 AM
    ✅ [RESOLVED] Video Player : Can anyone explain why EmbeddedMediaPlayerComponent and why not
    CallbackMediaPlayerComponent
    ? The CMPS works good on macOS :thread-please:
    i
    • 2
    • 3
  • t

    theapache64

    08/21/2021, 7:17 AM
    🧵 Is this the correct way to control state of an external component (non-composable)?
    ✅ 1
    i
    z
    • 3
    • 5
  • s

    Siva Nimmala

    08/21/2021, 8:06 AM
    Hi everyone, please let me know Folder chooser is available in jetpack compose desktop
    t
    • 2
    • 2
  • s

    Siva Nimmala

    08/21/2021, 4:36 PM
    Hi everyone, Native build (Windows) > How to set 'Publisher' and Installer exe icon ? I used iconFile but it is working only after installation. Please help me.
    t
    • 2
    • 5
  • s

    spierce7

    08/21/2021, 5:41 PM
    Is it possible to use fast lane to sign compose desktop applications for osx?
    👀 2
    l
    • 2
    • 4
  • h

    Halil Ozercan

    08/21/2021, 8:23 PM
    is there a list of compatible versions between Jetbrains Compose and Jetpack Compose?
    k
    • 2
    • 2
  • h

    Halil Ozercan

    08/22/2021, 12:25 PM
    Hi everyone. I understand that if I develop a KMM-Compose library, Android developers would have to add "org.jetbrains.compose" plugin in their app module to prevent duplicate class errors. On the other hand, in my android specific libraries that also use compose, this plugin is not needed when a KMM-Compose library is added as a dependency. That's really confusing to me.. My actual question is: "Is there any other way that Android developers can apply in their projects to prevent duplicate class errors without using org.jetbrains.compose plugin"?
    s
    k
    +3
    • 6
    • 14
  • m

    Mitchell Syer

    08/22/2021, 7:27 PM
    Hello, I am running into a issue with setting a icon for my window, I believe its because of a incompatibility with the Swing Laf library I use called DarkLaf. I am wondering if this needs to be fixed on the Compose side or the DarkLaf side. There is a exception when window tries to open, I have added it to the thread.
    :thread-please: 1
    i
    • 2
    • 2
  • p

    Pavle Joksovic

    08/22/2021, 8:59 PM
    Hi everyone, is there a way to define release and debug build variants?
    b
    j
    +2
    • 5
    • 9
  • r

    rcd27

    08/23/2021, 8:22 AM
    Facing some problems with running compose distributables, built with
    Wix
    for
    Windows
    (gradle task ":createDistributable").
    exe
    file just not launching. This is new issue, couple weeks ago all was fine. Anyone here has the same? I've tried to build with 15 and 16 JDK for Gradle, no differences.
    m
    o
    • 3
    • 6
  • k

    kevin

    08/23/2021, 2:16 PM
    In the CodeViewer example on Github there is code that sets the mouse cursor that looks like this
    AppWindowAmbient.current!!.window.cursor = Cursor(Cursor.E_RESIZE_CURSOR)
    This is for an early release of Desktop, I was using the 0.3.0 release and changed the code to be this:
    LocalAppWindow.current.window.cursor = Cursor(Cursor.E_RESIZE_CURSOR)
    But now LocalAppWindow has been deprecated and I’m wondering if there’s any way to set the cursor in the current (alpha) versions of Desktop? Thanks
    i
    • 2
    • 2
  • k

    kevin

    08/24/2021, 7:54 AM
    Should menu shortcut keys work? I have a menu that looks like this
    MenuBar {
    Menu("File") {
    Item(
    "Open",
    onClick = { openFileAction.value = true },
    shortcut = KeyShortcut(Key.O, meta = true)
    )
    }
    }
    The menu works but I can’t get the shortcut to work (this is on a Mac) on the alpha build.
    ✅ 1
    i
    • 2
    • 2
  • a

    Alexander Suraphel

    08/24/2021, 3:09 PM
    Do you use dependency injection library for your Desktop app? If so what is it?
    c
    b
    • 3
    • 12
  • h

    Hamza GATTAL

    08/24/2021, 8:53 PM
    Hi everyone The preview feature is available in compose for Desktop like compose on Android
    🆗 3
    d
    u
    • 3
    • 7
  • s

    spierce7

    08/25/2021, 12:52 AM
    How do we change this icon for the mounted DMG image on macOS?
    d
    e
    s
    • 4
    • 8
  • m

    Michael Paus

    08/25/2021, 2:51 PM
    Does Compose provide any platform independent way to create an ImageBitmap from an encoded byte array? Currently I use two different implementations of that: On Android I use
    override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
        val bitmap = BitmapFactory.decodeByteArray(encodedImageData, 0, encodedImageData.size)
        return bitmap.asImageBitmap()
    }
    and on Desktop I use
    override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
        return Image.makeFromEncoded(encodedImageData).asImageBitmap()
    }
    but I think something like this actually belongs into Compose itself. One also might add a similar method to construct an ImageBitmap from a raw bitmap represented as a byte array plus some image info needed to reconstruct the image. What do you think?
    r
    j
    • 3
    • 14
Powered by Linen
Title
m

Michael Paus

08/25/2021, 2:51 PM
Does Compose provide any platform independent way to create an ImageBitmap from an encoded byte array? Currently I use two different implementations of that: On Android I use
override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
    val bitmap = BitmapFactory.decodeByteArray(encodedImageData, 0, encodedImageData.size)
    return bitmap.asImageBitmap()
}
and on Desktop I use
override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
    return Image.makeFromEncoded(encodedImageData).asImageBitmap()
}
but I think something like this actually belongs into Compose itself. One also might add a similar method to construct an ImageBitmap from a raw bitmap represented as a byte array plus some image info needed to reconstruct the image. What do you think?
r

romainguy

08/25/2021, 4:00 PM
This would require Compose to have its own suite of image decoders which is not something we want to have (at least at this point). Building an
ImageBitmap
from a byte array would make sense but we would need to know the layout of said byte array (ARGB vs RGBA vs BGRA vs ABGR for instance, and that’s only for 8-bit encodings), which you would obtain from the platform’s native bitmap object anyway
j

jim

08/25/2021, 4:08 PM
You can easily build your own such API using expect/actuals.
m

Michael Paus

08/25/2021, 4:11 PM
@jim Yes, certainly. That’s what I am doing right now. But don’t you think that such a common task should be handled transparently by Compose itself?
j

jim

08/25/2021, 4:19 PM
Probably / intuitively I would have thought so, but I would need to sync with Romain and better understand his concern first. For instance, I don't know if ARGP/RGBA/BGRA/ABGR are automatically handled by the existing decoder functions or if those are making format assumptions - just not familiar enough with the space to make a firm statement myself.
m

Michael Paus

08/25/2021, 4:28 PM
Just to avoid any confusion. We are talking about two different cases here. The first case is reading an image from encoded data. That is nothing but the byte representation of a JPEG, PNG, etc. So this case is already fully handled by the platform code for which I have provided examples. The problem here is only that the various platforms use different code to do that and I would like to avoid having to let all users having to deal with that themselves. The second case is reading an image from raw bitmap data. In this case it would need a common description of the image layout as I said already above. The various platforms already can do that but once again in different ways.
r

romainguy

08/25/2021, 4:39 PM
The second case is a bit more complicated. Android for instance only understands ARGB for 8-bit data, not RGBA/etc. Supporting generic layouts would require extra work would require to build a conversion pipeline. I’m not saying it’s not worth it or difficult, just not straightforward.
Anyway, at the very least it seems like providing an equivalent of your
imageBitmapFromBytes
as a platform-specific implementation that just delegates to platform-specific decoders + extension methods would make sense.
Although I wonder how common it is in apps to decode from a byte array? On Android decoding is more commonly done from resource ids or input streams
j

jim

08/25/2021, 4:47 PM
Decoding from byte arrays is equivalent to decoding from inputstream, it is easy to use the two interchangeably, and providing either one would likely solve the above user's needs. I often read an inputstream to a bytearray just because it allows me to check the size, use it twice, etc. I think the problem is that at the moment, we provide neither decode-from-bytearray nor decode-from-inputstream as a platform-independent API.
If I'm reading the above correctly, sounds to me like maybe Romain doesn't have any objections to the first use case. @Michael Paus want to file a bug against Compose and link it here?
m

Michael Paus

08/25/2021, 4:51 PM
Reading from a stream would be ok for me too. Possible use-cases are for example reading images as BLOBs from a database or, as in my case, from some proprietary data formats.
j

jim

08/25/2021, 4:52 PM
Well, I think reading from ByteArray is an easier API to support since ByteArray is MPP but InputStream is not. Would need to take a 3rd party dependency in order to support some sort of streaming API.
m

Michael Paus

08/25/2021, 4:54 PM
So one more reason for the ByteArray variant. I’ll file a bug for it.
Here is the link to the issue: https://github.com/JetBrains/compose-jb/issues/1113
👍 2
:tnx: 1
View count: 9