Skip to content

Commit

Permalink
- Remove AllowFormChrome and replace with a sensible named Value fr…
Browse files Browse the repository at this point in the history
…om `Current Metrics`

- Fix fallout from changes
- A few nullables
- KryptonManager designer `IsDefault` visibility fix
- Update "Breaking Changes"

#139
#124
  • Loading branch information
Smurf-IV committed Dec 24, 2023
1 parent ceda57c commit 48a23be
Show file tree
Hide file tree
Showing 56 changed files with 379 additions and 601 deletions.
2 changes: 2 additions & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
=======

## 2024-11-xx - Build 2411 - November 2024
* Implemented [#139](https://github.com/Krypton-Suite/Standard-Toolkit/issues/139), Themes (via KryptonManager design option) should have option to resepect Current Metrics for Form Border widths
* Implemented [#124](https://github.com/Krypton-Suite/Standard-Toolkit/issues/124), When setting AllowFormChrome = false, then the Form Bar should still be Theme rendered
* Implemented [#1224](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1224), **[Breaking Change]** Move `GlobalPaletteMode` into `GlobalPalette` and rename
* Implemented [#1223](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1223), Move `UseKryptonFileDialogs` to a better designer location
* Implemented [#1222](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1222), Remove `CustomPalette` (Should be part of the palette definition)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ There are list of changes that have occurred during the development of the V90.#
- BaseFont is now part of the KryptonManager class, and will override the applied palette font(s)
- `CustomPalette` must be derived from the `KryptonCustomPaletteBase` class
- `BasePaletteMode` has been removed from `KryptonCustomPaletteBase` class
- [#124](https://github.com/Krypton-Suite/Standard-Toolkit/issues/124), When setting AllowFormChrome = false, then the Form Bar should still be Theme rendered
- `AllowFormChrome` has been removed and replaced with `UseThemeFormChromeBorderWidth` to better explain what it is doing
- It means that a theme can get closer to "Material Design", and that the Title bar can still be themed (And rounded)

### Support for .NET 7
As of V90.##, support for .NET 7 has been removed due to their release cadences.


### `KryptonButton` Properties
Some properties previously found in the root such as, `ShowSplitOption`, `UseAsADialogButton`, `UseAsUACElevationButton` and `UACShieldIconSize` are now located in the `Values` section.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QAT/@EntryIndexedValue">QAT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=ourself/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=to_0020layout_0020the/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/InstalledDictionaries/InstalledDictionaries/=Z_003A_005CGitHub_005CKrypton_002DSuite_005CStandard_002DToolkit_005Cdictionary_002Den_002Dgb_005Cindex_002Edic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/InstalledDictionaries/UseBundled/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=acti/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override bool GetVisible(PaletteBase palette)
{
// We do not show if the custom chrome is combined with composition,
// in which case the form buttons are handled by the composition
if (_navigator.Owner!.ApplyComposition && _navigator.Owner.ApplyCustomChrome)
if (_navigator.Owner!.ApplyComposition && _navigator.Owner.UseThemeFormChromeBorderWidth)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override bool GetVisible(PaletteBase palette)
{
// We do not show if the custom chrome is combined with composition,
// in which case the form buttons are handled by the composition
if (_navigator.Owner!.ApplyComposition && _navigator.Owner!.ApplyCustomChrome)
if (_navigator.Owner!.ApplyComposition && _navigator.Owner!.UseThemeFormChromeBorderWidth)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class ViewletHeaderGroup
private ViewDrawContent _viewContentPrimary;
private ViewDrawDocker _viewHeadingSecondary;
private ViewDrawContent _viewContentSecondary;
private ButtonSpecManagerDraw _buttonManager;
private ButtonSpecManagerDraw? _buttonManager; // Can be null in the designer
private readonly NeedPaintHandler _needPaintDelegate;
#endregion

Expand Down Expand Up @@ -84,19 +84,22 @@ public void PostCreate()
UpdateStatePalettes();

// Force buttons to be recreated in the headers
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
}

/// <summary>
/// Destruct and cleanup the view hierarchy of the header group.
/// </summary>
public void Destruct()
{
// Remove paint delegate so we can be garbage collected
_buttonManager.NeedPaint = null;
if (_buttonManager != null)
{
// Remove paint delegate so we can be garbage collected
_buttonManager.NeedPaint = null;

// Cleanup the button manager events and processing
_buttonManager.Destruct();
// Cleanup the button manager events and processing
_buttonManager.Destruct();
}

// Remove the old root from the canvas
_viewGroup.Dispose();
Expand All @@ -110,14 +113,14 @@ public void Destruct()
/// <returns>Reference to ButtonSpec; otherwise null.</returns>
public ButtonSpec? ButtonSpecFromView(ViewBase element) =>
// Ask the button manager for the button spec for this element
_buttonManager.ButtonSpecFromView(element);
_buttonManager?.ButtonSpecFromView(element);

/// <summary>
/// Recreate the buttons to reflect a change in selected page.
/// </summary>
public void UpdateButtons() =>
// Ensure buttons are recreated to reflect different page
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();

/// <summary>
/// Ensure the correct state palettes are being used.
Expand Down Expand Up @@ -162,7 +165,7 @@ public void UpdateStatePalettes()
public Point GetContextShowPoint()
{
// Get the display rectangle of the context button
Rectangle rect = _buttonManager.GetButtonRectangle(Navigator.Button.ContextButton);
Rectangle rect = _buttonManager!.GetButtonRectangle(Navigator.Button.ContextButton);

// We want the context menu to show just below the button
var pt = new Point(rect.Left, rect.Bottom + 3);
Expand All @@ -178,7 +181,7 @@ public Point GetContextShowPoint()
/// <returns>True if the view wants the mouse position; otherwise false.</returns>
public bool DesignerGetHitTest(Point pt) =>
// Check if any of the buttons want the point
_buttonManager.DesignerGetHitTest(pt);
_buttonManager?.DesignerGetHitTest(pt) ?? false;

/// <summary>
/// Get the appropriate action for the header group next action.
Expand Down Expand Up @@ -232,12 +235,12 @@ public virtual void ViewBuilderPropertyChanged(PropertyChangedEventArgs e)
break;
case @"HeaderPositionPrimary":
SetHeaderPosition(_viewHeadingPrimary, _viewContentPrimary, Navigator.Header.HeaderPositionPrimary);
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
Navigator.PerformNeedPaint(true);
break;
case @"HeaderPositionSecondary":
SetHeaderPosition(_viewHeadingSecondary, _viewContentSecondary, Navigator.Header.HeaderPositionSecondary);
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
Navigator.PerformNeedPaint(true);
break;
case @"HeaderVisiblePrimary":
Expand All @@ -255,7 +258,7 @@ public virtual void ViewBuilderPropertyChanged(PropertyChangedEventArgs e)
case @"ContextButtonDisplay":
case @"CloseButtonDisplay":
case nameof(ButtonDisplayLogic):
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
break;
}
}
Expand Down Expand Up @@ -381,47 +384,47 @@ private void SetHeaderStyle(ViewDrawDocker drawDocker,
switch (style)
{
case HeaderStyle.Primary:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetPrimary,
PaletteMetricPadding.HeaderButtonPaddingPrimary);
break;
case HeaderStyle.Secondary:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetSecondary,
PaletteMetricPadding.HeaderButtonPaddingSecondary);
break;
case HeaderStyle.DockActive:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetDockActive,
PaletteMetricPadding.HeaderButtonPaddingDockActive);
break;
case HeaderStyle.DockInactive:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetDockInactive,
PaletteMetricPadding.HeaderButtonPaddingDockInactive);
break;
case HeaderStyle.Form:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetForm,
PaletteMetricPadding.HeaderButtonPaddingForm);
break;
case HeaderStyle.Calendar:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetCalendar,
PaletteMetricPadding.HeaderButtonPaddingCalendar);
break;
case HeaderStyle.Custom1:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetCustom1,
PaletteMetricPadding.HeaderButtonPaddingCustom1);
break;
case HeaderStyle.Custom2:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetCustom2,
PaletteMetricPadding.HeaderButtonPaddingCustom2);
break;
case HeaderStyle.Custom3:
_buttonManager.SetDockerMetrics(drawDocker, palette,
_buttonManager?.SetDockerMetrics(drawDocker, palette,
PaletteMetricInt.HeaderButtonEdgeInsetCustom3,
PaletteMetricPadding.HeaderButtonPaddingCustom3);
break;
Expand Down Expand Up @@ -468,8 +471,8 @@ private void SetPalettes(PaletteHeaderGroup? palette)
_viewHeadingPrimary.SetPalettes(palette.HeaderPrimary.Back, palette.HeaderPrimary.Border, palette.HeaderPrimary);
_viewHeadingSecondary.SetPalettes(palette.HeaderSecondary.Back, palette.HeaderSecondary.Border, palette.HeaderSecondary);

_buttonManager.SetDockerMetrics(_viewHeadingPrimary, palette.HeaderPrimary);
_buttonManager.SetDockerMetrics(_viewHeadingSecondary, palette.HeaderSecondary);
_buttonManager?.SetDockerMetrics(_viewHeadingPrimary, palette.HeaderPrimary);
_buttonManager?.SetDockerMetrics(_viewHeadingSecondary, palette.HeaderSecondary);

_viewContentPrimary.SetPalette(palette.HeaderPrimary.Content);
_viewContentSecondary.SetPalette(palette.HeaderSecondary.Content);
Expand All @@ -482,7 +485,7 @@ private void SetEnabled(bool enabled)
_viewHeadingSecondary.Enabled = enabled;
_viewContentPrimary.Enabled = enabled;
_viewContentSecondary.Enabled = enabled;
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
}

private void OnDragStart(object sender, DragStartEventCancelArgs e) => Navigator.InternalDragStart(e, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*
* New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE)
* Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved.
*
* Modified: Monday 12th April, 2021 @ 18:00 GMT
*
*/
#endregion

Expand Down Expand Up @@ -731,13 +728,13 @@ public ViewDrawRibbonCaptionArea([DisallowNull] KryptonRibbon ribbon,
CAPTION_TEXT_GAPS = (int)(FactorDpiX * 10); // 4 below and 6 above
MIN_SELF_HEIGHT = (int)(FactorDpiY * 28); // Min height to show application button and the mini bar and context tabs
// Remember incoming references
_ribbon = ribbon;
_compositionArea = compositionArea;
_needPaintDelegate = needPaintDelegate;
_ribbon = ribbon!;
_compositionArea = compositionArea!;
_needPaintDelegate = needPaintDelegate!;
_needIntegratedDelegate = OnIntegratedNeedPaint;

// Create a special redirector for overriding the border setting
_redirect = new PaletteCaptionRedirect(redirect);
_redirect = new PaletteCaptionRedirect(redirect!);

CreateViewElements();
SetupParentMonitoring();
Expand Down Expand Up @@ -765,7 +762,7 @@ protected override void Dispose(bool disposing)
_integrated = false;
}

_kryptonForm.ApplyCustomChromeChanged -= OnFormChromeCheck;
_kryptonForm.ApplyUseThemeFormChromeBorderWidthChanged -= OnFormChromeCheck;
_kryptonForm.ClientSizeChanged -= OnFormChromeCheck;
_kryptonForm.WindowActiveChanged -= OnWindowActiveChanged;
_kryptonForm = null;
Expand Down Expand Up @@ -1062,7 +1059,7 @@ public override Size GetPreferredSize([DisallowNull] ViewLayoutContext context)
Debug.Assert(context != null);

// Enforce the minimum height
Size preferredSize = base.GetPreferredSize(context);
Size preferredSize = base.GetPreferredSize(context!);
preferredSize.Height = Math.Max(_calculatedHeight, preferredSize.Height);

return preferredSize;
Expand Down Expand Up @@ -1138,7 +1135,7 @@ private void CreateViewElements()
}

