diff --git a/BeefLibs/Beefy2D/src/BFApp.bf b/BeefLibs/Beefy2D/src/BFApp.bf index 1afc60d1..ff7f6a85 100644 --- a/BeefLibs/Beefy2D/src/BFApp.bf +++ b/BeefLibs/Beefy2D/src/BFApp.bf @@ -300,6 +300,17 @@ namespace Beefy } } + public BFWindow FocusedWindow + { + get + { + for (var window in mWindows) + if (window.mHasFocus) + return window; + return null; + } + } + public static void Startup(String[] args, Action startupCallback) { /*string[] newArgs = new string[args.Length + 1]; diff --git a/BeefLibs/Beefy2D/src/BFWindow.bf b/BeefLibs/Beefy2D/src/BFWindow.bf index 482ee9ab..cd3682de 100644 --- a/BeefLibs/Beefy2D/src/BFWindow.bf +++ b/BeefLibs/Beefy2D/src/BFWindow.bf @@ -462,6 +462,18 @@ namespace Beefy BFWindow_SetNonExclusiveMouseCapture(mNativeWindow); } + public bool HasParent(BFWindow widgetWindow) + { + var checkParent = mParent; + while (checkParent != null) + { + if (checkParent == widgetWindow) + return true; + checkParent = checkParent.mParent; + } + return false; + } + public virtual void Closed() { if (mHasClosed) diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf index 63c290e0..2826bfd1 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkEditWidget.bf @@ -108,7 +108,7 @@ namespace Beefy.theme.dark { float spaceWidth = mFont.GetWidth((char32)' '); if (mTabSize == 0) - return startX + spaceWidth; + return startX + spaceWidth*4; return (float)Math.Truncate((startX + spaceWidth) / mTabSize + 0.999f) * mTabSize; } @@ -299,15 +299,17 @@ namespace Beefy.theme.dark mFont = font; if (isMonospace) { - mCharWidth = mFont.GetWidth((char32)' '); - //Debug.Assert(mFont.GetWidth((char32)'W') == mCharWidth); + mCharWidth = mFont.GetWidth(' '); if (mTabSize == 0) mTabSize = mTabLength * mCharWidth; else mTabSize = (float)Math.Round(mTabSize / mCharWidth) * mCharWidth; } else + { mCharWidth = -1; + mTabSize = mTabLength * mFont.GetWidth('W'); + } if (virtualCursor) Debug.Assert(isMonospace); mAllowVirtualCursor = virtualCursor; diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTabbedView.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTabbedView.bf index 91ef6d4c..fe7c5680 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTabbedView.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTabbedView.bf @@ -38,6 +38,18 @@ namespace Beefy.theme.dark if (tabButton.mCloseClickedEvent.HasListeners) tabButton.mCloseClickedEvent(); } + + public override void MouseMove(float x, float y) + { + base.MouseMove(x, y); + MarkDirty(); + } + + public override void MouseLeave() + { + base.MouseLeave(); + MarkDirty(); + } } public class DarkTabButton : TabbedView.TabButton diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf index 0b000c18..e9991e9c 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf @@ -35,6 +35,7 @@ namespace Beefy.theme.dark public Insets mRelWidgetMouseInsets ~ delete _; public bool mAllowMouseInsideSelf; public bool mAllowMouseOutside; + public int mAutoCloseDelay; public const float cShadowSize = 8; @@ -199,7 +200,8 @@ namespace Beefy.theme.dark WidgetWindow widgetWindow = (WidgetWindow)evt.mSender; if (widgetWindow == mWidgetWindow) return; - + if (widgetWindow.HasParent(mWidgetWindow)) + return; Close(); } @@ -208,6 +210,8 @@ namespace Beefy.theme.dark WidgetWindow widgetWindow = (WidgetWindow)evt.mSender; if (widgetWindow == mWidgetWindow) return; + if (widgetWindow.HasParent(mWidgetWindow)) + return; //if ((!(widgetWindow.mRootWidget is HoverWatch)) && (!(widgetWindow.mRootWidget is MenuWidget))) Close(); } @@ -221,6 +225,12 @@ namespace Beefy.theme.dark { base.Update(); + if (mAutoCloseDelay > 0) + { + mAutoCloseDelay--; + return; + } + if (mWidgetWindow == null) return; @@ -242,10 +252,19 @@ namespace Beefy.theme.dark if ((mWidgetWindow.mHasMouseInside) && (mAllowMouseInsideSelf)) return; + + var checkWindow = BFApp.sApp.FocusedWindow; + if ((checkWindow != null) && (checkWindow.HasParent(mWidgetWindow))) + return; Close(); } + public void ExpandAllowedRegion() + { + + } + protected override void RemovedFromWindow() { base.RemovedFromWindow(); diff --git a/IDE/src/ui/FindAndReplaceDialog.bf b/IDE/src/ui/FindAndReplaceDialog.bf index 922b5f3d..db0071d1 100644 --- a/IDE/src/ui/FindAndReplaceDialog.bf +++ b/IDE/src/ui/FindAndReplaceDialog.bf @@ -83,17 +83,21 @@ namespace IDE.ui if (var editWidget = gApp.GetActiveWindow().mFocusWidget as EditWidget) { - var content = editWidget.mEditWidgetContent; - int selStart = content.mSelection.Value.MinPos; - int selEnd = content.mSelection.Value.MaxPos; bool isMultiline = false; - for (int i = selStart; i < selEnd; i++) + + var content = editWidget.mEditWidgetContent; + if (content.mSelection.HasValue) { - if (content.mData.mText[i].mChar == '\n') - { - isMultiline = true; - break; - } + int selStart = content.mSelection.Value.MinPos; + int selEnd = content.mSelection.Value.MaxPos; + for (int i = selStart; i < selEnd; i++) + { + if (content.mData.mText[i].mChar == '\n') + { + isMultiline = true; + break; + } + } } if (!isMultiline) diff --git a/IDE/src/ui/WatchPanel.bf b/IDE/src/ui/WatchPanel.bf index a6c5d92f..70bb186c 100644 --- a/IDE/src/ui/WatchPanel.bf +++ b/IDE/src/ui/WatchPanel.bf @@ -572,6 +572,8 @@ namespace IDE.ui public int mMaxShowSize = cMoreBlockSize; public DarkButton mMoreButton; public QuickFind mQuickFind; + public DarkTabbedView.DarkTabMenuButton mMenuButton; + public bool mViewWhiteSpace; public this(String text, String evalStr) { @@ -614,6 +616,36 @@ namespace IDE.ui if (evalStr != null) mEvalString.Set(evalStr); + + mMenuButton = new DarkTabbedView.DarkTabMenuButton(); + AddWidget(mMenuButton); + + mMenuButton.mOnMouseDown.Add(new (evt) => + { + float x = mMenuButton.mX + GS!(14); + float y = mMenuButton.mY + GS!(6); + + Menu menu = new Menu(); + var menuItem = menu.AddItem("Show Whitespace"); + if (mViewWhiteSpace) + menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check); + menuItem.mOnMenuItemSelected.Add(new (menu) => + { + mViewWhiteSpace = !mViewWhiteSpace; + var darkEditWidgetContent = (DarkEditWidgetContent)mEditWidget.Content; + darkEditWidgetContent.mViewWhiteSpaceColor = mViewWhiteSpace ? SourceEditWidgetContent.sTextColors[(int)SourceElementType.VisibleWhiteSpace] : 0; + }); + + MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu); + menuWidget.Init(this, x, y, true); + + menu.mOnMenuClosed.Add(new (menu, itemSelected) => + { + if (DarkTooltipManager.sTooltip != null) + DarkTooltipManager.sTooltip.mAutoCloseDelay = 90; + }); + //menuWidget.mWidgetWindow.mOnWindowClosed.Add(new => MenuClosed); + }); } public void ShowQuickFind(bool isReplace) @@ -750,8 +782,8 @@ namespace IDE.ui } g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis); - g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(120), textY); - g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(60), textY); + g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(130), textY); + g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(70), textY); //using (g.PushColor(0xD0FFFFFF)) base.DrawAll(g); @@ -764,6 +796,8 @@ namespace IDE.ui mEditWidget.Resize(0, 0, width, height - GS!(16)); if (mQuickFind != null) mQuickFind.ResizeSelf(); + + mMenuButton.Resize(width - GS!(26), height - GS!(12), GS!(16), GS!(16)); } public float GetWantHeight(float wantWidth)