Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Improved brush management + styles #788

Merged
merged 25 commits into from
Oct 22, 2023
Merged

[UX] Improved brush management + styles #788

merged 25 commits into from
Oct 22, 2023

Conversation

niels9001
Copy link
Collaborator

@niels9001 niels9001 commented Oct 17, 2023

This PR changes the hardcoded brushes for Button.xaml to dedicated Button-named brushes in Light/Dark.xaml

Addressing #777

First phase (= this PR):

  • Define dedicated control brush names for Light.xaml and Dark.xaml
  • Define the correct high contrast variations in HighContrast.xaml
  • Fixing / improving control styles (where needed)

@niels9001
Copy link
Collaborator Author

@pomianowski Would love to get your feedback on this approach before I continue with the other controls!

@niels9001 niels9001 changed the title Improved brush management [UX] Improved brush management + styles Oct 19, 2023
@pomianowski pomianowski marked this pull request as ready for review October 19, 2023 18:24
@pomianowski pomianowski self-requested a review as a code owner October 19, 2023 18:24
@pomianowski pomianowski self-assigned this Oct 22, 2023
@pomianowski pomianowski added themes Topic is related to managing themes controls Changes to the appearance or logic of custom controls. labels Oct 22, 2023
@pomianowski pomianowski added the styles Topic is related to styles label Oct 22, 2023
@pomianowski
Copy link
Member

Hey @niels9001, thanks for your next contribution to WPF UI. I will try to prepare the WPF UI Gallery settings page to enable the use of High Contrast, it will be easier to test everything. It's also worth modifying src/Wpf.Ui/Appearance/SystemThemeWatcher.cs to properly detect when the high contrast theme is set.

I also noticed that Windows offers several high contrast themes, I think it's worth customizing the look for all of them.
image

@niels9001
Copy link
Collaborator Author

@pomianowski Sounds great.. was planning to get this PR in first (to update all control styles) and add the high contrast brushes in a second PR? Does that make sense?

100% agree on the multiple high contrast brushes. Once we have 1 we can creste multiple? Can we already detect which one is running?

@github-actions github-actions bot removed controls Changes to the appearance or logic of custom controls. styles Topic is related to styles labels Oct 22, 2023
@pomianowski
Copy link
Member

I noticed that setting IsEnabled to False for Hyperlink causes an exception to be thrown.

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='Set property 'System.Windows.Media.SolidColorBrush.Color' threw an exception.' Line number '443' and line position '6'.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) in System.Windows.Markup\XamlReader.cs:line 401
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) in System.Windows.Markup\WpfXamlLoader.cs:line 121
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key) in System.Windows\ResourceDictionary.cs:line 1156
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 1003
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 698
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 669
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 698
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 669
   at System.Windows.DeferredResourceReference.GetValue(BaseValueSourceInternal valueSource) in System.Windows\DeferredResourceReference.cs:line 67
   at System.Windows.DeferredAppResourceReference.GetValue(BaseValueSourceInternal valueSource) in System.Windows\DeferredAppResourceReference.cs:line 16
   at System.Windows.DependencyObject.GetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, RequestFlags requests)
   at System.Windows.DependencyObject.GetValueEntry(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, RequestFlags requests)
   at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
   at MS.Internal.Text.TextProperties.InitCommon(DependencyObject target) in MS.Internal.Text\TextProperties.cs:line 151
   at MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue) in MS.Internal.Text\TextProperties.cs:line 79
   at System.Windows.Controls.TextBlock.GetLineProperties() in System.Windows.Controls\TextBlock.cs:line 2150
   at System.Windows.Controls.TextBlock.EnsureTextBlockCache() in System.Windows.Controls\TextBlock.cs:line 2140
   at System.Windows.Controls.TextBlock.OnRender(DrawingContext ctx) in System.Windows.Controls\TextBlock.cs:line 1446
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize) in MS.Internal\Helper.cs:line 329
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) in System.Windows\FrameworkElement.cs:line 3758
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore) in System.Windows\Application.cs:line 1540
   at System.Windows.Application.RunInternal(Window window) in System.Windows\Application.cs:line 1215
   at Wpf.Ui.Gallery.App.Main()

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
ArgumentException: '#5DFFFFFF' is not a valid value for property 'Color'.

