瀏覽代碼

Respect GetCaretBlinkTime

Brian Fiete 1 年之前
父節點
當前提交
60817eec48
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf

+ 15 - 1
BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf

@@ -513,6 +513,11 @@ namespace Beefy.theme.dark
 			return rect;
 			return rect;
 		}
 		}
 
 
+#if BF_PLATFORM_WINDOWS
+		[CLink]
+		static extern int32 GetCaretBlinkTime();
+#endif
+
         public override void Draw(Graphics g)
         public override void Draw(Graphics g)
         {            
         {            
             base.Draw(g);
             base.Draw(g);
@@ -568,7 +573,16 @@ namespace Beefy.theme.dark
 						g.OutlineRect(hiliteX, y, totalLineWidth, lineSpacing + thickness, thickness);
 						g.OutlineRect(hiliteX, y, totalLineWidth, lineSpacing + thickness, thickness);
 				}
 				}
 
 
-			    float brightness = (float)Math.Cos(Math.Max(0.0f, mCursorBlinkTicks - 20) / 9.0f);                            
+				float blinkRate = 1 / 9.0f;
+#if BF_PLATFORM_WINDOWS
+				int blinkTime = GetCaretBlinkTime();
+				if (blinkTime <= 0)
+					blinkRate = 0;
+				else
+					blinkRate = (blinkRate * 530) / blinkTime;
+#endif
+
+			    float brightness = (float)Math.Cos(Math.Max(0.0f, mCursorBlinkTicks - 20) * blinkRate);                      
 			    brightness = Math.Clamp(brightness * 2.0f + 1.6f, 0, 1);
 			    brightness = Math.Clamp(brightness * 2.0f + 1.6f, 0, 1);
 			    if (mEditWidget.mVertPos.IsMoving)
 			    if (mEditWidget.mVertPos.IsMoving)
 			        brightness = 0; // When we animate a pgup or pgdn, it's weird seeing the cursor scrolling around
 			        brightness = 0; // When we animate a pgup or pgdn, it's weird seeing the cursor scrolling around