Skip to content

Commit

Permalink
flutter: Add dump_layout()
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Jan 19, 2025
1 parent b511bbe commit 0d362af
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/flutter/dart/lib/models/DropArea.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,8 @@ class DropArea implements ffi.Finalizable {
ffi.Pointer<void> get hostPtr {
return _hostCpp;
}

void dumpLayout() {
Bindings.instance.nativeLibrary.dump_layout(_hostCpp.cast());
}
}
14 changes: 14 additions & 0 deletions src/flutter/dart/lib/private/kddw_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ class NativeLibrary {
late final _remove_guest = _remove_guestPtr.asFunction<
void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>)>();

void dump_layout(
ffi.Pointer<ffi.Void> host,
) {
return _dump_layout(
host,
);
}

late final _dump_layoutPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'dump_layout');
late final _dump_layout =
_dump_layoutPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();

/// Separators are created and destroyed by KDDW
void set_separator_added_callback(
ffi.Pointer<ffi.Void> host,
Expand Down
7 changes: 7 additions & 0 deletions src/flutter/kddw_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
host->m_rootItem->dumpLayout();
}
1 change: 1 addition & 0 deletions src/flutter/kddw_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 0d362af

Please sign in to comment.