Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow dynamically sized payload in drag & drop #655

@branpk

Description

@branpk

Is your feature request related to a problem? Please describe.
Currently the only way to use dynamically sized payloads in drag and drop is to use begin_payload_unchecked (unsafe) or use begin_payload with a Copy id, and manage memory on the user's side. This is inconvenient and a little tricky to get correct without wasting memory.

Describe the solution you'd like
Add a method:

pub fn begin_payload_buffer<'ui>(
    self,
    ui: &Ui<'ui>,
    payload: &[u8]
) -> Option<DragDropSourceToolTip<'ui>>

I believe imgui is able to support this. This will allow a dynamically sized payload and should cover the majority of use cases (other dynamically sized types can usually be converted to a u8 slice).

Describe alternatives you've considered
The argument could be generic &[P] where P: Copy + 'static. This isn't necessary for my use case and I'm not sure how that impacts safety.

Additional context
I'm guessing that this isn't already supported because you want to discourage large payloads. In my use case, the payload is small but it's inconvenient to set a hardcoded size limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions