Browse Source

Minor IDE modifications

Brian Fiete 6 years ago
parent
commit
908dbe1a6e

+ 6 - 0
BeefLibs/Beefy2D/src/widgets/Dialog.bf

@@ -248,6 +248,11 @@ namespace Beefy.widgets
                 SetFocus();
         }  
 
+		public virtual void WindowCreated()
+		{
+
+		}
+
         public virtual void PopupWindow(WidgetWindow parentWindow, float offsetX = 0, float offsetY = 0)
         {
             if (mClosed)
@@ -295,6 +300,7 @@ namespace Beefy.widgets
 
             widgetWindow.mOnWindowCloseQuery.Add(windowCloseHandler);
             widgetWindow.mOnWindowKeyDown.Add(new => WindowKeyDown);
+			WindowCreated();
         }
 
         public virtual bool HandleTab(int dir)

+ 4 - 3
IDE/src/Commands.bf

@@ -104,7 +104,8 @@ namespace IDE
 		public enum ContextFlags
 		{
 			None = 0,
-			Editor = 1
+			MainWindow = 1,
+			Editor = 2,
 		}
 
 		public String mName ~ delete _;
@@ -158,7 +159,7 @@ namespace IDE
 			};
 		public CommandMap mKeyMap = new .() ~ delete _;
 
-		void Add(StringView name, Action act, IDECommand.ContextFlags contextFlags = .None)
+		void Add(StringView name, Action act, IDECommand.ContextFlags contextFlags = .MainWindow)
 		{
 			let cmd = new IDECommand();
 			cmd.mName = new String(name);
@@ -170,7 +171,7 @@ namespace IDE
 		public void Init()
 		{
 			Add("About", new => gApp.ShowAbout);
-			Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete);
+			Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete, .None);
 			Add("Bookmark Next", new => gApp.Cmd_NextBookmark, .Editor);
 			Add("Bookmark Prev", new => gApp.Cmd_PrevBookmark, .Editor);
 			Add("Bookmark Toggle", new => gApp.Cmd_ToggleBookmark, .Editor);

+ 57 - 22
IDE/src/IDEApp.bf

@@ -1,4 +1,6 @@
-using System; //abc
+using System;
+using System.Security.Cryptography;
+using System.Text;
 using System.Collections.Generic;
 using System.Text;
 using System.IO;
@@ -10,7 +12,6 @@ using Beefy.widgets;
 using Beefy.gfx;
 using Beefy.theme;
 using Beefy.theme.dark;
-using IDE.ui;
 using Beefy.sys;
 using Beefy.events;
 using Beefy.geom;
@@ -20,8 +21,7 @@ using Beefy.utils;
 using IDE.Debugger;
 using IDE.Compiler;
 using IDE.Util;
-using System.Security.Cryptography;
-using System.Text;
+using IDE.ui;
 using IDE.util;
 
 [AttributeUsage(.Method, .ReflectAttribute | .AlwaysIncludeTarget, ReflectUser=.All)]
@@ -3363,12 +3363,10 @@ namespace IDE
 		[IDECommand]
 		public void Cmd_ShowAutoComplete()
 		{
-			var activeTextPanel = GetActivePanel() as TextPanel;
-			if (activeTextPanel != null)
+			var sewc = GetActiveSourceEditWidgetContent();
+			if (sewc != null)
 			{
-				var sewc = activeTextPanel.EditWidget.mEditWidgetContent as SourceEditWidgetContent;
-				if (sewc != null)
-					sewc.ShowAutoComplete(true);
+				sewc.ShowAutoComplete(true);
 			}
 		}
 
