Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Oct 28, 2021
1 parent e97450a commit e3db4d1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 62 deletions.
6 changes: 6 additions & 0 deletions data/io.github.lainsce.Colorway.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
</custom>
<translation type="gettext">io.github.lainsce.Colorway</translation>
<releases>
<release version="1.0.1" date="2021-11-06">
<description>
<p>Release: Copiable Colors</p>
<p>Added: Now the color boxes are now buttons which you can copy the individual color.</p>
</description>
</release>
<release version="1.0.0" date="2021-10-26">
<description>
<p>Release: First Release</p>
Expand Down
20 changes: 20 additions & 0 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,23 @@
color: rgba(255,255,255,0);
transition: 500ms color;
}

.clr-first {
border-radius: 8px 0 0 8px;
box-shadow: 0 0 0 1px @borders;
}
.clr-second,
.clr-third {
border-radius: 0;
box-shadow: 0 0 0 1px @borders;
}
.clr-fourth {
border-radius: 0 8px 8px 0;
box-shadow: 0 0 0 1px @borders;
}
.clr-palette button image {
color: #fff;
}
.clr-palette button.light image {
color: #333;
}
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('io.github.lainsce.Colorway', ['vala', 'c'], version: '1.0.0')
project('io.github.lainsce.Colorway', ['vala', 'c'], version: '1.0.1')
gnome = import('gnome')
i18n = import('i18n')

Expand Down Expand Up @@ -52,6 +52,7 @@ sources = files(
'src/portal.vala',
'src/chooser.vala',
'src/hue_slider.vala',
'src/colorbutton.vala',
)

dependencies = [
Expand Down
96 changes: 35 additions & 61 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ namespace Colorway {
public HueSlider hue_slider;

public Gtk.ComboBoxText color_rule_dropdown;
public Gtk.Box tbox;
public Gtk.Box sbox;
public PaletteButton box;
public PaletteButton tbox;
public PaletteButton sbox;
public PaletteButton ubox;
public Gtk.Box mbox;
public Gtk.Label color_exported_label;

Expand Down Expand Up @@ -105,27 +107,28 @@ namespace Colorway {
color_rule_dropdown.margin_start = color_rule_dropdown.margin_end = 18;
props_box.append (color_rule_dropdown);

var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
box = new PaletteButton ("#000", false);
box.set_size_request(64, 32);
box.get_style_context ().add_class ("clr-preview-rule-left");
sbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
box.get_style_context ().add_class ("clr-first");
sbox = new PaletteButton ("#000", false);
sbox.set_size_request(64, 32);
sbox.set_visible(false);
sbox.get_style_context ().add_class ("clr-preview-rule-middle1");
tbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
sbox.get_style_context ().add_class ("clr-second");
tbox = new PaletteButton ("#000", false);
tbox.set_size_request(64, 32);
tbox.set_visible(false);
tbox.get_style_context ().add_class ("clr-preview-rule-middle2");
var ubox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
tbox.get_style_context ().add_class ("clr-third");
ubox = new PaletteButton ("#000", false);
ubox.set_size_request(64, 32);
ubox.get_style_context ().add_class ("clr-preview-rule-right");
ubox.get_style_context ().add_class ("clr-fourth");

mbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
mbox.set_halign(Gtk.Align.CENTER);
mbox.set_homogeneous(true);
mbox.width_request = 260;
mbox.set_margin_end (18);
mbox.set_margin_start (18);
mbox.get_style_context ().add_class ("clr-palette");
mbox.append (box);
mbox.append (sbox);
mbox.append (tbox);
Expand Down Expand Up @@ -268,7 +271,7 @@ namespace Colorway {
this.show ();
}

public async void setup_color_rules (string color, string contrast, double hue, double s, double v, Gtk.ComboBoxText? crd, Gtk.Box? sbox, Gtk.Box? tbox) {
public async void setup_color_rules (string color, string contrast, double hue, double s, double v, Gtk.ComboBoxText? crd, PaletteButton? sbox, PaletteButton? tbox) {
switch (crd.get_active ()) {
case 0:
da.pos_to_sv (out s, out v);
Expand Down Expand Up @@ -455,57 +458,28 @@ namespace Colorway {
}

public void update_theme(string? color, string? contrast, string? rule_color1, string? rule_color2, string? rule_color) {
var css_provider = new Gtk.CssProvider();
string style = null;
style = """
.clr-preview {
background: %s;
color: %s;
border: 1px solid @borders;
border-radius: 9999px;
this.color = color;
this.contrast = contrast;
this.rule_color = rule_color;
this.rule_color1 = rule_color1;
this.rule_color2 = rule_color2;

box.hex = color;
sbox.hex = rule_color1;
tbox.hex = rule_color2;
ubox.hex = rule_color;

if (contrast == "#FFFFFF") {
box.light = false;
sbox.light = false;
tbox.light = false;
ubox.light = false;
} else {
box.light = true;
sbox.light = true;
tbox.light = true;
ubox.light = true;
}
.clr-preview-rule-left {
background: %s;
border-radius: 4px 0 0 4px;
min-height: 32px;
min-width: 32px;
outline: 1px solid @borders;
}
.clr-preview-rule-middle1 {
background: %s;
border-radius: 0;
min-height: 32px;
min-width: 32px;
outline: 1px solid @borders;
}
.clr-preview-rule-middle2 {
background: %s;
border-radius: 0;
min-height: 32px;
min-width: 32px;
outline: 1px solid @borders;
}
.clr-preview-rule-right {
background: %s;
border-radius: 0 4px 4px 0;
min-height: 32px;
min-width: 32px;
outline: 1px solid @borders;
}
""".printf(color,
contrast,
color,
rule_color1,
rule_color2,
rule_color);

css_provider.load_from_data(style.data);

Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (),
css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);
}

public void action_export () {
Expand Down

0 comments on commit e3db4d1

Please sign in to comment.