neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_drag_drop.hpp
Go to the documentation of this file.
1// i_drag_drop.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
24#include <neogfx/core/event.hpp>
29#include <neogfx/game/i_ecs.hpp>
30
31namespace neogfx
32{
34
36
38 {
39 public:
40 virtual ~i_drag_drop_object() = default;
41 public:
42 virtual i_drag_drop_source& source() const = 0;
44 public:
45 virtual bool can_render() const = 0;
46 virtual size render_extents() const = 0;
47 virtual void render(i_graphics_context& aGc, point const& aPosition = {}) const = 0;
48 public:
50 {
51 static drag_drop_object_type_id sId{ 0x00000000, 0x0000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
52 return sId;
53 }
54 };
55
57 {
58 public:
59 virtual neolib::i_vector<i_string> const& file_paths() const = 0;
60 public:
62 {
63 static drag_drop_object_type_id sId{ 0xfaa77f8e, 0xfabc, 0x413c, 0xacdb, { 0x5b, 0xc1, 0x74, 0xc5, 0xd2, 0xbf } };
64 return sId;
65 }
66 };
67
69 {
70 public:
71 virtual i_item_presentation_model const& presentation_model() const = 0;
72 virtual item_presentation_model_index const& index() const = 0;
73 public:
75 {
76 static drag_drop_object_type_id sId{ 0x53f26bc6, 0x1b0, 0x4c19, 0x955b, { 0x1c, 0x6d, 0xa, 0x3f, 0x3b, 0xaf } };
77 return sId;
78 }
79 };
80
82 {
83 public:
84 virtual game::i_ecs const& ecs() const = 0;
85 virtual game::entity_id entity() const = 0;
86 public:
88 {
89 static drag_drop_object_type_id sId{ 0x7d9e2908, 0x7b2a, 0x45e2, 0xa97, { 0xa0, 0x18, 0x6d, 0x97, 0x7e, 0x83 } };
90 return sId;
91 }
92 };
93
94 struct failed_drag_drop_registration : std::logic_error { failed_drag_drop_registration(std::string const& aReason) : std::logic_error{ "neogfx::failed_drag_drop_registration: " + aReason } {} };
95 struct failed_drag_drop_unregistration : std::logic_error { failed_drag_drop_unregistration(std::string const& aReason) : std::logic_error{ "neogfx::failed_drag_drop_unregistration: " + aReason } {} };
96 struct drag_drop_already_active : std::logic_error { drag_drop_already_active() : std::logic_error{ "neogfx::drag_drop_already_active" } {} };
97 struct drag_drop_not_active : std::logic_error { drag_drop_not_active() : std::logic_error{ "neogfx::drag_drop_not_active" } {} };
98 struct no_drag_drop_event_monitor : std::logic_error { no_drag_drop_event_monitor() : std::logic_error{ "neogfx::no_drag_drop_event_monitor" } {} };
99
101 {
102 public:
103 declare_event(dragging_object, i_drag_drop_object const&)
104 declare_event(dragging_cancelled, i_drag_drop_object const&)
105 declare_event(object_dropped_on_target, i_drag_drop_object const&, i_drag_drop_target&)
106 public:
107 virtual ~i_drag_drop_source() = default;
108 public:
109 virtual bool drag_drop_source_enabled() const = 0;
110 virtual void enable_drag_drop_source(bool aEnable = true) = 0;
111 virtual bool drag_drop_active() const = 0;
112 virtual i_drag_drop_object const& object_being_dragged() const = 0;
113 virtual void start_drag_drop(i_drag_drop_object const& aObject) = 0;
114 virtual void cancel_drag_drop() = 0;
115 virtual void end_drag_drop(i_drag_drop_target& aTarget) = 0;
116 public:
117 virtual point const& drag_drop_tracking_position() const = 0;
118 virtual i_ref_ptr<i_widget> const& drag_drop_widget() const = 0;
119 virtual void set_drag_drop_widget(i_ref_ptr<i_widget> const& aWidget) = 0;
120 public:
121 virtual i_widget& drag_drop_event_monitor() const = 0;
122 virtual void monitor_drag_drop_events(i_widget& aWidget) = 0;
124 public:
126 {
129 }
130 };
131
132 struct drag_drop_target_not_a_widget : std::logic_error { drag_drop_target_not_a_widget() : std::logic_error{ "neogfx::drag_drop_target_not_a_widget" } {} };
133
134 enum class drop_operation : uint32_t
135 {
136 None = 0x00000000,
137 Copy = 0x00000001,
138 Move = 0x00000002,
139 Link = 0x00000003
140 };
141
143 {
144 public:
146 declare_event(object_dropped, i_drag_drop_object const&, optional_point const&)
147 public:
148 virtual ~i_drag_drop_target() = default;
149 public:
150 virtual bool drag_drop_target_enabled() const = 0;
151 virtual void enable_drag_drop_target(bool aEnable = true) = 0;
152 public:
153 virtual bool can_accept(i_drag_drop_object const& aObject, optional_point const& aDropPosition = {}) const = 0;
154 virtual drop_operation accepted_as(i_drag_drop_object const& aObject, optional_point const& aDropPosition = {}) const = 0;
155 virtual bool accept(i_drag_drop_object const& aObject, optional_point const& aDropPosition = {}) = 0;
156 public:
157 virtual bool is_widget() const = 0;
158 virtual i_widget const& as_widget() const = 0;
159 virtual i_widget& as_widget() = 0;
160 };
161
162 struct drag_drop_target_not_found : std::logic_error { drag_drop_target_not_found() : std::logic_error{ "neogfx::drag_drop_target_not_found" } {} };
163
164 class i_drag_drop : public i_service
165 {
166 public:
168 declare_event(source_unregistered, i_drag_drop_source&)
170 declare_event(target_unregistered, i_drag_drop_target&)
171 public:
172 virtual ~i_drag_drop() = default;
173 public:
174 virtual void register_source(i_drag_drop_source& aSource) = 0;
175 virtual void unregister_source(i_drag_drop_source& aSource) = 0;
176 virtual void register_target(i_drag_drop_target& aTarget) = 0;
177 virtual void unregister_target(i_drag_drop_target& aTarget) = 0;
178 public:
179 virtual bool is_target_for(i_drag_drop_object const& aObject) const = 0;
180 virtual bool is_target_at(i_drag_drop_object const& aObject, point const& aPosition) const = 0;
181 virtual i_drag_drop_target& target_for(i_drag_drop_object const& aObject) const = 0;
182 virtual i_drag_drop_target& target_at(i_drag_drop_object const& aObject, point const& aPosition) const = 0;
183 public:
184 static uuid const& iid() { static uuid const sIid{ 0x393fd9c4, 0x6db8, 0x4c04, 0x87f6, { 0x39, 0x87, 0x6a, 0x30, 0x35, 0xd4 } }; return sIid; }
185 };
186}
static const drag_drop_object_type_id otid()
virtual game::entity_id entity() const =0
virtual game::i_ecs const & ecs() const =0
static const drag_drop_object_type_id otid()
virtual neolib::i_vector< i_string > const & file_paths() const =0
static const drag_drop_object_type_id otid()
virtual i_item_presentation_model const & presentation_model() const =0
virtual item_presentation_model_index const & index() const =0
virtual size render_extents() const =0
virtual void render(i_graphics_context &aGc, point const &aPosition={}) const =0
virtual drag_drop_object_type_id ddo_type() const =0
virtual ~i_drag_drop_object()=default
virtual i_drag_drop_source & source() const =0
static const drag_drop_object_type_id otid()
virtual bool can_render() const =0
virtual bool drag_drop_active() const =0
virtual void end_drag_drop(i_drag_drop_target &aTarget)=0
void enable_drag_drop_source(i_widget &aWidget)
virtual void stop_monitoring_drag_drop_events()=0
virtual void start_drag_drop(i_drag_drop_object const &aObject)=0
declare_event(dragging_object, i_drag_drop_object const &) declare_event(dragging_cancelled
virtual i_widget & drag_drop_event_monitor() const =0
virtual point const & drag_drop_tracking_position() const =0
virtual i_drag_drop_object const & object_being_dragged() const =0
virtual i_ref_ptr< i_widget > const & drag_drop_widget() const =0
virtual void monitor_drag_drop_events(i_widget &aWidget)=0
virtual void set_drag_drop_widget(i_ref_ptr< i_widget > const &aWidget)=0
virtual void cancel_drag_drop()=0
virtual void enable_drag_drop_source(bool aEnable=true)=0
virtual bool drag_drop_source_enabled() const =0
virtual i_widget & as_widget()=0
virtual bool is_widget() const =0
virtual i_widget const & as_widget() const =0
virtual bool can_accept(i_drag_drop_object const &aObject, optional_point const &aDropPosition={}) const =0
virtual bool accept(i_drag_drop_object const &aObject, optional_point const &aDropPosition={})=0
virtual bool drag_drop_target_enabled() const =0
declare_event(object_acceptable, i_drag_drop_object const &, optional_point const &, drop_operation &) declare_event(object_dropped
virtual ~i_drag_drop_target()=default
virtual drop_operation accepted_as(i_drag_drop_object const &aObject, optional_point const &aDropPosition={}) const =0
virtual void enable_drag_drop_target(bool aEnable=true)=0
virtual void unregister_source(i_drag_drop_source &aSource)=0
virtual bool is_target_at(i_drag_drop_object const &aObject, point const &aPosition) const =0
virtual i_drag_drop_target & target_for(i_drag_drop_object const &aObject) const =0
declare_event(source_registered, i_drag_drop_source &) declare_event(source_unregistered
virtual void register_source(i_drag_drop_source &aSource)=0
virtual void unregister_target(i_drag_drop_target &aTarget)=0
virtual i_drag_drop_target & target_at(i_drag_drop_object const &aObject, point const &aPosition) const =0
virtual bool is_target_for(i_drag_drop_object const &aObject) const =0
static uuid const & iid()
virtual void register_target(i_drag_drop_target &aTarget)=0
uuid drag_drop_object_type_id
id_t entity_id
Definition ecs_ids.hpp:51
#define declare_event(declName,...)
Definition i_event.hpp:305
failed_drag_drop_registration(std::string const &aReason)
failed_drag_drop_unregistration(std::string const &aReason)