https://kotlinlang.org logo
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
  • d

    David Silber

    02/06/2022, 2:06 AM
    I am just starting out with Compose Desktop. I've gone through the tutorial at https://github.com/JetBrains/compose-jb/tree/master/tutorials/Getting_Started . Now I want to add some tests. Is there a tutorial or example on this topic?
    ☝️ 2
    ☝️🏻 1
    p
    d
    • 3
    • 5
  • b

    Brian G

    02/06/2022, 3:31 AM
    I've been experimenting with using Compose to render a retro-pixel-art style RPG. All programmer art for now. Having fun though. The pixelated text is rendered using normal compose
    Text
    function, I made the human sprite in Aseprite. And yes, there are hats.
    progress.mp4
    👍🏻 2
    :nice: 19
    😮 9
    👍🏼 1
    👍 3
    t
    c
    b
    • 4
    • 12
  • j

    Jan

    02/06/2022, 12:27 PM
    Are the material icons not available for web compose? I tried this but then nothing is working anymore:
    implementation(compose.web.core)
    implementation(compose.runtime)
    implementation(compose.material)
    implementation(compose.materialIconsExtended)
    b
    c
    • 3
    • 6
  • f

    Fureeish

    02/06/2022, 8:50 PM
    Hello everyone, I have a rather specific question related to a problem regarding Compose for desktop. I have compiled and ran a sample Compose template from IntelliJ and, to my surprise, I have ran into issues regarding the performance / UI department. First of all, unless I specify an environmental variable 
    SKIKO_RENDER_API
    , IntelliJ, while building Compose projects, prompts me with an error regarding my hardware. To be exact, I am greeted with the following output:
    Failed to create DirectX12 device.
    Graphics card NVIDIA GeForce GTX 960M is not supported.
    Graphics card Intel(R) HD Graphics 530 is not supported.
    Graphics card Intel(R) HD Graphics 530 is not supported.
    Graphics card NVIDIA GeForce GTX 960M is not supported.
    Graphics card Intel(R) HD Graphics 530 is not supported.
    Graphics card Intel(R) HD Graphics 530 is not supported.
    Which I do not understand. I have done some reserach regarding hardware acceleration and that's where I found the information regarding
    SKIKO_RENDER_API
    . What's more, when the project built and ran, the sample windows is being shown, but all texts are blurry. I am attaching a screenshot below. If I define the environmental variable in question, the warnings go away, but unless its value is set to
    SOFTWARE
    , the blur persists. I have deployed an executable using
    gradle createDistributable
    and asked a couple of my friends to run some tests. In every single instance the resulting application was flawless, i.e., there was no blurry text. None of my friends is using my exact setup, though. Different CPUs and different GPUs. Because of that I suspect that the culprit may as well be my hardware. Is GTX 960M officially not supported by Compose / Skiko? Where can I read about the supported hardware? I am also curious about the DirectX12 error. I have it installed (the 12 edition). Did anyone encounter similar error? It may be good to add that when working with Android Studio, the whole emulator is blurry too. Regardless of the aforementioned environmental variable. I could just stick with
    SKIKO_RENDER_API = "SOFTWARE"
    but in the official JetBrains blog I read that:
    For testing and benchmarking purposes, you can also explicitly force your application to use the specific renderer of your choice by setting the corresponding environment variable: 
    SKIKO_RENDER_API="SOFTWARE"
     or 
    "OPENGL"
    . However, please keep in mind that this fallback renderer is significantly slower than its hardware-accelerated counterpart (up to 4 times slower).
    And, well, I don't really want my app to suffer from performance penalties, even for testing. Apologies if I misused this channel in terms of things that should and should not be posted here. Any pointers will be highly appreciated.
    👀 2
    s
    o
    r
    • 4
    • 11
  • m

    mikehearn

    02/06/2022, 9:30 PM
    Are there any docs on the Gradle plugin?
    o
    • 2
    • 2
  • s

    SrSouza

    02/06/2022, 11:27 PM
    Hi folks, I'm working on a 3d application poc using OpenGL but I want to control the render object with Compose. I basically want a Component that I can use to render using OpenGL, anyway knows a Swing component that let render OpenGL inside with LWJGL ?
    o
    • 2
    • 4
  • p

    pajatopmr

    02/07/2022, 3:42 AM
    Is JVM generally considered to be included in Compose Desktop? Does Compose run on the JVM outside of Android? An example repo?
    s
    k
    o
    • 4
    • 11
  • t

    therealbluepandabear

    02/07/2022, 6:54 AM
    Is there support for using Windows/Linux/Mac UI components for Compose Desktop apps to give a native feel?
    g
    o
    c
    • 4
    • 3
  • t

    Tunji Dahunsi

    02/07/2022, 8:47 AM
    Is there a way to to find out more details of the status of releases? For example I learned about a week ago that 1.2.0-alphaxx isn't quite ready for Android yet. Is there a bug tracker where things like this are covered?
    o
    a
    • 3
    • 7
  • g

    Grégory Lureau

    02/07/2022, 4:58 PM
    Hi folks! I've an app running fine in IntelliJ but generating a weird ClassCastException when I package the app (
    ./gradlew package
    ). I'm using a MAC M1.
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class foo.bar.MyClass cannot be cast to class ....
    interface Animal { fun foo() }
    interface Mammal : Animal
    class Tiger : Mammal { ... }
    It crashes when I call
    foo()
    on my Tiger instance. If I check with
    is
    , for some reasons
    Tiger is Animal
    on IDE and
    Tiger is NOT Animal
    once the app is packaged. (And Tiger is Mammal in both usage 🤷 ) Any idea what's going on?
    o
    • 2
    • 3
  • h

    Humphrey

    02/07/2022, 5:51 PM
    How do I load an image from URL: Trying out like this doesn't work! I've added the following dependencies, but still gives me compile error:
    val skijaArtifact = "skija-linux"
    val skijaVersion = "0.93.1"
    
    dependencies {
        implementation(compose.desktop.currentOs)
        api ("org.jetbrains.skija:${skijaArtifact}:${skijaVersion}")
    }
    I'm using the following version of compose:
    plugins {
        kotlin("jvm") version "1.6.10"
        id("org.jetbrains.compose") version "1.0.1-rc2"
    }
    o
    s
    • 3
    • 4
  • e

    Enrico Saggiorato

    02/07/2022, 6:10 PM
    Hi! I'm new to kotlin and compose and I have some doubts 🙂 I know that when using Compose in Android the screen state and application state are managed through the ViewModel API. Is ViewModel Android-specific or is it suitable also for Compose Desktop? And eventually, what are we supposed to use to manage app-scoped state instead?
    c
    d
    g
    • 4
    • 11
  • s

    Spikey Sanju

    02/07/2022, 10:19 PM
    Hi folks, will it be possible to hide the window toolbar on top when it is not needed?.
    k
    t
    • 3
    • 5
  • j

    John Aoussou

    02/08/2022, 1:43 AM
    Hello, is it possible to use both Compose and ktor-client-curl in the same project? It seems to use ktor-client-curl you need to target native desktop, but the Compose Desktop template in Intellij seems to only target the JVM platform.
    b
    • 2
    • 7
  • k

    Kirill Grouchnikov

    02/08/2022, 1:49 PM
    A question for @Igor Demin. I am trying to find the right place in Skiko / Compose-JB that converts Compose's font definition (the relevant parts of
    TextStyle
    such as
    fontFamily
    ,
    fontStyle
    ,
    fontWeight
    ,
    fontSize
    ) to Skiko's
    Typeface
    or
    Font
    . Is there any public function or class that provides that bridge? There's some code in here for example that looks interesting, but it's all either internal or works with local font resources.
    i
    • 2
    • 5
  • s

    Spikey Sanju

    02/08/2022, 10:16 PM
    Hey there! Would it be possible to show menus like this on Compose Desktop?
    k
    b
    +5
    • 8
    • 10
  • k

    Kirill Grouchnikov

    02/10/2022, 5:57 PM
    A new article on drawing text on a path in Compose Desktop with Skia is out!
    :kotlin-intensifies: 23
    😃 4
    o
    s
    +2
    • 5
    • 12
  • m

    Mario Javier Medina Cocom

    02/10/2022, 6:14 PM
    Hi, do someone know why when i trying to scale a popup, the content inside has been scaling but the popup size doesn’t fit? i mean is filling with blank space around the content, has anyone had this problem before?
    k
    • 2
    • 6
  • l

    luen

    02/11/2022, 5:17 PM
    I'm using the javacv library with compose for desktop, but when I run the project, I get an error: "CreateProcess error=206, The filename or extension is too long when running".
    s
    f
    e
    • 4
    • 10
  • c

    Cody Mikol

    02/12/2022, 3:17 AM
    Hey all, I'm trying to see if the shift key is down while in an onClick event handler, is there a simple way to do this?
    a
    t
    • 3
    • 7
  • l

    luen

    02/12/2022, 7:41 AM
    how can i convert avframe to ImageBitmap? Here is an example code:
    @Composable
    fun App() {
        val videoUrl by remember { mutableStateOf("<videoUrl>") }
        var imageBitmap by remember { mutableStateOf<ImageBitmap?>(null) }
    
        LaunchedEffect(Unit) {
            val pFormatContext = avformat_alloc_context()
    
            avformat_open_input(pFormatContext, videoUrl, null, null)
            avformat_find_stream_info(pFormatContext, null as PointerPointer<*>?)
    
    
            var pCodecParameters = AVCodecParameters(null)
            for (i in 0 until pFormatContext.nb_streams()) {
                val pLocalCodecParameters = pFormatContext.streams(i).codecpar()
    
                if(pLocalCodecParameters.codec_type() == avutil.AVMEDIA_TYPE_VIDEO) {
                    pCodecParameters = pLocalCodecParameters
                }
            }
    
            val pCodec = avcodec_find_decoder(pCodecParameters.codec_id())
            val pCodecContext = avcodec_alloc_context3(pCodec)
            avcodec_parameters_to_context(pCodecContext, pCodecParameters)
            avcodec_open2(pCodecContext, pCodec, null as PointerPointer<*>?)
    
            val pPacket = av_packet_alloc()
            val pFrame = avutil.av_frame_alloc()
    
            while(av_read_frame(pFormatContext, pPacket) >= 0) {
                avcodec_send_packet(pCodecContext, pPacket)
                avcodec_receive_frame(pCodecContext, pFrame)
    
                val buff = pPacket.data().position(0).capacity(pPacket.size().toLong()).asByteBuffer()
                val arr = byteArrayOf(buff.remaining().toByte())
                buff.get(arr)
                imageBitmap = Image.makeFromEncoded(arr).toComposeImageBitmap()
                delay(500)
            }
        }
    
        MaterialTheme {
            imageBitmap?.let {
                Image(
                    bitmap = it,
                    contentDescription = "Video"
                )
            }
        }
    }
    o
    • 2
    • 1
  • p

    pajatopmr

    02/12/2022, 12:54 PM
    In the ScrollBarTest class, the often cited example of Compose Desktop testing that is not Android code, there are the following lines:
    // don't inline, surface controls canvas life time
    private val surface = Surface.makeRasterN32Premul(100, 100)
    private val canvas = surface.canvas
    What's this code doing in terms of facilitating JVM Compose testing?
    k
    • 2
    • 3
  • d

    dkim

    02/12/2022, 9:38 PM
    Anyone know why my key listener activates 3 times and also has a 0 key code for one of them? Code:
    application {
        Window(
            onCloseRequest = ::exitApplication,
            title = "App",
            onKeyEvent = {
                println("keyTyped: ${it.key.nativeKeyCode}:${it.key.nativeKeyCode.toChar()}")
                false
            }
        ) {
            // Window stuff
        }
    }
    Logs:
    keyTyped: 65:A
    keyTyped: 0: 
    keyTyped: 65:A
    Using
    keyCode
    instead would just give this output (pressing a):
    keyTyped: 279709745152: 
    keyTyped: 536870912: 
    keyTyped: 279709745152:
    k
    • 2
    • 6
  • e

    Enrico Saggiorato

    02/13/2022, 9:25 AM
    Hey 🙂 I'm having trouble with my first animation. I'm trying to create a custom stepper and I want to animate the transition when the steps are incremented, so I'm rendering the "empty" stepper in background and then my idea was to render on top of that another stepper in a "step done" state, only if the step is actually done, using AnimatedVisibility. For that I am using as state a list of boolean values, but if I try to iterate over them and call AnimatedVisibility I'm getting an error: "@Composable invocations can only happen from the context of a @Composable function"
    val doneSteps by remember { mutableStateOf(/* my logic for boolean value */ }
    
    doneSteps.forEach {
        // If i try to put AnimatedVisibility here I get the error
    }
    What is the right approach?
    a
    • 2
    • 11
  • p

    pajatopmr

    02/13/2022, 10:50 AM
    Using the IntelliJ new project wizard, I have been able to create a very simple Compose Desktop app. See attachments. Next I would like to write a simple Junit4 test that will do the following: 1. assert that the black square is visible, and 2. automagically click on the close button to end the test. So far in trying to crack this nut, the best example of Compose Desktop test code I have found is the AOSP ScrollBarTest code. This code is excruciatingly difficult to penetrate while at the same time I'm sure it is just simply brilliant code. I will continue my attempt to grok that code but my entire fortune ($12 USD) goes to the saintly person who makes this grok work totally unnecessary.
    z
    • 2
    • 8
  • d

    dkim

    02/13/2022, 1:58 PM
    How can I force an update on the window? This is what I'm trying to do: Press a specific letter or number and parts of the window changes (ex color) (When you press the letter/number it changes a variable) But it only updates when the application starts/window opens
    a
    m
    z
    • 4
    • 10
  • c

    Cody Mikol

    02/13/2022, 11:13 PM
    What is the best way to schedule tasks on an interval within the context of a certain composable? Meaning the task only runs while the composable is on screen.
    b
    z
    s
    • 4
    • 5
  • s

    Sebastian Kürten

    02/14/2022, 8:20 AM
    This Compose Illustrator looks really interesting (https://mobile.twitter.com/JimSproch/status/1432418283794300929, https://twitter.com/ppvi/status/1432620383916761088). Is it an internal project or is it online somewhere?
    🔥 9
    s
    • 2
    • 2
  • s

    Spikey Sanju

    02/14/2022, 12:23 PM
    Hi, folks, can we
    animate
    the
    window size
    or
    skew direction
    of window to
    z-index
    ?
    k
    • 2
    • 1
  • m

    Michael Paus

    02/14/2022, 12:50 PM
    A simple (or maybe not) question. What is the Compose Desktop equivalent to
    val densityDpi = LocalContext.current.resources.displayMetrics.densityDpi
    This only seems to work on Android or maybe I am just blind and don’t see the obvious.
    s
    i
    • 3
    • 3
Powered by Linen
Title
m

Michael Paus

02/14/2022, 12:50 PM
A simple (or maybe not) question. What is the Compose Desktop equivalent to
val densityDpi = LocalContext.current.resources.displayMetrics.densityDpi
This only seems to work on Android or maybe I am just blind and don’t see the obvious.
s

Sebastian Kürten

02/14/2022, 1:03 PM
does
val density = LocalDensity.current
help?
i

ishitatsuyuki

02/14/2022, 1:04 PM
The code that initializes HiDPI is here, btw. https://github.com/JetBrains/androidx/blob/jb-main/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/LayoutConfiguration.desktop.kt But
LocalDensity
should be good enough to get that value in an application.
m

Michael Paus

02/14/2022, 2:22 PM
I want to get the physical DPI value and that does not seem to be possible without resorting to AWT methods.
val scaledDpi = Toolkit.getDefaultToolkit().screenResolution
val displayScalingFactor = LocalDensity.current.density.dp.value
val physicalDpi = displayScalingFactor * scaledDpi
I think the underlying issue is this: https://github.com/JetBrains/compose-jb/issues/531
View count: 2