private void SetupParentMonitoring() =>
// We have to know when the parent of the ribbon changes so we can then hook
// We have to know when the parent of the ribbon changes, so we can then hook
// into monitoring the top level custom chrome control. We need information this
// decide if we integrate with top chrome or show this control instead.
_ribbon.ParentChanged += OnRibbonParentChanged;
Expand All @@ -1148,7 +1145,7 @@ private void OnRibbonParentChanged(object sender, EventArgs e)
// Unhook from any current krypton form monitoring
if (_kryptonForm != null)
{
_kryptonForm.ApplyCustomChromeChanged -= OnFormChromeCheck;
_kryptonForm.ApplyUseThemeFormChromeBorderWidthChanged -= OnFormChromeCheck;
_kryptonForm.ClientSizeChanged -= OnFormChromeCheck;
_kryptonForm.WindowActiveChanged -= OnWindowActiveChanged;
_kryptonForm = null;
Expand All @@ -1165,7 +1162,7 @@ private void OnRibbonParentChanged(object sender, EventArgs e)
{
_kryptonForm = form;
_kryptonForm.Composition = _compositionArea;
_kryptonForm.ApplyCustomChromeChanged += OnFormChromeCheck;
_kryptonForm.ApplyUseThemeFormChromeBorderWidthChanged += OnFormChromeCheck;
_kryptonForm.ClientSizeChanged += OnFormChromeCheck;
_kryptonForm.WindowActiveChanged += OnWindowActiveChanged;
}
Expand All @@ -1181,7 +1178,7 @@ private void OnFormChromeCheck(object? sender, EventArgs e)
var integrated = false;

// Are we inside a KryptonForm instance that is using custom chrome?
if (_kryptonForm is { ApplyCustomChrome: true })
if (_kryptonForm != null)
{
// Ribbon must be placed at the top left of the forms client area
if (_ribbon.Location == Point.Empty)
Expand All @@ -1198,10 +1195,7 @@ private void OnFormChromeCheck(object? sender, EventArgs e)
// Update width of the separator used in place of the app button when app button not visible
_spaceInsteadOfAppButton.SeparatorSize = new Size(_kryptonForm.RealWindowBorders.Left, 0);
}
}

