Commit 0604e27
Settings tab
Changed files (12)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/BackgroundTool.valamodifiedlibbirdfont/BackgroundTools.valamodifiedlibbirdfont/ColorTool.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/OverViewItem.valamodifiedlibbirdfont/PenTool.valaaddedlibbirdfont/SettingsDisplay.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.valamodifiedlibbirdfont/ZoomBar.vala
Diff
@@ -476,7 +476,11 @@ public class GtkWindow : Gtk.Window, NativeWindow { Gtk.MenuItem select_language_item = new Gtk.MenuItem.with_mnemonic (t_("Select _Character Set")); file_menu.append (select_language_item); select_language_item.activate.connect (() => { MenuTab.select_language (); });- ++ Gtk.MenuItem settings_item = new Gtk.MenuItem.with_mnemonic (t_("Settings"));+ file_menu.append (settings_item);+ settings_item.activate.connect (() => { MenuTab.show_settings_tab (); });+ Gtk.MenuItem quit_item = new Gtk.MenuItem.with_mnemonic (t_("_Quit")); file_menu.append (quit_item); quit_item.activate.connect (() => { MenuTab.quit (); });@@ -99,6 +99,32 @@ public class BackgroundTool : Tool { move_action.connect((self, x, y) => { move (x, y); });++ key_press_action.connect ((self, keyval) => {+ move_bg = true;+ begin_x = 0;+ begin_y = 0;+ + switch (keyval) {+ case Key.UP:+ move (0, -1);+ break;+ case Key.DOWN:+ move (0, 1);+ break;+ case Key.LEFT:+ move (-1, 0);+ break;+ case Key.RIGHT:+ move (1, 0);+ break; + default:+ break;+ }+ + move_bg = false;+ });+ draw_action.connect ((self, cairo_context, glyph) => { Glyph g = MainWindow.get_current_glyph ();@@ -23,9 +23,9 @@ public class BackgroundTools : ToolCollection { public Gee.ArrayList<Expander> expanders = new Gee.ArrayList<Expander> (); public BackgroundTools () {+ Expander background_tools = new Expander (t_("Select Background Image")); Expander background_selection = new Expander (t_("Images"));- Expander background_tools = new Expander ();-+ Expander font_name = new Expander (); font_name.add_tool (new FontName ()); font_name.draw_separator = false;@@ -54,6 +54,7 @@ public class BackgroundTools : ToolCollection { expanders.add (font_name); expanders.add (background_tools);+ expanders.add (DrawingTools.zoombar_tool); expanders.add (DrawingTools.view_tools); expanders.add (DrawingTools.guideline_tools); expanders.add (background_selection);@@ -25,7 +25,7 @@ public class ColorTool : Tool { public signal void color_updated (); - public ColorTool (string tooltip) {+ public ColorTool (string tooltip = "") { base (null, tooltip); select_action.connect((self) => {@@ -30,8 +30,6 @@ public class DrawingTools : ToolCollection { public static Expander view_tools; public static Expander guideline_tools; - public static SpinButton precision;- public static PointType point_type = PointType.DOUBLE_CURVE; public static SpinButton object_stroke;@@ -44,7 +42,7 @@ public class DrawingTools : ToolCollection { static ZoomTool zoom_tool; public static ResizeTool resize_tool; StrokeTool stroke_tool;- TrackTool track_tool;+ public static TrackTool track_tool; public static BackgroundTool move_background; public static Tool move_canvas; @@ -110,8 +108,6 @@ public class DrawingTools : ToolCollection { Expander key_tools = new Expander (); // tools on android Expander test_tools = new Expander (); Expander grid = new Expander (t_("Grid Size"));-- Expander style_tools = new Expander (); grid_expander = grid; @@ -865,19 +861,21 @@ public class DrawingTools : ToolCollection { }); zoombar_tool.add_tool (zoom_bar); - Tool zoom_in = new Tool ("zoom_in", t_("Zoom in"), '+', CTRL);+ Tool zoom_in = new Tool ("zoom_in", "", '+', CTRL); zoom_in.select_action.connect ((self) => { zoom_tool.store_current_view (); glyph_canvas.get_current_display ().zoom_in (); }); view_tools.add_tool (zoom_in);+ zoom_in.set_tool_visibility (false); - Tool zoom_out = new Tool ("zoom_out", t_("Zoom out"), '-', CTRL);+ Tool zoom_out = new Tool ("zoom_out", "", '-', CTRL); zoom_out.select_action.connect ((self) => { zoom_tool.store_current_view (); glyph_canvas.get_current_display ().zoom_out (); }); view_tools.add_tool (zoom_out);+ zoom_out.set_tool_visibility (false); Tool reset_zoom = new Tool ("zoom_1_1", t_("Use one pixel per unit"), '0', CTRL); reset_zoom.select_action.connect ((self) => {@@ -886,6 +884,7 @@ public class DrawingTools : ToolCollection { glyph_canvas.redraw_area(0, 0, GlyphCanvas.allocation.width, GlyphCanvas.allocation.height); }); view_tools.add_tool (reset_zoom);+ reset_zoom.set_tool_visibility (false); Tool full_glyph = new Tool ("full_glyph", t_("Show full glyph")); full_glyph.select_action.connect((self) => {@@ -917,11 +916,12 @@ public class DrawingTools : ToolCollection { }); view_tools.add_tool (zoom_prev); - Tool zoom_next = new Tool ("next", t_("Next view"));+ Tool zoom_next = new Tool ("next"); zoom_next.select_action.connect((self) => { zoom_tool.next_view (); }); view_tools.add_tool (zoom_next);+ zoom_next.set_tool_visibility (false); // shape tools circle = new CircleTool ("circle");@@ -935,188 +935,7 @@ public class DrawingTools : ToolCollection { update_drawing_and_background_tools (self); }); shape_tools.add_tool (rectangle);- - // settings- ColorTool stroke_color = new ColorTool (t_("Stroke color"));- 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")));- style_tools.add_tool (stroke_color);- - SpinButton stroke_width = new SpinButton ("stroke_width", t_("Stroke width"));-- style_tools.add_tool (stroke_width);- - stroke_width.set_max (4);- stroke_width.set_min (0.002);- stroke_width.set_value_round (1);-- if (Preferences.get ("stroke_width_for_open_paths") != "") {- stroke_width.set_value (Preferences.get ("stroke_width_for_open_paths"));- }-- stroke_width.new_value_action.connect ((self) => {- Glyph g = MainWindow.get_current_glyph ();- Path.stroke_width = stroke_width.get_value ();- g.redraw_area (0, 0, g.allocation.width, g.allocation.height);- Preferences.set ("stroke_width_for_open_paths", stroke_width.get_display_value ());- MainWindow.get_toolbox ().redraw ((int) stroke_width.x, (int) stroke_width.y, 70, 70);- });- - Path.stroke_width = stroke_width.get_value ();- - ColorTool handle_color = new ColorTool (t_("Handle color"));- 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")));- style_tools.add_tool (handle_color);-- // adjust precision- string precision_value = Preferences.get ("precision");- precision = new SpinButton ("precision", t_("Set precision"));- - if (precision_value != "") {- precision.set_value (precision_value);- } else {-#if ANDROID- precision.set_value_round (0.5);-#else- precision.set_value_round (1);-#endif- }- - precision.new_value_action.connect ((self) => {- MainWindow.get_toolbox ().select_tool (precision);- Preferences.set ("precision", self.get_display_value ());- MainWindow.get_toolbox ().redraw ((int) precision.x, (int) precision.y, 70, 70);- });-- precision.select_action.connect((self) => {- pen_tool.set_precision (((SpinButton)self).get_value ());- });- - precision.set_min (0.001);- precision.set_max (1); - style_tools.add_tool (precision);-- Tool show_all_line_handles = new Tool ("show_all_line_handles", t_("Show all control point handles or only handles for the selected points."));- show_all_line_handles.select_action.connect((self) => {- Path.show_all_line_handles = !Path.show_all_line_handles;- Glyph g = MainWindow.get_current_glyph ();- g.redraw_area (0, 0, g.allocation.width, g.allocation.height); - });- style_tools.add_tool (show_all_line_handles);-- // fill color- ColorTool fill_color = new ColorTool (t_("Object color"));- 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")));- style_tools.add_tool (fill_color);-- Tool fill_open_path = new Tool ("fill_open_path", t_("Set fill color for open paths."));- fill_open_path.select_action.connect((self) => {- Path.fill_open_path = !Path.fill_open_path;- Glyph g = MainWindow.get_current_glyph ();- g.redraw_area (0, 0, g.allocation.width, g.allocation.height); - });- style_tools.add_tool (fill_open_path);-- Tool ttf_units = new Tool ("ttf_units", t_("Use TTF units."));- ttf_units.select_action.connect((self) => {- GridTool.ttf_units = !GridTool.ttf_units;- Preferences.set ("ttf_units", @"$(GridTool.ttf_units)");- });- style_tools.add_tool (ttf_units);-- SpinButton freehand_samples = new SpinButton ("freehand_samples_per_point", t_("Adjust the number of samples per point in the freehand tool."));-- style_tools.add_tool (freehand_samples);- - freehand_samples.set_max (9);- freehand_samples.set_min (0.002);- - if (BirdFont.android) {- freehand_samples.set_value_round (2.5);- } else {- freehand_samples.set_value_round (1);- }-- if (Preferences.get ("freehand_samples") != "") {- freehand_samples.set_value (Preferences.get ("freehand_samples"));- track_tool.set_samples_per_point (freehand_samples.get_value ());- }-- freehand_samples.new_value_action.connect ((self) => {- track_tool.set_samples_per_point (freehand_samples.get_value ());- });-- SpinButton simplification_threshold = new SpinButton ("simplification_threshold", t_("Simplification threshold"));- simplification_threshold.set_value_round (0.5);- style_tools.add_tool (simplification_threshold);- - simplification_threshold.set_max (5);- freehand_samples.set_min (0.002);-- if (Preferences.get ("simplification_threshold") != "") {- freehand_samples.set_value (Preferences.get ("simplification_threshold"));- pen_tool.set_simplification_threshold (simplification_threshold.get_value ());- }-- freehand_samples.new_value_action.connect ((self) => {- pen_tool.set_simplification_threshold (simplification_threshold.get_value ());- });- add_expander (font_name); add_expander (draw_tools); @@ -1130,7 +949,6 @@ public class DrawingTools : ToolCollection { add_expander (zoombar_tool); add_expander (view_tools); add_expander (shape_tools);- add_expander (style_tools); // Fixa: add_expander (trace); if (BirdFont.has_argument ("--test")) {@@ -1156,9 +974,6 @@ public class DrawingTools : ToolCollection { shape_tools.set_persistent (true); shape_tools.set_unique (true);- - style_tools.set_persistent (true);- style_tools.set_unique (true); view_tools.draw_separator = false; @@ -1179,9 +994,6 @@ public class DrawingTools : ToolCollection { move_background.persistent = true; cut_background.persistent = true; move_canvas.persistent = true;-- precision.persistent = true;- stroke_width.persistent = true; // Default selection IdleSource idle = new IdleSource ();@@ -532,6 +532,10 @@ public class MenuTab : FontDisplay { bt = BackgroundTab.get_instance (); MainWindow.get_tab_bar ().add_unique_tab (bt); }+ + public static void show_settings_tab () {+ MainWindow.get_tab_bar ().add_unique_tab (new SettingsDisplay ());+ } } }@@ -145,7 +145,7 @@ public class OverViewItem : GLib.Object { Font font; double gx, gy; double x1, x2, y1, y2;- double scale, scale_box;+ double scale_box; double w, h; double glyph_width, glyph_height; Surface s;@@ -186,7 +186,7 @@ public class OverViewItem : GLib.Object { fallback = new Text (); c.set_source_rgba (219 / 255.0, 221 / 255.0, 233 / 255.0, 1); fallback.set_text ((!) character.to_string ());- font_size = height * 0.9;+ font_size = height * 0.8; gx = (width - fallback.get_extent (font_size)) / 2.0; gy = height - 30; fallback.draw (c, gx, gy, font_size);@@ -532,7 +532,7 @@ public class PenTool : Tool { public void set_precision (double p) { precision = p;- DrawingTools.precision.set_value_round (p, false, false);+ SettingsDisplay.precision.set_value_round (p, false, false); } public void move (int x, int y) {new file mode 100644@@ -0,0 +1,383 @@+/*+ Copyright (C) 2014 Johan Mattsson++ This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version.++ This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details.+*/++using Cairo;+using Math;++namespace BirdFont {++public class SettingsDisplay : FontDisplay {+ + double scroll = 0;+ double content_height;+ WidgetAllocation allocation;+ Gee.ArrayList<SettingsItem> tools;++ public static SpinButton precision;+ + public SettingsDisplay () {+ allocation = new WidgetAllocation ();+ tools = new Gee.ArrayList<SettingsItem> ();+ content_height = 200;+ + // setting items+ 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")));+ + stroke_width.set_max (4);+ stroke_width.set_min (0.002);+ stroke_width.set_value_round (1);++ if (Preferences.get ("stroke_width_for_open_paths") != "") {+ stroke_width.set_value (Preferences.get ("stroke_width_for_open_paths"));+ }++ stroke_width.new_value_action.connect ((self) => {+ Glyph g = MainWindow.get_current_glyph ();+ Path.stroke_width = stroke_width.get_value ();+ g.redraw_area (0, 0, g.allocation.width, g.allocation.height);+ Preferences.set ("stroke_width_for_open_paths", stroke_width.get_display_value ());+ MainWindow.get_toolbox ().redraw ((int) stroke_width.x, (int) stroke_width.y, 70, 70);+ });+ + 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");+ + if (precision_value != "") {+ precision.set_value (precision_value);+ } else {+#if ANDROID+ precision.set_value_round (0.5);+#else+ precision.set_value_round (1);+#endif+ }+ + precision.new_value_action.connect ((self) => {+ MainWindow.get_toolbox ().select_tool (precision);+ Preferences.set ("precision", self.get_display_value ());+ MainWindow.get_toolbox ().redraw ((int) precision.x, (int) precision.y, 70, 70);+ });++ precision.select_action.connect((self) => {+ DrawingTools.pen_tool.set_precision (((SpinButton)self).get_value ());+ });+ + precision.set_min (0.001);+ precision.set_max (1);+ + tools.add (new SettingsItem (precision, t_("Precision for pen tool")));++ Tool show_all_line_handles = new Tool ("show_all_line_handles");+ show_all_line_handles.select_action.connect((self) => {+ Path.show_all_line_handles = !Path.show_all_line_handles;+ Glyph g = MainWindow.get_current_glyph ();+ 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) => {+ Path.fill_open_path = !Path.fill_open_path;+ Glyph g = MainWindow.get_current_glyph ();+ g.redraw_area (0, 0, g.allocation.width, g.allocation.height); + });+ tools.add (new SettingsItem (fill_open_path, t_("Fill open paths.")));++ Tool ttf_units = new Tool ("ttf_units");+ ttf_units.select_action.connect((self) => {+ GridTool.ttf_units = !GridTool.ttf_units;+ Preferences.set ("ttf_units", @"$(GridTool.ttf_units)");+ });+ tools.add (new SettingsItem (ttf_units, t_("Use TTF units.")));++ SpinButton freehand_samples = new SpinButton ("freehand_samples_per_point");+ tools.add (new SettingsItem (freehand_samples, t_("Number of points added by the freehand tool")));+ + freehand_samples.set_max (9);+ freehand_samples.set_min (0.002);+ + if (BirdFont.android) {+ freehand_samples.set_value_round (2.5);+ } else {+ freehand_samples.set_value_round (1);+ }++ if (Preferences.get ("freehand_samples") != "") {+ freehand_samples.set_value (Preferences.get ("freehand_samples"));+ DrawingTools.track_tool.set_samples_per_point (freehand_samples.get_value ());+ }++ freehand_samples.new_value_action.connect ((self) => {+ DrawingTools.track_tool.set_samples_per_point (freehand_samples.get_value ());+ });++ SpinButton simplification_threshold = new SpinButton ("simplification_threshold");+ simplification_threshold.set_value_round (0.5);+ tools.add (new SettingsItem (simplification_threshold, t_("Path simplification threshold")));+ + simplification_threshold.set_max (5);+ freehand_samples.set_min (0.002);++ if (Preferences.get ("simplification_threshold") != "") {+ freehand_samples.set_value (Preferences.get ("simplification_threshold"));+ DrawingTools.pen_tool.set_simplification_threshold (simplification_threshold.get_value ());+ }++ freehand_samples.new_value_action.connect ((self) => {+ DrawingTools.pen_tool.set_simplification_threshold (simplification_threshold.get_value ());+ });++ }++ public override void draw (WidgetAllocation allocation, Context cr) {+ Text headline;+ + this.allocation = allocation;+ + layout ();+ + // background+ cr.save ();+ cr.rectangle (0, 0, allocation.width, allocation.height);+ cr.set_line_width (0);+ cr.set_source_rgba (51 / 255.0, 54 / 255.0, 59 / 255.0, 1);+ cr.fill ();+ cr.stroke ();+ cr.restore ();++ // headline background+ cr.save ();+ cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);+ cr.rectangle (0, 0, allocation.width, 40 * MainWindow.units);+ cr.fill ();+ cr.restore ();+ + cr.save ();+ headline = new Text ();+ headline.set_text (t_("Settings"));+ cr.set_source_rgba (1, 1, 1, 1);+ headline.draw (cr, 21 * MainWindow.units, 25 * MainWindow.units, 20 * MainWindow.units);+ cr.restore (); + + foreach (SettingsItem s in tools) {+ s.draw (allocation, cr);+ }+ } ++ void layout () {+ double y = 50 * MainWindow.units;+ foreach (SettingsItem s in tools) {+ s.y = y;+ y += 40 * MainWindow.units;+ } + }++ public override void button_press (uint button, double x, double y) {+ foreach (SettingsItem s in tools) {+ if (s.button.is_over (x, y)) {+ s.button.panel_press_action (s.button, button, x, y);+ s.button.select_action (s.button);+ }+ }+ GlyphCanvas.redraw ();+ }+ + public override void button_release (int button, double x, double y) {+ foreach (SettingsItem s in tools) {+ if (s.button.is_over (x, y) || s.button.is_active ()) {+ s.button.panel_release_action (s.button, button, x, y);+ }+ }+ GlyphCanvas.redraw ();+ }++ public override void motion_notify (double x, double y) {+ bool consumed = false;+ + foreach (SettingsItem s in tools) {+ if (s.button.panel_move_action (s.button, x, y)) {+ consumed = true;+ }+ }+ + // TODO: ignore scrolling if event is consumed+ if (consumed) {+ GlyphCanvas.redraw ();+ }+ }++ public override string get_label () {+ return t_("Settings");+ }++ public override string get_name () {+ return "Settings";+ }++ public override bool has_scrollbar () {+ return true;+ }+ + public override void scroll_wheel_down (double x, double y) {+ foreach (SettingsItem s in tools) {+ if (s.button.is_over (x, y)) {+ s.button.scroll_wheel_down_action (s.button);+ return;+ }+ }+ + scroll += 10;++ if (scroll + allocation.height >= content_height) {+ scroll = content_height - allocation.height;+ }+ + update_scrollbar ();+ GlyphCanvas.redraw ();+ }+ + public override void scroll_wheel_up (double x, double y) {+ foreach (SettingsItem s in tools) {+ if (s.button.is_over (x, y)) {+ s.button.scroll_wheel_up_action (s.button);+ return;+ }+ }+ + scroll -= 10;+ + if (scroll < 0) {+ scroll = 0;+ }+ + update_scrollbar ();+ GlyphCanvas.redraw ();+ }++ public override void selected_canvas () {+ update_scrollbar ();+ GlyphCanvas.redraw ();+ }+ + public void update_scrollbar () {+ MainWindow.set_scrollbar_size (allocation.height / content_height);+ MainWindow.set_scrollbar_position (scroll / content_height);+ }++ public override void scroll_to (double percent) {+ scroll = percent * content_height;+ GlyphCanvas.redraw ();+ }+ + class SettingsItem : GLib.Object {+ + public double y;+ public Tool button;+ + Text label;+ + public SettingsItem (Tool tool, string description) {+ button = tool;+ label = new Text ();+ label.set_text (description);+ y = 0;+ }+ + public void draw (WidgetAllocation allocation, Context cr) {+ button.y = y;+ button.x = 20 * MainWindow.units;+ button.draw (cr);+ + cr.save ();+ cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);+ label.draw (cr, 60 * MainWindow.units, y + 20 * MainWindow.units, 17 * MainWindow.units);+ cr.restore ();+ }+ }+}++}@@ -20,9 +20,9 @@ public class Tool : GLib.Object { public double x = 0; public double y = 0;- public double w = 30;- public double h = 30;-+ public double w = 33 * Toolbox.get_scale ();+ public double h = (33 / 1.11) * Toolbox.get_scale ();+ protected bool active = false; protected bool selected = false; @@ -426,12 +426,7 @@ public class Toolbox : GLib.Object { cr.set_line_width (0); cr.set_source_rgba (51/255.0, 54/255.0, 59/255.0, 1); cr.fill ();- - cr.rectangle (0, 0, 1, h);- cr.set_line_width (0);- cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);- cr.fill ();- + draw_expanders (w, h, cr); cr.restore ();@@ -69,7 +69,10 @@ public class ZoomBar : Tool { } set_zoom (zoom_level);- new_zoom (zoom_level);+ + if (!MenuTab.suppress_event) {+ new_zoom (zoom_level);+ } } public override void draw (Context cr) {