Procházet zdrojové kódy

Fixed a bug where min/max range in int/float fields wasn't properly applied
Fixed an issue where clicking on an input box sometimes didn't show the caret
Clicking on an input box for the first time will now select all its contents
Fixed an issue where moving the caret up/down in an input field with a single line caused an exception
More work on ColorPicker

Marko Pintera před 10 roky
rodič
revize
0155525166

+ 1 - 0
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -308,6 +308,7 @@ namespace BansheeEngine
 
 
 		static const WString ColorPickerSliderHorzHandleTex;
 		static const WString ColorPickerSliderHorzHandleTex;
 		static const WString ColorPickerSliderVertHandleTex;
 		static const WString ColorPickerSliderVertHandleTex;
+		static const WString ColorPickerSlider2DHandleTex;
 
 
 		static const WString ProgressBarFillTex;
 		static const WString ProgressBarFillTex;
 		static const WString ProgressBarBgTex;
 		static const WString ProgressBarBgTex;

+ 13 - 1
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -179,6 +179,7 @@ namespace BansheeEngine
 
 
 	const WString BuiltinEditorResources::ColorPickerSliderHorzHandleTex = L"ColorPickerSliderHorzHandle.psd";
 	const WString BuiltinEditorResources::ColorPickerSliderHorzHandleTex = L"ColorPickerSliderHorzHandle.psd";
 	const WString BuiltinEditorResources::ColorPickerSliderVertHandleTex = L"ColorPickerSliderVertHandle.psd";
 	const WString BuiltinEditorResources::ColorPickerSliderVertHandleTex = L"ColorPickerSliderVertHandle.psd";
+	const WString BuiltinEditorResources::ColorPickerSlider2DHandleTex = L"ColorPicker2DHandle.psd";
 
 
 	const WString BuiltinEditorResources::ProgressBarFillTex = L"ProgressBarFill.psd";
 	const WString BuiltinEditorResources::ProgressBarFillTex = L"ProgressBarFill.psd";
 	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
 	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
@@ -1122,6 +1123,17 @@ namespace BansheeEngine
 		colorPickerSliderVertStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderVertHandle";
 		colorPickerSliderVertStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderVertHandle";
 
 
 		mSkin.setStyle("ColorSliderVert", colorPickerSliderVertStyle);
 		mSkin.setStyle("ColorSliderVert", colorPickerSliderVertStyle);
+
+		GUIElementStyle colorPickerSlider2DHandleStyle;
+		colorPickerSlider2DHandleStyle.fixedHeight = true;
+		colorPickerSlider2DHandleStyle.fixedWidth = true;
+		colorPickerSlider2DHandleStyle.height = 8;
+		colorPickerSlider2DHandleStyle.width = 8;
+		colorPickerSlider2DHandleStyle.normal.texture = getGUITexture(ColorPickerSlider2DHandleTex);
+		colorPickerSlider2DHandleStyle.hover.texture = colorPickerSlider2DHandleStyle.normal.texture;
+		colorPickerSlider2DHandleStyle.active.texture = colorPickerSlider2DHandleStyle.normal.texture;
+
+		mSkin.setStyle("ColorSlider2DHandle", colorPickerSlider2DHandleStyle);
 	}
 	}
 
 
 	void BuiltinEditorResources::preprocess()
 	void BuiltinEditorResources::preprocess()
@@ -1146,7 +1158,7 @@ namespace BansheeEngine
 			ScrollBarBgTex, MenuBarBgTex, MenuBarBtnNormalTex, MenuBarBtnHoverTex, MenuBarBansheeLogoTex, DockSliderNormalTex,
 			ScrollBarBgTex, MenuBarBgTex, MenuBarBtnNormalTex, MenuBarBtnHoverTex, MenuBarBansheeLogoTex, DockSliderNormalTex,
 			TreeViewExpandButtonOffNormal, TreeViewExpandButtonOffHover, TreeViewExpandButtonOnNormal, TreeViewExpandButtonOnHover,
 			TreeViewExpandButtonOffNormal, TreeViewExpandButtonOffHover, TreeViewExpandButtonOnNormal, TreeViewExpandButtonOnHover,
 			TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight, ProgressBarBgTex,
 			TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight, ProgressBarBgTex,
-			ProgressBarFillTex, ColorPickerSliderHorzHandleTex, ColorPickerSliderVertHandleTex };
+			ProgressBarFillTex, ColorPickerSliderHorzHandleTex, ColorPickerSliderVertHandleTex, ColorPickerSlider2DHandleTex };
 
 
 		static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] = 
 		static const GpuProgramImportData GPU_PROGRAM_IMPORT_DATA[] = 
 		{
 		{

+ 1 - 1
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -131,7 +131,7 @@ namespace BansheeEngine
 		// updates back to "0" effectively making "." unusable
 		// updates back to "0" effectively making "." unusable
 		float curValue = parseFloat(mInputBox->getText());
 		float curValue = parseFloat(mInputBox->getText());
 		if (mValue != curValue)
 		if (mValue != curValue)
-			mInputBox->setText(toWString(value));
+			mInputBox->setText(toWString(mValue));
 	}
 	}
 
 
 	void GUIFloatField::setTint(const Color& color)
 	void GUIFloatField::setTint(const Color& color)

