node_view.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**************************************************************************/
  2. /* node_view.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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. #pragma once
  31. #include "../snapshot_data.h"
  32. #include "shared_controls.h"
  33. #include "snapshot_view.h"
  34. class Tree;
  35. // When diffing in split view, we have two trees/filters
  36. // so this struct is used to group their properties together.
  37. struct NodeTreeElements {
  38. NodeTreeElements() {
  39. tree = nullptr;
  40. filter_bar = nullptr;
  41. root = nullptr;
  42. }
  43. Tree *tree = nullptr;
  44. TreeSortAndFilterBar *filter_bar = nullptr;
  45. VBoxContainer *root = nullptr;
  46. };
  47. class SnapshotNodeView : public SnapshotView {
  48. GDCLASS(SnapshotNodeView, SnapshotView);
  49. enum DiffGroup {
  50. DIFF_GROUP_NONE,
  51. DIFF_GROUP_ADDED,
  52. DIFF_GROUP_REMOVED
  53. };
  54. NodeTreeElements main_tree;
  55. NodeTreeElements diff_tree;
  56. Tree *active_tree = nullptr;
  57. PopupMenu *choose_object_menu = nullptr;
  58. bool combined_diff_view = true;
  59. HashMap<TreeItem *, LocalVector<SnapshotDataObject *>> tree_item_data;
  60. void _node_selected(Tree *p_tree_selected_from);
  61. void _notification(int p_what);
  62. NodeTreeElements _make_node_tree(const String &p_tree_name);
  63. void _apply_filters();
  64. void _refresh_icons();
  65. void _toggle_diff_mode(bool p_state);
  66. void _choose_object_pressed(int p_object_idx, bool p_confirm_override);
  67. void _show_choose_object_menu();
  68. void _add_snapshot_to_tree(Tree *p_tree, GameStateSnapshot *p_snapshot, DiffGroup p_diff_group = DIFF_GROUP_NONE);
  69. void _add_children_to_tree(TreeItem *p_parent_item, SnapshotDataObject *p_data, DiffGroup p_diff_group = DIFF_GROUP_NONE);
  70. TreeItem *_add_item_to_tree(Tree *p_tree, TreeItem *p_parent, const String &p_item_name, DiffGroup p_diff_group = DIFF_GROUP_NONE);
  71. TreeItem *_add_item_to_tree(Tree *p_tree, TreeItem *p_parent, SnapshotDataObject *p_data, DiffGroup p_diff_group = DIFF_GROUP_NONE);
  72. public:
  73. SnapshotNodeView();
  74. virtual void show_snapshot(GameStateSnapshot *p_data, GameStateSnapshot *p_diff_data) override;
  75. virtual void clear_snapshot() override;
  76. };