Browse Source

More documentation

Marko Pintera 11 years ago
parent
commit
742e37fce9

+ 10 - 10
BansheeEngine/Include/BsGUIButton.h

@@ -25,9 +25,9 @@ namespace BansheeEngine
 		 * Creates a new button with the specified label.
 		 *
 		 * @param	text		Label to display on the button.
-		 * @param	stylename	Optional style to use for the button. Style will be retrieved
-		 *						from GUISkin of the GUIWidget the element is used on. If not specified
-		 *						default button style is used.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default button style is used.
 		 */
 		static GUIButton* create(const HString& text, const String& styleName = StringUtil::BLANK);
 
@@ -37,7 +37,7 @@ namespace BansheeEngine
 		 * @param	text			Label to display on the button.
 		 * @param	layoutOptions	Options that allows you to control how is the element positioned in
 		 *							GUI layout. This will override any similar options set by style.
-		 * @param	stylename		Optional style to use for the button. Style will be retrieved
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
 		 *							from GUISkin of the GUIWidget the element is used on. If not specified
 		 *							default button style is used.
 		 */
@@ -47,9 +47,9 @@ namespace BansheeEngine
 		 * Creates a new button with the specified label.
 		 *
 		 * @param	content		Content to display on a button. May include a label, image and a tooltip.
-		 * @param	stylename	Optional style to use for the button. Style will be retrieved
-		 *						from GUISkin of the GUIWidget the element is used on. If not specified
-		 *						default button style is used.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default button style is used.
 		 */
 		static GUIButton* create(const GUIContent& content, const String& styleName = StringUtil::BLANK);
 
@@ -59,9 +59,9 @@ namespace BansheeEngine
 		 * @param	content		Content to display on a button. May include a label, image and a tooltip.
 		 * @param	layoutOptions	Options that allows you to control how is the element positioned in
 		 *							GUI layout. This will override any similar options set by style.
-		 * @param	stylename	Optional style to use for the button. Style will be retrieved
-		 *						from GUISkin of the GUIWidget the element is used on. If not specified
-		 *						default button style is used.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default button style is used.
 		 */
 		static GUIButton* create(const GUIContent& content, const GUIOptions& layoutOptions, const String& styleName = StringUtil::BLANK);
 

+ 35 - 26
BansheeEngine/Include/BsGUIElementStyle.h

@@ -8,13 +8,22 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Possible positions used for positioning content image within a GUI element.
+	 */
 	enum class GUIImagePosition
 	{
 		Left, Right
 	};
 
