diff --git a/IDE/src/BeefConfig.bf b/IDE/src/BeefConfig.bf index 361c1757..bdb1e1fc 100644 --- a/IDE/src/BeefConfig.bf +++ b/IDE/src/BeefConfig.bf @@ -13,6 +13,7 @@ namespace IDE public class RegistryEntry { public String mProjName ~ delete _; + public Project.TargetType mTargetType; public SemVer mVersion ~ delete _; public VerSpec mLocation ~ _.Dispose(); public ConfigFile mConfigFile; @@ -51,6 +52,29 @@ namespace IDE using (mMonitor.Enter()) entry.mProjName.Set(projName); } + + if (sd.Contains("StartupObject")) + entry.mTargetType = .BeefConsoleApplication; + else + entry.mTargetType = .BeefLib; + + var targetTypeName = scope String(); + sd.GetString("TargetType", targetTypeName); + + if (!targetTypeName.IsEmpty) + { + switch (targetTypeName) + { // Handle Legacy names first + case "BeefWindowsApplication": + entry.mTargetType = .BeefGUIApplication; + case "C_WindowsApplication": + entry.mTargetType = .C_GUIApplication; + case "BeefDynLib": + entry.mTargetType = .BeefLib; + default: + entry.mTargetType = sd.GetEnum("TargetType", entry.mTargetType); + } + } } } } diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index bb79cd3f..380fd0d1 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -2973,6 +2973,8 @@ namespace IDE { using (mBeefConfig.mRegistry.mMonitor.Enter()) { + BeefConfig.RegistryEntry matchedEntry = null; + for (int regEntryIdx = mBeefConfig.mRegistry.mEntries.Count - 1; regEntryIdx >= 0; regEntryIdx--) { var regEntry = mBeefConfig.mRegistry.mEntries[regEntryIdx]; @@ -2982,11 +2984,19 @@ namespace IDE if (regEntry.mProjName == projectName) { - useVerSpec = regEntry.mLocation; - verConfigDir = regEntry.mConfigFile.mConfigDir; - break FindLoop; + // Prioritize a lib file over a non-lib + if ((matchedEntry == null) || + ((!matchedEntry.mTargetType.IsLib) && (regEntry.mTargetType.IsLib))) + matchedEntry = regEntry; } } + + if (matchedEntry != null) + { + useVerSpec = matchedEntry.mLocation; + verConfigDir = matchedEntry.mConfigFile.mConfigDir; + break FindLoop; + } } mBeefConfig.mRegistry.WaitFor(); } diff --git a/IDE/src/Project.bf b/IDE/src/Project.bf index 9ef7c60f..f7a630c7 100644 --- a/IDE/src/Project.bf +++ b/IDE/src/Project.bf @@ -979,6 +979,20 @@ namespace IDE } } } + + public bool IsLib + { + get + { + switch (this) + { + case BeefLib: + return true; + default: + return false; + } + } + } } public class WindowsOptions diff --git a/IDE/src/ui/InstalledProjectDialog.bf b/IDE/src/ui/InstalledProjectDialog.bf index 88dbf864..e139dd1e 100644 --- a/IDE/src/ui/InstalledProjectDialog.bf +++ b/IDE/src/ui/InstalledProjectDialog.bf @@ -16,9 +16,11 @@ namespace IDE.ui public String mName ~ delete _; public String mPath ~ delete _; public VerSpecRecord mVersion; + public Project.TargetType mTargetType; } protected IDEListView mProjectList; + DarkComboBox mKindCombo; EditWidget mEditWidget; bool mFilterChanged; List mInstalledProjectList = new .() ~ DeleteContainerAndItems!(_); @@ -58,6 +60,21 @@ namespace IDE.ui mEditWidget.mOnKeyDown.Add(new => EditKeyDownHandler); mEditWidget.mOnContentChanged.Add(new (evt) => { mFilterChanged = true; }); + mKindCombo = new DarkComboBox(); + mKindCombo.Label = "Libraries"; + mKindCombo.mPopulateMenuAction.Add(new (menu) => + { + for (var kind in String[?]("All", "Libraries")) + { + menu.AddItem(kind).mOnMenuItemSelected.Add(new (menu) => + { + mFilterChanged = true; + mKindCombo.Label = kind; + }); + } + }); + AddWidget(mKindCombo); + FindProjects(); } @@ -78,6 +95,7 @@ namespace IDE.ui installedProject.mPath.Append("BeefProj.toml"); default: } + installedProject.mTargetType = registryEntry.mTargetType; mInstalledProjectList.Add(installedProject); } } @@ -128,9 +146,14 @@ namespace IDE.ui mEditWidget.GetText(filterString); filterString.Trim(); + bool onlyLibs = mKindCombo.Label == "Libraries"; + mFilteredList.Clear(); for (var installedProject in mInstalledProjectList) { + if ((onlyLibs) && (!installedProject.mTargetType.IsLib)) + continue; + if ((!filterString.IsEmpty) && (installedProject.mName.IndexOf(filterString, true) == -1)) continue; @@ -138,7 +161,7 @@ namespace IDE.ui listViewItem.Label = installedProject.mName; var subListViewItem = listViewItem.CreateSubItem(1); - subListViewItem.Label = installedProject.mPath; + subListViewItem.Label = Path.GetDirectoryPath(installedProject.mPath, .. scope .()); mFilteredList.Add(installedProject); } @@ -223,6 +246,7 @@ namespace IDE.ui float insetSize = GS!(6); mProjectList.Resize(insetSize, insetSize, mWidth - insetSize - insetSize, mHeight - GS!(66)); mEditWidget.Resize(insetSize, mProjectList.mY + mProjectList.mHeight + insetSize, mWidth - insetSize - insetSize, GS!(22)); + mKindCombo.Resize(insetSize, mHeight - GS!(26), Math.Min(GS!(160), mDefaultButton.mX - GS!(6)), GS!(26)); } public override void CalcSize()