Commit c8477a8
Dark theme and a separate tool box for the overview tab
Changed files (13)
modifiedgraphics/tools_and_buttons.svgaddedicons/overview_counter.pngmodifiedlibbirdfont/DefaultCharactersSet.valamodifiedlibbirdfont/Expander.valamodifiedlibbirdfont/Glyph.valamodifiedlibbirdfont/GlyphRange.valamodifiedlibbirdfont/Line.valamodifiedlibbirdfont/OverView.valamodifiedlibbirdfont/OverViewItem.valaaddedlibbirdfont/OverviewTools.valamodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/TabBar.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -1206,15 +1206,15 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2"- inkscape:zoom="6.250608"- inkscape:cx="294.83826"- inkscape:cy="593.47879"+ inkscape:zoom="1.1049618"+ inkscape:cx="329.13142"+ inkscape:cy="671.7607" inkscape:current-layer="layer1" inkscape:document-units="px" showgrid="false"- inkscape:window-width="1202"+ inkscape:window-width="1218" inkscape:window-height="745"- inkscape:window-x="78"+ inkscape:window-x="62" inkscape:window-y="27" inkscape:window-maximized="1" showguides="true"@@ -1228,7 +1228,7 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />- <dc:title></dc:title>+ <dc:title /> </cc:Work> </rdf:RDF> </metadata>@@ -3624,48 +3624,15 @@ sodipodi:ry="18.070375" d="m 219.00678,133.99237 a 15.290318,18.070375 0 1 1 -30.58064,0 15.290318,18.070375 0 1 1 30.58064,0 z" transform="matrix(0.39792146,0,0,0.03494084,148.58689,59.804985)" />- <image- y="0.6927166"- x="404.71494"- id="image3518"- xlink:href="file:///home/johan/H%C3%A4mtningar/BF_CharacterSet_Dark.jpg"- height="738"- width="909" /> <rect- style="opacity:0.98000004;color:#000000;fill:#ea4d1a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.75199997;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"- id="rect3521"- width="5.4599066"- height="38.8801"- x="270.5"- y="134.5" />- <rect- style="opacity:0.98000004;color:#000000;fill:#464d53;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.75199997;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"- id="rect3523"- width="1.8100172"- height="38.902409"- x="270.37643"- y="134.53888" />- <g- id="g4318"- inkscape:export-filename="/home/johan/birdfont/icons/tab3_right.png"+ style="opacity:0.98000004;color:#000000;fill:#5e6c77;fill-opacity:1;fill-rule:nonzero;stroke:#5e6c77;stroke-width:11.4018774;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"+ id="rect3516"+ width="10.67344"+ height="4.1808019"+ x="395.18619"+ y="19.503733"+ inkscape:export-filename="/home/johan/birdfont/icons/overview_counter.png" inkscape:export-xdpi="320"- inkscape:export-ydpi="320">- <rect- transform="scale(-1,1)"- y="134.50909"- x="-284.88071"- height="38.8801"- width="4.5"- id="rect3521-8"- style="opacity:0.98000004;color:#000000;fill:#ea4d1a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.75199997;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />- <rect- transform="scale(-1,1)"- y="134.54797"- x="-285.00427"- height="38.902409"- width="1.8100172"- id="rect3523-6"- style="opacity:0.98000004;color:#000000;fill:#464d53;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.75199997;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />- </g>+ inkscape:export-ydpi="320" /> </g> </svg>new file mode 100644Binary files /dev/null and b/icons/overview_counter.png differ@@ -22,8 +22,8 @@ public class DefaultCharacterSet { public static void create_default_character_sets () { languages = new DefaultLanguages (); - add_language (t_("Default language"), "", "");- add_language (t_("Private use area"), "PRIVATE_USE", "");+ add_language (t_("Default Language"), "", "");+ add_language (t_("Private Use Area"), "PRIVATE_USE", ""); add_language (t_("Chinese"), "zh", ""); add_language (t_("English"), "en", "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z");@@ -63,6 +63,8 @@ public class DefaultCharacterSet { } else { use_default_range_alphabetic (gr); }+ + gr.name = "Default"; } private static string get_prefered_language_code () {@@ -277,6 +279,8 @@ public class DefaultCharacterSet { gr.add_range ('\0', (unichar) 0xFFF8); } }+ + gr.name = "Unicode"; } public static DefaultLanguages get_default_languages () {@@ -1,5 +1,5 @@ /*- Copyright (C) 2012 Johan Mattsson+ Copyright (C) 2012 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 @@ -18,6 +18,8 @@ using Math; namespace BirdFont { public class Expander : GLib.Object {++ private static const double HEADLINE_MARGIN = 20; public bool draw_separator { get; set; } @@ -41,7 +43,10 @@ public class Expander : GLib.Object { double content_height = 0; - public Expander () {+ string? headline;+ + public Expander (string? headline = null) {+ this.headline = headline; tool = new Gee.ArrayList<Tool> (); draw_separator = true; }@@ -93,7 +98,10 @@ public class Expander : GLib.Object { } foreach (Tool t in tool) {- if (t is FontName) {+ if (t is OverviewTool) {+ t.w = Toolbox.allocation_width;+ t.h = 15 * scale;+ } else if (t is FontName) { t.w = Toolbox.allocation_width * scale; t.h = 20 * scale; } else if (t is KerningRange) {@@ -111,6 +119,11 @@ public class Expander : GLib.Object { content_height = 0; } + if (headline != null) {+ yt += 10 + HEADLINE_MARGIN;+ content_height += yt;+ }+ foreach (Tool t in tool) { if (t.tool_is_visible ()) { if (new_row) {@@ -191,11 +204,17 @@ public class Expander : GLib.Object { double yt = y + scroll + 2; double ih2 = 5.4 / 2; double iw2 = 5.4 / 2;- - if (draw_separator) { + Text title;++ if (headline != null) {+ title = new Text ();+ title.set_text ((!) headline);+ cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1);+ title.draw (cr, x, y + HEADLINE_MARGIN, 8);+ } else if (draw_separator) { cr.save (); cr.set_line_width (0.5);- cr.set_source_rgba (0, 0, 0, 0.25);+ cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1); cr.move_to (x, yt); cr.line_to (wd - w - x + 6, yt); cr.stroke ();@@ -373,7 +373,8 @@ public class Glyph : FontDisplay { double xhp = BirdFont.get_current_font ().xheight_position; Line xheight_line = new Line ("x-height", xhp, false);- xheight_line.set_color (33 / 255.0, 68 / 255.0, 120 / 255.0, 166 / 255.0);+ xheight_line.set_color (120 / 255.0, 68 / 255.0, 120 / 255.0, 120 / 255.0);+ xheight_line.dashed = true; xheight_line.position_updated.connect ((pos) => { Font f = BirdFont.get_current_font (); f.xheight_position = pos;@@ -16,6 +16,8 @@ namespace BirdFont { public class GlyphRange { + public string name {get; set;}+ public Gee.ArrayList<UniRange> ranges; /** Glyphs without a corresponding unicode value (ligatures). */@@ -28,6 +30,7 @@ public class GlyphRange { public GlyphRange () { ranges = new Gee.ArrayList<UniRange> (); unassigned = new Gee.ArrayList<string> ();+ name = "No name"; } public void add_unassigned (string glyph_name) {@@ -21,6 +21,8 @@ public class Line : GLib.Object { public static const bool VERTICAL = true; public static const bool HORIZONTAL = false; + public bool dashed { get; set; }+ string label; bool vertical; @@ -45,6 +47,8 @@ public class Line : GLib.Object { this.vertical = vertical; this.pos = position; + dashed = false;+ r = 0.7; g = 0.7; b = 0.8;@@ -60,6 +64,7 @@ public class Line : GLib.Object { l.a = a; l.visible = visible;+ l.dashed = dashed; return l; }@@ -264,13 +269,22 @@ public class Line : GLib.Object { double p, h, w; double size = (active) ? 8 : 5; - if (!visible) return;+ if (!visible) {+ return;+ } cr.save (); cr.set_line_width (1); - if (active) cr.set_source_rgba (0, 0, 0.3, 1);- else cr.set_source_rgba (r, this.g, b, a);+ if (dashed) {+ cr.set_dash ({20, 20}, 0);+ }+ + if (active) {+ cr.set_source_rgba (0, 0, 0.3, 1);+ } else {+ cr.set_source_rgba (r, this.g, b, a);+ } // Line if (is_vertical ()) {@@ -36,7 +36,7 @@ public class OverView : FontDisplay { public signal void open_new_glyph_signal (unichar c); public signal void open_glyph_signal (GlyphCollection c); - GlyphRange glyph_range;+ public GlyphRange glyph_range; string search_query = ""; Gee.ArrayList<OverViewItem> visible_items = new Gee.ArrayList<OverViewItem> ();@@ -46,7 +46,7 @@ public class OverView : FontDisplay { Gee.ArrayList<OverViewUndoItem> redo_items = new Gee.ArrayList<OverViewUndoItem> (); /** Show all characters that has been drawn. */- bool all_available = true;+ public bool all_available = true; /** Show unicode database info. */ CharacterInfo? character_info = null;@@ -102,6 +102,8 @@ public class OverView : FontDisplay { set_initial_zoom (); }+ + OverviewTools.update_overview_characterset (); }); update_scrollbar ();@@ -224,6 +226,7 @@ public class OverView : FontDisplay { } public override void selected_canvas () {+ OverviewTools.update_overview_characterset (); redraw_area (0, 0, allocation.width, allocation.height); KeyBindings.set_require_modifier (true); update_scrollbar ();@@ -292,6 +295,8 @@ public class OverView : FontDisplay { if (selected > visible_items.size) { selected_item = get_selected_item (); }+ + GlyphCanvas.redraw (); } OverViewItem get_selected_item () {@@ -32,6 +32,8 @@ public class OverViewItem : GLib.Object { public static double width = 100; public static double height = 130; public static double margin = 20;++ static double glyph_scale = 1.0; public OverViewItem (GlyphCollection? glyphs, unichar character, double x, double y) { this.x = x;@@ -125,40 +127,49 @@ public class OverViewItem : GLib.Object { draw_caption (cr); } - private bool draw_thumbnail (Context cr, GlyphCollection? gl, double x, double y) {+ private void draw_thumbnail (Context cr, GlyphCollection? gl, double x, double y) { Glyph g; Font font; double gx, gy; double x1, x2, y1, y2;- double scale;- double scale_box;+ double scale, scale_box; double w, h; double glyph_width, glyph_height; Surface s; Context c;+ Text fallback;+ double font_size;++ font = BirdFont.get_current_font ();+ w = width;+ h = height; - if (gl != null) {- font = BirdFont.get_current_font ();- w = width;- h = height;+ scale_box = width / DEFAULT_WIDTH;++ s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20);+ c = new Context (s); - scale_box = (width / DEFAULT_WIDTH);- + if (gl != null) { g = ((!) gl).get_current (); g.boundaries (out x1, out y1, out x2, out y2); glyph_width = x2 - x1; glyph_height = y2 - y1;++ if (glyph_scale == 1) {+ // caption height is 20+ glyph_scale = (h - 20) / (font.top_limit - font.bottom_limit); + } - // caption height is 20- scale = (h - 20) / (font.top_limit - font.bottom_limit);+ scale = glyph_scale; gx = ((w / scale) - glyph_width) / 2; gy = (h / scale) - 25 / scale;- - s = new Surface.similar (cr.get_target (), Content.COLOR_ALPHA, (int) w, (int) h - 20);- c = new Context (s);- + + if (gx < 0) {+ glyph_scale = 1 + 2 * gx / width;+ }+ c.save (); c.scale (scale, scale); @@ -168,14 +179,22 @@ public class OverViewItem : GLib.Object { g.draw_paths (c); c.restore ();-- cr.save ();- cr.set_source_surface (s, x, y - h);- cr.paint ();- cr.restore ();+ } else {+ c.save ();+ 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 = DEFAULT_HEIGHT * 0.5;+ gx = (width - fallback.get_extent (font_size)) / 2.0;+ gy = (height - DEFAULT_HEIGHT / 2.0) / 2.0;+ fallback.draw (c, gx, gy, font_size);+ c.restore (); } - return (gl != null);+ cr.save ();+ cr.set_source_surface (s, x, y - h);+ cr.paint ();+ cr.restore (); } public bool has_icons () {new file mode 100644@@ -0,0 +1,128 @@+/*+ 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;++namespace BirdFont {++public class OverviewTools : ToolCollection {++ static OverviewTool all_glyphs;+ static OverviewTool default_glyphs;+ static OverviewTool unicode;++ public static Gee.ArrayList<Expander> expanders;++ public OverviewTools () {+ Expander font_name = new Expander ();+ Expander character_sets = new Expander (t_("Character Sets"));+ + expanders = new Gee.ArrayList<Expander> ();+ + font_name.add_tool (new FontName ());+ font_name.draw_separator = false;+ + all_glyphs = new OverviewTool (t_("All Glyphs"));+ all_glyphs.select_action.connect ((self) => {+ OverView overview = MainWindow.get_overview ();+ overview.display_all_available_glyphs ();+ });+ character_sets.add_tool (all_glyphs);++ default_glyphs = new OverviewTool (t_("Default"));+ default_glyphs.select_action.connect ((self) => {+ OverView overview = MainWindow.get_overview ();+ GlyphRange gr = new GlyphRange ();+ DefaultCharacterSet.use_default_range (gr);+ overview.set_glyph_range (gr);+ });+ character_sets.add_tool (default_glyphs);++ unicode = new OverviewTool (t_("Unicode"));+ unicode.select_action.connect ((self) => {+ OverView overview = MainWindow.get_overview ();+ GlyphRange gr = new GlyphRange ();+ DefaultCharacterSet.use_full_unicode_range (gr);+ overview.set_glyph_range (gr);+ });+ character_sets.add_tool (unicode);++ character_sets.set_persistent (true);+ character_sets.set_unique (true);++ expanders.add (font_name);+ expanders.add (character_sets);+ + update_overview_characterset ();+ }+ + public static void update_overview_characterset () {+ GlyphRange gr;+ uint size;+ OverView overview;+ + // All characters+ size = BirdFont.get_current_font ().length ();+ all_glyphs.number = get_display_value (size);+ + // Default+ gr = new GlyphRange ();+ DefaultCharacterSet.use_default_range (gr);+ size = gr.get_length ();+ default_glyphs.number = get_display_value (size);+ + // Unicode+ gr = new GlyphRange ();+ DefaultCharacterSet.use_full_unicode_range (gr);+ size = gr.get_length ();+ unicode.number = get_display_value (size);+ + overview = MainWindow.get_overview ();+ + // set selected item+ all_glyphs.set_selected (false);+ default_glyphs.set_selected (false);+ unicode.set_selected (false);+ + if (overview.all_available) {+ all_glyphs.set_selected (true);+ } else if (overview.glyph_range.name == "Default") {+ default_glyphs.set_selected (true);+ } else if (overview.glyph_range.name == "Unicode") {+ unicode.set_selected (true);+ } + }++ static string get_display_value (uint size) {+ double k;+ string display_size;+ + if (size >= 1000) {+ k = size / 1000.0;+ size = (uint) Math.rint (k);+ display_size = @"$(size)k";+ } else {+ display_size = @"$(size)";+ }+ + return display_size;+ }+ + public override Gee.ArrayList<Expander> get_expanders () {+ return expanders;+ }+ +}++}@@ -41,7 +41,7 @@ public class Text { string text; GlyphSequence glyph_sequence; double line_gap = 20;- public delegate void Iterator (Glyph glyph, double kerning);+ public delegate void Iterator (Glyph glyph, double kerning, bool last); public Text () { current_font = null;@@ -80,6 +80,7 @@ public class Text { GlyphRange? gr_left, gr_right; double row_height; GlyphSequence word;+ Glyph? g; row_height = get_row_height (); @@ -94,7 +95,9 @@ public class Text { word_with_ligatures = word.process_ligatures (); gr_left = null; gr_right = null;- foreach (Glyph? g in word_with_ligatures.glyph) {+ for (int i = 0; i < word_with_ligatures.glyph.size; i++) {+ g = word_with_ligatures.glyph.get (i);+ if (prev == null || wi == 0) { kern = 0; } else {@@ -109,7 +112,7 @@ public class Text { // process glyph glyph = (g == null) ? font.get_not_def_character ().get_current () : (!) g;- iter (glyph, kern);+ iter (glyph, kern, i + 1 == word_with_ligatures.glyph.size); prev = g; wi++;@@ -119,9 +122,20 @@ public class Text { public double get_extent (double font_size_in_pixels) { double x = 0; double ratio = font_size_in_pixels / get_row_height ();- - iterate ((glyph, kerning) => {- x += (glyph.get_width () + kerning) * ratio;++ iterate ((glyph, kerning, last) => {+ double x1, y1, x2, y2;+ double lsb;+ + glyph.add_help_lines ();+ lsb = glyph.left_limit;+ + if (!last) {+ x += (glyph.get_width () + kerning) * ratio;+ } else {+ glyph.boundaries (out x1, out y1, out x2, out y2);+ x += (x2 - lsb) * ratio;+ } }); return x;@@ -149,11 +163,13 @@ public class Text { y = ratio * (get_row_height () + font.base_line) + py; x = px; - iterate ((glyph, kerning) => {- double lsb = glyph.left_limit;+ iterate ((glyph, kerning, last) => {+ double lsb;; glyph.add_help_lines (); + lsb = glyph.left_limit;+ x += kerning * ratio; cr.save (); cr.new_path ();@@ -754,7 +754,7 @@ public class TabBar : GLib.Object { if (tab_index == first_tab) { cr.save (); cr.set_source_rgba (70 / 255.0, 77 / 255.0, 83 / 255.0, 1);- cr.rectangle (- 1 / scale, 0, 1 / scale, h);+ cr.rectangle (0, 0, 1 / scale, h); cr.fill (); cr.restore (); }@@ -23,6 +23,7 @@ public class Toolbox : GLib.Object { public DrawingTools drawing_tools; public KerningTools kerning_tools; public PreviewTools preview_tools;+ public OverviewTools overview_tools; Tool current_tool; @@ -49,6 +50,7 @@ public class Toolbox : GLib.Object { drawing_tools = new DrawingTools (glyph_canvas); kerning_tools = new KerningTools (); preview_tools = new PreviewTools ();+ overview_tools = new OverviewTools (); tool_sets.append (drawing_tools); tool_sets.append (kerning_tools);@@ -62,6 +64,8 @@ public class Toolbox : GLib.Object { current_set = kerning_tools; } else if (tab_name == "Preview") { current_set = preview_tools;+ } else if (tab_name == "Overview") {+ current_set = overview_tools; } else { current_set = drawing_tools; }@@ -414,16 +418,12 @@ public class Toolbox : GLib.Object { cr.rectangle (0, 0, w, h); cr.set_line_width (0);- if (BirdFont.android) {- cr.set_source_rgba (222/255.0, 221/255.0, 222/255.0, 1);- } else {- cr.set_source_rgba (51/255.0, 54/255.0, 59/255.0, 1);- }+ 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 (0/255.0, 0/255.0, 0/255.0, 1);+ cr.set_source_rgba (101 / 255.0, 108 / 255.0, 116 / 255.0, 1); cr.fill (); draw_expanders (w, h, cr);