@@ -4885,7 +4883,7 @@ namespace IDE
         IDETabbedView CreateTabbedView()
         {
             var tabbedView = new IDETabbedView();
-            tabbedView.mSharedData.mOpenNewWindowDelegate.Add(new (fromTabbedView, newWindow) => SetupNewWindow(newWindow));
+            tabbedView.mSharedData.mOpenNewWindowDelegate.Add(new (fromTabbedView, newWindow) => SetupNewWindow(newWindow, true));
 			tabbedView.mSharedData.mTabbedViewClosed.Add(new (tabbedView) =>
                 {
 					if (tabbedView == mActiveDocumentsTabbedView)
@@ -4894,10 +4892,11 @@ namespace IDE
             return tabbedView;
         }
 
-        void SetupNewWindow(WidgetWindow window)
+        public void SetupNewWindow(WidgetWindow window, bool isMainWindow)
         {
             window.mOnWindowKeyDown.Add(new => SysKeyDown);
-            window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose);
+			if (isMainWindow)
+            	window.mOnWindowCloseQuery.Add(new => SecondaryAllowClose);
         }        
 
 		DarkTabbedView FindDocumentTabbedView()
@@ -5045,6 +5044,28 @@ namespace IDE
             return null;
         }
 
+		public SourceEditWidgetContent GetActiveSourceEditWidgetContent()
+		{
+			let activeWindow = GetActiveWindow();
+			if (activeWindow.mFocusWidget != null)
+			{
+				if (let editWidget = activeWindow.mFocusWidget as EditWidget)
+				{
+					let sewc = editWidget.mEditWidgetContent as SourceEditWidgetContent;
+					if (sewc != null)
+						return sewc;
+				}
+			}
+
+			var activeTextPanel = GetActivePanel() as TextPanel;
+			if (activeTextPanel != null)
+			{
+				return activeTextPanel.EditWidget.mEditWidgetContent as SourceEditWidgetContent;
+			}
+
+			return null;
+		}
+
 		public WidgetWindow GetActiveWindow()
 		{
 			for (let window in mWindows)
@@ -6345,7 +6366,7 @@ namespace IDE
 					}
 					else
 						mWorkspace.mDir = fullDir;
-				case "-path":
+				case "-file":
 					String.NewOrSet!(mDeferredOpenFileName, value);
 					if (mDeferredOpenFileName.EndsWith(".bfdbg", .OrdinalIgnoreCase))
 						mDeferredOpen = .DebugSession;
