diff android/DWindows.kt @ 2686:95f61d3f3d0d

Android: Initial attempt at implmenting dw_window_get_preferred_size(). This function missing was causing layout issues in code using this function. The SeekBar (slider/scrollbar/etc) code seems to be backwards but it works this way.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 27 Oct 2021 22:00:31 +0000
parents 17c34bdaec6c
children 42ff9d95e87b
line wrap: on
line diff
--- a/android/DWindows.kt	Tue Oct 26 06:17:53 2021 +0000
+++ b/android/DWindows.kt	Wed Oct 27 22:00:31 2021 +0000
@@ -1241,6 +1241,27 @@
         }
     }
 
+    fun windowGetPreferredSize(window: View): Long
+    {
+        var retval: Long = 0
+
+        waitOnUiThread {
+            window.measure(0, 0)
+            val width = window.measuredWidth
+            val height = window.measuredHeight
+            retval = width.toLong() or (height.toLong() shl 32)
+            if(window is SeekBar) {
+                val slider = window as SeekBar
+
+                // If the widget is rotated, swap width and height
+                if(slider.rotation != 270F && slider.rotation != 90F) {
+                    retval = height.toLong() or (width.toLong() shl 32)
+                }
+            }
+        }
+        return retval
+    }
+
     fun windowGetData(window: View, name: String): Long {
         var retval = 0L