+ 1 - 1
BansheeEditor/Source/BsGUIIntField.cpp

@@ -158,7 +158,7 @@ namespace BansheeEngine
 		// updates back to "0" effectively making "." unusable
 		// updates back to "0" effectively making "." unusable
 		float curValue = parseFloat(mInputBox->getText());
 		float curValue = parseFloat(mInputBox->getText());
 		if (mValue != curValue)
 		if (mValue != curValue)
-			mInputBox->setText(toWString(value));
+			mInputBox->setText(toWString(mValue));
 	}
 	}
 
 
 	void GUIIntField::setRange(INT32 min, INT32 max)
 	void GUIIntField::setRange(INT32 min, INT32 max)

+ 7 - 15
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -434,7 +434,10 @@ namespace BansheeEngine
 						showSelection(gGUIManager().getInputCaretTool()->getCaretPos());
 						showSelection(gGUIManager().getInputCaretTool()->getCaretPos());
 				}
 				}
 				else
 				else
+				{
 					clearSelection();
 					clearSelection();
+					showCaret();
+				}
 
 
 				if(mText.size() > 0)
 				if(mText.size() > 0)
 					gGUIManager().getInputCaretTool()->moveCaretToPos(ev.getPosition());
 					gGUIManager().getInputCaretTool()->moveCaretToPos(ev.getPosition());
@@ -443,20 +446,10 @@ namespace BansheeEngine
 
 
 				if(ev.isShiftDown())
 				if(ev.isShiftDown())
 					gGUIManager().getInputSelectionTool()->moveSelectionToCaret(gGUIManager().getInputCaretTool()->getCaretPos());
 					gGUIManager().getInputSelectionTool()->moveSelectionToCaret(gGUIManager().getInputCaretTool()->getCaretPos());
-			}
-			else
-			{
-				clearSelection();
-				showCaret();
 
 
-				if(mText.size() > 0)
-					gGUIManager().getInputCaretTool()->moveCaretToPos(ev.getPosition());
-				else
-					gGUIManager().getInputCaretTool()->moveCaretToStart();
+				scrollTextToCaret();
 			}
 			}
 
 
-			scrollTextToCaret();
-
 			markContentAsDirty();
 			markContentAsDirty();
 
 
 			return true;
 			return true;
