Jelajahi Sumber

Modified how I measure optimal text size - Optimal height now uses line height instead of height of actually visible characters

Marko Pintera 12 tahun lalu
induk
melakukan
53af23ab1d
3 mengubah file dengan 16 tambahan dan 5 penghapusan
  1. 6 3
      BansheeEngine/Source/BsGUIHelper.cpp
  2. 1 1
      CamelotCore/Include/CmTextData.h
  3. 9 1
      TreeView.txt

+ 6 - 3
BansheeEngine/Source/BsGUIHelper.cpp

@@ -38,10 +38,13 @@ namespace BansheeEngine
 		UINT32 contentWidth = style.margins.left + style.margins.right + style.contentOffset.left + style.contentOffset.right;
 		UINT32 contentHeight = style.margins.top + style.margins.bottom + style.contentOffset.top + style.contentOffset.bottom;
 
-		TextData textData(text, style.font, style.fontSize, wordWrapWidth, 0, style.wordWrap);
+		if(style.font != nullptr)
+		{
+			TextData textData(text, style.font, style.fontSize, wordWrapWidth, 0, style.wordWrap);
 
-		contentWidth += textData.getWidth();
-		contentHeight += textData.getHeight();
+			contentWidth += textData.getWidth();
+			contentHeight += textData.getNumLines() * textData.getLineHeight(); 
+		}
 
 		return Vector2I(contentWidth, contentHeight);
 	}

+ 1 - 1
CamelotCore/Include/CmTextData.h

@@ -120,6 +120,7 @@ namespace CamelotFramework
 
 		CM_EXPORT UINT32 getNumLines() const { return mNumLines; }
 		CM_EXPORT UINT32 getNumPages() const { return mNumPageInfos; }
+		CM_EXPORT UINT32 getLineHeight() const;
 
 		CM_EXPORT const TextLine& getLine(UINT32 idx) const { return mLines[idx]; }
 		CM_EXPORT const HTexture& getTextureForPage(UINT32 page) const;
@@ -132,7 +133,6 @@ namespace CamelotFramework
 		friend class TextLine;
 
 		INT32 getBaselineOffset() const;
-		UINT32 getLineHeight() const;
 		UINT32 getSpaceWidth() const;
 
 		const CHAR_DESC& getChar(UINT32 idx) const { return *mChars[idx]; }

+ 9 - 1
TreeView.txt

@@ -9,6 +9,9 @@ TreeView
   - Deleting
       - Simply track currently selected element and Delete event
 
+IMMEDIATE:
+ - Selection sprite seems to be one pixel too high even if its on the same level as the text sprite. I think this is a discrepancy on sprite level.
+
 Implementation steps:
  - Selection
    - Clicking on element selects it, delete removes it, F2 renames is. Slow double click renames it.
@@ -32,4 +35,9 @@ Detecting external clicks:
    - Each GUIElement can implement acceptsMouseFocus event. If it does, then mouse click will cause a ReceivedFocus event.
      - Mouse click on any other element, or window losing focus will trigger LostFocus events
  - I can replace clumsy Selective Input with this approach
- - DropDownBox can also use the same approach although I will likely need to convert DropDownBox to a GUIElement - DO THIS AFTER TreeView implementation is working
+ - DropDownBox can also use the same approach although I will likely need to convert DropDownBox to a GUIElement - DO THIS AFTER TreeView implementation is working
+
+ Other:
+ - When dragging in tree view automatically expand mouse over elements
+ - Ability to select and drag multiple elements
+ - "Ping" effect