Skip to content

Commit

Permalink
Move ColorInformation to Background
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Sep 24, 2024
1 parent 5544bc2 commit 947cd78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
17 changes: 13 additions & 4 deletions background/Background.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
*/

public interface Gala.Background.Background : Object, Gdk.Paintable {
public struct ColorInformation {
double average_red;
double average_green;
double average_blue;
double mean_luminance;
double luminance_variance;
double mean_acutance;
}

public static Background get_for_color (Gdk.RGBA color) {
return new SolidColor (color);
}
Expand All @@ -26,7 +35,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable {
return new DimBackground (other);
}

public abstract Utils.ColorInformation? get_color_information (int height);
public abstract ColorInformation? get_color_information (int height);

private class SolidColor : Object, Gdk.Paintable, Background {
public Gdk.RGBA color { get; construct; }
Expand All @@ -35,7 +44,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable {
Object (color: color);
}

public Utils.ColorInformation? get_color_information (int height) {
public ColorInformation? get_color_information (int height) {
return null;
}

Expand All @@ -60,7 +69,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable {
Object (texture: texture);
}

public Utils.ColorInformation? get_color_information (int height) {
public ColorInformation? get_color_information (int height) {
var info = texture.get_color_information (height);
if (info == null) {
return null;
Expand Down Expand Up @@ -108,7 +117,7 @@ public interface Gala.Background.Background : Object, Gdk.Paintable {
Object (texture: texture);
}

public Utils.ColorInformation? get_color_information (int height) {
public ColorInformation? get_color_information (int height) {
return Utils.get_background_color_information (texture, height);
}

Expand Down
2 changes: 1 addition & 1 deletion background/BackgroundManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class Gala.Background.BackgroundManager : Object {
changed ();
}

public Utils.ColorInformation? get_background_color_information (int height) throws DBusError, IOError {
public Background.ColorInformation? get_background_color_information (int height) throws DBusError, IOError {
if (current_background == null) {
return null;
}
Expand Down
11 changes: 1 addition & 10 deletions background/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ namespace Gala.Background.Utils {
private const double SATURATION_WEIGHT = 1.5;
private const double WEIGHT_THRESHOLD = 1.0;

public struct ColorInformation {
double average_red;
double average_green;
double average_blue;
double mean_luminance;
double luminance_variance;
double mean_acutance;
}

public static ColorInformation? get_background_color_information (Gdk.Texture texture, int panel_height) {
public static Background.ColorInformation? get_background_color_information (Gdk.Texture texture, int panel_height) {
int width = texture.width;
int height = int.min (texture.height, panel_height);

Expand Down

0 comments on commit 947cd78

Please sign in to comment.