Browse Source

Documentation

Marko Pintera 10 years ago
parent
commit
baa64d1449

+ 33 - 5
BansheeEditor/Include/BsEditorApplication.h

@@ -5,18 +5,33 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Primary editor class containing the editor entry point.
+	 */
 	class BS_ED_EXPORT EditorApplication : public Application
 	{
 	public:
 		EditorApplication(RenderSystemPlugin renderSystemPlugin);
 		virtual ~EditorApplication();
 
+		/**
+		 * @brief	Starts the editorn with the specified render system.
+		 */
 		static void startUp(RenderSystemPlugin renderSystemPlugin);
 
+		/**
+		 * @brief	Checks whether the editor currently has a project loaded.
+		 */
 		bool isProjectLoaded() const;
-		bool isGameViewFocused() const;
-		bool isSceneViewFocused() const;
+
+		/**
+		 * @brief	Returns the path to the currently loaded project.
+		 */
 		const Path& getProjectPath() const;
+
+		/**
+		 * @brief	Returns the name of the currently loaded project.
+		 */
 		const WString& getProjectName() const;
 
 		/**
@@ -34,6 +49,10 @@ namespace BansheeEngine
 		 */
 		Path getScriptAssemblyFolder() const override;
 
+		/**
+		 * @brief	Returns a set of serializable editor settings that contain
+		 *			every globally customizable editor property.
+		 */
 		EditorSettingsPtr getEditorSettings() const { return mEditorSettings; }
 
 	private:
@@ -42,15 +61,21 @@ namespace BansheeEngine
 		virtual void preUpdate() override;
 		virtual void postUpdate() override;
 
+		/**
+		 * @brief	Loads the previously saved editor widget layout from the default location.
+		 *			Can return null if no layout was previously saved.
+		 */
 		EditorWidgetLayoutPtr loadWidgetLayout();
-		void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
 
-		static void closeModalWindow(RenderWindowPtr window, HSceneObject sceneObject);
+		/**
+		 * @brief	Saves the provided widget layout at the default layout location.
+		 */
+		void saveWidgetLayout(const EditorWidgetLayoutPtr& layout);
 
 		/**
 		 * @copydoc	Application::getShaderIncludeHandler
 		 */
-		virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const;
+		virtual ShaderIncludeHandlerPtr getShaderIncludeHandler() const override;
 
 	private:
 		static const Path WIDGET_LAYOUT_PATH;
@@ -68,5 +93,8 @@ namespace BansheeEngine
 		HMesh mDbgMeshRef;
 	};
 
+	/**
+	 * @brief	Returns the globally accessible instance of editor application.
+	 */
 	BS_ED_EXPORT EditorApplication& gEditorApplication();
 }

+ 82 - 6
BansheeEditor/Include/BsEditorSettings.h