+	/**
+	 * @brief	GUI element style that determines GUI element look depending on its active state
+	 */
 	struct BS_EXPORT GUIElementStyle
 	{
+		/**
+		 * @brief	Specific texture and text color used in a particular GUI element style
+		 */
 		struct BS_EXPORT GUIElementStateStyle
 		{
 			HSpriteTexture texture;
@@ -30,34 +39,34 @@ namespace BansheeEngine
 
 		}
 
-		HFont font;
-		UINT32 fontSize;
-		TextHorzAlign textHorzAlign;
-		TextVertAlign textVertAlign;
-		GUIImagePosition imagePosition;
-		bool wordWrap;
+		HFont font; /**< Font to use for all text within the GUI element. */
+		UINT32 fontSize; /**< Font size to use for all text within the GUI element. */
+		TextHorzAlign textHorzAlign; /**< Horizontal alignment of text within the GUI element. */
+		TextVertAlign textVertAlign; /**< Vertical alignment of text within the GUI element. */
+		GUIImagePosition imagePosition; /**< Position of content image relative to text. */
+		bool wordWrap; /**< Should the text word wrap if it doesn't fit. */
 
-		GUIElementStateStyle normal;
-		GUIElementStateStyle hover;
-		GUIElementStateStyle active;
-		GUIElementStateStyle focused;
+		GUIElementStateStyle normal; /**< Style used when element is in normal state and off. */
+		GUIElementStateStyle hover; /**< Style used when element is in hover state and off. */
+		GUIElementStateStyle active; /**< Style used when element is in active state and off. */
+		GUIElementStateStyle focused; /**< Style used when element is in focused state and off. */
 
 		// For controls that can be turned on-off
-		GUIElementStateStyle normalOn;
-		GUIElementStateStyle hoverOn;
-		GUIElementStateStyle activeOn;
-		GUIElementStateStyle focusedOn;
-
-		RectOffset border; // Determines how the element is scaled (using the typical Scale9Grid approach)
-		RectOffset margins; // Determines offset from the background graphics to the content. Input uses bounds offset by this value.
-		RectOffset contentOffset; // Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets.
-		RectOffset padding; // Determines extra distance between this and other elements in a layout
-
-		UINT32 width;
-		UINT32 height;
-		UINT32 minWidth, maxWidth;
-		UINT32 minHeight, maxHeight;
-		bool fixedWidth;
-		bool fixedHeight;
+		GUIElementStateStyle normalOn; /**< Style used when element is in normal state and on. */
+		GUIElementStateStyle hoverOn; /**< Style used when element is in hover state and on. */
+		GUIElementStateStyle activeOn; /**< Style used when element is in active state and on. */
+		GUIElementStateStyle focusedOn; /**< Style used when element is in focused state and on. */
+
+		RectOffset border; /**< Determines how the element is scaled (using the typical Scale9Grid approach). */
+		RectOffset margins; /**< Determines offset from the background graphics to the content. Input uses bounds offset by this value. */
+		RectOffset contentOffset; /**< Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets. */
+		RectOffset padding; /**< Determines extra distance between this and other elements in a layout. */
+
+		UINT32 width; /** Wanted width of the GUI element in pixels. Only used if fixedWidth is enabled. */
+		UINT32 height; /** Wanted height of the GUI element in pixels. Only used if fixedHeight is enabled. */
+		UINT32 minWidth, maxWidth; /**< Minimum and maximum width allowed for this object. Used by the layout only when exact width is not specified. */
+		UINT32 minHeight, maxHeight; /**< Minimum and maximum height allowed for this object. Used by the layout only when exact height is not specified. */
+		bool fixedWidth; /**< If width is fixed, layout will not attempt to resize the element depending on available size. */
+		bool fixedHeight; /**< If height is fixed, layout will not attempt to resize the element depending on available size. */
 	};
 }

+ 26 - 0
BansheeEngine/Include/BsGUIHelper.h

