Skip to content

Commit

Permalink
Merge pull request #2475 from cwensley/curtis/mac-override-nsbox-tinting
Browse files Browse the repository at this point in the history
Add ability to override NSBox tinting using styles
  • Loading branch information
cwensley committed May 16, 2023
2 parents 990442a + 0a6f317 commit 7ce5c68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/Controls/GroupBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ public override void InvalidateMeasure()
_borderSize = null;
}

protected override bool UseNSBoxBackgroundColor => false;
protected override bool DefaultUseNSBoxBackgroundColor => false;
}
}
11 changes: 9 additions & 2 deletions src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public interface IMacViewHandler : IMacControlHandler
int SuppressMouseEvents { get; set; }
bool TextInputCancelled { get; set; }
bool TextInputImplemented { get; }
bool UseNSBoxBackgroundColor { get; set; }

DragEventArgs GetDragEventArgs(NSDraggingInfo info, object customControl);

Expand Down Expand Up @@ -179,6 +180,7 @@ static partial class MacView
public static readonly object SuppressMouseEvents_Key = new object();
public static readonly object UseMouseTrackingLoop_Key = new object();
public static readonly object MouseTrackingRunLoopMode_Key = new object();
public static readonly object UseNSBoxBackgroundColor_Key = new object();
public static readonly IntPtr selSetDataProviderForTypes_Handle = Selector.GetHandle("setDataProvider:forTypes:");
public static readonly IntPtr selInitWithPasteboardWriter_Handle = Selector.GetHandle("initWithPasteboardWriter:");
public static readonly IntPtr selClass_Handle = Selector.GetHandle("class");
Expand All @@ -187,7 +189,6 @@ static partial class MacView
// before 10.12, we have to call base.Layout() AFTER we do our layout otherwise it doesn't work correctly..
// however, that causes (temporary) glitches when resizing especially with Scrollable >= 10.12
public static readonly bool NewLayout = MacVersion.IsAtLeast(10, 12);

internal static MarshalDelegates.Action_IntPtr_IntPtr_IntPtr TriggerMouseDragged_Delegate = TriggerMouseDragged;
static void TriggerMouseDragged(IntPtr sender, IntPtr sel, IntPtr e)
{
Expand Down Expand Up @@ -934,7 +935,13 @@ public virtual Color BackgroundColor

bool drawRectAdded;

protected virtual bool UseNSBoxBackgroundColor => true;
public bool UseNSBoxBackgroundColor
{
get => Widget.Properties.Get<bool>(MacView.UseNSBoxBackgroundColor_Key, DefaultUseNSBoxBackgroundColor);
set => Widget.Properties.Set(MacView.UseNSBoxBackgroundColor_Key, value, DefaultUseNSBoxBackgroundColor);
}

protected virtual bool DefaultUseNSBoxBackgroundColor => true;

protected virtual IColorizeCell ColorizeCell => null;

Expand Down

0 comments on commit 7ce5c68

Please sign in to comment.