if (_kryptonForm != null)
{
var overrideIntegrated = integrated;

// If told to prevent the integration, then prevent it now
Expand Down Expand Up @@ -1279,7 +1273,7 @@ private void OnFormChromeCheck(object? sender, EventArgs e)
Font ribbonFont = _ribbon.StateCommon.RibbonGeneral.GetRibbonTextFont(PaletteState.Normal);

// Can we use the cached font height?
if (ribbonFont != _cacheRibbonFont)
if (!Equals(ribbonFont, _cacheRibbonFont))
{
_cacheRibbonFont = ribbonFont;
_cacheRibbonFontHeight = ribbonFont.Height;
Expand Down Expand Up @@ -1310,7 +1304,7 @@ private void OnFormChromeCheck(object? sender, EventArgs e)

private void OnWindowActiveChanged(object sender, EventArgs e)
{
if (_kryptonForm is { ApplyCustomChrome: true, ApplyComposition: true })
if (_kryptonForm is { ApplyComposition: true })
// When integrated into composition we need to repaint whenever the
// owning form changes active status, as we are drawing the caption
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override Size GetPreferredSize(ViewLayoutContext context)
var preferredSize = Size.Empty;

// We need an owning form to perform calculations
if (CompOwnerForm is { ApplyCustomChrome: true, ApplyComposition: true })
if (CompOwnerForm is { ApplyComposition: true })
// We only have size if custom chrome is being used with composition
{
try
Expand Down
Loading

0 comments on commit 48a23be

Please sign in to comment.