Commit 246fe09
new tab bar
Changed files (18)
modifiedicons/tab1_left.pngmodifiedicons/tab1_right.pngmodifiedicons/tab2_left.pngmodifiedicons/tab2_right.pngmodifiedicons/tab3_left.pngmodifiedicons/tab3_right.pngmodifiedsrc/BackgroundTool.valamodifiedsrc/ExportTool.valamodifiedsrc/Glyph.valamodifiedsrc/GlyphCanvas.valamodifiedsrc/Line.valamodifiedsrc/MainWindow.valamodifiedsrc/MoveTool.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/OverView.valamodifiedsrc/PenTool.valamodifiedsrc/TabBar.valamodifiedsrc/Toolbox.vala
Diff
Binary files a/icons/tab1_left.png and b/icons/tab1_left.png differBinary files a/icons/tab1_right.png and b/icons/tab1_right.png differBinary files a/icons/tab2_left.png and b/icons/tab2_left.png differBinary files a/icons/tab2_right.png and b/icons/tab2_right.png differBinary files a/icons/tab3_left.png and b/icons/tab3_left.png differBinary files a/icons/tab3_right.png and b/icons/tab3_right.png differ@@ -129,6 +129,9 @@ class BackgroundTool : Tool { dx *= 1/g.view_zoom; dy *= 1/g.view_zoom; + dx *= PenTool.precision;+ dy *= PenTool.precision;+ if (bg.selected_handle == 2) { bg.set_img_rotation_from_coordinate (x, y); }@@ -26,6 +26,8 @@ class ExportTool : Tool { public static bool export_thread_is_running = false; private static unowned Thread<void*> export_thread_handle; + private static bool stop_export_thread = false;+ public ExportTool (string n) { base (n, "Export glyph to svg file", 'e', CTRL); @@ -361,6 +363,21 @@ os.put_string ( return export_ttf_font_path (file); } + /** Stop a running export thread.*/+ public static void stop_export () {+ lock (stop_export_thread) {+ stop_export_thread = true;+ }+ }+ + public static bool should_stop () {+ bool r;+ lock (stop_export_thread) {+ r = stop_export_thread;+ }+ return r;+ } + public static bool export_ttf_font_path (File folder, bool async = true) { Font current_font = Supplement.get_current_font (); string path;@@ -371,8 +388,16 @@ os.put_string ( string temp_file; bool done = true; + lock (stop_export_thread) {+ stop_export_thread = true;+ }+ export_mutex.lock (); + lock (stop_export_thread) {+ stop_export_thread = false;+ }+ if (Supplement.win32) { async = false; }@@ -480,8 +505,13 @@ os.put_string ( assert (!is_null (ttf)); assert (!is_null (eot)); - write_ttf ();- write_eof ();+ if (!should_stop ()) { + write_ttf ();+ }+ + if (!should_stop ()) { + write_eof ();+ } ExportTool.export_thread_is_running = false; @@ -510,6 +540,7 @@ os.put_string ( } void write_eof () {+ print ("WRITE EOF\n"); EotWriter fo; return_if_fail (!is_null (this));@@ -438,7 +438,7 @@ class Glyph : FontDisplay { return (int) Math.fabs (a.data.pos / SCALE - b.data.pos / SCALE); } - public int get_width () {+ public double get_width () { return (int) Math.fabs (right_limit / SCALE - left_limit / SCALE); } @@ -1383,10 +1383,6 @@ class Glyph : FontDisplay { ImageSurface ps = new ImageSurface (Format.ARGB32, allocation.width, allocation.height); Context cmp = new Context (ps); - cr.save ();- draw_background_color (cr, 1);- cr.restore ();- if (Supplement.show_coordinates) { draw_coordinate (cmp); }@@ -1746,6 +1742,10 @@ class Glyph : FontDisplay { double x, kern; double left, baseline; string last_name;++ cr.save ();+ draw_background_color (cr, 1);+ cr.restore (); x = 0; @@ -72,13 +72,13 @@ class GlyphCanvas : DrawingArea { Surface s = new Surface.similar (cw.get_target (), Cairo.Content.COLOR_ALPHA, allocation.width, allocation.height); Context c = new Context (s); - - current_display.draw (allocation, c); - + if (current_display is Glyph) { ((Glyph) current_display).juxtapose (allocation, c); } - + + current_display.draw (allocation, c); + cw.save (); cw.set_source_surface (c.get_target (), 0, 0); cw.paint (); @@ -135,9 +135,6 @@ class Line : GLib.Object { event_move_to (x, y, x, y, allocation); } - /** Move to line to @param x, @param y and execute ove line handle - * event for @param x, @param y.- */ public void event_move_to (double x, double y, double ax, double ay, Allocation allocation) { double p, c, mx, my; bool a = false;@@ -125,7 +125,7 @@ internal class MainWindow { } over_view = new OverView(); - tabs.add_unique_tab (over_view, 75, false); + tabs.add_unique_tab (over_view, 100, false); return over_view; } @@ -87,12 +87,12 @@ class MoveTool : Tool { move_action.connect ((self, x, y) => { if (move_path) { Glyph glyph = MainWindow.get_current_glyph ();- double dx = last_x - x; double dy = last_y - y; + double p = PenTool.precision; foreach (Path path in glyph.active_paths) {- path.move (glyph.ivz () * -dx, glyph.ivz () * dy);+ path.move (glyph.ivz () * -dx * p, glyph.ivz () * dy * p); } MainWindow.get_glyph_canvas ().redraw ();@@ -627,7 +627,6 @@ class LocaTable : Table { if (0 < i < size && glyph_offsets[i - 1] > glyph_offsets[i]) { warning (@"Invalid loca table, it must be sorted. ($(glyph_offsets[i - 1]) > $(glyph_offsets[i]))"); - print_offsets (); } } break; @@ -638,8 +637,7 @@ class LocaTable : Table { if (0 < i < size && glyph_offsets[i - 1] > glyph_offsets[i]) { warning (@"Invalid loca table, it must be sorted. ($(glyph_offsets[i - 1]) > $(glyph_offsets[i]))"); - print_offsets (); - } + } } break; @@ -1627,6 +1625,10 @@ class GlyfTable : Table { printd (@"loca fd.length (): $(fd.length ())\n"); last_len = fd.length (); + + if (ExportTool.should_stop ()) { + break; + } } location_offsets.append (fd.length ()); // last entry in loca table is special @@ -400,15 +400,9 @@ class OverView : FontDisplay { g = (!) gl; g.boundries (out x1, out y1, out x2, out y2);- - if (g.get_width () > w) {- m = 0;- } else {- m = ((w - g.get_width ()) / 2.0) / scale;- }- - gx = -x1 + m;- gy = -f.bottom_position + 210 - 65;++ gx = 0;+ gy = h / scale - 40; Surface s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h); Context c = new Context (s);@@ -44,7 +44,7 @@ class PenTool : Tool { private static bool adjust_precision = false; private static double adjust_precision_begin_x = 0; private static double adjust_precision_begin_y = 0;- private static double precision = 1;+ public static double precision = 1; public PenTool (string name) { base (name, "Edit path", ',', CTRL);@@ -101,19 +101,19 @@ class TabBar : DrawingArea { return true; }); - set_size_request (20, 50);+ set_size_request (20, 25); } private void is_over_close (double x, double y, out int over, out int over_close) { int i = 0;- double offset = 40;+ double offset = 0; foreach (Tab t in tabs) { if ( offset < x < offset + t.get_width ()) { over = i; - if (28 < y < 46 && x > offset + t.get_width () - 16) {+ if (8 < y < 20 && x > offset + t.get_width () - 16) { over_close = i; } else { over_close = -1;@@ -122,7 +122,7 @@ class TabBar : DrawingArea { return; } - offset += t.get_width () + 10;+ offset += t.get_width () + 3; i++; } @@ -361,30 +361,30 @@ class TabBar : DrawingArea { get_allocation(out alloc); double close_opacity;- double offset = 40;+ double offset = 0; int i = 0; foreach (Tab t in tabs) { cr.save ();- cr.translate (offset, 27);+ cr.translate (offset, 0); + // background if (i == selected) {- cr.set_source_rgba (1, 1, 1, 1);+ for (int j = 0; j < t.get_width (); j++) {+ cr.set_source_surface ((!) tab3_right, j, 2);+ cr.paint ();+ } } else if (i == over) {- cr.set_source_rgba (230/255.0, 236/255.0, 244/255.0, 1);+ for (int j = 0; j < t.get_width (); j++) {+ cr.set_source_surface ((!) tab2_right, j, 2);+ cr.paint ();+ } } else {- cr.set_source_rgba (142/255.0, 158/255.0, 190/255.0, 1);+ for (int j = 0; j < t.get_width (); j++) {+ cr.set_source_surface ((!) tab1_right, j, 2);+ cr.paint ();+ } } - cr.rectangle(-2, 5, t.get_width (), 18);- cr.set_line_width (0);- cr.fill ();- - cr.set_source_rgba (0, 0, 0, 1);- cr.set_font_size (12);- cr.move_to (0, 18);- cr.show_text (t.get_label ());- cr.stroke ();- // close if (t.has_close_button ()) { cr.set_line_width (1);@@ -401,31 +401,38 @@ class TabBar : DrawingArea { cr.stroke (); } + cr.set_source_rgba (0, 0, 0, 1);+ cr.set_font_size (14);+ cr.move_to (8, 18);+ cr.show_text (t.get_label ());+ cr.stroke ();+ + // edges if (tab1_left != null && tab1_right != null && tab2_left != null && tab2_right != null && tab3_left != null && tab3_right != null) { if (i == selected) {- cr.set_source_surface ((!) tab3_left, -7, 5);+ cr.set_source_surface ((!) tab3_left, 0, 2); cr.paint (); - cr.set_source_surface ((!) tab3_right, t.get_width () - 2, 5);+ cr.set_source_surface ((!) tab3_right, t.get_width () - 2, 2); cr.paint (); } else if (i == over) {- cr.set_source_surface ((!) tab2_left, -7, 5);+ cr.set_source_surface ((!) tab2_left, 0, 2); cr.paint (); - cr.set_source_surface ((!) tab2_right, t.get_width () - 2, 5);+ cr.set_source_surface ((!) tab2_right, t.get_width () - 2, 2); cr.paint (); } else {- cr.set_source_surface ((!) tab1_left, -7, 5);+ cr.set_source_surface ((!) tab1_left, 0, 2); cr.paint (); - cr.set_source_surface ((!) tab1_right, t.get_width () - 2, 5);+ cr.set_source_surface ((!) tab1_right, t.get_width () - 2, 2); cr.paint (); } } cr.restore (); - offset += t.get_width () + 10; // FIXA 10 should be x off marg eller så+ offset += t.get_width () + 3; i++; } }@@ -199,7 +199,7 @@ class Toolbox : GLib.Object { // Character set tools Tool full_unicode = new Tool ("utf_8", "Show full unicode characters set", 'a', CTRL); full_unicode.select_action.connect ((self) => {- MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false); + MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview (); GlyphRange gr = new GlyphRange (); gr.use_full_unicode_range ();@@ -210,7 +210,7 @@ class Toolbox : GLib.Object { Tool custom_character_set = new Tool ("custom_character_set", "Show default characters set", 'r', CTRL); custom_character_set.select_action.connect ((self) => {- MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);+ MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview (); GlyphRange gr = new GlyphRange (); gr.use_default_range ();@@ -221,7 +221,7 @@ class Toolbox : GLib.Object { Tool avalilable_characters = new Tool ("available_characters", "Show characters in font", 'd', CTRL); avalilable_characters.select_action.connect ((self) => {- MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 75, false);+ MainWindow.get_tab_bar ().add_unique_tab (new OverView (), 100, false); OverView o = MainWindow.get_overview (); o.display_all_available_glyphs (); MainWindow.get_tab_bar ().select_tab_name ("Overview");