Skip to content

Commit

Permalink
Fix accents
Browse files Browse the repository at this point in the history
  • Loading branch information
lainsce committed Aug 13, 2024
1 parent c81d237 commit 8a58ad8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 0 additions & 1 deletion data/com.fyralabs.desktop.appearance.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<value nick="muted" value="2"/>
<value nick="mono" value="3"/>
<value nick="salad" value="4"/>
<value nick="content" value="5"/>
</enum>
<schema path="/com/fyralabs/desktop/appearance/" id="com.fyralabs.desktop.appearance">
<key name='ensor-scheme' enum='com.fyralabs.desktop.appearance.ensor-scheme'>
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 (); }
Expand Down
28 changes: 23 additions & 5 deletions lib/Models/StyleManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
}
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -195,7 +213,7 @@ public class He.StyleManager : Object {
var heavy_weight = 600 * font_weight;

string css = "";
css = @"
css += @"
label,
.big-display,
.view-subtitle,
Expand Down
4 changes: 2 additions & 2 deletions lib/Utils/Desktop.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 () {
Expand Down

0 comments on commit 8a58ad8

Please sign in to comment.