| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- using BansheeEngine;
- namespace BansheeEditor
- {
- /** @addtogroup Windows
- * @{
- */
- /// <summary>
- /// Editor window that displays the scene hierarchy tree view, displaying all scene objects in the current scene.
- /// </summary>
- public class HierarchyWindow : EditorWindow, IGlobalShortcuts
- {
- private GUISceneTreeView treeView;
- /// <summary>
- /// Opens the hierarchy window.
- /// </summary>
- [MenuItem("Windows/Hierarchy", ButtonModifier.CtrlAlt, ButtonCode.H, 6000)]
- private static void OpenHierarchyWindow()
- {
- OpenWindow<HierarchyWindow>();
- }
- /// <inheritdoc/>
- protected override LocString GetDisplayName()
- {
- return new LocEdString("Hierarchy");
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnDeletePressed()
- {
- treeView.DeleteSelection();
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnRenamePressed()
- {
- treeView.RenameSelection();
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnDuplicatePressed()
- {
- treeView.DuplicateSelection();
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnCopyPressed()
- {
- treeView.CopySelection();
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnCutPressed()
- {
- treeView.CutSelection();
- }
- /// <inheritdoc/>
- void IGlobalShortcuts.OnPastePressed()
- {
- treeView.PasteToSelection();
- }
- private void OnInitialize()
- {
- GUIScrollArea scrollArea = new GUIScrollArea();
- GUI.AddElement(scrollArea);
- treeView = new GUISceneTreeView(GUIOption.FlexibleHeight(20), GUIOption.FlexibleWidth(20));
- scrollArea.Layout.AddElement(treeView);
- EditorVirtualInput.OnButtonUp += OnButtonUp;
- }
- private void OnEditorUpdate()
- {
- treeView.Update();
- }
- private void OnDestroy()
- {
- EditorVirtualInput.OnButtonUp -= OnButtonUp;
- }
- /// <summary>
- /// Triggered when the user presses a virtual button.
- /// </summary>
- /// <param name="btn">Button that was pressed.</param>
- /// <param name="deviceIdx">Index of the device it was pressed on. </param>
- private void OnButtonUp(VirtualButton btn, int deviceIdx)
- {
- if (!HasFocus)
- return;
- IGlobalShortcuts shortcuts = this;
- if (btn == EditorApplication.CopyKey)
- shortcuts.OnCopyPressed();
- else if (btn == EditorApplication.CutKey)
- shortcuts.OnCutPressed();
- else if (btn == EditorApplication.PasteKey)
- shortcuts.OnPastePressed();
- else if (btn == EditorApplication.DuplicateKey)
- shortcuts.OnDuplicatePressed();
- else if (btn == EditorApplication.RenameKey)
- shortcuts.OnRenamePressed();
- else if (btn == EditorApplication.DeleteKey)
- shortcuts.OnDeletePressed();
- else if(btn == EditorApplication.PasteKey)
- shortcuts.OnPastePressed();
- }
- }
- /** @} */
- }
|