mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Improved Add From Installed IDE project dialog
This commit is contained in:
parent
48635c1939
commit
d204922403
4 changed files with 76 additions and 4 deletions
|
@ -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<Project.TargetType>("TargetType", entry.mTargetType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -979,6 +979,20 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLib
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case BeefLib:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowsOptions
|
||||
|
|
|
@ -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<InstalledProject> 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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue