Przeglądaj źródła

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 10 lat temu
rodzic
commit
0155525166

+ 1 - 0
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -308,6 +308,7 @@ namespace BansheeEngine
 
 		static const WString ColorPickerSliderHorzHandleTex;
 		static const WString ColorPickerSliderVertHandleTex;
+		static const WString ColorPickerSlider2DHandleTex;
 
 		static const WString ProgressBarFillTex;
 		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::ColorPickerSliderVertHandleTex = L"ColorPickerSliderVertHandle.psd";
+	const WString BuiltinEditorResources::ColorPickerSlider2DHandleTex = L"ColorPicker2DHandle.psd";
 
 	const WString BuiltinEditorResources::ProgressBarFillTex = L"ProgressBarFill.psd";
 	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
@@ -1122,6 +1123,17 @@ namespace BansheeEngine
 		colorPickerSliderVertStyle.subStyles[GUISlider::getHandleStyleType()] = "ColorSliderVertHandle";
 
 		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()
@@ -1146,7 +1158,7 @@ namespace BansheeEngine
 			ScrollBarBgTex, MenuBarBgTex, MenuBarBtnNormalTex, MenuBarBtnHoverTex, MenuBarBansheeLogoTex, DockSliderNormalTex,
 			TreeViewExpandButtonOffNormal, TreeViewExpandButtonOffHover, TreeViewExpandButtonOnNormal, TreeViewExpandButtonOnHover,
 			TreeViewSelectionBackground, TreeViewEditBox, TreeViewElementHighlight, TreeViewElementSepHighlight, ProgressBarBgTex,
-			ProgressBarFillTex, ColorPickerSliderHorzHandleTex, ColorPickerSliderVertHandleTex };
+			ProgressBarFillTex, ColorPickerSliderHorzHandleTex, ColorPickerSliderVertHandleTex, ColorPickerSlider2DHandleTex };
 
 		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
 		float curValue = parseFloat(mInputBox->getText());
 		if (mValue != curValue)
-			mInputBox->setText(toWString(value));
+			mInputBox->setText(toWString(mValue));
 	}
 
 	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
 		float curValue = parseFloat(mInputBox->getText());
 		if (mValue != curValue)
-			mInputBox->setText(toWString(value));
+			mInputBox->setText(toWString(mValue));
 	}
 
 	void GUIIntField::setRange(INT32 min, INT32 max)

+ 7 - 15
BansheeEngine/Source/BsGUIInputBox.cpp

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

+ 2 - 1
BansheeEngine/Source/BsGUIInputTool.cpp

@@ -173,7 +173,8 @@ namespace BansheeEngine
 		UINT32 idx = 0;
 		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)
 					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);
             guiSliderBHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
             guiSliderAHorz = new GUISliderH(EditorStyles.ColorSliderHorz);
-            guiSlider2DHandle = new GUITexture(null);
+            guiSlider2DHandle = new GUITexture(null, EditorStyles.ColorSlider2DHandle);
 
             guiLabelR = new GUILabel("R");
             guiLabelG = new GUILabel("G");
@@ -233,6 +233,7 @@ namespace BansheeEditor
             Update2DSliderValues();
             Update1DSliderTextures();
             Update1DSliderValues();
+            UpdateSliderMode();
 
             Color startA = new Color(0, 0, 0, 1);
             Color stepA = new Color(1, 1, 1, 0);
@@ -245,8 +246,6 @@ namespace BansheeEditor
             Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition);
 
             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)
@@ -308,26 +307,7 @@ namespace BansheeEditor
             int maxModes = Enum.GetNames(sliderMode.GetType()).Length;
             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());
             UpdateInputBoxValues();
@@ -553,12 +533,40 @@ namespace BansheeEditor
         {
             if (closedCallback != null)
                 closedCallback(true, SelectedColor);
+
+            Close();
         }
 
         void OnCancel()
         {
             if (closedCallback != null)
                 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()

+ 1 - 0
MBansheeEditor/EditorStyles.cs

@@ -14,5 +14,6 @@ namespace BansheeEditor
         public const string InputBox = "InputBox";
         public const string ColorSliderHorz = "ColorSliderHorz";
         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
  - 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. 
 Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.