create_dialog.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*************************************************************************/
  2. /* create_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 CREATE_DIALOG_H
  30. #define CREATE_DIALOG_H
  31. #include "scene/gui/dialogs.h"
  32. #include "scene/gui/button.h"
  33. #include "scene/gui/tree.h"
  34. #include "scene/gui/line_edit.h"
  35. #include "scene/gui/label.h"
  36. /**
  37. @author Juan Linietsky <[email protected]>
  38. */
  39. #if 1
  40. class CreateDialog : public ConfirmationDialog {
  41. OBJ_TYPE(CreateDialog,ConfirmationDialog )
  42. LineEdit *search_box;
  43. Tree *search_options;
  44. String base_type;
  45. void _update_search();
  46. void _sbox_input(const InputEvent& p_ie);
  47. void _confirmed();
  48. void _text_changed(const String& p_newtext);
  49. void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root,TreeItem **to_select);
  50. protected:
  51. void _notification(int p_what);
  52. static void _bind_methods();
  53. public:
  54. Object *instance_selected();
  55. void set_base_type(const String& p_base);
  56. String get_base_type() const;
  57. void popup(bool p_dontclear);
  58. CreateDialog();
  59. };
  60. #else
  61. //old create dialog, disabled
  62. class CreateDialog : public ConfirmationDialog {
  63. OBJ_TYPE( CreateDialog, ConfirmationDialog );
  64. Tree *tree;
  65. Button *create;
  66. Button *cancel;
  67. LineEdit *filter;
  68. void update_tree();
  69. void _create();
  70. void _cancel();
  71. void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem
  72. *p_root);
  73. String base;
  74. void _text_changed(String p_text);
  75. virtual void _post_popup() { tree->grab_focus();}
  76. protected:
  77. static void _bind_methods();
  78. void _notification(int p_what);
  79. public:
  80. Object *instance_selected();
  81. void set_base_type(const String& p_base);
  82. String get_base_type() const;
  83. CreateDialog();
  84. ~CreateDialog();
  85. };
  86. #endif
  87. #endif