diff android/dw.cpp @ 2650:7101b5692601

Android: Attempt at implementing splitbar using ConstraintLayout. Getting errors with the layout with HandyFTP, but I need to switch locations... so committing unfinished.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 14 Sep 2021 05:53:51 +0000
parents 22105f99dd6a
children 9535f533a230
line wrap: on
line diff
--- a/android/dw.cpp	Tue Aug 31 09:35:36 2021 +0000
+++ b/android/dw.cpp	Tue Sep 14 05:53:51 2021 +0000
@@ -4104,6 +4104,19 @@
  */
 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid)
 {
+    JNIEnv *env;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID splitBarNew = env->GetMethodID(clazz, "splitBarNew",
+                                                 "(ILandroid/view/View;Landroid/view/View;I)Landroidx/constraintlayout/widget/ConstraintLayout;");
+        // Call the method on the object
+        jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, splitBarNew, type, topleft, bottomright, (int)cid), _DW_REFERENCE_WEAK);
+        return result;
+    }
     return nullptr;
 }
 
@@ -4115,6 +4128,20 @@
  */
 void API dw_splitbar_set(HWND handle, float percent)
 {
+    JNIEnv *env;
+
+    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        jfloat position = (jfloat)percent;
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID splitBarSet = env->GetMethodID(clazz, "splitBarSet",
+                                                 "(Landroidx/constraintlayout/widget/ConstraintLayout;F)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, splitBarSet, handle, position);
+        _dw_jni_check_exception(env);
+    }
 }
 
 /*
@@ -4126,7 +4153,22 @@
  */
 float API dw_splitbar_get(HWND handle)
 {
-    return 0;
+    JNIEnv *env;
+    float retval = 0;
+
+    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID splitBarGet = env->GetMethodID(clazz, "splitBarGet",
+                                                 "(Landroidx/constraintlayout/widget/ConstraintLayout;)F");
+        // Call the method on the object
+        retval = (float)env->CallFloatMethod(_dw_obj, splitBarGet, handle);
+        if(_dw_jni_check_exception(env))
+            retval = 0;
+    }
+    return retval;
 }
 
 /*