From 8a58ad8441823adc7b30a3345319862a0cf7b40d Mon Sep 17 00:00:00 2001 From: lainsce Date: Tue, 13 Aug 2024 18:28:10 -0300 Subject: [PATCH] Fix accents --- ...om.fyralabs.desktop.appearance.gschema.xml | 1 - lib/Models/Application.vala | 2 +- lib/Models/StyleManager.vala | 28 +++++++++++++++---- lib/Utils/Desktop.vala | 4 +-- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/data/com.fyralabs.desktop.appearance.gschema.xml b/data/com.fyralabs.desktop.appearance.gschema.xml index 094fd8f9..a54ad2e0 100644 --- a/data/com.fyralabs.desktop.appearance.gschema.xml +++ b/data/com.fyralabs.desktop.appearance.gschema.xml @@ -6,7 +6,6 @@ - diff --git a/lib/Models/Application.vala b/lib/Models/Application.vala index ae9e8421..da9b1f24 100644 --- a/lib/Models/Application.vala +++ b/lib/Models/Application.vala @@ -74,7 +74,7 @@ public class He.Application : Gtk.Application { * A scheme variant to use for the application. If not set, the user's preferred scheme will be used. * This is especially useful for applications with their own color needs, such as media applications using the Content variant. */ - private SchemeVariant? _default_scheme_variant; + private SchemeVariant? _default_scheme_variant = null; public SchemeVariant? default_scheme_variant { get { return _default_scheme_variant; } set { _default_scheme_variant = value; update_style_manager (); } diff --git a/lib/Models/StyleManager.vala b/lib/Models/StyleManager.vala index d307de85..b166c038 100644 --- a/lib/Models/StyleManager.vala +++ b/lib/Models/StyleManager.vala @@ -51,7 +51,7 @@ public class He.StyleManager : Object { /** * A function that returns a color scheme from a given accent color and whether dark mode is enabled. */ - public SchemeVariant scheme_variant; + public SchemeVariant? scheme_variant = null; /** * Whether the style manager has been registered. Unregistered style managers will not apply their styles. @@ -83,26 +83,42 @@ public class He.StyleManager : Object { if (!is_registered) return; - var rgb_color = accent_color != null ? accent_color : is_dark ? He.DEFAULT_DARK_ACCENT : He.DEFAULT_LIGHT_ACCENT; - HCTColor hct = hct_from_int (rgb_to_argb_int (rgb_color)); + RGBColor rgb_color = accent_color != null ? accent_color : is_dark ? He.DEFAULT_DARK_ACCENT : He.DEFAULT_LIGHT_ACCENT; string css = ""; if (scheme_variant == SchemeVariant.DEFAULT) { + RGBColor accent_color = { rgb_color.r* 255, rgb_color.g* 255, rgb_color.b* 255 }; + var hct = hct_from_int (rgb_to_argb_int (accent_color)); + var scheme_factory = new DefaultScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } else if (scheme_variant == SchemeVariant.MONOCHROME) { + RGBColor accent_color = { accent_color.r* 255, accent_color.g* 255, accent_color.b* 255 }; + var hct = hct_from_int (rgb_to_argb_int (accent_color)); + var scheme_factory = new MonochromaticScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } else if (scheme_variant == SchemeVariant.MUTED) { + RGBColor accent_color = { accent_color.r* 255, accent_color.g* 255, accent_color.b* 255 }; + var hct = hct_from_int (rgb_to_argb_int (accent_color)); + var scheme_factory = new MutedScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } else if (scheme_variant == SchemeVariant.SALAD) { + RGBColor accent_color = { accent_color.r* 255, accent_color.g* 255, accent_color.b* 255 }; + var hct = hct_from_int (rgb_to_argb_int (accent_color)); + var scheme_factory = new SaladScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } else if (scheme_variant == SchemeVariant.VIBRANT) { + RGBColor accent_color = { accent_color.r* 255, accent_color.g* 255, accent_color.b* 255 }; + var hct = hct_from_int (rgb_to_argb_int (accent_color)); + var scheme_factory = new VibrantScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } else if (scheme_variant == SchemeVariant.CONTENT) { + var hct = hct_from_int (rgb_to_argb_int (rgb_color)); + var scheme_factory = new ContentScheme (); css += style_refresh (scheme_factory.generate (hct, is_dark, contrast)); } @@ -121,7 +137,7 @@ public class He.StyleManager : Object { public string style_refresh (DynamicScheme scheme_factory) { string css = ""; - css = @" + css += @" @define-color accent_color $(scheme_factory.get_primary()); @define-color accent_bg_color $(scheme_factory.get_primary()); @define-color accent_fg_color $(scheme_factory.get_on_primary()); @@ -148,7 +164,9 @@ public class He.StyleManager : Object { @define-color surface_container_bg_color $(scheme_factory.get_surface_container()); @define-color surface_container_high_bg_color $(scheme_factory.get_surface_container_high()); @define-color surface_container_highest_bg_color $(scheme_factory.get_surface_container_highest()); + "; + css += @" @define-color destructive_bg_color $(scheme_factory.get_error()); @define-color destructive_fg_color $(scheme_factory.get_on_error()); @define-color destructive_color $(scheme_factory.get_error()); @@ -195,7 +213,7 @@ public class He.StyleManager : Object { var heavy_weight = 600 * font_weight; string css = ""; - css = @" + css += @" label, .big-display, .view-subtitle, diff --git a/lib/Utils/Desktop.vala b/lib/Utils/Desktop.vala index 402ae80f..3bb71f7d 100644 --- a/lib/Utils/Desktop.vala +++ b/lib/Utils/Desktop.vala @@ -234,7 +234,7 @@ public class He.Desktop : Object { /** * The system contrast preference. */ - private double? _contrast = 2.0; + private double? _contrast = 0.0; public double contrast { get { return _contrast; @@ -255,7 +255,7 @@ public class He.Desktop : Object { debug ("%s", e.message); } - contrast = 2.0; + contrast = 0.0; } private void init_handle_settings_change () {