@@ -5,48 +5,126 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains various globally accessible editor preferences.
+	 */
 	class BS_ED_EXPORT EditorSettings
 	{
 	public:
 		EditorSettings();
 
+		/**
+		 * @brief	Checks is snapping enabled for move handles in scene view.
+		 */
 		bool getMoveHandleSnapActive() const { return mMoveSnapActive; }
+
+		/**
+		 * @brief	Checks is angle snapping enabled for rotate handles in scene view.
+		 */
 		bool getRotateHandleSnapActive() const { return mRotateSnapActive; }
 
+		/**
+		 * @brief	Gets the snap amount if move snapping is enabled. All move handles
+		 *			will move in multiples of this amount.
+		 */
 		float getMoveHandleSnap() const { return mMoveSnap; }
+
+		/**
+		 * @brief	Gets the snap amount if rotate snapping is enabled. All rotate handles
+		 *			will rotate in multiples of this amount.
+		 */
 		Degree getRotationHandleSnap() const { return mRotationSnap; }
 
+		/**
+		 * @brief	Returns the size that determines to total size of the scene view grid (its width and height).
+		 */
 		UINT32 getGridSize() const { return mGridSize; }
+
+		/**
+		 * @brief	Returns the distance between scene view grid lines.
+		 */
 		float getGridSpacing() const { return mGridAxisSpacing; }
-		UINT32 getGridMajorAxisSpacing() const { return mGridMajorAxisSpacing; }
-		UINT32 getGridAxisMarkerSpacing() const { return mGridAxisMarkerSpacing; }
 
+		/**
+		 * @brief	Gets the default size of all scene view handles.
+		 */
 		float getHandleSize() const { return mHandleSize; }
 
+		/**
+		 * @brief	Returns the currently active scene view tool (e.g. move, rotate, etc.)
+		 */
 		UINT32 getActiveSceneTool() const { return mActiveSceneTool; }
+
+		/**
+		 * @brief	Returns the currently active coordinate mode for scene view (e.g. global/local)
+		 */
 		UINT32 getActiveCoordinateMode() const { return mActiveCoordinateMode; }
+
+		/**
+		 * @brief	Returns the currently active pivot mode for scene view (e.g. pivot/center)
+		 */
 		UINT32 getActivePivotMode() const { return mActivePivotMode; }
 
+		/**
+		 * @brief	Enables/disables snapping for move handles in scene view.
+		 */
 		void setMoveHandleSnapActive(bool snapActive) { mMoveSnapActive = snapActive; markAsDirty(); }
+
+		/**
+		 * @brief	Enables/disables angle snapping for rotate handles in scene view.
+		 */
 		void setRotateHandleSnapActive(bool snapActive) { mRotateSnapActive = snapActive; markAsDirty(); }
 
+		/**
+		 * @brief	Sets the move snap amount. All move handles will move in multiples of this amount.
+		 */
 		void setMoveHandleSnap(float value) { mMoveSnap = value; markAsDirty(); }
+
+		/**
+		 * @brief	Sets the rotate snap amount. All rotate handles will rotate in multiples of this amount.
+		 */
 		void setRotationHandleSnap(Degree value) { mRotationSnap = value; markAsDirty(); }
 
+		/**
+		 * @brief	Sets the size that determines to total size of the scene view grid (its width and height).
+		 */
 		void setGridSize(UINT32 value) { mGridSize = value; markAsDirty(); }
+
+		/**
+		 * @brief	Sets the distance between scene view grid lines.
+		 */
 		void setGridSpacing(float value) { mGridAxisSpacing = value; markAsDirty(); }
-		void setGridMajorAxisSpacing(UINT32 value) { mGridMajorAxisSpacing = value; markAsDirty(); }
-		void setGridAxisMarkerSpacing(UINT32 value) { mGridMajorAxisSpacing = value; markAsDirty(); }
 
+		/**
+		 * @brief	Sets the default size of all scene view handles.
+		 */
 		void setHandleSize(float value) { mHandleSize = value; markAsDirty(); }
 
+		/**
+		 * @brief	Changes the currently active scene view tool (e.g. move, rotate, etc.)
+		 */
 		void setActiveSceneTool(UINT32 value) { mActiveSceneTool = value; markAsDirty(); }
+
+		/**
+		 * @brief	Changes the currently active coordinate mode for scene view (e.g. global/local)
+		 */
 		void setActiveCoordinateMode(UINT32 value) { mActiveCoordinateMode = value; markAsDirty(); }
+
+		/**
+		 * @brief	Changes the currently active pivot mode for scene view (e.g. pivot/center)
+		 */
 		void setActivePivotMode(UINT32 value) { mActivePivotMode = value; markAsDirty(); }
 
+		/**
+		 * @brief	Returns a hash value that may be used for checking if any internal settings were
+		 *			modified.
+		 */
 		UINT32 getHash() const { return mHash; }
 
 	private:
+		/**
+		 * @brief	Marks the object as dirty so that outside objects know when to update.
+		 */
 		void markAsDirty() const { mHash++; }
 
 		bool mMoveSnapActive;
@@ -57,8 +135,6 @@ namespace BansheeEngine
 
 		UINT32 mGridSize;
 		float mGridAxisSpacing;
-		UINT32 mGridMajorAxisSpacing;
-		UINT32 mGridAxisMarkerSpacing;
 
 		UINT32 mActiveSceneTool;
 		UINT32 mActiveCoordinateMode;

+ 16 - 0
BansheeEditor/Include/BsEditorTestSuite.h

@@ -60,14 +60,30 @@ namespace BansheeEngine
 		TestComponentB() {} // Serialization only
 	};
 
+	/**
+	 * @brief	Contains a set of unit tests for the editor.
+	 */
 	class EditorTestSuite : public TestSuite
 	{
 	public:
 		EditorTestSuite();
 
 	private:
+		/**
+		 * @brief	Tests SceneObject record undo/redo operation.
+		 */
 		void SceneObjectRecord_UndoRedo();
+
+		/**
+		 * @brief	Tests native diff by modifiying an object, generating a diff
+		 *			and re-applying the modifications.
+		 */
 		void BinaryDiff();
+
+		/**
+		 * @brief	Tests prefab diff by modifiying a prefab, generating a diff
+		 *			and re-applying the modifications.
+		 */
 		void TestPrefabDiff();
 	};
 }