@@ -6,11 +6,37 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Contains various helper methods used by GUI.
+	 */
 	class BS_EXPORT GUIHelper
 	{
 	public:
+		/**
+		 * @brief	Calculates optimal content size by returning the nearest valid size to the provided value.
+		 *
+		 * @param	contentSize		Wanted content size. This will be limited by minimal constraints of the style and layout options.
+		 * @param	style			Style to use for determining size constraints.
+		 * @param	layoutOptions	Layout options to use for determining size constraints.
+		 */
 		static Vector2I calcOptimalContentsSize(const Vector2I& contentSize, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
+
+		/**
+		 * @brief	Calculates optimal content size for the provided content using the provided style and layout options for constraints.
+		 *
+		 * @param	content			Content to calculate size for.
+		 * @param	style			Style to use for determining size constraints.
+		 * @param	layoutOptions	Layout options to use for determining size constraints.
+		 */
 		static Vector2I calcOptimalContentsSize(const GUIContent& content, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
+
+		/**
+		 * @brief	Calculates optimal content size for the provided text using the provided style and layout options for constraints.
+		 *
+		 * @param	text			Text to calculate size for.
+		 * @param	style			Style to use for determining size constraints.
+		 * @param	layoutOptions	Layout options to use for determining size constraints.
+		 */
 		static Vector2I calcOptimalContentsSize(const WString& text, const GUIElementStyle& style, const GUILayoutOptions& layoutOptions);
 	};
 }

+ 214 - 25
BansheeEngine/Include/BsGUIInputBox.h

@@ -8,8 +8,15 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Input box is a GUI element at accepts Unicode textual input. It can be
+	 *			single or multi-line and handles various types of text manipulation.
+	 */
 	class BS_EXPORT GUIInputBox : public GUIElement
 	{
+		/**
+		 * @brief	Possible visual states the input box can be in.
+		 */
 		enum class State
 		{
 			Normal,
@@ -18,23 +25,85 @@ namespace BansheeEngine
 		};
 
 	public:
+		/**
+		 * Returns type name of the GUI element used for finding GUI element styles. 
+		 */
 		static const String& getGUITypeName();
 
+		/**
+		 * Creates a new input box.
+		 *
+		 * @param	multiline		If true the input box can be of arbitrary height and will accept multiple lines of text.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default style for this element is used.
+		 */
 		static GUIInputBox* create(bool multiline = false, const String& styleName = StringUtil::BLANK);
+
+		/**
+		 * Creates a new input box.
+		 *
+		 * @param	multiline		If true the input box can be of arbitrary height and will accept multiple lines of text.
+		 * @param	layoutOptions	Options that allows you to control how is the element positioned in
+		 *							GUI layout. This will override any similar options set by style.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default button style is used.
+		 */
 		static GUIInputBox* create(bool multiline, const GUIOptions& layoutOptions, const String& styleName = StringUtil::BLANK);
+
+
+		/**
+		 * Creates a new single-line input box.
+		 *
+		 * @param	layoutOptions	Options that allows you to control how is the element positioned in
+		 *							GUI layout. This will override any similar options set by style.
+		 * @param	styleName		Optional style to use for the element. Style will be retrieved
+		 *							from GUISkin of the GUIWidget the element is used on. If not specified
+		 *							default button style is used.
+		 */
 		static GUIInputBox* create(const GUIOptions& layoutOptions, const String& styleName = StringUtil::BLANK);
 
+		/**
+		 * @brief	Returns the text currently entered in the input box.
+		 */
 		const WString& getText() const { return mText; }
+
+		/**
+		 * @brief	Sets the text inside the input box. This will replace any current text.
+		 */
 		void setText(const WString& text);
 
+		/**
+		 * @brief	Sets an optional filter that can control what is allowed to be entered into the
+		 *			input box. Filter should return true if the provided string is valid and false otherwise.
+		 *			Set the filter to null to deactivate filtering.
+		 */
 		void setFilter(std::function<bool(const WString&)> filter) { mFilter = filter; }
 
+		/**
+		 * @copydoc	GUIElement::getElementType
+		 */
 		virtual ElementType getElementType() const { return ElementType::InputBox; }
 
+		/**
+		 * @copydoc	GUIElement::_getOptimalSize
+		 */
 		virtual Vector2I _getOptimalSize() const;
 
+		/**
+		 * @brief	Triggered whenever input text has changed.
+		 */
 		Event<void(const WString&)> onValueChanged;
+
+		/**
+		 * @brief	Triggered whenever the input box receives focus.
+		 */
 		Event<void()> onFocusGained;
+
+		/**
+		 * @brief	Triggered whenever the input box loses focus.
+		 */
 		Event<void()> onFocusLost;
 	protected:
 		GUIInputBox(const String& styleName, const GUILayoutOptions& layoutOptions, bool multiline);
@@ -71,70 +140,190 @@ namespace BansheeEngine
 		 */
 		virtual void updateClippedBounds();
 
+		/**
+		 * @copydoc	GUIElement::mouseEvent
+		 */
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
+
+		/**
+		 * @copydoc	GUIElement::textInputEvent
+		 */
 		virtual bool textInputEvent(const GUITextInputEvent& ev);
+
+		/**
+		 * @copydoc	GUIElement::commandEvent
+		 */
 		virtual bool commandEvent(const GUICommandEvent& ev);
+
+		/**
+		 * @copydoc	GUIElement::virtualButtonEvent
+		 */
 		virtual bool virtualButtonEvent(const GUIVirtualButtonEvent& ev);
 
+		/**
+		 * @brief	Returns how much to offset text due to scrolling.
+		 *
+		 * @note	This is used when text is larger than the input box itself. As the
+		 *			caret moves the text will scroll so that the caret remains visible, and
+		 *			how much scroll is applied is determined by this value.
+		 */
 		virtual Vector2I _getTextInputOffset() const;
+
+		/**
+		 * @brief	Returns rectangle in which the text can be displayed, in local
+		 *			coordinates (i.e. text will start at 0, 0).
+		 */
 		virtual RectI _getTextInputRect() const;
 
+		/**
+		 * @copydoc	GUIElement::_getRenderElementDepth
+		 */
 		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc	GUIElement::_hasCustomCursor
+		 */
 		virtual bool _hasCustomCursor(const Vector2I position, CursorType& type) const;
 
+		/**
+		 * @copydoc	GUIElement::getContextMenu
+		 */
 		virtual GUIContextMenu* getContextMenu() const;
 	private:
-		static VirtualButton mCopyVB;
-		static VirtualButton mPasteVB;
-		static VirtualButton mCutVB;
-		static VirtualButton mSelectAllVB;
-
-		// Sprites
-		ImageSprite* mImageSprite;
-		TextSprite* mTextSprite;
-		bool mIsMultiline;
-		Vector2I mTextOffset;
-		bool mHasFocus;
-		bool mIsMouseOver;
-		State mState;
-
-		IMAGE_SPRITE_DESC mImageDesc;
-		WString mText;
-		std::function<bool(const WString&)> mFilter;
-
-		bool mCaretShown;
-		bool mSelectionShown;
-		bool mDragInProgress;
-
+		/**
+		 * @brief	Retrieves a sprite from a render element index, and a local render element index
+		 *			that represents render element within the returned sprite.
+		 */
 		Sprite* renderElemToSprite(UINT32 renderElemIdx, UINT32& localRenderElemIdx) const;
+
+		/**
+		 * @brief	Returns offset at which is the element with the provided render element index.
+		 *			Offset is relative to parent widget.
+		 */
 		Vector2I renderElemToOffset(UINT32 renderElemIdx) const;
+
+		/**
+		 * @brief	Returns a clip rectangle that can be used for clipping the render element
+		 *			with the provided index. Rectangle is in local coordiantes relative to
+		 *			element origin.
+		 */
 		RectI renderElemToClipRect(UINT32 renderElemIdx) const;
 
+		/**
+		 * @brief	Inserts a new string into the current text at the specified index.
+		 */
 		void insertString(UINT32 charIdx, const WString& string);
+
+		/**
+		 * @brief	Inserts a new character into the current text at the specified index.
+		 */
 		void insertChar(UINT32 charIdx, UINT32 charCode);
+
+		/**
+		 * @brief	Erases a single character at the specified index.
+		 */
 		void eraseChar(UINT32 charIdx);
+
+		/**
+		 * @brief	Deletes text that is currently selected.
+		 */
 		void deleteSelectedText();
+
+		/**
+		 * @brief	Returns currently selected text.
+		 */
 		WString getSelectedText();
 
+		/**
+		 * @brief	Shows the input caret. You must position the caret manually after showing it.
+		 */
 		void showCaret();
+
+		/**
+		 * @brief	Hides the input caret.
+		 */
 		void hideCaret();
 
+		/**
+		 * @brief	Shows selection with the specified anchor position. You must
+		 *			position selection start and end before selection will actually render.
+		 *			Anchor position determines selection behavior as the user moves the selection
+		 *			with the keyboard.
+		 */
 		void showSelection(UINT32 anchorCaretPos);
-		void clearSelection();
 
-		void moveSelectionLeft(bool skipNewline);
-		void moveSelectionRight(bool skipNewline);
+		/**
+		 * @brief	Removes any active selection.
+		 */
+		void clearSelection();
 
+		/**
+		 * @brief	Adjusts the text offset (scroll) so that the caret is visible.
+		 */
 		void scrollTextToCaret();
+
+		/**
+		 * @brief	Clamps the text offset (scroll)	so that the text fits in the
+		 *			provided bounds nicely with minimal white space.
+		 */
 		void clampScrollToBounds(RectI unclippedTextBounds);
 
+		/**
+		 * @brief	Returns offset at which to render the text. Relative to parent widget.
+		 */
 		Vector2I getTextOffset() const;
+
+		/**
+		 * @brief	Returns rectangle used for clipping the text. Relative to element.
+		 */
 		RectI getTextClipRect() const;
+
+		/**
+		 * @brief	Returns text sprite descriptor determining how is text sprite created.
+		 */
 		TEXT_SPRITE_DESC getTextDesc() const;
+
+		/**
+		 * @brief	Returns currently active input box texture, depending on active state.
+		 */
 		const HSpriteTexture& getActiveTexture() const;
 		
+		/**
+		 * @brief	Cuts currently selected text to clipboard.
+		 */
 		void cutText();
+
+		/**
+		 * @brief	Copies currently selected text to clipboard.
+		 */
 		void copyText();
+
+		/**
+		 * @brief	Inserts text from clipboard to current caret location.
+		 */
 		void pasteText();
+
+	private:
+		static VirtualButton mCopyVB;
+		static VirtualButton mPasteVB;
+		static VirtualButton mCutVB;
+		static VirtualButton mSelectAllVB;
+
+		// Sprites
+		ImageSprite* mImageSprite;
+		TextSprite* mTextSprite;
+		bool mIsMultiline;
+		Vector2I mTextOffset;
+		bool mHasFocus;
+		bool mIsMouseOver;
+		State mState;
+
+		IMAGE_SPRITE_DESC mImageDesc;
+		WString mText;
+		std::function<bool(const WString&)> mFilter;
+
+		bool mCaretShown;
+		bool mSelectionShown;
+		bool mDragInProgress;
 	};
 }

