Skip to content

Commit

Permalink
Merge pull request #289 from gui-cs/pre636-support
Browse files Browse the repository at this point in the history
Start working on updating to pre710 nuget package
  • Loading branch information
tznind authored Jun 15, 2024
2 parents dabb543 + 2481c6c commit 86c83f8
Show file tree
Hide file tree
Showing 89 changed files with 1,746 additions and 1,594 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can add new code to `MyDialog.cs` but avoid making any changes to `MyDialog.
For example in `MyDialog.cs` after `InitializeComponent()` add the following:

```csharp
button1.Clicked += ()=>MessageBox.Query("Hello","Hello World","Ok");
button1.Accept += ()=>MessageBox.Query("Hello","Hello World","Ok");
```
Now when run clicking the button will trigger a message box.

Expand Down
25 changes: 0 additions & 25 deletions src/ApplicationExtensions.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/AttributeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public static class AttributeExtensions
/// <returns>Code construct <paramref name="a"/>.</returns>
public static string ToCode(this Terminal.Gui.Attribute a)
{
return $"new Terminal.Gui.Attribute(Color.{a.Foreground},Color.{a.Background})";
return $"new Terminal.Gui.Attribute(Terminal.Gui.Color.{a.Foreground},Terminal.Gui.Color.{a.Background})";
}
}
66 changes: 36 additions & 30 deletions src/DefaultColorSchemes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,49 @@ public class DefaultColorSchemes
/// </summary>
public DefaultColorSchemes()
{
this.RedOnBlack = new NamedColorScheme("redOnBlack");
this.RedOnBlack.Scheme.Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Black);
this.RedOnBlack.Scheme.HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Black);
this.RedOnBlack.Scheme.Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Yellow);
this.RedOnBlack.Scheme.HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Yellow);
this.RedOnBlack.Scheme.Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black);
this.RedOnBlack = new NamedColorScheme("redOnBlack",
new ColorScheme(
normal: new Terminal.Gui.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Black),
hotNormal: new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Black),
focus: new Terminal.Gui.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Yellow),
hotFocus: new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Yellow),
disabled: new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)
));

this.GreenOnBlack = new NamedColorScheme("greenOnBlack");
this.GreenOnBlack.Scheme.Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Black);
this.GreenOnBlack.Scheme.HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Black);
this.GreenOnBlack.Scheme.Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Magenta);
this.GreenOnBlack.Scheme.HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Magenta);
this.GreenOnBlack.Scheme.Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black);
this.GreenOnBlack = new NamedColorScheme("greenOnBlack",
new ColorScheme(
normal : new Terminal.Gui.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Black),
hotNormal: new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Black),
focus: new Terminal.Gui.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Magenta),
hotFocus: new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Magenta),
disabled : new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)));

this.BlueOnBlack = new NamedColorScheme("blueOnBlack");
this.BlueOnBlack.Scheme.Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.Black);
this.BlueOnBlack.Scheme.HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.Black);
this.BlueOnBlack.Scheme.Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.BrightYellow);
this.BlueOnBlack.Scheme.HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.BrightYellow);
this.BlueOnBlack.Scheme.Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black);
this.BlueOnBlack = new NamedColorScheme("blueOnBlack",
new ColorScheme(
normal : new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.Black),
hotNormal: new Terminal.Gui.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.Black),
focus: new Terminal.Gui.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.BrightYellow),
hotFocus: new Terminal.Gui.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.BrightYellow),
disabled: new Terminal.Gui.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)));

this.GrayOnBlack = new NamedColorScheme("greyOnBlack");
this.GrayOnBlack.Scheme.Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);
this.GrayOnBlack.Scheme.HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);
this.GrayOnBlack.Scheme.Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray);
this.GrayOnBlack.Scheme.HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray);
this.GrayOnBlack.Scheme.Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);
this.GrayOnBlack = new NamedColorScheme("greyOnBlack",
new ColorScheme(
normal : new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
hotNormal: new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
focus: new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
hotFocus: new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
disabled: new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black)));

this.TerminalGuiDefault = new NamedColorScheme("tgDefault");
this.TerminalGuiDefault.Scheme.Normal = new Terminal.Gui.Attribute(Color.White, Color.Blue);
this.TerminalGuiDefault.Scheme.HotNormal = new Terminal.Gui.Attribute(Color.BrightCyan, Color.Blue);
this.TerminalGuiDefault.Scheme.Focus = new Terminal.Gui.Attribute(Color.Black, Color.Gray);
this.TerminalGuiDefault.Scheme.HotFocus = new Terminal.Gui.Attribute(Color.BrightBlue, Color.Gray);
this.TerminalGuiDefault = new NamedColorScheme("tgDefault",
new ColorScheme(
normal : new Terminal.Gui.Attribute(Color.White, Color.Blue),
hotNormal : new Terminal.Gui.Attribute(Color.BrightCyan, Color.Blue),
focus : new Terminal.Gui.Attribute(Color.Black, Color.Gray),
hotFocus : new Terminal.Gui.Attribute(Color.BrightBlue, Color.Gray),

// HACK : Keeping this foreground as Brown because otherwise designer will think this is legit
// the real default and assume user has not chosen it. See: https://github.com/gui-cs/TerminalGuiDesigner/issues/133
this.TerminalGuiDefault.Scheme.Disabled = new Terminal.Gui.Attribute(Color.Yellow, Color.Blue);
disabled: new Terminal.Gui.Attribute(Color.Yellow, Color.Blue)));
}

/// <summary>
Expand Down
19 changes: 10 additions & 9 deletions src/Design.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ private IEnumerable<Property> LoadDesignableProperties()

yield return this.CreateSuppressedProperty(nameof(this.View.Visible), true);

yield return this.CreateSuppressedProperty(nameof(this.View.Arrangement), ViewArrangement.Movable);

yield return new ColorSchemeProperty(this);

// its important that this comes before Text because
Expand All @@ -671,11 +673,10 @@ private IEnumerable<Property> LoadDesignableProperties()
yield return this.CreateProperty(nameof(Slider.Orientation));
yield return this.CreateProperty(nameof(Slider.RangeAllowSingle));
yield return this.CreateProperty(nameof(Slider.AllowEmpty));
yield return this.CreateProperty(nameof(Slider.AutoSize));
yield return this.CreateProperty(nameof(Slider.InnerSpacing));
yield return this.CreateProperty(nameof(Slider.MinimumInnerSpacing));
yield return this.CreateProperty(nameof(Slider.LegendsOrientation));
yield return this.CreateProperty(nameof(Slider.ShowLegends));
yield return this.CreateProperty(nameof(Slider.ShowSpacing));
yield return this.CreateProperty(nameof(Slider.ShowEndSpacing));
yield return this.CreateProperty(nameof(Slider.Type));
}

Expand All @@ -688,11 +689,6 @@ private IEnumerable<Property> LoadDesignableProperties()
viewType.GetProperty(nameof(SpinnerView.Style)) ?? throw new Exception($"Could not find expected Property SpinnerView.Style on View of Type '{this.View.GetType()}'"));
}

if (this.View is ScrollView)
{
yield return this.CreateProperty(nameof(ScrollView.ContentSize));
}

if (this.View is TextView)
{
yield return this.CreateProperty(nameof(TextView.AllowsTab));
Expand Down Expand Up @@ -836,7 +832,6 @@ private IEnumerable<Property> LoadDesignableProperties()
if (this.View is RadioGroup)
{
yield return this.CreateProperty(nameof(RadioGroup.RadioLabels));
yield return this.CreateProperty(nameof(RadioGroup.DisplayMode));
}
}

Expand Down Expand Up @@ -866,6 +861,12 @@ private bool ShowTextProperty()
return false;
}

// Do not let Text be set on Slider or Slider<> implementations as weird stuff happens
if(this.View.GetType().Name.StartsWith("Slider") || View is RadioGroup)
{
return false;
}

return !this.excludeTextPropertyFor.Contains(this.View.GetType());
}

Expand Down
4 changes: 2 additions & 2 deletions src/DesignState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ private void DrawContentComplete(object? sender, DrawEventArgs r)
{
if (this.Design.View.IsBorderlessContainerView() && Editor.ShowBorders)
{
this.DrawBorderlessViewFrame(r.Rect);
this.DrawBorderlessViewFrame(r.NewViewport);
}
}

private void DrawBorderlessViewFrame(Rect r)
private void DrawBorderlessViewFrame(Rectangle r)
{
bool isSelected = SelectionManager.Instance.Selected.Contains(this.Design);

Expand Down
Loading

0 comments on commit 86c83f8

Please sign in to comment.