From 5f84a7e4e316554f1974ef15d57d1b374c89131e Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 23 Sep 2019 09:40:56 -0700 Subject: [PATCH] Adding "CTRL UP/DOWN" tutorial for autocomplete --- .../Beefy2D/src/theme/dark/DarkTooltip.bf | 6 ++--- IDE/src/Settings.bf | 16 ++++++++++++ IDE/src/ui/SourceEditWidgetContent.bf | 26 ++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf index 709aec62..3104e3a1 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf @@ -34,6 +34,7 @@ namespace Beefy.theme.dark public bool mHasClosed; public Insets mRelWidgetMouseInsets ~ delete _; public bool mAllowMouseInsideSelf; + public bool mRequireMouseInside; public const float cShadowSize = 8; @@ -223,9 +224,8 @@ namespace Beefy.theme.dark if (mWidgetWindow == null) return; - /*var lastMouseWidget = IDEApp.sApp.sLastMouseWidget; - if ((lastMouseWidget != null) && (lastMouseWidget != mRelWidget) && (lastMouseWidget.mWidgetWindow != mWidgetWindow)) - Close();*/ + if (!mRequireMouseInside) + return; float rootX; float rootY; diff --git a/IDE/src/Settings.bf b/IDE/src/Settings.bf index f2f02aa3..ffbfe30a 100644 --- a/IDE/src/Settings.bf +++ b/IDE/src/Settings.bf @@ -631,6 +631,11 @@ namespace IDE } } + public struct TutorialsFinished + { + public bool mCtrlCursor; + } + public bool mLoadedSettings; public CompilerSettings mCompilerSettings = new .() ~ delete _; @@ -641,6 +646,7 @@ namespace IDE public RecentFiles mRecentFiles = new RecentFiles() ~ delete _; public String mWakaTimeKey = new .() ~ delete _; public bool mEnableDevMode; + public TutorialsFinished mTutorialsFinished = .(); public this() { @@ -700,6 +706,11 @@ namespace IDE sd.Add("EnableDevMode", mEnableDevMode); } + using (sd.CreateObject("TutorialsFinished")) + { + sd.Add("CtrlCursor", mTutorialsFinished.mCtrlCursor); + } + String dataStr = scope String(); sd.ToTOML(dataStr); gApp.SafeWriteTextFile(path, dataStr); @@ -749,6 +760,11 @@ namespace IDE sd.Get("WakaTimeKey", mWakaTimeKey); sd.Get("EnableDevMode", ref mEnableDevMode); } + + using (sd.Open("TutorialsFinished")) + { + sd.Get("CtrlCursor", ref mTutorialsFinished.mCtrlCursor); + } } public void Apply() diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 3624ba06..c5184081 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -2722,6 +2722,28 @@ namespace IDE.ui { mIgnoreKeyChar = false; + if (((keyCode == .Up) || (keyCode == .Down)) && + (mAutoComplete != null) && (mAutoComplete.IsShowing()) && (mAutoComplete.mListWindow != null) && + (!mAutoComplete.IsInPanel()) && + (!gApp.mSettings.mTutorialsFinished.mCtrlCursor)) + { + if (mWidgetWindow.IsKeyDown(.Control)) + { + if ((DarkTooltipManager.sTooltip != null) && (!DarkTooltipManager.sTooltip.mRequireMouseInside)) + DarkTooltipManager.CloseTooltip(); + gApp.mSettings.mTutorialsFinished.mCtrlCursor = true; + } + else + { + GetTextCoordAtCursor(var cursorX, var cursorY); + + let tooltip = DarkTooltipManager.ShowTooltip("Hold CTRL when using UP and DOWN", this, cursorX - GS!(24), cursorY - GS!(40)); + if (tooltip != null) + tooltip.mRequireMouseInside = false; + return; + } + } + /*if (keyCode == .Tilde) { Thread.Sleep(300); @@ -2847,7 +2869,9 @@ namespace IDE.ui int prevTextLength = mData.mTextLength; base.KeyDown(keyCode, isRepeat); - if (mAutoComplete != null) + if ((mAutoComplete != null) && + (keyCode != .Control) && + (keyCode != .Shift)) { mAutoComplete.MarkDirty(); bool isCursorInRange = prevCursorPos == CursorTextPos;