+ 85 - 0
BansheeEngine/Include/BsGUIInputCaret.h

@@ -6,39 +6,124 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	When paired with a character index determines should the caret be placed
+	 *			before or after it.
+	 */
 	enum CaretPos
 	{
 		CARET_BEFORE,
 		CARET_AFTER
 	};
 
+	/**
+	 * @brief	Helper class for dealing with caret for text input boxes and similar
+	 *			controls.
+	 */
 	class BS_EXPORT GUIInputCaret : public GUIInputTool
 	{
 	public:
 		GUIInputCaret();
 		~GUIInputCaret();
 
+		/**
+		 * @brief	Returns sprite used for rendering the caret.
+		 */
 		ImageSprite* getSprite() const { return mCaretSprite; }
+
+		/**
+		 * @brief	Returns offset relative to parent widget that determines placement of the
+		 *			caret sprite.
+		 */
 		Vector2I getSpriteOffset() const;
+
+		/**
+		 * @brief	Returns clip rectangle relative to parent GUI element that determines
+		 *			how is caret sprite clipped.
+		 *
+		 * @param	parentClipRect	Clip rectangle of the parent GUI element. Caret clip rectangle will additionally be
+		 *							clipped by this area. Relative to parent element.
+		 */
 		RectI getSpriteClipRect(const RectI& parentClipRect) const;
 
+		/**
+		 * @brief	Rebuilts internal caret sprite using current properties.
+		 */
 		void updateSprite();
 
+		/**
+		 * @brief	Moves caret to the start of text.
+		 */
 		void moveCaretToStart();
+
+		/**
+		 * @brief	Moves caret to the end of text.
+		 */
 		void moveCaretToEnd();
+
+		/**
+		 * @brief	Moves caret one character to the left, if not at start already.
+		 */
 		void moveCaretLeft();
+
+		/**
+		 * @brief	Moves caret one character to the right, if not at end already.
+		 */
 		void moveCaretRight();
+
+		/**
+		 * @brief	Moves caret one line up if possible.
+		 */
 		void moveCaretUp();
+
+		/**
+		 * @brief	Moves caret one line down if possible.
+		 */
 		void moveCaretDown();
+
+		/**
+		 * @brief	Moves caret to the character nearest to the specified position.
+		 *			Position is relative to parent widget.
+		 */
 		void moveCaretToPos(const Vector2I& pos);
+
+		/**
+		 * @brief	Moves the caret to a specific character index.
+		 *
+		 * @param	charIdx		Index of the character to move the caret to.
+		 * @param	caretPos	Whether to place the caret before or after the character.
+		 */
 		void moveCaretToChar(UINT32 charIdx, CaretPos caretPos);
 
+		/**
+		 * @brief	Returns character index after the current caret position.
+		 */
 		UINT32 getCharIdxAtCaretPos() const;
+
+		/**
+		 * @brief	Returns current caret position, relative to parent widget. Requires
+		 *			you to provide offset to text the caret is used for (also relative to parent widget).
+		 */
 		Vector2I getCaretPosition(const Vector2I& offset) const;
+
+		/**
+		 * @brief	Returns height of the caret, in pixels.
+		 */
 		UINT32 getCaretHeight() const;
 
+		/**
+		 * @brief	Returns true if the character after the caret is  newline.
+		 */
 		bool isCaretAtNewline() const;
+
+		/**
+		 * @brief	Returns maximum valid caret index.
+		 */
 		UINT32 getMaxCaretPos() const;
+
+		/**
+		 * @brief	Returns current caret index (not equal to character index).
+		 */
 		UINT32 getCaretPos() const { return mCaretPos; }
 	private:
 		UINT32 mCaretPos;

+ 74 - 2
BansheeEngine/Include/BsGUIInputSelection.h

@@ -6,31 +6,105 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Helper class for dealing with text selection for text input boxes and similar
+	 *			controls.
+	 */
 	class BS_EXPORT GUIInputSelection : public GUIInputTool
 	{
 	public:
 		GUIInputSelection();
 		~GUIInputSelection();
 
+		/**
+		 * @brief	Returns sprites representing the currently selected areas
+		 */
 		const Vector<ImageSprite*>& getSprites() const { return mSprites; }
+
+		/**
+		 * @brief	Returns how much to offset the sprite with the specified index, relative to
+		 *			the parent widget.
+		 */
 		Vector2I GUIInputSelection::getSelectionSpriteOffset(UINT32 spriteIdx) const;
+
+		/**
+		 * @brief	Returns clip rectangle relative to parent GUI element for the sprite with the specified index. 
+		 *
+		 * @param	spriteIdx	Index of the sprite to retrieve the clip rectangle for.
+		 * @param	parentClipRect	Clip rectangle of the parent GUI element. Selection clip rectangle will additionally be
+		 *							clipped by this area. Relative to parent element.
+		 */
 		RectI GUIInputSelection::getSelectionSpriteClipRect(UINT32 spriteIdx, const RectI& parentClipRect) const;
+
+		/**
+		 * @brief	Recreates the selection clip sprites.
+		 */
 		void updateSprite();
 
+		/**
+		 * @brief	Shows the selection using the specified anchor. By default this will select 0 characters so you
+		 *			must manually move the selection using "moveSelectionToCaret" before anything is considered selected.
+		 *
+		 * @param	anchorCaretPos	Anchor position which to initially select. Anchor position determines selection area behavior
+		 *							when the input caret moves (determines whether left or right side of the selection will move with the caret).
+		 */
 		void showSelection(UINT32 anchorCaretPos);
+
+		/**
+		 * @brief	Clears the currently active selection.
+		 */
 		void clearSelection();
 
+		/**
+		 * @brief	Moves the selection to caret. Selected area will be from the anchor provided in
+		 *			"showSelection" to the caret position provided here.
+		 */
 		void moveSelectionToCaret(UINT32 caretPos);
+
+		/**
+		 * @brief	Checks is anything selected.
+		 */
 		bool isSelectionEmpty() const;
+
+		/**
+		 * @brief	Selects all available text.
+		 */
 		void selectAll();
 
+		/**
+		 * @brief	Starts selection drag at the specified caret position. Call
+		 *			"selectionDragUpdate" and "selectionDragEnd" as the drag operation
+		 *			progresses.
+		 */
 		void selectionDragStart(UINT32 caretPos);
+
+		/**
+		 * @brief	Updates selection drag at the specified caret position. 
+		 */
 		void selectionDragUpdate(UINT32 caretPos);
+
+		/**
+		 * @brief	Stops selection drag.
+		 */
 		void selectionDragEnd();
 
+		/**
+		 * @brief	Gets caret index of selection start.
+		 */
 		UINT32 getSelectionStart() const { return mSelectionStart; }
+
+		/**
+		 * @brief	Gets caret index of selection end.
+		 */
 		UINT32 getSelectionEnd() const { return mSelectionEnd; }
 
+	private:
+		/**
+		 * @brief	Returns rectangles describing the currently selected areas. Rectangles
+		 *			are relative to parent GUI element.
+		 */
+		Vector<RectI> getSelectionRects() const;
+
 	private:
 		UINT32 mSelectionStart;
 		UINT32 mSelectionEnd;
@@ -39,7 +113,5 @@ namespace BansheeEngine
 
 		Vector<RectI> mSelectionRects;
 		Vector<ImageSprite*> mSprites;
-
-		Vector<RectI> getSelectionRects() const;
 	};
 }