+ 21 - 0
BansheeEditor/Include/BsEditorUtility.h

@@ -5,13 +5,34 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains miscelanous helper methods.
+	 */
 	class BS_ED_EXPORT EditorUtility
 	{
 	public:
+		/**
+		 * @brief	Calculates world space bounds of the specified scene object. This will
+		 *			consider components with bounds like Renderable.
+		 */
 		static AABox calculateBounds(const HSceneObject& object);
+
+		/**
+		 * @brief	Calculates world space bounds of the specified scene objects. This will
+		 *			consider components with bounds like Renderable.
+		 */
 		static AABox calculateBounds(const Vector<HSceneObject>& objects);
 
 	private:
+		/**
+		 * @brief	Retrieves all components containing meshes on the specified object and outputs
+		 *			their bounds.
+		 *
+		 * @param	object	Object to calculate bounds for.
+		 * @param	bounds	Output bounds, if successful.
+		 *
+		 * @returns true if a mesh component was found, otherwise false (bounds will not be updated).
+		 */
 		static bool calculateMeshBounds(const HSceneObject& object, AABox& bounds);
 	};
 }

+ 151 - 9
BansheeEditor/Include/BsEditorWidget.h

@@ -7,50 +7,179 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Editor widget represents a single "window" in the editor. It may be dragged,
+	 *			docked and can share space with multiple other widgets by using tabs.
+	 *
+	 * Each widget has its own position, size, GUI and update method.
+	 * Widget is always docked inside an EditorWidgetContainer unless it's being dragged
+	 * and is not visible.
+	 */
 	class BS_ED_EXPORT EditorWidgetBase
 	{
 	public:
+		/**
+		 * @brief	Gets a unique name for this widget. This name will be used for referencing
+		 *			the widget by other systems.
+		 */
 		const String& getName() const { return mName; }
+
+		/**
+		 * @brief	Gets the display name for the widget. This is what editor users will see
+		 *			in the widget title bar.
+		 */
 		const HString& getDisplayName() const { return mDisplayName; }
 
+		/**
+		 * @brief	Returns the X position of the widget inside of its container.
+		 */
 		INT32 getX() const { return mX; }
+
+		/**
+		 * @brief	Returns the Y position of the widget inside of its container.
+		 */
 		INT32 getY() const { return mY; }
+
+		/**
+		 * @brief	Returns the width of the widget in pixels.
+		 */
 		UINT32 getWidth() const { return mWidth; }
+
+		/**
+		 * @brief	Returns the height of the widget in pixels.
+		 */
 		UINT32 getHeight() const { return mHeight; }
+
+		/**
+		 * @brief	Returns the bounds of the widget in pixels, relative
+		 *			to its parent container.
+		 */
 		Rect2I getBounds() const { return Rect2I(mX, mY, mWidth, mHeight); }
+
+		/**
+		 * @brief	Checks if the widget has focus (usually means user clicked on it last).
+		 */
 		bool hasFocus() const { return mHasFocus; }
+
+		/**
+		 * @brief	Gets the parent editor window this widget is docked in.
+		 */
 		EditorWindowBase* getParentWindow() const;
 
+		/**
+		 * @brief	Changes the size of the widget (and its internal GUI panel).
+		 * 
+		 * @note	Internal method.
+		 */
 		void _setSize(UINT32 width, UINT32 height);
+
+		/**
+		 * @brief	Changes the position of the widget (and its internal GUI panel), 
+		 *			relative to its parent container.
+		 * 
+		 * @note	Internal method.
+		 */
 		void _setPosition(INT32 x, INT32 y);
+
+		/**
+		 * @brief	Changes the parent container of the widget (e.g. when re-docking or moving
+		 *			a widget to another window). Parent can be null (e.g. when widget is in the
+		 *			process of dragging and not visible).
+		 *
+		 * @note	Internal method.
+		 */
 		void _changeParent(EditorWidgetContainer* parent);
+
+		/**
+		 * @brief	Sets or removes focus for this widget.
+		 *
+		 * @note	Internal method.
+		 */
 		void _setHasFocus(bool focus);
+
+		/**
+		 * @brief	Returns the parent widget container. Can be null (e.g. when widget is in the
+		 *			process of dragging and not visible).
+		 *
+		 * @note	Internal method.
+		 */
 		EditorWidgetContainer* _getParent() const { return mParent; }
 
+		/**
+		 * @brief	Converts screen coordinates to coordinates relative to the
+		 *			widget.
+		 */
 		Vector2I screenToWidgetPos(const Vector2I& screenPos) const;
+
+		/**
+		 * @brief	Converts widget relative coordinates to screen coordiantes.
+		 */
 		Vector2I widgetToScreenPos(const Vector2I& widgetPos) const;
 
+		/**
+		 * @brief	Disables the widget making its GUI contents not visible. The widget
+		 *			remains docked in its container.
+		 *
+		 * @note	Internal method.
+		 */
 		void _disable();
+
+		/**
+		 * @brief	Enables the widget making its previously hidden GUI contents visible.
+		 *
+		 * @note	Internal method.
+		 */
 		void _enable();
 
+		/**
+		 * @brief	Closes the widget, undocking it from its container and freeing any resources
+		 *			related to it.
+		 */
 		void close();
 
+		/**
+		 * @brief	Called once per frame.
+		 *
+		 * @note	Internal method.
+		 */
 		virtual void update() { }
 
-		Event<void(UINT32, UINT32)> onResized;
-		Event<void(INT32, INT32)> onMoved;
-		Event<void(EditorWidgetContainer*)> onParentChanged;
-		Event<void(bool)> onFocusChanged;
+		Event<void(UINT32, UINT32)> onResized; /**< Triggered whenever widget size changes. */
+		Event<void(INT32, INT32)> onMoved; /**< Triggered whenever widget position changes. */
+		Event<void(EditorWidgetContainer*)> onParentChanged; /**< Triggered whenever widget parent container changes. */
+		Event<void(bool)> onFocusChanged; /**< Triggered whenever widget receives or loses focus. */
 	protected:
 		friend class EditorWidgetManager;
 
 		EditorWidgetBase(const HString& displayName, const String& name, EditorWidgetContainer& parentContainer);
 		virtual ~EditorWidgetBase();
 
+		/**
+		 * @brief	Triggered whenever widget position changes.
+		 */
 		virtual void doOnMoved(INT32 x, INT32 y);
+
+		/**
+		 * @brief	Triggered whenever widget size changes.
+		 */
 		virtual void doOnResized(UINT32 width, UINT32 height);
+
+		/**
+		 * @brief	Triggered whenever widget parent container changes.
+		 */
 		virtual void doOnParentChanged();
 
+		/**
+		 * @brief	Returns the parent GUI widget. Before calling this you must ensure
+		 *			the widget has a container parent otherwise this method will fail.
+		 */
+		GUIWidget& getParentWidget() const;
+
+		/**
+		 * @brief	Frees widget resources and deletes the instance.
+		 */
+		static void destroy(EditorWidgetBase* widget);
+
 		String mName;
 		HString mDisplayName;
 		EditorWidgetContainer* mParent;
@@ -58,12 +187,13 @@ namespace BansheeEngine
 		UINT32 mWidth, mHeight;
 		GUIPanel* mContent;
 		bool mHasFocus;
-
-		GUIWidget& getParentWidget() const;
-
-		static void destroy(EditorWidgetBase* widget);
 	};
 
