//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// using System.Collections.Generic; using BansheeEngine; namespace BansheeEditor { /** @addtogroup Inspector * @{ */ /// /// Displays GUI elements for all the inspectable fields in an object. /// public abstract class Inspector { public const short START_BACKGROUND_DEPTH = 50; /// /// Returns the main GUI layout for the inspector. /// protected GUILayoutY Layout { get { return layout; } } /// /// Returns the main GUI panel for the inspector. is a child of this panel. /// protected GUIPanel GUI { get { return mainPanel; } } /// /// Returns the object the inspector is currently displaying. /// protected object InspectedObject { get { return inspectedObject; } } /// /// A set of properties that the inspector can read/write. They will be persisted even after the inspector is closed /// and restored when it is re-opened. /// protected internal SerializableProperties Persistent { get { return persistent; } } private GUIPanel rootGUI; private GUIPanel mainPanel; private GUILayoutY layout; private object inspectedObject; private SerializableProperties persistent; /// /// Initializes the inspector. Must be called after construction. /// /// GUI panel to add the GUI elements to. /// Instance of the object whose fields to display GUI for. /// A set of properties that the inspector can read/write. They will be persisted even /// after the inspector is closed and restored when it is re-opened. internal virtual void Initialize(GUIPanel gui, object instance, SerializableProperties persistent) { rootGUI = gui; this.persistent = persistent; GUILayout contentLayoutX = gui.AddLayoutX(); contentLayoutX.AddSpace(5); GUILayout contentLayoutY = contentLayoutX.AddLayoutY(); contentLayoutY.AddSpace(5); GUIPanel contentPanel = contentLayoutY.AddPanel(); contentLayoutY.AddSpace(5); contentLayoutX.AddSpace(5); GUIPanel backgroundPanel = gui.AddPanel(START_BACKGROUND_DEPTH); GUITexture inspectorContentBg = new GUITexture(null, EditorStylesInternal.InspectorContentBg); backgroundPanel.AddElement(inspectorContentBg); mainPanel = contentPanel; layout = GUI.AddLayoutY(); inspectedObject = instance; Initialize(); Refresh(); } /// /// Hides or shows the inspector GUI elements. /// /// True to make the GUI elements visible. internal virtual void SetVisible(bool visible) { rootGUI.Active = visible; } /// /// Destroys all inspector GUI elements. /// internal void Destroy() { Layout.Destroy(); GUI.Destroy(); } /// /// Called when the inspector is first created. /// protected internal abstract void Initialize(); /// /// Checks if contents of the inspector have been modified, and updates them if needed. /// /// State representing was anything modified between two last calls to . protected internal abstract InspectableState Refresh(); } /** @} */ }