Gorgon Game Engine
DnD.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "./Layer.h"
6 #include "../Resource/GID.h"
7 #include "../Event.h"
8 #include "../DataExchange.h"
9 
10 namespace Gorgon {
11  class Window;
12 }
13 
14 namespace Gorgon { namespace Input {
15 
58  class DragInfo;
59 
63  class DropTarget : public Gorgon::Layer {
64  friend void Drop(Geometry::Point location);
65  friend void CancelDrag();
66  friend class Gorgon::Window;
67  public:
69 
70  //BEGIN Event handling
71 
74 
79  void SetHitCheck(std::function<bool(DropTarget &, Geometry::Point)> fn) {
80  hitcheck = fn;
81  }
82 
87  void SetHitCheck(std::function<bool(Geometry::Point)> fn) {
88  hitcheck = [fn](DropTarget &, Geometry::Point point) { return fn(point); };
89  }
90 
95  template<class C_>
96  void SetHitCheck(C_ &c, bool(C_::*fn)(DropTarget &, Geometry::Point)) {
97  C_ *my = &c;
98  hitcheck = [fn, my](DropTarget &layer, Geometry::Point point) { return my->fn(layer, point); };
99  }
100 
105  template<class C_>
106  void SetHitCheck(C_ &c, bool(C_::*fn)(Geometry::Point)) {
107  C_ *my = &c;
108  hitcheck = [fn, my](DropTarget &, Geometry::Point point) { return my->fn(point); };
109  }
110 
115  template<class C_>
116  void SetHitCheck(C_ *my, bool(C_::*fn)(DropTarget &, Geometry::Point)) {
117  hitcheck = [fn, my](DropTarget &layer, Geometry::Point point) { return my->fn(layer, point); };
118  }
119 
124  template<class C_>
125  void SetHitCheck(C_ *my, bool(C_::*fn)(Geometry::Point)) {
126  hitcheck = [fn, my](DropTarget &, Geometry::Point point) { return my->fn(point); };
127  }
128 
130  void ResetHitCheck() {
131  hitcheck = {};
132  }
133 
134 
135 
138  void SetOver(std::function<bool(DropTarget &, DragInfo &)> fn) {
139  over = fn;
140  }
141 
144  void SetOver(std::function<bool(DragInfo &)> fn) {
145  over = [fn](DropTarget &, DragInfo &data) { return fn(data); };
146  }
147 
151  template<class C_>
152  void SetOver(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &)) {
153  C_ *my = &c;
154  over = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
155  }
156 
160  template<class C_>
161  void SetOver(C_ &c, bool(C_::*fn)(DragInfo &)) {
162  C_ *my = &c;
163  over = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
164  }
165 
169  template<class C_>
170  void SetOver(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &)) {
171  over = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
172  }
173 
177  template<class C_>
178  void SetOver(C_ *my, bool(C_::*fn)(DragInfo &)) {
179  over = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
180  }
181 
183  void ResetOver() {
184  over = {};
185  }
186 
187 
188 
191  void SetOut(std::function<void(DropTarget &, DragInfo &)> fn) {
192  out = fn;
193  }
194 
197  void SetOut(std::function<void(DragInfo &)> fn) {
198  out = [fn](DropTarget &, DragInfo &data) { return fn(data); };
199  }
200 
204  template<class C_>
205  void SetOut(C_ &c, void(C_::*fn)(DropTarget &, DragInfo &)) {
206  C_ *my = &c;
207  out = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
208  }
209 
213  template<class C_>
214  void SetOut(C_ &c, void(C_::*fn)(DragInfo &)) {
215  C_ *my = &c;
216  out = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
217  }
218 
222  template<class C_>
223  void SetOut(C_ *my, void(C_::*fn)(DropTarget &, DragInfo &)) {
224  out = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
225  }
226 
230  template<class C_>
231  void SetOut(C_ *my, void(C_::*fn)(DragInfo &)) {
232  out = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
233  }
234 
236  void ResetOut() {
237  out = {};
238  }
239 
240 
241 
245  void SetMove(std::function<bool(DropTarget &, DragInfo &, Geometry::Point)> fn) {
246  move = fn;
247  }
248 
252  void SetMove(std::function<bool(DragInfo &, Geometry::Point)> fn) {
253  move = [fn](DropTarget &, DragInfo &data, Geometry::Point p) { return fn(data, p); };
254  }
255 
260  template<class C_>
261  void SetMove(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point)) {
262  C_ *my = &c;
263  move = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
264  }
265 
270  template<class C_>
271  void SetMove(C_ &c, bool(C_::*fn)(DragInfo &, Geometry::Point)) {
272  C_ *my = &c;
273  move = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
274  }
275 
280  template<class C_>
281  void SetMove(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point)) {
282  move = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
283  }
284 
289  template<class C_>
290  void SetMove(C_ *my, bool(C_::*fn)(DragInfo &, Geometry::Point)) {
291  move = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
292  }
293 
297  void SetMove(std::function<bool(DropTarget &, DragInfo &)> fn) {
298  move = [fn](DropTarget &layer, DragInfo &data, Geometry::Point p) { return fn(layer, data); };
299  }
300 
304  void SetMove(std::function<bool(DragInfo &)> fn) {
305  move = [fn](DropTarget &, DragInfo &data, Geometry::Point p) { return fn(data); };
306  }
307 
312  template<class C_>
313  void SetMove(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &)) {
314  C_ *my = &c;
315  move = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data); };
316  }
317 
322  template<class C_>
323  void SetMove(C_ &c, bool(C_::*fn)(DragInfo &)) {
324  C_ *my = &c;
325  move = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data); };
326  }
327 
332  template<class C_>
333  void SetMove(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &)) {
334  move = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data); };
335  }
336 
341  template<class C_>
342  void SetMove(C_ *my, bool(C_::*fn)(DragInfo &)) {
343  move = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data); };
344  }
345 
347  void ResetMove() {
348  move ={};
349  }
350 
351 
352 
355  void SetDrop(std::function<bool(DropTarget &, DragInfo &, Geometry::Point)> fn) {
356  drop = fn;
357  }
358 
361  void SetDrop(std::function<bool(DragInfo &, Geometry::Point)> fn) {
362  drop = [fn](DropTarget &, DragInfo &data, Geometry::Point p) { return fn(data, p); };
363  }
364 
368  template<class C_>
369  void SetDrop(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point)) {
370  C_ *my = &c;
371  drop = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
372  }
373 
377  template<class C_>
378  void SetDrop(C_ &c, bool(C_::*fn)(DragInfo &, Geometry::Point)) {
379  C_ *my = &c;
380  drop = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
381  }
382 
386  template<class C_>
387  void SetDrop(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point)) {
388  drop = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
389  }
390 
394  template<class C_>
395  void SetDrop(C_ *my, bool(C_::*fn)(DragInfo &, Geometry::Point)) {
396  drop = [fn, my](DropTarget &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
397  }
398 
401  void SetDrop(std::function<bool(DropTarget &, DragInfo &)> fn) {
402  drop = [fn](DropTarget &layer, DragInfo &data, Geometry::Point p) { return fn(layer, data); };
403  }
404 
407  void SetDrop(std::function<bool(DragInfo &)> fn) {
408  drop = [fn](DropTarget &, DragInfo &data, Geometry::Point) { return fn(data); };
409  }
410 
414  template<class C_>
415  void SetDrop(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &)) {
416  C_ *my = &c;
417  drop = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point) { return my->fn(layer, data); };
418  }
419 
423  template<class C_>
424  void SetDrop(C_ &c, bool(C_::*fn)(DragInfo &)) {
425  C_ *my = &c;
426  drop = [fn, my](DropTarget &, DragInfo &data, Geometry::Point) { return my->fn(data); };
427  }
428 
432  template<class C_>
433  void SetDrop(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &)) {
434  drop = [fn, my](DropTarget &layer, DragInfo &data, Geometry::Point) { return my->fn(layer, data); };
435  }
436 
440  template<class C_>
441  void SetDrop(C_ *my, bool(C_::*fn)(DragInfo &)) {
442  drop = [fn, my](DropTarget &, DragInfo &data, Geometry::Point) { return my->fn(data); };
443  }
444 
446  void ResetDrop() {
447  drop = {};
448  }
449 
450 
451 
454  void SetCancel(std::function<void(DropTarget &, DragInfo &)> fn) {
455  cancel = fn;
456  }
457 
460  void SetCancel(std::function<void(DragInfo &)> fn) {
461  cancel = [fn](DropTarget &, DragInfo &data) { return fn(data); };
462  }
463 
467  template<class C_>
468  void SetCancel(C_ &c, void(C_::*fn)(DropTarget &, DragInfo &)) {
469  C_ *my = &c;
470  cancel = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
471  }
472 
476  template<class C_>
477  void SetCancel(C_ &c, void(C_::*fn)(DragInfo &)) {
478  C_ *my = &c;
479  cancel = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
480  }
481 
485  template<class C_>
486  void SetCancel(C_ *my, void(C_::*fn)(DropTarget &, DragInfo &)) {
487  cancel = [fn, my](DropTarget &layer, DragInfo &data) { return my->fn(layer, data); };
488  }
489 
493  template<class C_>
494  void SetCancel(C_ *my, void(C_::*fn)(DragInfo &)) {
495  cancel = [fn, my](DropTarget &, DragInfo &data) { return my->fn(data); };
496  }
497 
499  void ResetCancel() {
500  cancel = {};
501  }
503 
504  //END
505 
506  protected:
507  std::function<bool(DropTarget &, Geometry::Point)> hitcheck;
508  std::function<bool(DropTarget &, DragInfo &)> over;
509  std::function<void(DropTarget &, DragInfo &)> out;
510  std::function<bool(DropTarget &, DragInfo &, Geometry::Point)> move;
511  std::function<bool(DropTarget &, DragInfo &, Geometry::Point)> drop;
512  std::function<void(DropTarget &, DragInfo &)> cancel;
513 
515 
516 
518  virtual bool propagate_mouseevent(Input::Mouse::EventType event, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers) override;
519  };
520 
521  class DragSource {
522  friend class DropTarget;
523  friend void Drop(Geometry::Point location);
524  friend void CancelDrag();
525  public:
528 
531  void SetOver(std::function<bool(DragSource &, DragInfo &)> fn) {
532  over = fn;
533  }
534 
537  void SetOver(std::function<bool(DragInfo &)> fn) {
538  over = [fn](DragSource &, DragInfo &data) { return fn(data); };
539  }
540 
544  template<class C_>
545  void SetOver(C_ &c, bool(C_::*fn)(DragSource &, DragInfo &)) {
546  C_ *my = &c;
547  over = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
548  }
549 
553  template<class C_>
554  void SetOver(C_ &c, bool(C_::*fn)(DragInfo &)) {
555  C_ *my = &c;
556  over = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
557  }
558 
562  template<class C_>
563  void SetOver(C_ *my, bool(C_::*fn)(DragSource &, DragInfo &)) {
564  over = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
565  }
566 
570  template<class C_>
571  void SetOver(C_ *my, bool(C_::*fn)(DragInfo &)) {
572  over = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
573  }
574 
576  void ResetOver() {
577  over ={};
578  }
579 
580 
581 
584  void SetOut(std::function<void(DragSource &, DragInfo &)> fn) {
585  out = fn;
586  }
587 
590  void SetOut(std::function<void(DragInfo &)> fn) {
591  out = [fn](DragSource &, DragInfo &data) { return fn(data); };
592  }
593 
597  template<class C_>
598  void SetOut(C_ &c, void(C_::*fn)(DragSource &, DragInfo &)) {
599  C_ *my = &c;
600  out = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
601  }
602 
606  template<class C_>
607  void SetOut(C_ &c, void(C_::*fn)(DragInfo &)) {
608  C_ *my = &c;
609  out = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
610  }
611 
615  template<class C_>
616  void SetOut(C_ *my, void(C_::*fn)(DragSource &, DragInfo &)) {
617  out = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
618  }
619 
623  template<class C_>
624  void SetOut(C_ *my, void(C_::*fn)(DragInfo &)) {
625  out = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
626  }
627 
629  void ResetOut() {
630  out ={};
631  }
632 
633 
634 
636  void SetMove(std::function<void(DragSource &, DragInfo &, Geometry::Point)> fn) {
637  move = fn;
638  }
639 
641  void SetMove(std::function<void(DragInfo &, Geometry::Point)> fn) {
642  move = [fn](DragSource &, DragInfo &data, Geometry::Point p) { return fn(data, p); };
643  }
644 
647  template<class C_>
648  void SetMove(C_ &c, void(C_::*fn)(DragSource &, DragInfo &, Geometry::Point)) {
649  C_ *my = &c;
650  move = [fn, my](DragSource &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
651  }
652 
655  template<class C_>
656  void SetMove(C_ &c, void(C_::*fn)(DragInfo &, Geometry::Point)) {
657  C_ *my = &c;
658  move = [fn, my](DragSource &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
659  }
660 
663  template<class C_>
664  void SetMove(C_ *my, void(C_::*fn)(DragSource &, DragInfo &, Geometry::Point)) {
665  move = [fn, my](DragSource &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data, p); };
666  }
667 
670  template<class C_>
671  void SetMove(C_ *my, void(C_::*fn)(DragInfo &, Geometry::Point)) {
672  move = [fn, my](DragSource &, DragInfo &data, Geometry::Point p) { return my->fn(data, p); };
673  }
674 
676  void SetMove(std::function<void(DragSource &, DragInfo &)> fn) {
677  move = [fn](DragSource &layer, DragInfo &data, Geometry::Point p) { return fn(layer, data); };
678  }
679 
681  void SetMove(std::function<void(DragInfo &)> fn) {
682  move = [fn](DragSource &, DragInfo &data, Geometry::Point p) { return fn(data); };
683  }
684 
687  template<class C_>
688  void SetMove(C_ &c, void(C_::*fn)(DragSource &, DragInfo &)) {
689  C_ *my = &c;
690  move = [fn, my](DragSource &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data); };
691  }
692 
695  template<class C_>
696  void SetMove(C_ &c, void(C_::*fn)(DragInfo &)) {
697  C_ *my = &c;
698  move = [fn, my](DragSource &, DragInfo &data, Geometry::Point p) { return my->fn(data); };
699  }
700 
703  template<class C_>
704  void SetMove(C_ *my, void(C_::*fn)(DragSource &, DragInfo &)) {
705  move = [fn, my](DragSource &layer, DragInfo &data, Geometry::Point p) { return my->fn(layer, data); };
706  }
707 
710  template<class C_>
711  void SetMove(C_ *my, void(C_::*fn)(DragInfo &)) {
712  move = [fn, my](DragSource &, DragInfo &data, Geometry::Point p) { return my->fn(data); };
713  }
714 
716  void ResetMove() {
717  move ={};
718  }
719 
720 
721 
723  void SetAccept(std::function<void(DragSource &, DragInfo &)> fn) {
724  accept = fn;
725  }
726 
728  void SetAccept(std::function<void(DragInfo &)> fn) {
729  accept = [fn](DragSource &, DragInfo &data) { return fn(data); };
730  }
731 
734  template<class C_>
735  void SetAccept(C_ &c, void(C_::*fn)(DragSource &, DragInfo &)) {
736  C_ *my = &c;
737  accept = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
738  }
739 
742  template<class C_>
743  void SetAccept(C_ &c, void(C_::*fn)(DragInfo &)) {
744  C_ *my = &c;
745  accept = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
746  }
747 
750  template<class C_>
751  void SetAccept(C_ *my, void(C_::*fn)(DragSource &, DragInfo &)) {
752  accept = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
753  }
754 
757  template<class C_>
758  void SetAccept(C_ *my, void(C_::*fn)(DragInfo &)) {
759  accept = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
760  }
761 
763  void ResetAccept() {
764  accept ={};
765  }
766 
767 
769  void SetCancel(std::function<void(DragSource &, DragInfo &)> fn) {
770  cancel = fn;
771  }
772 
774  void SetCancel(std::function<void(DragInfo &)> fn) {
775  cancel = [fn](DragSource &, DragInfo &data) { return fn(data); };
776  }
777 
780  template<class C_>
781  void SetCancel(C_ &c, void(C_::*fn)(DragSource &, DragInfo &)) {
782  C_ *my = &c;
783  cancel = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
784  }
785 
788  template<class C_>
789  void SetCancel(C_ &c, void(C_::*fn)(DragInfo &)) {
790  C_ *my = &c;
791  cancel = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
792  }
793 
796  template<class C_>
797  void SetCancel(C_ *my, void(C_::*fn)(DragSource &, DragInfo &)) {
798  cancel = [fn, my](DragSource &layer, DragInfo &data) { return my->fn(layer, data); };
799  }
800 
803  template<class C_>
804  void SetCancel(C_ *my, void(C_::*fn)(DragInfo &)) {
805  cancel = [fn, my](DragSource &, DragInfo &data) { return my->fn(data); };
806  }
807 
809  void ResetCancel() {
810  cancel ={};
811  }
813 
814 
815  private:
816  std::function<bool(DragSource &, DragInfo &)> over;
817  std::function<void(DragSource &, DragInfo &)> out;
818  std::function<void(DragSource &, DragInfo &, Geometry::Point)> move;
819  std::function<void(DragSource &, DragInfo &)> accept;
820  std::function<void(DragSource &, DragInfo &)> cancel;
821  };
822 
823 
829  class DragInfo {
830  public:
832  explicit DragInfo(DragSource &source) : source(&source) {}
833 
835  DragInfo() { }
836 
838  void AddTextData(const std::string &text);
839 
841  void AddFileData(const std::string &text);
842 
844  void AddData(ExchangeData &data);
845 
847  void AssumeData(ExchangeData &data);
848 
850  bool HasData(Resource::GID::Type type) const;
851 
853  void DataReady() {
854  std::cout<<"Ready!"<<std::endl;
855  dataready = true;
856  }
857 
859  bool IsDataReady() const {
860  return dataready;
861  }
862 
865  return data.begin();
866  }
867 
870  return data.end();
871  }
872 
876 
878  ExchangeData &operator [](int ind) const { return data[ind]; }
879 
881  int GetSize() const { return (int)data.GetSize(); }
882 
885  bool HasTarget() const { return active != nullptr; }
886 
891  if(!active) throw std::runtime_error("There is no active target.");
892  return *active;
893  }
894 
897  void SetTarget(DropTarget &value) { active = &value; }
898 
901  void RemoveTarget() { active = nullptr; }
902 
904  bool HasSource() const { return source != nullptr; }
905 
909  if(!source) throw std::runtime_error("There is no source.");
910  return *source;
911  }
912 
914  void MarkAsOS() {
915  os = true;
916  }
917 
919  bool IsFromOS() {
920  return os;
921  }
922 
925  destroylist.Destroy();
926  }
927  private:
930 
931  DragSource *source = nullptr;
932  DropTarget *active = nullptr;
933 
934  bool os = false;
935  bool dataready = false;
936  };
937 
940  extern DragInfo *DragOperation;
941 
944 
950 
952 
953  void begindrag(DragSource &source);
954  void begindrag();
955 
956  template<class D_, class ...A_>
957  void begindrag(D_ &&data, A_&& ... rest) {
958  begindrag(std::forward<A_>(rest)...);
959 
960  DragOperation->AddData(std::forward<D_>(data));
961  }
962 
963  template<class ...A_>
964  void begindrag(const std::string &data, A_&& ... rest) {
965  begindrag(std::forward<A_>(rest)...);
966 
967  DragOperation->AddTextData(data);
968  }
969  template<class ...A_>
970  void begindrag(const char *data, A_&& ... rest) {
971  begindrag(std::forward<A_>(rest)...);
972 
973  DragOperation->AddTextData(data);
974  }
975 
976  template<class ...A_>
977  void begindrag(std::string &data, A_&& ... rest) {
978  begindrag(std::forward<A_>(rest)...);
979 
980  DragOperation->AddTextData(data);
981  }
982  template<class ...A_>
983  void begindrag(char *data, A_&& ... rest) {
984  begindrag(std::forward<A_>(rest)...);
985 
986  DragOperation->AddTextData(data);
987  }
988 
989 
990  template<class D_, class ...A_>
991  void begindrag(DragSource &source, D_ &&data, A_&& ... rest) {
992  begindrag(source, std::forward<A_>(rest)...);
993 
994  DragOperation->AddData(std::forward<D_>(data));
995  }
996 
997  template<class ...A_>
998  void begindrag(DragSource &source, const std::string &data, A_&& ... rest) {
999  begindrag(source, std::forward<A_>(rest)...);
1000 
1001  DragOperation->AddTextData(data);
1002  }
1003 
1004  template<class ...A_>
1005  void begindrag(DragSource &source, std::string &data, A_&& ... rest) {
1006  begindrag(source, std::forward<A_>(rest)...);
1007 
1008  DragOperation->AddTextData(data);
1009  }
1010 
1011  template<class ...A_>
1012  void begindrag(DragSource &source, char *data, A_&& ... rest) {
1013  begindrag(source, std::forward<A_>(rest)...);
1014 
1015  DragOperation->AddTextData(data);
1016  }
1017 
1018  template<class ...A_>
1019  void begindrag(DragSource &source, const char *data, A_&& ... rest) {
1020  begindrag(source, std::forward<A_>(rest)...);
1021 
1022  DragOperation->AddTextData(data);
1023  }
1024 
1026 
1028  void startdrag();
1030 
1034  template<class ...A_>
1035  DragInfo &BeginDrag(DragSource &source, A_&& ... data) {
1036  begindrag(source, std::forward<A_>(data)...);
1037 
1038  startdrag();
1039 
1040  if(sizeof...(data) > 0)
1042 
1043  return *DragOperation;
1044  }
1045 
1050  template<class ...A_>
1051  inline DragInfo &BeginDrag(A_&& ... data) {
1052  begindrag(std::forward<A_&&>(data)...);
1053 
1054  startdrag();
1055 
1056  if(sizeof...(data) > 0)
1058 
1059  return *DragOperation;
1060  }
1061 
1062  void initdrag();
1063 
1067  inline DragInfo &PrepareDrag(DragSource &source) {
1068  DragOperation = new DragInfo(source);
1069 
1070  initdrag();
1071 
1072  return *DragOperation;
1073  }
1074 
1078  inline DragInfo &PrepareDrag() {
1079  DragOperation = new DragInfo();
1080 
1081  initdrag();
1082 
1083  return *DragOperation;
1084  }
1085 
1088  inline DragInfo &StartDrag() {
1089  startdrag();
1090 
1091  return *DragOperation;
1092  }
1093 
1095  extern bool dragstarted;
1097 
1099  inline bool IsDragging() {
1100  return DragOperation != nullptr && dragstarted;
1101  }
1102 
1104  inline bool IsDragPrepared() {
1105  return DragOperation != nullptr;
1106  }
1107 
1110  if(!DragOperation)
1111  throw std::runtime_error("No current drag operation is in progress");
1112 
1113  return *DragOperation;
1114  }
1115 
1117  void CancelDrag();
1118 
1121  void Drop(Geometry::Point location = {0, 0});
1122 } }
Gorgon::Input::DragSource
Definition: DnD.h:521
Gorgon::Input::DragInfo::HasSource
bool HasSource() const
Whether this object has a source.
Definition: DnD.h:904
Gorgon::Input::DragSource::SetCancel
void SetCancel(C_ &c, void(C_::*fn)(DragSource &, DragInfo &))
Sets accept function.
Definition: DnD.h:781
Gorgon::Input::DragSource::SetOut
void SetOut(C_ &c, void(C_::*fn)(DragSource &, DragInfo &))
Sets out function.
Definition: DnD.h:598
Gorgon::Input::DragInfo::AssumeData
void AssumeData(ExchangeData &data)
Adds data to this info object, ownership of the data is transfered.
Definition: DnD.cpp:20
Gorgon::Input::DragSource::SetMove
void SetMove(C_ *my, void(C_::*fn)(DragSource &, DragInfo &, Geometry::Point))
Sets move handler.
Definition: DnD.h:664
DnD.h
Gorgon::Window
This class represents a window.
Definition: Window.h:31
Gorgon::Resource::GID::File
constexpr Type File
File.
Definition: GID.h:84
Layer.h
Gorgon::String::From
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
Gorgon::WindowManager::XdndActionCopy
Atom XdndActionCopy
Definition: X11.h:107
Gorgon::Input::DropTarget::SetOut
void SetOut(C_ &c, void(C_::*fn)(DragInfo &))
Sets out function.
Definition: DnD.h:214
Gorgon::WindowManager::handledndselectionnotify
void handledndselectionnotify(XEvent event, Window &wind)
Definition: DnD.cpp:193
Gorgon::Input::DragInfo::AddFileData
void AddFileData(const std::string &text)
Adds file data to this info object.
Definition: DnD.cpp:12
Gorgon::Input::DragInfo::DragInfo
DragInfo(DragSource &source)
Constructor, requires the source for drag operation.
Definition: DnD.h:832
Gorgon::Input::DragSource::SetAccept
void SetAccept(C_ &c, void(C_::*fn)(DragSource &, DragInfo &))
Sets accept function.
Definition: DnD.h:735
Gorgon::Input::DragInfo::AddData
void AddData(ExchangeData &data)
Adds data to this info object, ownership of the data is not transfered.
Definition: DnD.cpp:16
Gorgon::Input::DragInfo::GetTarget
DropTarget & GetTarget() const
Returns the target of the drag operation.
Definition: DnD.h:890
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point))
Sets drop function.
Definition: DnD.h:369
Gorgon::Input::DragSource::ResetOver
void ResetOver()
Removes over handler, default action for over is to return true.
Definition: DnD.h:576
Gorgon::Event
This class provides event mechanism.
Definition: Event.h:134
Gorgon::Input::DragInfo::GetSource
DragSource & GetSource() const
Returns the drag source.
Definition: DnD.h:908
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets move function.
Definition: DnD.h:313
Gorgon::Input::Mouse::HitCheck
@ HitCheck
Checks if the coordinate hits the layer, always called first.
Definition: Mouse.h:15
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point))
Sets move function.
Definition: DnD.h:261
Gorgon::Input::DropTarget::CancelDrag
friend void CancelDrag()
Cancel the current drag operation.
Definition: DnD.cpp:207
Gorgon::Input::DragSource::SetOut
void SetOut(std::function< void(DragSource &, DragInfo &)> fn)
Sets out function.
Definition: DnD.h:584
Gorgon::Input::DragSource::SetOver
void SetOver(std::function< bool(DragInfo &)> fn)
Sets over function.
Definition: DnD.h:537
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ &c, bool(C_::*fn)(DragInfo &))
Sets move function.
Definition: DnD.h:323
Gorgon::Input::DropTarget::cancel
std::function< void(DropTarget &, DragInfo &)> cancel
Definition: DnD.h:512
Gorgon::Input::DropTarget::SetOver
void SetOver(C_ &c, bool(C_::*fn)(DragInfo &))
Sets over function.
Definition: DnD.h:161
Gorgon::Layer::dotransformandclip
void dotransformandclip(bool inverse=false)
Performs transformation and clipping. Use inverse for reverse mapping for mouse events.
Definition: Layer.cpp:115
Gorgon::WindowManager::XA_Filelist
Atom XA_Filelist
Definition: X11.h:110
Gorgon::Input::DropTarget::SetMove
void SetMove(std::function< bool(DragInfo &, Geometry::Point)> fn)
Sets move function.
Definition: DnD.h:252
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(C_ *my, bool(C_::*fn)(DropTarget &, Geometry::Point))
Sets hit check function.
Definition: DnD.h:116
Gorgon::Input::DropTarget::SetOver
void SetOver(std::function< bool(DragInfo &)> fn)
Sets over function.
Definition: DnD.h:144
Gorgon::Input::DragSource::SetAccept
void SetAccept(std::function< void(DragSource &, DragInfo &)> fn)
Sets accept function. If set, called whenever drag operation is accepted.
Definition: DnD.h:723
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets move function.
Definition: DnD.h:333
Gorgon::OS::GetEnvVar
std::string GetEnvVar(const std::string &var)
Returns the value of an environment variable.
Definition: Linux.cpp:17
Gorgon::Input::DragSource::SetMove
void SetMove(C_ &c, void(C_::*fn)(DragInfo &, Geometry::Point))
Sets move handler.
Definition: DnD.h:656
Gorgon::Input::DragSource::ResetAccept
void ResetAccept()
Removes accept handler.
Definition: DnD.h:763
Gorgon::Geometry::basic_Bounds::Width
T_ Width() const
Calculates and returns the width of the bounds.
Definition: Bounds.h:130
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(C_ &c, bool(C_::*fn)(Geometry::Point))
Sets hit check function.
Definition: DnD.h:106
Gorgon::WindowManager::XdndLeave
Atom XdndLeave
Definition: X11.h:105
Gorgon::Input::DragStarted
Event< void, DragInfo & > DragStarted
This event is fired whenever a drag operation begins.
Definition: DnD.cpp:225
Gorgon::Input::PrepareDrag
DragInfo & PrepareDrag(DragSource &source)
Prepares the drag operation.
Definition: DnD.h:1067
Gorgon::Resource::GID::Text
constexpr Type Text
Stores text data, no longer a resource.
Definition: GID.h:134
Gorgon::WindowManager::internal::getdata
Gorgon::internal::windowdata * getdata(const Window &w)
Definition: Window.cpp:15
Gorgon::Input::DragSource::SetMove
void SetMove(C_ *my, void(C_::*fn)(DragInfo &))
Sets move handler.
Definition: DnD.h:711
Gorgon::Input::DragSource::SetCancel
void SetCancel(std::function< void(DragSource &, DragInfo &)> fn)
Sets accept function. If set, called whenever drag operation is canceled.
Definition: DnD.h:769
Gorgon::Clip
Geometry::Bounds Clip
Current clipping size, for mouse and clipping events.
Definition: Layer.cpp:20
Gorgon::Input::DragSource::ResetCancel
void ResetCancel()
Removes cancel handler.
Definition: DnD.h:809
Gorgon::Input::DropTarget::move
std::function< bool(DropTarget &, DragInfo &, Geometry::Point)> move
Definition: DnD.h:510
Gorgon::Input::DragSource::SetOver
void SetOver(C_ &c, bool(C_::*fn)(DragSource &, DragInfo &))
Sets over function.
Definition: DnD.h:545
Gorgon::Input::DragSource::SetAccept
void SetAccept(C_ &c, void(C_::*fn)(DragInfo &))
Sets accept function.
Definition: DnD.h:743
Gorgon::Input::Mouse::Move
@ Move
Definition: Mouse.h:17
Gorgon::WindowManager::XdndSelection
Atom XdndSelection
Definition: X11.h:100
Gorgon::Input::DropTarget::SetCancel
void SetCancel(C_ *my, void(C_::*fn)(DropTarget &, DragInfo &))
Sets cancel function.
Definition: DnD.h:486
Gorgon::Window::IsLocalPointer
bool IsLocalPointer() const
Returns whether the current pointer is a local pointer.
Definition: Window.h:279
Gorgon::Geometry::basic_Bounds::Height
T_ Height() const
Calculates and returns the height of the bounds.
Definition: Bounds.h:135
Gorgon::Input::DragInfo::end
Containers::Collection< ExchangeData >::Iterator end()
For range based iteration.
Definition: DnD.h:869
Gorgon::Input::DropTarget::ResetOut
void ResetOut()
Removes out handler.
Definition: DnD.h:236
Gorgon::Input::DragSource::ResetOut
void ResetOut()
Removes out handler.
Definition: DnD.h:629
Gorgon::Input::DragSource::SetMove
void SetMove(std::function< void(DragSource &, DragInfo &, Geometry::Point)> fn)
Sets move handler. If set, called continuously until the drag operation is complete.
Definition: DnD.h:636
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ &c, bool(C_::*fn)(DragInfo &, Geometry::Point))
Sets move function.
Definition: DnD.h:271
Gorgon::Geometry::basic_Transform3D
Definition: Transform3D.h:12
Gorgon::Input::DropTarget::SetCancel
void SetCancel(C_ &c, void(C_::*fn)(DropTarget &, DragInfo &))
Sets cancel function.
Definition: DnD.h:468
Gorgon::WindowManager::handledndleave
void handledndleave(XEvent, Window &wind)
Definition: DnD.cpp:82
Gorgon::WindowManager::XdndActionMove
Atom XdndActionMove
Definition: X11.h:108
Gorgon::Input::DragSource::SetMove
void SetMove(std::function< void(DragInfo &, Geometry::Point)> fn)
Sets move handler. If set, called continuously until the drag operation is complete.
Definition: DnD.h:641
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets drop function.
Definition: DnD.h:415
Gorgon::Input::DragSource::SetMove
void SetMove(C_ *my, void(C_::*fn)(DragSource &, DragInfo &))
Sets move handler.
Definition: DnD.h:704
Gorgon::WindowManager::XA_STRING
Atom XA_STRING
Definition: X11.h:72
Gorgon::Input::DragInfo::IsFromOS
bool IsFromOS()
Returns whether the DnD operation is coming from OS.
Definition: DnD.h:919
Gorgon::Input::DropTarget::ResetHitCheck
void ResetHitCheck()
Removes hit check handler, default action for hit check is to return true.
Definition: DnD.h:130
Gorgon::Input::DragSource::SetOut
void SetOut(C_ *my, void(C_::*fn)(DragInfo &))
Sets out function.
Definition: DnD.h:624
Gorgon::WindowManager::XA_UTF8_STRING
Atom XA_UTF8_STRING
Definition: X11.h:73
Gorgon::Input::DropTarget::out
std::function< void(DropTarget &, DragInfo &)> out
Definition: DnD.h:509
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Input::DropTarget::ResetOver
void ResetOver()
Removes over handler, default action for over is to return true.
Definition: DnD.h:183
Gorgon::Layer::reverttransformandclip
void reverttransformandclip()
Reverts previously done transformation.
Definition: Layer.cpp:149
Gorgon::Input::DragInfo::AddTextData
void AddTextData(const std::string &text)
Adds text data to this info object.
Definition: DnD.cpp:8
Gorgon::FileData::Clear
void Clear()
Clears the file list.
Definition: DataExchange.h:86
Gorgon::Input::Keyboard::Keycodes::Up
constexpr Key Up
Definition: Keyboard.h:63
Gorgon::Encoding::URIDecode
std::string URIDecode(const std::string &str)
Decodes a given URI string according to RFC 3986. May throw URIError.
Definition: URI.cpp:74
Gorgon::Input::DragSource::SetCancel
void SetCancel(C_ *my, void(C_::*fn)(DragSource &, DragInfo &))
Sets accept function.
Definition: DnD.h:797
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ *my, bool(C_::*fn)(DragInfo &, Geometry::Point))
Sets move function.
Definition: DnD.h:290
Gorgon::Input::DragSource::SetMove
void SetMove(C_ &c, void(C_::*fn)(DragInfo &))
Sets move handler.
Definition: DnD.h:696
Gorgon::WindowManager::handledndevent
void handledndevent(XEvent event, Window &wind)
Definition: DnD.cpp:312
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ *my, bool(C_::*fn)(DragInfo &))
Sets drop function.
Definition: DnD.h:441
Gorgon::Input::DragSource::SetMove
void SetMove(C_ &c, void(C_::*fn)(DragSource &, DragInfo &, Geometry::Point))
Sets move handler.
Definition: DnD.h:648
Gorgon::Input::DropTarget::hitcheck
std::function< bool(DropTarget &, Geometry::Point)> hitcheck
Definition: DnD.h:507
Gorgon::Input::DragInfo::~DragInfo
~DragInfo()
Destructor.
Definition: DnD.h:924
Gorgon::Input::DropTarget::ResetCancel
void ResetCancel()
Removes cancel handler.
Definition: DnD.h:499
Gorgon::Input::DropTarget::SetDrop
void SetDrop(std::function< bool(DropTarget &, DragInfo &, Geometry::Point)> fn)
Sets drop function.
Definition: DnD.h:355
ASSERT
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(std::function< bool(Geometry::Point)> fn)
Sets hit check function.
Definition: DnD.h:87
Gorgon::WindowManager::handledndenter
void handledndenter(XEvent event, Window &wind)
Definition: DnD.cpp:24
Gorgon::Input::DropTarget::Drop
friend void Drop(Geometry::Point location)
Drop the current drag object.
Definition: DnD.cpp:179
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Geometry::Point
basic_Point< int > Point
Definition: Point.h:598
Gorgon::Input::DragSource::SetOut
void SetOut(C_ *my, void(C_::*fn)(DragSource &, DragInfo &))
Sets out function.
Definition: DnD.h:616
Gorgon::Transform
Geometry::Transform3D Transform
Current layer transformation, only for render and mouse.
Definition: Layer.cpp:18
Gorgon::Input::DropTarget::SetOver
void SetOver(C_ &c, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets over function.
Definition: DnD.h:152
Gorgon::WindowManager::XdndPosition
Atom XdndPosition
Definition: X11.h:104
Gorgon::Input::DragInfo::begin
Containers::Collection< ExchangeData >::Iterator begin()
For range based iteration.
Definition: DnD.h:864
Gorgon::Input::DragSource::SetOut
void SetOut(std::function< void(DragInfo &)> fn)
Sets out function.
Definition: DnD.h:590
Gorgon::Input::DragInfo
Contains information about a drag operation.
Definition: DnD.h:829
Gorgon::Input::DragSource::SetOver
void SetOver(C_ *my, bool(C_::*fn)(DragInfo &))
Sets over function.
Definition: DnD.h:571
Gorgon::WindowManager::XdndStatus
Atom XdndStatus
Definition: X11.h:103
Gorgon::MouseHandler
Definition: Layer.h:22
Gorgon::Input::Mouse::Over
@ Over
Definition: Mouse.h:16
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ *my, bool(C_::*fn)(DragInfo &))
Sets move function.
Definition: DnD.h:342
Gorgon::Input::DragSource::SetOut
void SetOut(C_ &c, void(C_::*fn)(DragInfo &))
Sets out function.
Definition: DnD.h:607
Gorgon::Input::DropTarget::SetOver
void SetOver(C_ *my, bool(C_::*fn)(DragInfo &))
Sets over function.
Definition: DnD.h:178
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ &c, bool(C_::*fn)(DragInfo &))
Sets drop function.
Definition: DnD.h:424
Gorgon::ExchangeData
Base object for data to be exchanged.
Definition: DataExchange.h:12
Gorgon::Input::DragSource::SetOver
void SetOver(C_ *my, bool(C_::*fn)(DragSource &, DragInfo &))
Sets over function.
Definition: DnD.h:563
Gorgon::TextData
Stores text data for data exchange.
Definition: DataExchange.h:31
Gorgon::Input::DropTarget::propagate_mouseevent
virtual bool propagate_mouseevent(Input::Mouse::EventType event, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers) override
Propagates a mouse event. Some events will be called directly.
Definition: DnD.cpp:67
Gorgon::Input::DragInfo::SetTarget
void SetTarget(DropTarget &value)
Sets the target of the drag operation.
Definition: DnD.h:897
Gorgon::Input::DragSource::SetAccept
void SetAccept(C_ *my, void(C_::*fn)(DragSource &, DragInfo &))
Sets accept function.
Definition: DnD.h:751
Gorgon::Input::DropTarget::SetOver
void SetOver(std::function< bool(DropTarget &, DragInfo &)> fn)
Sets over function.
Definition: DnD.h:138
Gorgon::Input::DragSource::SetMove
void SetMove(std::function< void(DragSource &, DragInfo &)> fn)
Sets move handler. If set, called continuously until the drag operation is complete.
Definition: DnD.h:676
Gorgon::Input::DragInfo::RemoveTarget
void RemoveTarget()
Removes the target of the drag operation.
Definition: DnD.h:901
Gorgon::Input::BeginDrag
DragInfo & BeginDrag(DragSource &source, A_ &&... data)
Begins a drag operation using the given source and data.
Definition: DnD.h:1035
Gorgon::Input::DragInfo::GetData
ExchangeData & GetData(Resource::GID::Type type) const
Returns the data associated with the given type, throws runtime_error if data does not exists.
Definition: DnD.cpp:35
Gorgon::Containers::Collection::Iterator
Iterator_< T_, Collection > Iterator
Regular iterator.
Definition: Collection.h:134
Gorgon::FileData::AddFile
void AddFile(std::string value)
Adds a new file to the list.
Definition: DataExchange.h:76
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ &c, bool(C_::*fn)(DragInfo &, Geometry::Point))
Sets drop function.
Definition: DnD.h:378
Gorgon::Input::DropTarget::SetDrop
void SetDrop(std::function< bool(DropTarget &, DragInfo &)> fn)
Sets drop function.
Definition: DnD.h:401
Gorgon::Input::DragSource::SetAccept
void SetAccept(std::function< void(DragInfo &)> fn)
Sets accept function. If set, called whenever drag operation is accepted.
Definition: DnD.h:728
Gorgon::Input::DragInfo::DragInfo
DragInfo()
Constructor, requires the source for drag operation.
Definition: DnD.h:835
Gorgon::Input::DropTarget::SetOut
void SetOut(std::function< void(DragInfo &)> fn)
Sets out function.
Definition: DnD.h:197
Gorgon::Input::Drop
void Drop(Geometry::Point location={0, 0})
Drop the current drag object.
Definition: DnD.cpp:179
Gorgon::Input::DragSource::SetCancel
void SetCancel(C_ *my, void(C_::*fn)(DragInfo &))
Sets accept function.
Definition: DnD.h:804
Gorgon::Input::DragInfo::MarkAsOS
void MarkAsOS()
Marks this DnD operation coming from OS.
Definition: DnD.h:914
Gorgon::Layer
This class is the base class for all layer types.
Definition: Layer.h:79
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ *my, bool(C_::*fn)(DragInfo &, Geometry::Point))
Sets drop function.
Definition: DnD.h:395
Gorgon::Input::DragInfo::GetSize
int GetSize() const
Returns the number of data stored in this object.
Definition: DnD.h:881
Gorgon::Input::DropTarget::SetCancel
void SetCancel(C_ &c, void(C_::*fn)(DragInfo &))
Sets cancel function.
Definition: DnD.h:477
Gorgon::Input::DragSource::SetMove
void SetMove(C_ &c, void(C_::*fn)(DragSource &, DragInfo &))
Sets move handler.
Definition: DnD.h:688
Gorgon::Input::DragOperation
DragInfo * DragOperation
Current Drag operation, could be nullptr, denoting there is none.
Definition: DnD.cpp:221
Gorgon::Window::SwitchToLocalPointers
void SwitchToLocalPointers()
Removes the operating system pointer and starts using Locally defined pointers.
Definition: Window.cpp:222
Gorgon::Input::DropTarget::SetCancel
void SetCancel(C_ *my, void(C_::*fn)(DragInfo &))
Sets cancel function.
Definition: DnD.h:494
Gorgon::Input::DropTarget::SetOver
void SetOver(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets over function.
Definition: DnD.h:170
Gorgon::Input::Mouse::EventType
EventType
The type of a mouse event.
Definition: Mouse.h:14
Gorgon::Input::IsDragging
bool IsDragging()
Returns whether a drag operation is in progress.
Definition: DnD.h:1099
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &))
Sets drop function.
Definition: DnD.h:433
Gorgon::Input::DropTarget::ResetDrop
void ResetDrop()
Removes drop handler, default is to cancel the drag operation.
Definition: DnD.h:446
Gorgon::Input::DragInfo::DataReady
void DataReady()
Marks drag data as ready.
Definition: DnD.h:853
Gorgon::Input::DragSource::SetOver
void SetOver(C_ &c, bool(C_::*fn)(DragInfo &))
Sets over function.
Definition: DnD.h:554
Gorgon::Input::DragSource::SetCancel
void SetCancel(C_ &c, void(C_::*fn)(DragInfo &))
Sets accept function.
Definition: DnD.h:789
Gorgon::Input::DragSource::SetAccept
void SetAccept(C_ *my, void(C_::*fn)(DragInfo &))
Sets accept function.
Definition: DnD.h:758
Gorgon::Input::DropTarget::SetDrop
void SetDrop(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point))
Sets drop function.
Definition: DnD.h:387
Gorgon::Input::DropTarget::SetMove
void SetMove(std::function< bool(DropTarget &, DragInfo &, Geometry::Point)> fn)
Sets move function.
Definition: DnD.h:245
Gorgon::Input::DropTarget::mytransform
Geometry::Transform3D mytransform
Definition: DnD.h:514
Gorgon::Input::DropTarget::SetDrop
void SetDrop(std::function< bool(DragInfo &, Geometry::Point)> fn)
Sets drop function.
Definition: DnD.h:361
Gorgon::Input::DragSource::SetMove
void SetMove(std::function< void(DragInfo &)> fn)
Sets move handler. If set, called continuously until the drag operation is complete.
Definition: DnD.h:681
Gorgon::WindowManager::handledndposition
void handledndposition(XEvent event, Window &wind)
Definition: DnD.cpp:120
Gorgon::Input::needsclip
bool needsclip(Input::Mouse::EventType event)
Definition: Layer.cpp:5
Gorgon::Input::DropTarget::drop
std::function< bool(DropTarget &, DragInfo &, Geometry::Point)> drop
Definition: DnD.h:511
Gorgon::Input::StartDrag
DragInfo & StartDrag()
Starts the drag operation.
Definition: DnD.h:1088
Gorgon::Input::DragSource::SetMove
void SetMove(C_ *my, void(C_::*fn)(DragInfo &, Geometry::Point))
Sets move handler.
Definition: DnD.h:671
Gorgon::Input::DragSource::CancelDrag
friend void CancelDrag()
Cancel the current drag operation.
Definition: DnD.cpp:207
Gorgon::Input::DropTarget::SetOut
void SetOut(C_ &c, void(C_::*fn)(DropTarget &, DragInfo &))
Sets out function.
Definition: DnD.h:205
Gorgon::Input::DropTarget::SetCancel
void SetCancel(std::function< void(DropTarget &, DragInfo &)> fn)
Sets cancel function.
Definition: DnD.h:454
Gorgon::Input::finishdrag
void finishdrag(bool success)
Definition: DnD.cpp:166
Gorgon::Input::DragInfo::IsDataReady
bool IsDataReady() const
Check wheather the drag data is ready.
Definition: DnD.h:859
Gorgon::Input::DropTarget::SetMove
void SetMove(std::function< bool(DragInfo &)> fn)
Sets move function.
Definition: DnD.h:304
Gorgon::Input::DropTarget::over
std::function< bool(DropTarget &, DragInfo &)> over
Definition: DnD.h:508
Gorgon::Input::startdrag
void startdrag()
Definition: DnD.cpp:48
Gorgon::Input::DragEnded
Event< void, DragInfo &, bool > DragEnded
This event is fired whenever a drag operation ends.
Definition: DnD.cpp:227
Gorgon::Input::DragInfo::HasTarget
bool HasTarget() const
If this drag operation has a target.
Definition: DnD.h:885
Gorgon::Input::DragInfo::HasData
bool HasData(Resource::GID::Type type) const
Check whether this drag info has the given data.
Definition: DnD.cpp:26
Gorgon::WindowManager::XdndTypeList
Atom XdndTypeList
Definition: X11.h:109
Gorgon::Input::Mouse::Button
Button
Lists the mouse button constants.
Definition: Mouse.h:31
Gorgon::Layer::Layer
Layer()
Constructor that sets the layer to cover entire parent, no matter how big it is.
Definition: Layer.h:90
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(C_ &c, bool(C_::*fn)(DropTarget &, Geometry::Point))
Sets hit check function.
Definition: DnD.h:96
Gorgon::Resource::GID::Type
Type to store GID information.
Definition: GID.h:23
Gorgon::Input::DragSource::SetOver
void SetOver(std::function< bool(DragSource &, DragInfo &)> fn)
Sets over function.
Definition: DnD.h:531
Gorgon::Input::DropTarget::SetMove
void SetMove(C_ *my, bool(C_::*fn)(DropTarget &, DragInfo &, Geometry::Point))
Sets move function.
Definition: DnD.h:281
Gorgon::WindowManager::handlednddrop
void handlednddrop(XEvent event, Window &wind)
Definition: DnD.cpp:94
Gorgon::Input::DropTarget
This layer acts as a drop target.
Definition: DnD.h:63
Gorgon::Input::DropTarget::SetDrop
void SetDrop(std::function< bool(DragInfo &)> fn)
Sets drop function.
Definition: DnD.h:407
Gorgon::Input::GetDragOperation
DragInfo & GetDragOperation()
Returns the current drag operation, throws if IsDragPrepared is false.
Definition: DnD.h:1109
Gorgon::Input::dragstarted
bool dragstarted
Definition: DnD.cpp:223
Gorgon::MouseHandler::Add
void Add(Layer *l)
Definition: Layer.h:53
Gorgon::Input::IsDragPrepared
bool IsDragPrepared()
Returns whether a drag operation is available.
Definition: DnD.h:1104
Gorgon::Input::DropTarget::SetCancel
void SetCancel(std::function< void(DragInfo &)> fn)
Sets cancel function.
Definition: DnD.h:460
Gorgon::Input::DropTarget::ResetMove
void ResetMove()
Removes move handler, default is to continue the drag operation.
Definition: DnD.h:347
Gorgon::Input::DragSource::SetCancel
void SetCancel(std::function< void(DragInfo &)> fn)
Sets accept function. If set, called whenever drag operation is canceled.
Definition: DnD.h:774
Gorgon::FileData
Stores list of files for data exchange.
Definition: DataExchange.h:64
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(C_ *my, bool(C_::*fn)(Geometry::Point))
Sets hit check function.
Definition: DnD.h:125
Gorgon::Input::DropTarget::SetOut
void SetOut(C_ *my, void(C_::*fn)(DropTarget &, DragInfo &))
Sets out function.
Definition: DnD.h:223
Gorgon::Input::DropTarget::SetMove
void SetMove(std::function< bool(DropTarget &, DragInfo &)> fn)
Sets move function.
Definition: DnD.h:297
Gorgon::WindowManager::XdndDrop
Atom XdndDrop
Definition: X11.h:106
Gorgon::Input::DropTarget::SetOut
void SetOut(C_ *my, void(C_::*fn)(DragInfo &))
Sets out function.
Definition: DnD.h:231
Gorgon::WindowManager::XA_PRIMARY
Atom XA_PRIMARY
Definition: X11.h:97
Gorgon::TextData::SetText
void SetText(std::string value)
Changes the text in this data.
Definition: DataExchange.h:36
X11.h
Gorgon::Input::begindrag
void begindrag()
Definition: DnD.cpp:55
Gorgon::Input::Mouse::Out
@ Out
Definition: Mouse.h:19
Gorgon::Input::DragSource::ResetMove
void ResetMove()
Removes move handler, default is to continue the drag operation.
Definition: DnD.h:716
Gorgon::Input::DropTarget::SetHitCheck
void SetHitCheck(std::function< bool(DropTarget &, Geometry::Point)> fn)
Sets hit check function.
Definition: DnD.h:79
Gorgon::Window::SwitchToWMPointers
void SwitchToWMPointers()
Stops showing local pointers and makes window manager pointer visible.
Definition: Window.cpp:228
Gorgon::Input::DragInfo::operator[]
ExchangeData & operator[](int ind) const
Returns the data at the given index.
Definition: DnD.h:878
Gorgon::Input::DropTarget::SetOut
void SetOut(std::function< void(DropTarget &, DragInfo &)> fn)
Sets out function.
Definition: DnD.h:191
Gorgon::Input::DragSource::Drop
friend void Drop(Geometry::Point location)
Drop the current drag object.
Definition: DnD.cpp:179
Gorgon::Input::CancelDrag
void CancelDrag()
Cancel the current drag operation.
Definition: DnD.cpp:207
Gorgon::WindowManager::XdndEnter
Atom XdndEnter
Definition: X11.h:101
Gorgon::Input::Keyboard::Keycodes::Down
constexpr Key Down
Definition: Keyboard.h:65
Gorgon::Input::initdrag
void initdrag()
Definition: DnD.cpp:44