+	/**
+	 * @brief	Helper class that registers a widget creation callback with the widget manager.
+	 *			The creation callback allows the runtime to open widgets just by their name
+	 *			without knowing the actual type.
+	 */
 	template<typename Type>
 	struct RegisterWidgetOnStart
 	{
@@ -73,18 +203,30 @@ namespace BansheeEngine
 			EditorWidgetManager::preRegisterWidget(Type::getTypeName(), &create);
 		}
 
+		/**
+		 * @brief	Creates a new widget of a specific type and adds it to the provided container.
+		 */
 		static EditorWidgetBase* create(EditorWidgetContainer& parentContainer)
 		{
 			return bs_new<Type>(EditorWidget<Type>::ConstructPrivately(), parentContainer);
 		}
 
+		/**
+		 * @brief	Helper method to make sure this type doesn't get optimized out.
+		 */
 		void makeSureIAmInstantiated() { }
 	};
 
+	/**
+	 * @brief	Editor widget template class that widgets can inherit from. Ensures that
+	 *			all widget implementations are automatically registered with the widget manager.
+	 *
+	 * @see		EditorWidgetBase
+	 */
 	template <class Type>
 	class EditorWidget : public EditorWidgetBase
 	{
-		static RegisterWidgetOnStart<Type> RegisterOnStart;
+		static volatile RegisterWidgetOnStart<Type> RegisterOnStart;
 
 	protected:
 		friend struct RegisterWidgetOnStart<Type>;

+ 0 - 2
BansheeEditor/Include/BsSceneGrid.h

@@ -15,8 +15,6 @@ namespace BansheeEngine
 		void setOrigin(const Vector3& origin);
 		void setSize(UINT32 size);
 		void setSpacing(float spacing);
-		void setMajorAxisSpacing(UINT32 spacing);
-		void setAxisMarkerSpacing(UINT32 spacing);
 		void setSettings(const EditorSettingsPtr& settings);
 
 		void render(const CameraHandlerPtr& camera, DrawList& drawList);

+ 0 - 16
BansheeEditor/Source/BsEditorApplication.cpp

@@ -236,12 +236,6 @@ namespace BansheeEngine
 		CoreApplication::startUp<EditorApplication>(renderSystemPlugin);
 	}
 
