Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions Showcase/Buttons.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Showcase/Checkboxes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Showcase/ColorPickers.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Showcase/Ranges.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Showcase/Showcase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Terminal.Gui" Version="2.0.2-develop.40 " />
<PackageReference Include="Terminal.Gui" Version="2.4.5" />
</ItemGroup>

</Project>
34 changes: 33 additions & 1 deletion src/Design.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,37 @@ private void CreateSubControlDesigns(View view)
}
}

private void SuppressNativeClickEvents(ColorPicker cp)
{

cp.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
cp.MouseEnter += (s, e) => e.Cancel = true;
cp.MouseBindings.Clear();

cp.SubViewAdded += (s,e)=> {
if(e.SubView is ColorBar cb)
{
// Many things trigger CreateBars to happen which recreates all the hue/saturation/lightness etc bars
// So we need to re-register our events each time they are created
SuppressNativeClickEvents(cb);
}
};

foreach (var cb in cp.SubViews.OfType<ColorBar>())
{
SuppressNativeClickEvents(cb);
}
}


private void SuppressNativeClickEvents(ColorBar cb)
{
// prevent control from responding to events
cb.MouseEvent += (s, e) => this.SuppressNativeClickEvents(s, e, true);
cb.MouseEnter += (s, e) => e.Cancel = true;
cb.MouseBindings.Clear();
}

private void SuppressNativeClickEvents(object? sender, Mouse obj, bool alsoSuppressClick = false)
{
if (alsoSuppressClick)
Expand Down Expand Up @@ -642,7 +673,6 @@ private IEnumerable<Property> LoadDesignableProperties()
yield return this.CreateProperty(nameof(LinearRange.LegendsOrientation));
yield return this.CreateProperty(nameof(LinearRange.ShowLegends));
yield return this.CreateProperty(nameof(LinearRange.ShowEndSpacing));
yield return this.CreateProperty(nameof(LinearRange.Type));
}

if(this.View is Link)
Expand Down Expand Up @@ -725,6 +755,8 @@ private IEnumerable<Property> LoadDesignableProperties()
yield return this.CreateSubProperty(nameof(ColorPickerStyle.ColorModel),nameof(ColorPicker.Style),cp.Style);
yield return this.CreateSubProperty(nameof(ColorPickerStyle.ShowColorName), nameof(ColorPicker.Style), cp.Style);
yield return this.CreateSubProperty(nameof(ColorPickerStyle.ShowTextFields), nameof(ColorPicker.Style), cp.Style);

SuppressNativeClickEvents(cp);
}

if (this.View is ListView lv)
Expand Down
6 changes: 4 additions & 2 deletions src/TerminalGuiDesigner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageOutputPath>./nupkg</PackageOutputPath>
<ImplicitUsings>enable</ImplicitUsings>
<PackageId>TerminalGuiDesigner</PackageId>
<Version>2.0.2-develop.40</Version>
<Version>2.4.5</Version>
<Authors>Thomas Nind</Authors>
<Nullable>enable</Nullable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -33,6 +33,8 @@
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>
2.4.5
* Update to latest Terminal.Gui v2.4.5
2.0.2-develop.40
* Release version of v2 Terminal Gui !!!
2.0.0-alpha.5373
Expand Down Expand Up @@ -167,7 +169,7 @@
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Terminal.Gui" Version="2.0.2-develop.40" />
<PackageReference Include="Terminal.Gui" Version="2.4.5" />
<PackageReference Include="nlog" Version="5.3.3" />
<PackageReference Include="Basic.Reference.Assemblies.Net100" Version="1.7.7" />
<PackageReference Include="System.CodeDom" Version="10.0.0" />
Expand Down
46 changes: 44 additions & 2 deletions src/UI/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public class Editor : Runnable, IErrorReporter
/// </summary>
public const string? DesignerCorePopoverName = "CoreDesignerPopupMenu";


/// <summary>
/// The file path that was opened or newed last, allows opening the same directory in file dialog as last time.
/// </summary>
string? LastOpenedFilePath = null;

/// <summary>
/// Initializes a new instance of the <see cref="Editor"/> class.
/// </summary>
Expand Down Expand Up @@ -1264,14 +1270,15 @@ private void DoForSelectedViews(Func<Design, Operation> operationFunc, bool allo
OperationManager.Instance.Do(operationFunc(viewDesign));
}
}

private void Open()
{
var ofd = new OpenDialog()
{
Title = "Open",
AllowedTypes = new List<IAllowedType>(new[] { new AllowedType("View", SourceCodeFile.ExpectedExtension) })
AllowedTypes = new List<IAllowedType>(new[] { new AllowedType("View", SourceCodeFile.ExpectedExtension) }),
};

SetOpenPath(ofd, null);

app.Run(ofd, this.ErrorHandler);

Expand All @@ -1286,6 +1293,7 @@ private void Open()
return;
}

LastOpenedFilePath = path;
this.Open(new FileInfo(path));
}
catch (Exception ex)
Expand Down Expand Up @@ -1354,6 +1362,8 @@ private void New()
};
// ofd.Style.PreserveFilenameOnDirectoryChanges = true;

SetOpenPath(ofd, "MyView.cs");

app.Run(ofd);

if (!ofd.Canceled)
Expand Down Expand Up @@ -1409,6 +1419,38 @@ private void New()
}
}

/// <summary>
/// Sets the path to open to the last opened/newed path optionally with a filename
/// e.g. MyView.cs
/// </summary>
/// <param name="fd"></param>
/// <param name="fileName"></param>
private void SetOpenPath(FileDialog fd, string? fileName)
{
try
{
if (!string.IsNullOrWhiteSpace(LastOpenedFilePath))
{
var p = Path.GetDirectoryName(LastOpenedFilePath);

if (p != null)
{
if (!string.IsNullOrWhiteSpace(fileName))
{
p = Path.Combine(p, fileName);
}

fd.Path = p;
fd.OpenMode = OpenMode.File;
}
}
}
catch (Exception)
{
return;
}
}

private static Type[] GetSupportedRootViews()
{
return new Type[] { typeof(Window), typeof(Dialog), typeof(View), typeof(Runnable) };
Expand Down
Loading
Loading