connections_dialog.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*************************************************************************/
  2. /* connections_dialog.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef CONNECTIONS_DIALOG_H
  30. #define CONNECTIONS_DIALOG_H
  31. #include "scene/gui/popup.h"
  32. #include "scene/gui/button.h"
  33. #include "scene/gui/check_button.h"
  34. #include "scene/gui/tree.h"
  35. #include "scene/gui/dialogs.h"
  36. #include "scene/gui/menu_button.h"
  37. #include "scene/gui/line_edit.h"
  38. #include "tools/editor/scene_tree_editor.h"
  39. #include "tools/editor/property_editor.h"
  40. #include "undo_redo.h"
  41. /**
  42. @author Juan Linietsky <[email protected]>
  43. */
  44. class ConnectDialogBinds;
  45. class ConnectDialog : public ConfirmationDialog {
  46. OBJ_TYPE( ConnectDialog, ConfirmationDialog );
  47. ConfirmationDialog *error;
  48. LineEdit *dst_path;
  49. LineEdit *dst_method;
  50. SceneTreeEditor *tree;
  51. //MenuButton *dst_method_list;
  52. OptionButton *type_list;
  53. CheckButton *deferred;
  54. CheckButton *make_callback;
  55. PropertyEditor *bind_editor;
  56. Node *node;
  57. ConnectDialogBinds *cdbinds;
  58. void ok_pressed();
  59. void _cancel_pressed();
  60. void _tree_node_selected();
  61. void _dst_method_list_selected(int p_idx);
  62. void _add_bind();
  63. void _remove_bind();
  64. protected:
  65. void _notification(int p_what);
  66. static void _bind_methods();
  67. public:
  68. bool get_make_callback() { return !make_callback->is_hidden() && make_callback->is_pressed(); }
  69. NodePath get_dst_path() const;
  70. StringName get_dst_method() const;
  71. bool get_deferred() const;
  72. Vector<Variant> get_binds() const;
  73. void set_dst_method(const StringName& p_method);
  74. void set_dst_node(Node* p_node);
  75. // Button *get_ok() { return ok; }
  76. // Button *get_cancel() { return cancel; }
  77. void edit(Node *p_node);
  78. ConnectDialog();
  79. ~ConnectDialog();
  80. };
  81. class ConnectionsDialog : public ConfirmationDialog {
  82. OBJ_TYPE( ConnectionsDialog , ConfirmationDialog );
  83. EditorNode *editor;
  84. Node *node;
  85. Tree *tree;
  86. ConfirmationDialog *remove_confirm;
  87. ConnectDialog *connect_dialog;
  88. void update_tree();
  89. void _close();
  90. void _connect();
  91. void _something_selected();
  92. UndoRedo *undo_redo;
  93. protected:
  94. virtual void ok_pressed();
  95. void _notification(int p_what);
  96. static void _bind_methods();
  97. public:
  98. void set_undoredo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
  99. void set_node(Node* p_node);
  100. String get_selected_type();
  101. ConnectionsDialog(EditorNode *p_editor=NULL);
  102. ~ConnectionsDialog();
  103. };
  104. #endif