views: Use default theme background color for all controls (see #3671)

Add new CefViewDelegate::OnThemeChanged callback for optionally overriding
default theme colors when the current theme changes.
This commit is contained in:
Marshall Greenblatt
2024-03-22 19:51:00 -04:00
parent a13b6dc7f6
commit 19ba8b2b8d
43 changed files with 510 additions and 102 deletions

View File

@@ -357,13 +357,16 @@ class CefView : public CefBaseRefCounted {
virtual void RequestFocus() = 0;
///
/// Sets the background color for this View.
/// Sets the background color for this View. The background color will be
/// automatically reset if the current theme changes. See
/// CefViewDelegate::OnThemeChanged for related documentation.
///
/*--cef()--*/
virtual void SetBackgroundColor(cef_color_t color) = 0;
///
/// Returns the background color for this View.
/// Returns the background color for this View. If the background color has
/// not been explicitly set then the current theme color will be returned.
///
/*--cef()--*/
virtual cef_color_t GetBackgroundColor() = 0;

View File

@@ -131,6 +131,17 @@ class CefViewDelegate : public virtual CefBaseRefCounted {
///
/*--cef()--*/
virtual void OnBlur(CefRefPtr<CefView> view) {}
///
/// Called when the theme for |view| has changed, after the new theme colors
/// have already been applied. This will be called at least one time when
/// |view| is added to a parent View. Further theme changes can be disabled by
/// passing the `--force-dark-mode` or `--force-light-mode` command-line flag.
/// Optionally use this callback to override the new theme colors by calling
/// the appropriate CefView methods (SetBackgroundColor, etc).
///
/*--cef()--*/
virtual void OnThemeChanged(CefRefPtr<CefView> view) {}
};
#endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_