Previously UI view items would support custom drop controllers (so they could react to data being dragged over them and dropped). This is now more generalized so the views themselves can do this as well. Main changes: - Support calculating a bounding box for the view, so this can be used for recognizing mouse hovering. - Rename "drop controller" to "drop target", this is more clear, less abstract naming. - Generalize drop controllers/targets. There is a new `ui::DropTargetInterface` now. - Add support for drop targets in the `ui::AbstractView` base class, so custom views can use this. Pull Request: blender/blender#105963
33 lines
784 B
C++
33 lines
784 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup edinterface
|
|
*/
|
|
|
|
#include "UI_interface.hh"
|
|
|
|
namespace blender::ui {
|
|
|
|
bool drop_target_apply_drop(bContext &C,
|
|
const DropTargetInterface &drop_target,
|
|
const ListBase &drags)
|
|
{
|
|
|
|
const char *disabled_hint_dummy = nullptr;
|
|
LISTBASE_FOREACH (const wmDrag *, drag, &drags) {
|
|
if (drop_target.can_drop(*drag, &disabled_hint_dummy)) {
|
|
return drop_target.on_drop(&C, *drag);
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
char *drop_target_tooltip(const DropTargetInterface &drop_target, const wmDrag &drag)
|
|
{
|
|
const std::string tooltip = drop_target.drop_tooltip(drag);
|
|
return tooltip.empty() ? nullptr : BLI_strdup(tooltip.c_str());
|
|
}
|
|
|
|
} // namespace blender::ui
|