progress_dialog.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*************************************************************************/
  2. /* progress_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 PROGRESS_DIALOG_H
  30. #define PROGRESS_DIALOG_H
  31. #include "scene/gui/popup.h"
  32. #include "scene/gui/box_container.h"
  33. #include "scene/gui/progress_bar.h"
  34. #include "scene/gui/label.h"
  35. class BackgroundProgress : public HBoxContainer {
  36. OBJ_TYPE(BackgroundProgress,HBoxContainer);
  37. _THREAD_SAFE_CLASS_
  38. struct Task {
  39. HBoxContainer *hb;
  40. ProgressBar *progress;
  41. };
  42. Map<String,Task> tasks;
  43. Map<String,int> updates;
  44. void _update();
  45. protected:
  46. void _add_task(const String& p_task,const String& p_label, int p_steps);
  47. void _task_step(const String& p_task, int p_step=-1);
  48. void _end_task(const String& p_task);
  49. static void _bind_methods();
  50. public:
  51. void add_task(const String& p_task,const String& p_label, int p_steps);
  52. void task_step(const String& p_task, int p_step=-1);
  53. void end_task(const String& p_task);
  54. BackgroundProgress() {}
  55. };
  56. class ProgressDialog : public Popup {
  57. OBJ_TYPE( ProgressDialog, Popup );
  58. struct Task {
  59. String task;
  60. VBoxContainer *vb;
  61. ProgressBar *progress;
  62. Label *state;
  63. };
  64. Map<String,Task> tasks;
  65. VBoxContainer *main;
  66. void _popup();
  67. protected:
  68. void _notification(int p_what);
  69. public:
  70. void add_task(const String& p_task,const String& p_label, int p_steps);
  71. void task_step(const String& p_task,const String& p_state, int p_step=-1);
  72. void end_task(const String& p_task);
  73. ProgressDialog();
  74. };
  75. #endif // PROGRESS_DIALOG_H