@@ -542,7 +535,7 @@ namespace BansheeEngine
 	{
 	{
 		if(ev.getType() == GUICommandEventType::Redraw)
 		if(ev.getType() == GUICommandEventType::Redraw)
 		{
 		{
-			markMeshAsDirty();
+			markContentAsDirty();
 			return true;
 			return true;
 		}
 		}
 
 
@@ -550,9 +543,8 @@ namespace BansheeEngine
 		{
 		{
 			mState = State::Focused;
 			mState = State::Focused;
 
 
-			clearSelection();
-			showCaret();
-
+			showSelection(0);
+			gGUIManager().getInputSelectionTool()->selectAll();
 			markContentAsDirty();
 			markContentAsDirty();
 
 
 			mHasFocus = true;
 			mHasFocus = true;

+ 2 - 1
BansheeEngine/Source/BsGUIInputTool.cpp

@@ -173,7 +173,8 @@ namespace BansheeEngine
 		UINT32 idx = 0;
 		UINT32 idx = 0;
 		for(auto& line : mLineDescs)
 		for(auto& line : mLineDescs)
 		{
 		{
-			if(charIdx >= line.getStartChar() && charIdx < line.getEndChar())
+			if((charIdx >= line.getStartChar() && charIdx < line.getEndChar()) || 
+				(charIdx == line.getStartChar() && line.getStartChar() == line.getEndChar()))
 			{
 			{
 				if(line.isNewline(charIdx) && newlineCountsOnNextLine)
 				if(line.isNewline(charIdx) && newlineCountsOnNextLine)
 					return idx + 1; // Incrementing is safe because next line must exist, since we just found a newline char
 					return idx + 1; // Incrementing is safe because next line must exist, since we just found a newline char

+ 31 - 23
MBansheeEditor/ColorPicker.cs

@@ -116,7 +116,7 @@ namespace BansheeEditor
             guiSliderGHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderGHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderBHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderBHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderAHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderAHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
-            guiSlider2DHandle = new GUITexture(null);
+            guiSlider2DHandle = new GUITexture(null, EditorStyles.ColorSlider2DHandle);
 
 
             guiLabelR = new GUILabel("R");
             guiLabelR = new GUILabel("R");
             guiLabelG = new GUILabel("G");
             guiLabelG = new GUILabel("G");
@@ -233,6 +233,7 @@ namespace BansheeEditor
             Update2DSliderValues();
             Update2DSliderValues();
             Update1DSliderTextures();
             Update1DSliderTextures();
             Update1DSliderValues();
             Update1DSliderValues();
+            UpdateSliderMode();
 
 
             Color startA = new Color(0, 0, 0, 1);
             Color startA = new Color(0, 0, 0, 1);
             Color stepA = new Color(1, 1, 1, 0);
             Color stepA = new Color(1, 1, 1, 0);
@@ -245,8 +246,6 @@ namespace BansheeEditor
             Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition);
             Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition);
 
 
             colorBox.UpdateInput(windowPos);
             colorBox.UpdateInput(windowPos);
-
-            Debug.Log(Width + " - " + Height + " - " + GUI.childAreas[0].mCachedPtr);
         }
         }
 
 
         private static void FillArea(int width, int height, Color[] colors, Color start, Color rightGradient, Color downGradient)
         private static void FillArea(int width, int height, Color[] colors, Color start, Color rightGradient, Color downGradient)
@@ -308,26 +307,7 @@ namespace BansheeEditor
             int maxModes = Enum.GetNames(sliderMode.GetType()).Length;
             int maxModes = Enum.GetNames(sliderMode.GetType()).Length;
             sliderMode = (SliderMode)(((int)sliderMode + 1) % maxModes);
             sliderMode = (SliderMode)(((int)sliderMode + 1) % maxModes);
 
 
-            if (sliderMode == SliderMode.RGB)
-            {
-                guiLabelR.SetContent("R");
-                guiLabelG.SetContent("G");
-                guiLabelB.SetContent("B");
-
-                guiInputR.SetRange(0, 255);
-                guiInputG.SetRange(0, 255);
-                guiInputB.SetRange(0, 255);
-            }
-            else
-            {
-                guiLabelR.SetContent("H");
-                guiLabelG.SetContent("S");
-                guiLabelB.SetContent("V");
-
-                guiInputR.SetRange(0, 359);
-                guiInputG.SetRange(0, 255);
-                guiInputB.SetRange(0, 255);
-            }
+            UpdateSliderMode();
 
 
             guiColorModeBtn.SetContent(sliderMode.ToString());
             guiColorModeBtn.SetContent(sliderMode.ToString());
             UpdateInputBoxValues();
             UpdateInputBoxValues();
@@ -553,12 +533,40 @@ namespace BansheeEditor
         {
         {
             if (closedCallback != null)
             if (closedCallback != null)
                 closedCallback(true, SelectedColor);
                 closedCallback(true, SelectedColor);
+
+            Close();
         }
         }
 
 
         void OnCancel()
         void OnCancel()
         {
         {
             if (closedCallback != null)
             if (closedCallback != null)
                 closedCallback(false, SelectedColor);
                 closedCallback(false, SelectedColor);
+
+            Close();
+        }
+
+        void UpdateSliderMode()
+        {
+            if (sliderMode == SliderMode.RGB)
+            {
+                guiLabelR.SetContent("R");
+                guiLabelG.SetContent("G");
+                guiLabelB.SetContent("B");
+
+                guiInputR.SetRange(0, 255);
+                guiInputG.SetRange(0, 255);
+                guiInputB.SetRange(0, 255);
+            }
+            else
+            {
+                guiLabelR.SetContent("H");
+                guiLabelG.SetContent("S");
+                guiLabelB.SetContent("V");
+
+                guiInputR.SetRange(0, 359);
+                guiInputG.SetRange(0, 255);
+                guiInputB.SetRange(0, 255);
+            }
         }
         }
 
 
         void UpdateInputBoxValues()
         void UpdateInputBoxValues()

+ 1 - 0
MBansheeEditor/EditorStyles.cs

@@ -14,5 +14,6 @@ namespace BansheeEditor
         public const string InputBox = "InputBox";
         public const string InputBox = "InputBox";
         public const string ColorSliderHorz = "ColorSliderHorz";
         public const string ColorSliderHorz = "ColorSliderHorz";
         public const string ColorSliderVert = "ColorSliderVert";
         public const string ColorSliderVert = "ColorSliderVert";
+        public const string ColorSlider2DHandle = "ColorSlider2DHandle";
     }
     }
 }
 }

+ 2 - 1
TODO.txt

@@ -12,7 +12,8 @@ Dialog.Show(title, text, btn1 text, btn1 callback, btn2 text, btn2 callback, btn
 
 
 ColorPicker
 ColorPicker
  - Input range limit on int fields seems broken. As I enter larger values they seem to overflow to other fields?
  - Input range limit on int fields seems broken. As I enter larger values they seem to overflow to other fields?
- - Need texture for 2D slider handle
+ - Set up proper sizes for elements as it looks pretty shit at the moment
+ - Sliders don't show up
 
 
 Got a crash on shutdown that was caused by locking a mutex in an Event destructor. Event was Platform::onMouseCaptureChanged. 
 Got a crash on shutdown that was caused by locking a mutex in an Event destructor. Event was Platform::onMouseCaptureChanged. 
 Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.
 Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.