Path: blob/master/modules/objectdb_profiler/editor/data_viewers/snapshot_view.cpp
11325 views
/**************************************************************************/1/* snapshot_view.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */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/**************************************************************************/2930#include "snapshot_view.h"3132#include "scene/gui/tree.h"3334void SnapshotView::clear_snapshot() {35snapshot_data = nullptr;36diff_data = nullptr;37for (int i = 0; i < get_child_count(); i++) {38get_child(i)->queue_free();39}40}4142void SnapshotView::show_snapshot(GameStateSnapshot *p_data, GameStateSnapshot *p_diff_data) {43clear_snapshot();44snapshot_data = p_data;45diff_data = p_diff_data;46}4748bool SnapshotView::is_showing_snapshot(GameStateSnapshot *p_data, GameStateSnapshot *p_diff_data) {49return p_data == snapshot_data && p_diff_data == diff_data;50}5152Vector<TreeItem *> SnapshotView::_get_children_recursive(Tree *p_tree) {53Vector<TreeItem *> found_items;54List<TreeItem *> items_to_check;55if (p_tree && p_tree->get_root()) {56items_to_check.push_back(p_tree->get_root());57}58while (items_to_check.size() > 0) {59TreeItem *to_check = items_to_check.front()->get();60items_to_check.pop_front();61found_items.push_back(to_check);62for (int i = 0; i < to_check->get_child_count(); i++) {63items_to_check.push_back(to_check->get_child(i));64}65}66return found_items;67}686970