@@ -6584,11 +6605,26 @@ namespace IDE
 
         void SysKeyDown(KeyDownEvent evt)
         {
+			 if (evt.mHandled)
+				return;
+
             var window = (WidgetWindow)evt.mSender;                     
 
+			IDECommand.ContextFlags useFlags = .None;
+			var activeWindow = GetActiveWindow();
+			bool isMainWindow = activeWindow.mRootWidget is MainFrame;
+
+			var activePanel = GetActivePanel() as Panel;
+			if (activePanel is SourceViewPanel)
+				useFlags |= .Editor;
+			else if (activePanel is DisassemblyPanel)
+				useFlags |= .Editor;
+
+			if (isMainWindow)
+				useFlags |= .MainWindow;
+
 			if (evt.mKeyCode == .Tab)
 			{
-				var activePanel = GetActivePanel() as Panel;
 				if (activePanel != null)
 				{
 					if (activePanel.HandleTab(window.IsKeyDown(.Shift) ? -1 : 1))
@@ -6620,20 +6656,19 @@ namespace IDE
 				}
 				else if (var command = commandBase as IDECommand)
 				{
-					IDECommand.ContextFlags useFlags = .None;
-					var activePanel = GetActivePanel();
-					if (activePanel is SourceViewPanel)
-						useFlags |= .Editor;
-					else if (activePanel is DisassemblyPanel)
-						useFlags |= .Editor;
-
 					bool foundMatch = false;
 					if (useFlags != .None)
 					{
 						var checkCommand = command;
 						while (checkCommand != null)
 						{
-							if (checkCommand.mContextFlags.HasFlag(useFlags))
+							bool matches = checkCommand.mContextFlags == .None;
+							if (checkCommand.mContextFlags.HasFlag(.Editor))
+								matches |= useFlags.HasFlag(.Editor);
+							if (checkCommand.mContextFlags.HasFlag(.MainWindow))
+								matches |= useFlags.HasFlag(.MainWindow);
+
+							if (matches)
 							{
 								checkCommand.mAction();
 								foundMatch = true;

+ 6 - 0
IDE/src/ui/IDEDialog.bf

@@ -12,6 +12,12 @@ namespace IDE.ui
 		public DarkButton mNextButton;
 		public SettingHistoryManager mSettingHistoryManager;
 
+		public override void WindowCreated()
+		{
+			base.WindowCreated();
+			gApp.SetupNewWindow(mWidgetWindow, false);
+		}
+
 		public void CreatePrevNextButtons()
 		{
 			mPrevButton = new DarkButton();

+ 8 - 0
IDE/src/ui/ProjectPanel.bf

@@ -1908,6 +1908,14 @@ namespace IDE.ui
 								gApp.mWorkspace.SetChanged();
 							}
 					    });
+					
+					item = menu.AddItem("Rename");
+					item.mOnMenuItemSelected.Add(new (item) =>
+						{
+							var projectItem = GetSelectedProjectItem();
+							if (projectItem != null)
+								RenameItem(projectItem);
+						});
 
 					item = menu.AddItem("Refresh");
 					item.mOnMenuItemSelected.Add(new (item) =>

+ 9 - 1
IDE/src/ui/ProjectProperties.bf

@@ -908,10 +908,17 @@ namespace IDE.ui
 
         protected override bool ApplyChanges()
         {
+			if (mApplyButton.mDisabled)
+				return true;
+
 			if (mProject.mLocked)
 			{
 				let dialog = gApp.Fail(
-					"This project is locked because it may be a shared library, and editing shared libraries may have unwanted effects on other programs that use it.\n\nIf you are sure you want to edit this project then you can unlock it with the lock icon in the lower left of the",
+					"""
+					This project is locked because it may be a shared library, and editing shared libraries may have unwanted effects on other programs that use it.
+
+					If you are sure you want to edit this project then you can unlock it with the lock icon in the lower left of the properties dialog.
+					""",
 					null, mWidgetWindow);
 				dialog.mWindowFlags |= .Modal;
 				if (dialog != null)
@@ -1090,6 +1097,7 @@ namespace IDE.ui
 					{
 						mProject.mLocked = !mProject.mLocked;
 						gApp.mWorkspace.SetChanged();
+						gApp.mProjectPanel.MarkDirty();
 					});
 				if (mProject.mLocked)
 					menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);

+ 5 - 1
IDE/src/ui/SourceEditWidgetContent.bf

@@ -3057,7 +3057,11 @@ namespace IDE.ui
 
 						menuItem = menu.AddItem("Go to Definition");
 						menuItem.SetDisabled(!hasText);
-	                    menuItem.mOnMenuItemSelected.Add(new (evt) => IDEApp.sApp.GoToDefinition());
+	                    menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.GoToDefinition());
+
+						menuItem = menu.AddItem("Rename Symbol");
+						menuItem.SetDisabled(!hasText);
+						menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.Cmd_RenameSymbol());
 
 	                    menuItem = menu.AddItem("Add Watch");
 						menuItem.SetDisabled(!hasText);

+ 2 - 4
IDE/src/ui/TypeWildcardEditWidget.bf

@@ -24,8 +24,7 @@ namespace IDE.ui
 			var editText = scope String();
 			GetText(editText);
 
-			int cursorPos = doAutoComplete ? mEditWidgetContent.CursorTextPos - 1 : -1;
-#unwarn
+			int cursorPos = doAutoComplete ? mEditWidgetContent.CursorTextPos : -1;
 
 			int editOffset = 0;
 			if (cursorPos > 0)
@@ -54,8 +53,7 @@ namespace IDE.ui
 			{
 				mEditWidgetContent.mData.mText[editOffset + ofs].mDisplayTypeId = isValid ? 0 : 1;
 			}
-			//mColors[0] = isValid ? 0xFFFFFFFF : 0xFFFF8080;
-
+			
 			if (doAutoComplete)
 			{
 				String autocompleteInfo = scope String();