From 0d362af1da10515c955aa89dbabbbc9db67699a6 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sun, 19 Jan 2025 16:05:56 +0000 Subject: [PATCH] flutter: Add dump_layout() --- src/flutter/dart/lib/models/DropArea.dart | 4 ++++ src/flutter/dart/lib/private/kddw_bindings.dart | 14 ++++++++++++++ src/flutter/kddw_bindings.cpp | 7 +++++++ src/flutter/kddw_bindings.h | 1 + 4 files changed, 26 insertions(+) diff --git a/src/flutter/dart/lib/models/DropArea.dart b/src/flutter/dart/lib/models/DropArea.dart index 253f4e49a..fcfca46a2 100644 --- a/src/flutter/dart/lib/models/DropArea.dart +++ b/src/flutter/dart/lib/models/DropArea.dart @@ -181,4 +181,8 @@ class DropArea implements ffi.Finalizable { ffi.Pointer get hostPtr { return _hostCpp; } + + void dumpLayout() { + Bindings.instance.nativeLibrary.dump_layout(_hostCpp.cast()); + } } diff --git a/src/flutter/dart/lib/private/kddw_bindings.dart b/src/flutter/dart/lib/private/kddw_bindings.dart index 3cf75ebfc..85b6d4310 100644 --- a/src/flutter/dart/lib/private/kddw_bindings.dart +++ b/src/flutter/dart/lib/private/kddw_bindings.dart @@ -239,6 +239,20 @@ class NativeLibrary { late final _remove_guest = _remove_guestPtr.asFunction< void Function(ffi.Pointer, ffi.Pointer)>(); + void dump_layout( + ffi.Pointer host, + ) { + return _dump_layout( + host, + ); + } + + late final _dump_layoutPtr = + _lookup)>>( + 'dump_layout'); + late final _dump_layout = + _dump_layoutPtr.asFunction)>(); + /// Separators are created and destroyed by KDDW void set_separator_added_callback( ffi.Pointer host, diff --git a/src/flutter/kddw_bindings.cpp b/src/flutter/kddw_bindings.cpp index 1760ad8c0..ebed5601b 100644 --- a/src/flutter/kddw_bindings.cpp +++ b/src/flutter/kddw_bindings.cpp @@ -336,3 +336,10 @@ void set_separator_removed_callback(void *host_, void (*callback)(void *host, vo assert(host->_separator_removed_callback == nullptr); host->_separator_removed_callback = callback; } + +void dump_layout(void *host_) +{ + assert(host_); + auto host = reinterpret_cast(host_); + host->m_rootItem->dumpLayout(); +} diff --git a/src/flutter/kddw_bindings.h b/src/flutter/kddw_bindings.h index c1f7ecf39..2287f8f8f 100644 --- a/src/flutter/kddw_bindings.h +++ b/src/flutter/kddw_bindings.h @@ -30,6 +30,7 @@ DOCKS_EXPORT void set_guest_host(void *host, void *guest); DOCKS_EXPORT void insert_item(void *host, void *guest, int location); DOCKS_EXPORT void insert_item_relative_to(void *host, void *guest, void *relativeToGuest, int location); DOCKS_EXPORT void remove_guest(void *host, void *guest); +DOCKS_EXPORT void dump_layout(void *host); /// Separators are created and destroyed by KDDW DOCKS_EXPORT void set_separator_added_callback(void *host, void (*callback)(void *host, void *separator, int isVertical));