-	void EditorApplication::closeModalWindow(RenderWindowPtr window, HSceneObject sceneObject)
-	{
-		//sceneObject->destroy();
-		window->destroy();
-	}
-
 	void EditorApplication::preUpdate()
 	{
 		Application::preUpdate();
@@ -263,16 +257,6 @@ namespace BansheeEngine
 		return true; // TODO - DEBUG ONLY
 	}
 
-	bool EditorApplication::isGameViewFocused() const
-	{
-		return false; // TODO
-	}
-
-	bool EditorApplication::isSceneViewFocused() const
-	{
-		return true; // TODO
-	}
-
 	const Path& EditorApplication::getProjectPath() const
 	{
 		static Path dummyProjectPath = L"D:\\DummyBansheeProject\\";

+ 2 - 2
BansheeEditor/Source/BsEditorSettings.cpp

@@ -4,7 +4,7 @@ namespace BansheeEngine
 {
 	EditorSettings::EditorSettings()
 		:mMoveSnapActive(false), mRotateSnapActive(false), mMoveSnap(0.1f), mRotationSnap(20.0f), 
-		mGridSize(256), mGridAxisSpacing(1.0f), mGridMajorAxisSpacing(10), mGridAxisMarkerSpacing(25), 
-		mHandleSize(0.10f), mHash(0), mActiveSceneTool(1 /* Move */), mActiveCoordinateMode(0), mActivePivotMode(0)
+		mGridSize(256), mGridAxisSpacing(1.0f), mHandleSize(0.10f), mHash(0), mActiveSceneTool(1 /* Move */), 
+		mActiveCoordinateMode(0), mActivePivotMode(0)
 	{ }
 }

+ 0 - 22
BansheeEditor/Source/BsSceneGrid.cpp

@@ -69,26 +69,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void SceneGrid::setMajorAxisSpacing(UINT32 spacing)
-	{
-		// TODO - Ignored with the current shader
-		if (mMajorAxisSpacing != spacing)
-		{
-			mMajorAxisSpacing = spacing;
-			updateGridMesh();
-		}
-	}
-
-	void SceneGrid::setAxisMarkerSpacing(UINT32 spacing)
-	{
-		// TODO - Ignored with the current shader
-		if (mAxisMarkerSpacing != spacing)
-		{
-			mAxisMarkerSpacing = spacing;
-			updateGridMesh();
-		}
-	}
-
 	void SceneGrid::setSettings(const EditorSettingsPtr& settings)
 	{
 		mSettings = settings;
@@ -126,8 +106,6 @@ namespace BansheeEngine
 	{
 		setSize(mSettings->getGridSize());
 		setSpacing(mSettings->getGridSpacing());
-		setMajorAxisSpacing(mSettings->getGridMajorAxisSpacing());
-		setAxisMarkerSpacing(mSettings->getGridAxisMarkerSpacing());
 
 		mSettingsHash = mSettings->getHash();
 	}

+ 0 - 1
TODO.txt

@@ -72,7 +72,6 @@ There's a large hang when doing certain operations like selecting a mesh in scen
 Crash on shutdown in mono_gchandle_free
 When selecting an gizmo icon the selection seems delayed and its gizmos flash for a frame before hiding (Can't reproduce atm but I saw it)
 ProjectLibrary seems to import some files on every start-up
-Selection rendering seems to be delayed 1 frame (noticeable when rotating/moving)
 
 SceneTreeView
  - Hook up ping effect so it triggers when I select a resource or sceneobject