@niels9001
Copy link
Collaborator Author

I noticed that setting IsEnabled to False for Hyperlink causes an exception to be thrown.

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='Set property 'System.Windows.Media.SolidColorBrush.Color' threw an exception.' Line number '443' and line position '6'.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) in System.Windows.Markup\XamlReader.cs:line 401
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) in System.Windows.Markup\WpfXamlLoader.cs:line 121
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key) in System.Windows\ResourceDictionary.cs:line 1156
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 1003
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 698
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 669
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 698
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache) in System.Windows\ResourceDictionary.cs:line 669
   at System.Windows.DeferredResourceReference.GetValue(BaseValueSourceInternal valueSource) in System.Windows\DeferredResourceReference.cs:line 67
   at System.Windows.DeferredAppResourceReference.GetValue(BaseValueSourceInternal valueSource) in System.Windows\DeferredAppResourceReference.cs:line 16
   at System.Windows.DependencyObject.GetEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, RequestFlags requests)
   at System.Windows.DependencyObject.GetValueEntry(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, RequestFlags requests)
   at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
   at MS.Internal.Text.TextProperties.InitCommon(DependencyObject target) in MS.Internal.Text\TextProperties.cs:line 151
   at MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue) in MS.Internal.Text\TextProperties.cs:line 79
   at System.Windows.Controls.TextBlock.GetLineProperties() in System.Windows.Controls\TextBlock.cs:line 2150
   at System.Windows.Controls.TextBlock.EnsureTextBlockCache() in System.Windows.Controls\TextBlock.cs:line 2140
   at System.Windows.Controls.TextBlock.OnRender(DrawingContext ctx) in System.Windows.Controls\TextBlock.cs:line 1446
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize) in MS.Internal\Helper.cs:line 329
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) in System.Windows\FrameworkElement.cs:line 3758
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore) in System.Windows\Application.cs:line 1540
   at System.Windows.Application.RunInternal(Window window) in System.Windows\Application.cs:line 1215
   at Wpf.Ui.Gallery.App.Main()

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
ArgumentException: '#5DFFFFFF' is not a valid value for property 'Color'.

Thanks! Should be fixed now!

@pomianowski
Copy link
Member

pomianowski commented Oct 22, 2023

Also, the new background for flyout looks transparent for CalendarDatePicker, it would be worth improving it.
Either by using WinApi to force acrylic for Flyout (I don't know how yet, I always don't have time for it) or a background without transparency.
image

Same for DatePicker
image

@niels9001
Copy link
Collaborator Author

Also, the new background for flyout looks transparent for CalendarDatePicker, it would be worth improving it. Either by using WinApi to force acrylic for Flyout (I don't know how yet, I always don't have time for it) or a background without transparency. image

Same for DatePicker image

Oh good point.. will look at that! I guess this color should be used on top of a acrylic layer (or as a fallback, a solid layer). Will investigate!

@pomianowski
Copy link
Member

It also seems that the border for TextBox ends at some point if we have many lines.

<ui:TextBox
  Grid.Row="1"
  MinLines="4"
  Text="{Binding ViewModel.TextToCopy}" />

image

@pomianowski
Copy link
Member

Okay, let's close this PR here for now and further changes can be made in subsequent ones.

@pomianowski pomianowski merged commit 45aa352 into lepoco:development Oct 22, 2023
2 checks passed
pomianowski added a commit that referenced this pull request Oct 22, 2023
wfjsw added a commit to hanamizuki-ai/wpfui that referenced this pull request Nov 3, 2023
@wfjsw wfjsw mentioned this pull request Nov 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
themes Topic is related to managing themes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants