Updated Files
libbirdfont/Glyph.vala |
libbirdfont/Path.vala |
libbirdfont/SettingsDisplay.vala |
libbirdfont/Theme.vala |
--- a/libbirdfont/Glyph.vala
+++ b/libbirdfont/Glyph.vala
@@ -1517,7 +1517,7 @@
}
private Color get_path_fill_color () {
- return new Color (Path.fill_color_r, Path.fill_color_g, Path.fill_color_b, Path.fill_color_a);
+ return Theme.get_color ("Fill Color");
}
private void draw_outline_for_paths (PathList pl, Context cr) {
--- a/libbirdfont/Path.vala
+++ b/libbirdfont/Path.vala
@@ -79,21 +79,6 @@
public static ImageSurface? cubic_selected_edit_point_image = null;
public static ImageSurface? cubic_active_selected_edit_point_image = null;
-
- public static double line_color_r = 0;
- public static double line_color_g = 0;
- public static double line_color_b = 0;
- public static double line_color_a = 1;
-
- public static double handle_color_r = 0;
- public static double handle_color_g = 0;
- public static double handle_color_b = 0;
- public static double handle_color_a = 1;
-
- public static double fill_color_r = 0;
- public static double fill_color_g = 0;
- public static double fill_color_b = 0;
- public static double fill_color_a = 1;
/** The stroke of an outline when the path is not filled. */
public static double stroke_width = 1;
@@ -127,21 +112,6 @@
width = Preferences.get ("stroke_width");
if (width != "") {
stroke_width = double.parse (width);
-
- line_color_r = double.parse (Preferences.get ("line_color_r"));
- line_color_g = double.parse (Preferences.get ("line_color_g"));
- line_color_b = double.parse (Preferences.get ("line_color_b"));
- line_color_a = double.parse (Preferences.get ("line_color_a"));
-
- handle_color_r = double.parse (Preferences.get ("handle_color_r"));
- handle_color_g = double.parse (Preferences.get ("handle_color_g"));
- handle_color_b = double.parse (Preferences.get ("handle_color_b"));
- handle_color_a = double.parse (Preferences.get ("handle_color_a"));
-
- fill_color_r = double.parse (Preferences.get ("fill_color_r"));
- fill_color_g = double.parse (Preferences.get ("fill_color_g"));
- fill_color_b = double.parse (Preferences.get ("fill_color_b"));
- fill_color_a = double.parse (Preferences.get ("fill_color_a"));
}
}
}
@@ -265,18 +235,8 @@
// draw highlighted segment
if (highlight_last_segment && points.size >= 2) {
- line_color_r = 0.5;
- line_color_g = 0.5;
- line_color_b = 0.8;
- line_color_a = 1;
-
- draw_next (points.get (points.size - 2), points.get (points.size - 1), cr);
+ draw_next (points.get (points.size - 2), points.get (points.size - 1), cr, true);
cr.stroke ();
-
- line_color_r = 0;
- line_color_g = 0;
- line_color_b = 0;
- line_color_a = 1;
}
}
@@ -352,18 +312,18 @@
}
}
- private void draw_next (EditPoint e, EditPoint en, Context cr) {
+ private void draw_next (EditPoint e, EditPoint en, Context cr, bool highlighted = false) {
PointType r = e.get_right_handle ().type;
PointType l = en.get_left_handle ().type;
if (r == PointType.DOUBLE_CURVE || l == PointType.DOUBLE_CURVE) {
- draw_double_curve (e, en, cr);
+ draw_double_curve (e, en, cr, highlighted);
} else {
- draw_curve (e, en, cr);
+ draw_curve (e, en, cr, highlighted);
}
}
- private static void draw_double_curve (EditPoint e, EditPoint en, Context cr) {
+ private static void draw_double_curve (EditPoint e, EditPoint en, Context cr, bool highlighted) {
EditPoint middle;
double x, y;
@@ -376,11 +336,11 @@
middle.right_handle.type = PointType.DOUBLE_CURVE;
middle.left_handle.type = PointType.DOUBLE_CURVE;
- draw_curve (e, middle, cr);
- draw_curve (middle, en, cr);
+ draw_curve (e, middle, cr, highlighted);
+ draw_curve (middle, en, cr, highlighted);
}
- private static void draw_curve (EditPoint e, EditPoint en, Context cr, double alpha = 1) {
+ private static void draw_curve (EditPoint e, EditPoint en, Context cr, bool highlighted = false, double alpha = 1) {
Glyph g = MainWindow.get_current_glyph ();
double xa, ya, xb, yb, xc, yc, xd, yd;
PointType t = e.get_right_handle ().type;
@@ -388,7 +348,12 @@
get_bezier_points (e, en, out xa, out ya, out xb, out yb, out xc, out yc, out xd, out yd);
- cr.set_source_rgba (line_color_r, line_color_g, line_color_b, line_color_a);
+ if (!highlighted) {
+ Theme.color (cr, "Stroke Color");
+ } else {
+ Theme.color (cr, "Highlighted Guide");
+ }
+
cr.set_line_width (stroke_width / g.view_zoom);
cr.line_to (xa, ya); // this point makes sense only if it is in the first or last position
@@ -454,8 +419,8 @@
double ax, ay, bx, by;
get_line_points (e, en, out ax, out ay, out bx, out by);
-
- cr.set_source_rgba (handle_color_r, handle_color_g, handle_color_b, handle_color_a);
+
+ Theme.color (cr, "Handle Color");
cr.set_line_width (1.7 * (stroke_width / g.view_zoom));
cr.line_to (ax, ay);
--- a/libbirdfont/SettingsDisplay.vala
+++ b/libbirdfont/SettingsDisplay.vala
@@ -36,31 +36,6 @@
// setting items
tools.add (new SettingsItem.head_line (t_("Settings")));
-
- ColorTool stroke_color = new ColorTool ();
- stroke_color.color_updated.connect (() => {
- Path.line_color_r = stroke_color.color_r;
- Path.line_color_g = stroke_color.color_g;
- Path.line_color_b = stroke_color.color_b;
- Path.line_color_a = stroke_color.color_a;
-
- if (Path.line_color_a == 0) {
- Path.line_color_a = 1;
- }
-
- Preferences.set ("line_color_r", @"$(Path.line_color_r)");
- Preferences.set ("line_color_g", @"$(Path.line_color_g)");
- Preferences.set ("line_color_b", @"$(Path.line_color_b)");
- Preferences.set ("line_color_a", @"$(Path.line_color_a)");
-
- Glyph g = MainWindow.get_current_glyph ();
- g.redraw_area (0, 0, g.allocation.width, g.allocation.height);
- });
- stroke_color.set_r (double.parse (Preferences.get ("line_color_r")));
- stroke_color.set_g (double.parse (Preferences.get ("line_color_g")));
- stroke_color.set_b (double.parse (Preferences.get ("line_color_b")));
- stroke_color.set_a (double.parse (Preferences.get ("line_color_a")));
- tools.add (new SettingsItem (stroke_color, t_("Stroke color")));
SpinButton stroke_width = new SpinButton ("stroke_width");
tools.add (new SettingsItem (stroke_width, t_("Stroke width")));
@@ -83,28 +58,6 @@
Path.stroke_width = stroke_width.get_value ();
- ColorTool handle_color = new ColorTool ();
- handle_color.color_updated.connect (() => {
- Path.handle_color_r = handle_color.color_r;
- Path.handle_color_g = handle_color.color_g;
- Path.handle_color_b = handle_color.color_b;
- Path.handle_color_a = handle_color.color_a;
-
- Preferences.set ("handle_color_r", @"$(Path.handle_color_r)");
- Preferences.set ("handle_color_g", @"$(Path.handle_color_g)");
- Preferences.set ("handle_color_b", @"$(Path.handle_color_b)");
- Preferences.set ("handle_color_a", @"$(Path.handle_color_a)");
-
- Glyph g = MainWindow.get_current_glyph ();
- g.redraw_area (0, 0, g.allocation.width, g.allocation.height);
- });
- handle_color.set_r (double.parse (Preferences.get ("handle_color_r")));
- handle_color.set_g (double.parse (Preferences.get ("handle_color_g")));
- handle_color.set_b (double.parse (Preferences.get ("handle_color_b")));
- handle_color.set_a (double.parse (Preferences.get ("handle_color_a")));
-
- tools.add (new SettingsItem (handle_color, t_("Handle color")));
-
// adjust precision
string precision_value = Preferences.get ("precision");
precision = new SpinButton ("precision");
@@ -141,28 +94,6 @@
g.redraw_area (0, 0, g.allocation.width, g.allocation.height);
});
tools.add (new SettingsItem (show_all_line_handles, t_("Show or hide control point handles")));
-
- // fill color
- ColorTool fill_color = new ColorTool ();
- fill_color.color_updated.connect (() => {
- Path.fill_color_r = fill_color.color_r;
- Path.fill_color_g = fill_color.color_g;
- Path.fill_color_b = fill_color.color_b;
- Path.fill_color_a = fill_color.color_a;
-
- Preferences.set ("fill_color_r", @"$(Path.fill_color_r)");
- Preferences.set ("fill_color_g", @"$(Path.fill_color_g)");
- Preferences.set ("fill_color_b", @"$(Path.fill_color_b)");
- Preferences.set ("fill_color_a", @"$(Path.fill_color_a)");
-
- Glyph g = MainWindow.get_current_glyph ();
- g.redraw_area (0, 0, g.allocation.width, g.allocation.height);
- });
- fill_color.set_r (double.parse (Preferences.get ("fill_color_r")));
- fill_color.set_g (double.parse (Preferences.get ("fill_color_g")));
- fill_color.set_b (double.parse (Preferences.get ("fill_color_b")));
- fill_color.set_a (double.parse (Preferences.get ("fill_color_a")));
- tools.add (new SettingsItem (fill_color, t_("Object color")));
Tool fill_open_path = new Tool ("fill_open_path");
fill_open_path.select_action.connect((self) => {
--- a/libbirdfont/Theme.vala
+++ b/libbirdfont/Theme.vala
@@ -83,6 +83,10 @@
public static void set_default_colors () {
color_list = new Gee.ArrayList<string> ();
colors = new Gee.HashMap<string, Color> ();
+
+ Theme.set_default_color ("Stroke Color", 0, 0, 0, 1);
+ Theme.set_default_color ("Handle Color", 0, 0, 0, 1);
+ Theme.set_default_color ("Fill Color", 0.5, 0.5, 0.5, 1);
Theme.set_default_color ("Background 1", 1, 1, 1, 1);
Theme.set_default_color ("Background 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
@@ -124,6 +128,10 @@
Theme.set_default_color ("Tool Background 4", 33 / 255.0, 36 / 255.0, 39 / 255.0, 1);
Theme.set_default_color ("Button Foreground", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);
+
+ N_("Stroke Color");
+ N_("Handle Color");
+ N_("Fill Color");
N_("Background 1");
N_("Background 2");