+ 102 - 12
BansheeEngine/Include/BsGUIInputTool.h

@@ -5,16 +5,55 @@
 
 namespace BansheeEngine
 {
+	/**
+	 * @brief	Represents a single line of text used by the input tools.
+	 */
 	class BS_EXPORT GUIInputLineDesc
 	{
 	public:
+		/**
+		 * @brief	Constructs a new input line description.
+		 *
+		 * @param	startChar		Index of the first character on the line.
+		 * @param	endChar			Index of the last character on the line.
+		 * @param	lineHeight		Height of the line in pixels.
+		 * @param	lineYStart		Vertical offset from the top of the text to the start of this line (0 for first line usually)
+		 * @param	includesNewLine	True if the lines end character is a newline character.
+		 */
 		GUIInputLineDesc(UINT32 startChar, UINT32 endChar, UINT32 lineHeight, INT32 lineYStart, bool includesNewline);
 
+		/**
+		 * @brief	Returns index of the last character on the line. If lines contains a newline character it will be returned
+		 *			unless you set "includeNewLine" to false, in which case the next end-most character is returned.
+		 *			(If newline is the only character on the line, it's index will still be returned).
+		 */
 		UINT32 getEndChar(bool includeNewline = true) const;
+
+		/**
+		 * @brief	Returns index of the first character on the line.
+		 */
 		UINT32 getStartChar() const { return mStartChar; }
+
+		/**
+		 * @brief	Returns line height in pixels.
+		 */
 		UINT32 getLineHeight() const { return mLineHeight; }
+
+		/**
+		 * @brief	Returns vertical offset from the top of the text to the start of this line (0 for first line usually).
+		 */
 		INT32 getLineYStart() const { return mLineYStart; }
+
+		/**
+		 * @brief	Checks is the specified character index a newline. Character index is a global character index,
+		 *			not relative to the start character index of this line. If the index is out of range of this line
+		 *			character indices, it will always return false.
+		 */
 		bool isNewline(UINT32 charIdx) const;
+
+		/**
+		 * @brief	Returns true if the last character on this line is a newline.
+		 */
 		bool hasNewlineChar() const { return mIncludesNewline; }
 
 	private:
@@ -31,37 +70,88 @@ namespace BansheeEngine
 		GUIInputTool();
 		~GUIInputTool();
 
+		/**
+		 * @brief	Updates the input tool with new text descriptor and parent GUI element. These
+		 *			values will be used for all further calculations.
+		 */
 		void updateText(const GUIElement* element, const TEXT_SPRITE_DESC& textDesc);
 	protected:
-		const GUIElement* mElement;
-
-		Vector2* mQuads;
-		UINT32 mNumQuads;
-
-		TEXT_SPRITE_DESC mTextDesc;
-
-		Vector<GUIInputLineDesc> mLineDescs;
-
+		/**
+		 * @brief	Returns text offset relative to parent widget.
+		 */
 		Vector2I getTextOffset() const;
 
+		/**
+		 * @brief	Returns number of lines in the current text string.
+		 */
 		UINT32 getNumLines() const { return (UINT32)mLineDescs.size(); }
+
+		/**
+		 * @brief	Returns descriptor for a line with the specified index.
+		 */
 		const GUIInputLineDesc& getLineDesc(UINT32 lineIdx) const { return mLineDescs.at(lineIdx); }
+
+		/**
+		 * @brief	Returns index of a line containing the specified character.
+		 *
+		 * @param	charIdx					Index of the character to look for.
+		 * @param	newlineCountsOnNextLine	If true, newline characters will return the next line
+		 *									and not the line they're actually on.
+		 */
 		UINT32 getLineForChar(UINT32 charIdx, bool newlineCountsOnNextLine = false) const;
+
+		/**
+		 * @brief	Returns a rectangle containing position and size of the character with the provided
+		 *			index, relative to parent widget.
+		 */
 		RectI getCharRect(UINT32 charIdx) const;
+
+		/**
+		 * @brief	Returns a rectangle containing position and size of the character with the provided
+		 *			index, relative to parent element.
+		 */
 		RectI getLocalCharRect(UINT32 charIdx) const;
+
+		/**
+		 * @brief	Returns character index nearest to the specified position. Position should be relative
+		 *			to parent widget.
+		 */
 		INT32 getCharIdxAtPos(const Vector2I& pos) const;
+
+		/**
+		 * @brief	Returns true if the currently set text desctiptor is valid (has any characters).
+		 */
 		bool isDescValid() const;
 
 		/**
-		 * @brief	Gets a character index AFTER the input index. 
-		 * 			"Input index" represents the empty areas between the characters. Newline counts as a character.
-		 * 			(e.g. 0 is before the first character, 1 is after the first character but before the second, etc.)
+		 * @brief	Gets a character index after the input index. Input index represents the empty areas between the characters. 
+		 *			Newline counts as a character. (e.g. 0 is before the first character, 1 is after the first character but before 
+		 *			the second, etc.)
 		 * 			
 		 * @note	This can return an out of range character index, in case the input index is specified after the last character.
 		 */
 		UINT32 getCharIdxAtInputIdx(UINT32 inputIdx) const;
 
+		/**
+		 * @brief	Checks is the specified character index a newline.
+		 */
 		bool isNewlineChar(UINT32 charIdx) const;
+
+		/**
+		 * @brief	Checks is the character after the specified input index a newline.
+		 *
+		 * @see		getCharIdxAtInputIdx
+		 */
 		bool isNewline(UINT32 inputIdx) const;
+
+	protected:
+		const GUIElement* mElement;
+
+		Vector2* mQuads;
+		UINT32 mNumQuads;
+
+		TEXT_SPRITE_DESC mTextDesc;
+
+		Vector<GUIInputLineDesc> mLineDescs;
 	};
 }