public MethodHandle list_get_selection_allocated;
public MethodHandle list_selection_get_count;
public MethodHandle list_selection_get_rows;
+ public MethodHandle list_set_selected_indices;
+ public MethodHandle list_setselection;
public MethodHandle list_selection_free;
public MethodHandle srclist_new;
FunctionDescriptor sigm_m = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigv_mm = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS);
FunctionDescriptor sigv_mim = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
+ FunctionDescriptor sigv_mmi = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
FunctionDescriptor sigv_mi = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT);
FunctionDescriptor sigv_m = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS);
FunctionDescriptor sigi_m = FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS);
MemorySegment ui_list_get_selection_allocated_addr = lib.find("ui_list_get_selection_allocated").orElseThrow();
MemorySegment ui_list_selection_get_count_addr = lib.find("ui_list_selection_get_count").orElseThrow();
MemorySegment ui_list_selection_get_rows_addr = lib.find("ui_list_selection_get_rows").orElseThrow();
+ MemorySegment ui_list_set_selected_indices_addr = lib.find("ui_list_set_selected_indices").orElseThrow();
+ MemorySegment ui_list_setselection_addr = lib.find("ui_list_setselection").orElseThrow();
MemorySegment ui_list_selection_free_addr = lib.find("ui_list_selection_free").orElseThrow();
MemorySegment ui_srclist_new_addr = lib.find("ui_srclist_new").orElseThrow();
list_get_selection_allocated = linker.downcallHandle(ui_list_get_selection_allocated_addr, sigm_m);
list_selection_get_count = linker.downcallHandle(ui_list_selection_get_count_addr, sigi_m);
list_selection_get_rows = linker.downcallHandle(ui_list_selection_get_rows_addr, sigm_m);
+ list_set_selected_indices = linker.downcallHandle(ui_list_set_selected_indices_addr, sigv_mmi);
+ list_setselection = linker.downcallHandle(ui_list_setselection_addr, sigv_mi);
list_selection_free = linker.downcallHandle(ui_list_selection_free_addr, sigv_m);
srclist_new = linker.downcallHandle(ui_srclist_new_addr, sigm_mm);
return selection[0];
}
+ public void setSelectedIndex(int index) {
+ ListFuncs ui = ListFuncs.getInstance();
+ try {
+ ui.list_setselection.invoke(valuePtr, index);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setSelection(int[] selection) {
+ ListFuncs ui = ListFuncs.getInstance();
+ try (Arena arena = Arena.ofConfined()) {
+ MemorySegment rows = arena.allocateFrom(ValueLayout.JAVA_INT, selection);
+ ui.list_set_selected_indices.invoke(valuePtr, rows, selection.length);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public T getSelected() {
int index = getSelectedIndex();
if(index == -1) {