connections_dialog.h 4.4 KB

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