29 template <
typename DragDropObjectInterface>
63 i_drag_drop_source& iSource;
71 template <
typename... Files>
74 iFilePaths{
std::forward<Files>(aFiles)... }
92 iPresentationModel{ aPresentationModel },
99 return iPresentationModel;
101 item_presentation_model_index
const&
index() const final
108 bool canRender =
false;
110 presentation_model().dragging_item_render_info().trigger(*
this, canRender, renderExtents);
115 bool canRender =
false;
117 presentation_model().dragging_item_render_info().trigger(*
this, canRender, renderExtents);
118 return renderExtents;
125 i_item_presentation_model
const& iPresentationModel;
126 item_presentation_model_index iItem;
155 template <
typename Base = drag_drop_source_empty_base>
158 typedef Base base_type;
164 template <typename... Args>
166 base_type{ std::forward<Args>(aArgs)... }, iEnabled{
false }, iObject{
nullptr }, iMonitor{
nullptr }
180 if (iEnabled != aEnable)
185 if constexpr (std::is_base_of_v<i_widget, base_type>)
187 service<i_drag_drop>().register_source(*
this);
191 service<i_drag_drop>().unregister_source(*
this);
198 return iObject !=
nullptr;
213 DraggingObject.trigger(*iObject);
219 auto object = iObject;
221 DraggingCancelled.trigger(*
object);
223 iWidgetOffset = std::nullopt;
229 auto object = iObject;
231 ObjectDroppedOnTarget.trigger(*
object, aTarget);
233 iWidgetOffset = std::nullopt;
239 return *iTrackCurrent;
252 iWidgetOffset = std::nullopt;
257 if (iMonitor !=
nullptr)
266 handle_drag_drop_event(aWidget, aEvent);
282 return iTriggerDistance;
286 iTriggerDistance = aDistance;
294 auto const eventPos = aEvent.
position() - aWidget.origin();
295 switch (aEvent.
type())
301 iTrackStart = eventPos;
302 iTrackCurrent = eventPos;
308 iTrackCurrent = eventPos;
309 bool needUpdate =
false;
317 iWidget->move(*iTrackCurrent + *iWidgetOffset);
319 iWidget->set_opacity(service<i_drag_drop>().is_target_at(
object_being_dragged(), windowPosition) ? 1.0 : 0.25);
339 iTrackStart = std::nullopt;
340 iTrackCurrent = std::nullopt;
349 iWidget->set_opacity(1.0);
369 scalar iTriggerDistance = 8.0;
374 template <
typename Base>
382 template <
typename... Args>
384 base_type{ std::forward<Args>(aArgs)... }, iEnabled{
false }
398 if (iEnabled != aEnable)
402 service<i_drag_drop>().register_target(*
this);
404 service<i_drag_drop>().unregister_target(*
this);
415 ObjectAcceptable.trigger(aObject, aDropPosition, acceptableAs);
422 ObjectDropped.trigger(aObject, aDropPosition);
430 return std::is_base_of_v<i_widget, base_type>;
434 if constexpr (std::is_base_of_v<i_widget, base_type>)
441 return const_cast<i_widget&
>(to_const(*this).as_widget());
mouse_event_type type() const
bool is_left_button() const
neogfx::point position() const
game::i_ecs const & ecs() const final
game::entity_id entity() const final
drag_drop_entity(i_drag_drop_source &aSource, game::i_ecs const &aEcs, game::entity_id aEntity)
drag_drop_file_list(i_drag_drop_source &aSource, Files &&... aFiles)
neolib::vector< string > const & file_paths() const final
i_item_presentation_model const & presentation_model() const final
item_presentation_model_index const & index() const final
size render_extents() const final
void render(i_graphics_context &aGc, point const &aPosition={}) const final
drag_drop_item(i_drag_drop_source &aSource, i_item_presentation_model const &aPresentationModel, item_presentation_model_index const &aItem)
bool can_render() const final
drag_drop_object_type_id ddo_type() const final
bool can_render() const override
i_drag_drop_source & source() const final
DragDropObjectInterface object_interface
void render(i_graphics_context &aGc, point const &aPosition={}) const override
size render_extents() const override
drag_drop_object(i_drag_drop_source &aSource, drag_drop_object_type_id aType=object_interface::otid())
i_drag_drop_object const & object_being_dragged() const final
void set_drag_drop_widget(i_ref_ptr< i_widget > const &aWidget) final
scalar drag_drop_trigger_distance() const
void enable_drag_drop_source(bool aEnable=true) override
bool drag_drop_active() const final
bool drag_drop_source_enabled() const final
void monitor_drag_drop_events(i_widget &aWidget) final
void stop_monitoring_drag_drop_events() final
virtual bool is_drag_drop_object(point const &aPosition) const =0
void set_drag_drop_trigger_distance(scalar aDistance)
void start_drag_drop(i_drag_drop_object const &aObject) final
point const & drag_drop_tracking_position() const final
void cancel_drag_drop() final
void end_drag_drop(i_drag_drop_target &aTarget) final
virtual i_drag_drop_object const * drag_drop_object(point const &aPosition)=0
i_ref_ptr< i_widget > const & drag_drop_widget() const final
i_widget & drag_drop_event_monitor() const final
define_declared_event(DraggingObject, dragging_object, i_drag_drop_object const &) define_declared_event(DraggingCancelled
bool drag_drop_target_enabled() const final
bool is_widget() const final
bool accept(i_drag_drop_object const &aObject, optional_point const &aDropPosition={}) final
void enable_drag_drop_target(bool aEnable=true) final
i_widget const & as_widget() const final
drop_operation accepted_as(i_drag_drop_object const &aObject, optional_point const &aDropPosition={}) const final
bool can_accept(i_drag_drop_object const &aObject, optional_point const &aDropPosition={}) const final
i_widget & as_widget() final
i_drag_drop_target & target_at(i_drag_drop_object const &aObject, point const &aPosition) const final
void unregister_source(i_drag_drop_source &aSource) override
void register_source(i_drag_drop_source &aSource) override
bool is_target_at(i_drag_drop_object const &aObject, point const &aPosition) const final
i_drag_drop_source target_unregistered
define_declared_event(SourceRegistered, source_registered, i_drag_drop_source &) define_declared_event(SourceUnregistered
i_drag_drop_target & target_for(i_drag_drop_object const &aObject) const final
bool is_target_for(i_drag_drop_object const &aObject) const final
void register_target(i_drag_drop_target &aTarget) override
i_drag_drop_target * find_target(i_drag_drop_object const &aObject) const
void unregister_target(i_drag_drop_target &aTarget) override
virtual void render(i_graphics_context &aGc, point const &aPosition={}) const =0
virtual bool can_render() const =0
virtual const i_widget & as_widget() const =0
virtual point window_position() const =0
uuid drag_drop_object_type_id
#define define_declared_event(name, declName,...)