Commit 3fa60c2
compile libbirdfont without gtk
Changed files (26)
modifiedsrc/BackgroundSelection.valamodifiedsrc/BackgroundTool.valamodifiedsrc/Context.valamodifiedsrc/CutBackgroundTool.valamodifiedsrc/ExportTool.valamodifiedsrc/FontDisplay.valamodifiedsrc/Glyph.valamodifiedsrc/GlyphBackgroundImage.valamodifiedsrc/GlyphCanvas.valamodifiedsrc/GlyphCollection.valadeletedsrc/GtkInterface.valaaddedsrc/GtkWindow.valamodifiedsrc/KeyBindings.valamodifiedsrc/Line.valamodifiedsrc/MainWindow.valamodifiedsrc/OverView.valamodifiedsrc/Path.valamodifiedsrc/SaveDialog.valamodifiedsrc/Scrollbar.valamodifiedsrc/ShrinkTool.valamodifiedsrc/SpinButton.valamodifiedsrc/Supplement.valamodifiedsrc/TooltipArea.valamodifiedsrc/VersionList.valamodifiedsrc/wscriptmodifiedwscript
Diff
@@ -15,9 +15,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;-using Gdk; using Cairo;+using Gdk; namespace Supplement { @@ -15,9 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;-using Gdk;- namespace Supplement { class BackgroundTool : Tool {@@ -15,8 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;-using Gdk; using Cairo; namespace Supplement {@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Math; namespace Supplement {@@ -233,7 +231,7 @@ class CutBackgroundTool : Tool { } newbg = new GlyphBackgroundImage ((!) f.get_backgrounds_folder ().get_child ("parts").get_child (fn).get_path ());- + // set position for the new background wc = newbg.get_margin_width (); hc = newbg.get_margin_height ();@@ -18,7 +18,6 @@ namespace Supplement { public class ExportTool : Tool {- private static string? prefered_browser = null; private static ExportThread export_thread; @@ -130,55 +129,6 @@ public class ExportTool : Tool { status ("Wrote $svg_file."); } - /** Export font and open html document */- public void view_result () {- Font font = Supplement.get_current_font ();- string path = @"$(font.get_name ()).html";- File dir = font.get_folder ();- File file = dir.get_child (path);- string browser = ""; - - if (!export_svg_font ()) {- warning ("Failed to export svg font.");- return;- }- - if (!export_ttf_font ()) {- warning ("Failed to export ttf font.");- return;- }- - try { - if (!file.query_exists ()) {- generate_html_document ((!)file.get_path (), font); - }-- browser = find_browser ();- Process.spawn_command_line_async (@"$browser $(file.get_uri ())");- } catch (Error e) {- stderr.printf (@"Failed to execute \"$browser $path\" \n");- critical (@"$(e.message)");- }- - }- - private string find_browser () { - File f;- string b;- if (prefered_browser != null) return (!) prefered_browser;- - b = @"C:\\Users\\$(Environment.get_user_name())\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"; // mind the hyphen- - f = File.new_for_path (b);- if (f.query_exists ()) {- prefered_browser = @"'$b'"; // hyphen for windows command- return (!) prefered_browser;- }- - prefered_browser = "sensible-browser";- return (!) prefered_browser;- }- public static void generate_html_document (string html_file, Font font) { File file = File.new_for_path (html_file); DataOutputStream os;@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Birdfont; namespace Supplement {@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Math; namespace Supplement {@@ -16,9 +16,8 @@ */ using Cairo;-using Gtk;-using Gdk; using Math;+using Gdk; namespace Supplement { @@ -16,12 +16,17 @@ */ using Cairo; -using Gtk; -using Gdk; using Math; namespace Supplement { +public struct Allocation { + public int width; + public int height; + public int x; + public int y; +} + public class GlyphCanvas : GLib.Object { public FontDisplay current_display; @@ -71,8 +76,7 @@ public class GlyphCanvas : GLib.Object { public FontDisplay get_current_display () { return current_display; } - - // Deprecated + public void redraw_area (int x, int y, int w, int h) { signal_redraw_area (x, y, w, h); } @@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Math; namespace Supplement {deleted file mode 100644@@ -1,439 +0,0 @@-/*- Copyright (C) 2012 Johan Mattsson-- This program is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program 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 General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--using Cairo;-using Gtk;-using Gdk;-using Supplement;-using WebKit;--namespace Supplement {--public class GtkWindow : Gtk.Window, NativeWindow {-- HBox list_box;- HBox canvas_box;- - WebView html_canvas;- ScrolledWindow html_box;-- VBox tab_box;-- static DrawingArea margin_bottom;- static DrawingArea margin_right;- - GlyphCanvasArea glyph_canvas_area;- - public GtkWindow (string title) {- // set_title (title);- }- - public void init () {- margin_bottom = new DrawingArea ();- margin_right = new DrawingArea ();- - margin_bottom.set_size_request (0, 0);- margin_right.set_size_request (0, 0);- - delete_event.connect (quit);- - set_size_and_position ();- - html_canvas = new WebView ();- WebKit.set_cache_model (CacheModel.DOCUMENT_VIEWER);- html_canvas.get_settings ().enable_default_context_menu = false;- - html_canvas.title_changed.connect ((p, s) => {- webkit_callback (s);- });- - html_box = new ScrolledWindow (null, null);- html_box.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);- - html_box.add (html_canvas);- - html_canvas.set_editable (true);- - MainWindow.get_tab_bar ().signal_tab_selected.connect ((f, tab) => {- bool n;- File layout_dir;- File layout_uri;- string uri = "";- FontDisplay fd = tab.get_display ();- - MainWindow.glyph_canvas.set_current_glyph (fd);- n = fd.is_html_canvas ();- - if (n) {- layout_dir = FontDisplay.find_layout_dir ();- uri = fd.get_uri ();- - if (uri == "") {- layout_uri = layout_dir.get_child (fd.get_html_file ());- uri = fd.path_to_uri ((!) layout_uri.get_path ());- }-- if (fd.get_name () == "Preview") {- ExportTool.export_all ();- }- - if (fd.get_html () == "") {- html_canvas.load_html_string ("<html></html>", "file:///"); - html_canvas.reload_bypass_cache ();- - html_canvas.load_uri (uri);- html_canvas.reload_bypass_cache ();- html_canvas.load_uri (uri);- - } else {- html_canvas.load_html_string (fd.get_html (), uri);- }- - html_box.set_visible (n);- glyph_canvas_area.set_visible (!n);- } else {- html_box.set_visible (false);- glyph_canvas_area.set_visible (true);- }- });-- // Hide this canvas when window is realized and flip canvas - // visibility in tab selection signal.- html_canvas.expose_event.connect ((t, e) => {- glyph_canvas_area.set_visible (false);- return false;- });- - MainWindow.tabs.add_unique_tab (MainWindow.content, 60, true);- - MainWindow.tabs.select_tab_name ("Menu");-- glyph_canvas_area = new GlyphCanvasArea (MainWindow.glyph_canvas);-- canvas_box = new HBox (false, 0);- canvas_box.pack_start (glyph_canvas_area, true, true, 0);- canvas_box.pack_start (html_box, true, true, 0);- - tab_box = new VBox (false, 0);- tab_box.pack_start (new TabbarCanvas (MainWindow.tabs), false, false, 0); - - tab_box.pack_start (canvas_box, true, true, 0);-- tab_box.pack_start (MainWindow.tool_tip, false, false, 0);- tab_box.pack_start (margin_bottom, false, false, 0);- - list_box = new HBox (false, 0);- list_box.pack_start (tab_box, true, true, 0);- list_box.pack_start (new ToolboxCanvas (MainWindow.tools), false, false, 0);- list_box.pack_start (margin_right, false, false, 0);-- add (list_box);- - key_snooper_install (MainWindow.global_key_bindings, null);- - add_events (EventMask.FOCUS_CHANGE_MASK);- - focus_in_event.connect ((t, e)=> {- MainWindow.key_bindings.reset ();- return true;- });- - set_icon_from_file ((!) Icons.find_icon ("window_icon.png").get_path ());- - show_all (); - - }-- internal void toggle_expanded_margin_bottom () {- int w, h;- margin_bottom.get_size_request (out w, out h);- - if (h == 1) h = 2; - else h = 1;- - margin_bottom.set_size_request (w, h);- }- - internal void toggle_expanded_margin_right () { - int w, h;- margin_right.get_size_request (out w, out h);-- if (w == 1) w = 2; - else w = 1;-- margin_right.set_size_request (w, h);- }-- public static void hide_cursor () {- Pixmap pixmap = new Pixmap (null, 1, 1, 1);- Color color = { 0, 0, 0, 0 };- Cursor cursor = new Cursor.from_pixmap (pixmap, pixmap, color, color, 0, 0);-- // Fixa: But why?- // (Supplement.exe:1300): Gdk-CRITICAL **: gdk_window_set_cursor: assertion `GDK_IS_WINDOW (window)' failed - // singleton.frame.set_cursor (cursor);- }-- public void update_window_size () {- int w, h;- get_size (out w, out h);- - Preferences.set ("window_width", @"$w");- Preferences.set ("window_height", @"$h");- }- - private void set_size_and_position () {- int w = Preferences.get_window_width ();- int h = Preferences.get_window_height ();- - set_default_size (w, h);- // move (10, 240);- }- - public bool quit () {- bool added;- SaveDialog s = new SaveDialog ();- - if (Supplement.get_current_font ().is_modified ()) {- added = MainWindow.get_tab_bar ().add_unique_tab (s, 50);- } else {- added = false;- }- - if (!added) {- Supplement.get_current_font ().save_backup ();- Gtk.main_quit ();- }- - s.finished.connect (() => {- Supplement.get_current_font ().delete_backup ();- Gtk.main_quit ();- });- - return true;- }- - public string? file_chooser (string title) {- string? fn = null;- FileChooserDialog file_chooser = new FileChooserDialog (title, this, FileChooserAction.SAVE, Stock.CANCEL, ResponseType.CANCEL, Stock.SAVE, ResponseType.ACCEPT);- Font font = Supplement.get_current_font ();- - try {- file_chooser.set_current_folder_file (font.get_folder ());- } catch (GLib.Error e) {- stderr.printf (e.message);- }- - if (file_chooser.run () == ResponseType.ACCEPT) { - MainWindow.get_glyph_canvas ().redraw ();- fn = file_chooser.get_filename ();- }-- file_chooser.destroy ();- - return fn;- } -}--class TabbarCanvas : DrawingArea {- TabBar tabbar;- - public TabbarCanvas (TabBar tb) { - tabbar = tb;-- set_extension_events (ExtensionMode.CURSOR | EventMask.POINTER_MOTION_MASK);- add_events (EventMask.BUTTON_PRESS_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK);- - motion_notify_event.connect ((t, e)=> {- Allocation alloc;- tabbar.motion (e.x, e.y);- get_allocation (out alloc);- queue_draw_area (0, 0, alloc.width, alloc.height);- return true;- }); - - button_press_event.connect ((t, e)=> {- Allocation alloc;- get_allocation (out alloc);- tabbar.select_tab_click (e.x, e.y, alloc.width, alloc.height);- queue_draw_area (0, 0, alloc.width, alloc.height);- return true;- });-- expose_event.connect ((t, e)=> {- Context cr = cairo_create (get_window ());-- Allocation alloc;- get_allocation (out alloc);-- tabbar.draw (cr, alloc.width, alloc.height);- return true;- });- - tabbar.signal_tab_selected.connect ((t) => {- Allocation alloc;- get_allocation (out alloc);- queue_draw_area (0, 0, alloc.width, alloc.height); - });- - set_size_request (20, 25);- }- -}--class ToolboxCanvas : DrawingArea {- Toolbox tb;- - public ToolboxCanvas (Toolbox toolbox) {- tb = toolbox;- - tb.redraw.connect ((x, y, w, h) => {- queue_draw_area (x, y, w, h);- });- - button_press_event.connect ((se, e)=> {- tb.press (e.button, e.x, e.y);- return true;- }); - - button_release_event.connect ((se, e)=> {- tb.release (e.button, e.x, e.y);- return true;- });-- motion_notify_event.connect ((sen, e)=> {- tb.move (e.x, e.y);- return true;- });- - expose_event.connect ((t, e)=> {- Allocation allocation;- get_allocation (out allocation);- - Context cw = cairo_create(get_window());- tb.allocation_width = allocation.width;- tb.allocation_height = allocation.height;- tb.draw (allocation.width, allocation.height, cw);- - return true;- });- - add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK);-- set_size_request (160, 100);-- leave_notify_event.connect ((t, e)=> {- tb.reset_active_tool ();- return true;- });- - }-}--public class GlyphCanvasArea : DrawingArea {- GlyphCanvas glyph_canvas;- Allocation alloc;- - public GlyphCanvasArea (GlyphCanvas gc) {- glyph_canvas = gc;-- add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK | EventMask.SCROLL_MASK);-- glyph_canvas.signal_redraw_area.connect ((x, y, w, h) => {- queue_draw_area ((int)x, (int)y, (int)w, (int)h);- });-- expose_event.connect ((t, e)=> { - Allocation allocation;- get_allocation (out allocation);- - glyph_canvas.allocation = allocation;- - if (unlikely (allocation != alloc && alloc.width != 0)) {- // Set size of glyph widget to an even number and notify - // set new allocation for glyph- bool ug = false;- - if (allocation.height % 2 != 0) {- MainWindow.native_window.toggle_expanded_margin_bottom ();- ug = true;- }- - if (allocation.width % 2 != 0) {- MainWindow.native_window.toggle_expanded_margin_right ();- ug = true;- } - - if (ug) {- //redraw_area (1, 1, 2, 2);- } else if (unlikely (allocation.width % 2 != 0 || allocation.height % 2 != 0)) {- warning (@"\nGlyph canvas is not divisible by two.\nWidth: $(allocation.width)\nHeight: $(allocation.height)");- }- - Supplement.current_glyph.resized ();- }- - alloc = allocation;- - Context cw = cairo_create (get_window());- - Surface s = new Surface.similar (cw.get_target (), Cairo.Content.COLOR_ALPHA, allocation.width, allocation.height);- Context c = new Context (s); -- glyph_canvas.current_display.draw (allocation, c);-- cw.save ();- cw.set_source_surface (c.get_target (), 0, 0);- cw.paint ();- cw.restore ();- - return true;- });-- button_press_event.connect ((t, e)=> {- if (e.type == EventType.BUTTON_PRESS) {- glyph_canvas.current_display.button_press (e.button, e.x, e.y); - } else if (e.type == EventType.2BUTTON_PRESS) {- glyph_canvas.current_display.double_click (e.button, e.x, e.y);- }- - return true;- });- - button_release_event.connect ((t, e)=> {- glyph_canvas.current_display.button_release ((int) e.button, e.x, e.y);- return true;- });- - motion_notify_event.connect ((t, e)=> {- glyph_canvas.current_display.motion_notify (e.x, e.y); - return true;- });- - scroll_event.connect ((t, e)=> {- if (e.direction == Gdk.ScrollDirection.UP) {- glyph_canvas.current_display.scroll_wheel_up (e.x, e.y);- } else if (e.direction == Gdk.ScrollDirection.DOWN) {- glyph_canvas.current_display.scroll_wheel_down (e.x, e.y);- }- - return true;- }); - }-}--}new file mode 100644@@ -0,0 +1,498 @@+/*+ Copyright (C) 2012 Johan Mattsson++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program 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 General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++using Cairo;+using Gtk;+using Gdk;+using Supplement;+using WebKit;++namespace Supplement {++public class GtkWindow : Gtk.Window, NativeWindow {++ HBox list_box;+ HBox canvas_box;+ + WebView html_canvas;+ ScrolledWindow html_box;++ VBox tab_box;++ static DrawingArea margin_bottom;+ static DrawingArea margin_right;+ + GlyphCanvasArea glyph_canvas_area;+ + static List<uint> key_pressed = new List<uint> ();+ + public GtkWindow (string title) {+ // set_title (title);+ }+ + public void init () {+ margin_bottom = new DrawingArea ();+ margin_right = new DrawingArea ();+ + margin_bottom.set_size_request (0, 0);+ margin_right.set_size_request (0, 0);+ + delete_event.connect (quit);+ + set_size_and_position ();+ + html_canvas = new WebView ();+ WebKit.set_cache_model (CacheModel.DOCUMENT_VIEWER);+ html_canvas.get_settings ().enable_default_context_menu = false;+ + html_canvas.title_changed.connect ((p, s) => {+ webkit_callback (s);+ });+ + html_box = new ScrolledWindow (null, null);+ html_box.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);+ + html_box.add (html_canvas);+ + html_canvas.set_editable (true);+ + MainWindow.get_tab_bar ().signal_tab_selected.connect ((f, tab) => {+ bool n;+ File layout_dir;+ File layout_uri;+ string uri = "";+ FontDisplay fd = tab.get_display ();+ + MainWindow.glyph_canvas.set_current_glyph (fd);+ n = fd.is_html_canvas ();+ + if (n) {+ layout_dir = FontDisplay.find_layout_dir ();+ uri = fd.get_uri ();+ + if (uri == "") {+ layout_uri = layout_dir.get_child (fd.get_html_file ());+ uri = fd.path_to_uri ((!) layout_uri.get_path ());+ }++ if (fd.get_name () == "Preview") {+ ExportTool.export_all ();+ }+ + if (fd.get_html () == "") {+ html_canvas.load_html_string ("<html></html>", "file:///"); + html_canvas.reload_bypass_cache ();+ + html_canvas.load_uri (uri);+ html_canvas.reload_bypass_cache ();+ html_canvas.load_uri (uri);+ + } else {+ html_canvas.load_html_string (fd.get_html (), uri);+ }+ + html_box.set_visible (n);+ glyph_canvas_area.set_visible (!n);+ } else {+ html_box.set_visible (false);+ glyph_canvas_area.set_visible (true);+ }+ });++ // Hide this canvas when window is realized and flip canvas + // visibility in tab selection signal.+ html_canvas.expose_event.connect ((t, e) => {+ glyph_canvas_area.set_visible (false);+ return false;+ });+ + MainWindow.tabs.add_unique_tab (MainWindow.content, 60, true);+ + MainWindow.tabs.select_tab_name ("Menu");++ glyph_canvas_area = new GlyphCanvasArea (MainWindow.glyph_canvas);++ canvas_box = new HBox (false, 0);+ canvas_box.pack_start (glyph_canvas_area, true, true, 0);+ canvas_box.pack_start (html_box, true, true, 0);+ + tab_box = new VBox (false, 0);+ tab_box.pack_start (new TabbarCanvas (MainWindow.tabs), false, false, 0); + + tab_box.pack_start (canvas_box, true, true, 0);++ tab_box.pack_start (new TooltipCanvas (MainWindow.tool_tip), false, false, 0);+ tab_box.pack_start (margin_bottom, false, false, 0);+ + list_box = new HBox (false, 0);+ list_box.pack_start (tab_box, true, true, 0);+ list_box.pack_start (new ToolboxCanvas (MainWindow.tools), false, false, 0);+ list_box.pack_start (margin_right, false, false, 0);++ add (list_box);+ + key_snooper_install (GtkWindow.global_key_bindings, null);+ + add_events (EventMask.FOCUS_CHANGE_MASK);+ + focus_in_event.connect ((t, e)=> {+ MainWindow.key_bindings.reset ();+ return true;+ });+ + set_icon_from_file ((!) Icons.find_icon ("window_icon.png").get_path ());+ + show_all (); + + }++ public static int global_key_bindings (Widget grab_widget, EventKey event, void* data) { + MainWindow window = MainWindow.get_singleton ();+ + foreach (uint k in key_pressed) {+ if (k == event.keyval) {+ key_pressed.remove_all (k);+ window.glyph_canvas.key_release (event.keyval);+ window.key_bindings.key_release (event.keyval);+ return 0;+ }+ }+ + key_pressed.append (event.keyval);+ window.glyph_canvas.key_press (event.keyval);+ window.key_bindings.key_press (event.keyval);+ + return 0;+ }++ internal void toggle_expanded_margin_bottom () {+ int w, h;+ margin_bottom.get_size_request (out w, out h);+ + if (h == 1) h = 2; + else h = 1;+ + margin_bottom.set_size_request (w, h);+ }+ + internal void toggle_expanded_margin_right () { + int w, h;+ margin_right.get_size_request (out w, out h);++ if (w == 1) w = 2; + else w = 1;++ margin_right.set_size_request (w, h);+ }++ public static void hide_cursor () {+ Pixmap pixmap = new Pixmap (null, 1, 1, 1);+ Color color = { 0, 0, 0, 0 };+ Cursor cursor = new Cursor.from_pixmap (pixmap, pixmap, color, color, 0, 0);++ // Fixa: But why?+ // (Supplement.exe:1300): Gdk-CRITICAL **: gdk_window_set_cursor: assertion `GDK_IS_WINDOW (window)' failed + // singleton.frame.set_cursor (cursor);+ }++ public void update_window_size () {+ int w, h;+ get_size (out w, out h);+ + Preferences.set ("window_width", @"$w");+ Preferences.set ("window_height", @"$h");+ }+ + private void set_size_and_position () {+ int w = Preferences.get_window_width ();+ int h = Preferences.get_window_height ();+ + set_default_size (w, h);+ // move (10, 240);+ }+ + public bool quit () {+ bool added;+ SaveDialog s = new SaveDialog ();+ + if (Supplement.get_current_font ().is_modified ()) {+ added = MainWindow.get_tab_bar ().add_unique_tab (s, 50);+ } else {+ added = false;+ }+ + if (!added) {+ Supplement.get_current_font ().save_backup ();+ Gtk.main_quit ();+ }+ + s.finished.connect (() => {+ Supplement.get_current_font ().delete_backup ();+ Gtk.main_quit ();+ });+ + return true;+ }+ + public string? file_chooser (string title) {+ string? fn = null;+ FileChooserDialog file_chooser = new FileChooserDialog (title, this, FileChooserAction.SAVE, Stock.CANCEL, ResponseType.CANCEL, Stock.SAVE, ResponseType.ACCEPT);+ Font font = Supplement.get_current_font ();+ + try {+ file_chooser.set_current_folder_file (font.get_folder ());+ } catch (GLib.Error e) {+ stderr.printf (e.message);+ }+ + if (file_chooser.run () == ResponseType.ACCEPT) { + MainWindow.get_glyph_canvas ().redraw ();+ fn = file_chooser.get_filename ();+ }++ file_chooser.destroy ();+ + return fn;+ } +}++class TabbarCanvas : DrawingArea {+ TabBar tabbar;+ + public TabbarCanvas (TabBar tb) { + tabbar = tb;++ set_extension_events (ExtensionMode.CURSOR | EventMask.POINTER_MOTION_MASK);+ add_events (EventMask.BUTTON_PRESS_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK);+ + motion_notify_event.connect ((t, e)=> {+ Gtk.Allocation alloc;+ tabbar.motion (e.x, e.y);+ get_allocation (out alloc);+ queue_draw_area (0, 0, alloc.width, alloc.height);+ return true;+ }); + + button_press_event.connect ((t, e)=> {+ Gtk.Allocation alloc;+ get_allocation (out alloc);+ tabbar.select_tab_click (e.x, e.y, alloc.width, alloc.height);+ queue_draw_area (0, 0, alloc.width, alloc.height);+ return true;+ });++ expose_event.connect ((t, e)=> {+ Context cr = cairo_create (get_window ());++ Gtk.Allocation alloc;+ get_allocation (out alloc);++ tabbar.draw (cr, alloc.width, alloc.height);+ return true;+ });+ + tabbar.signal_tab_selected.connect ((t) => {+ Gtk.Allocation alloc;+ get_allocation (out alloc);+ queue_draw_area (0, 0, alloc.width, alloc.height); + });+ + set_size_request (20, 25);+ }+ +}++class ToolboxCanvas : DrawingArea {+ Toolbox tb;+ + public ToolboxCanvas (Toolbox toolbox) {+ tb = toolbox;+ + tb.redraw.connect ((x, y, w, h) => {+ queue_draw_area (x, y, w, h);+ });+ + button_press_event.connect ((se, e)=> {+ tb.press (e.button, e.x, e.y);+ return true;+ }); + + button_release_event.connect ((se, e)=> {+ tb.release (e.button, e.x, e.y);+ return true;+ });++ motion_notify_event.connect ((sen, e)=> {+ tb.move (e.x, e.y);+ return true;+ });+ + expose_event.connect ((t, e)=> {+ Gtk.Allocation allocation;+ get_allocation (out allocation);+ + Context cw = cairo_create(get_window());+ tb.allocation_width = allocation.width;+ tb.allocation_height = allocation.height;+ tb.draw (allocation.width, allocation.height, cw);+ + return true;+ });+ + add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK);++ set_size_request (160, 100);++ leave_notify_event.connect ((t, e)=> {+ tb.reset_active_tool ();+ return true;+ });+ + }+}++public class GlyphCanvasArea : DrawingArea {+ GlyphCanvas glyph_canvas;+ Gtk.Allocation alloc;+ + public GlyphCanvasArea (GlyphCanvas gc) {+ glyph_canvas = gc;++ add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK | EventMask.SCROLL_MASK);++ glyph_canvas.signal_redraw_area.connect ((x, y, w, h) => {+ queue_draw_area ((int)x, (int)y, (int)w, (int)h);+ });++ expose_event.connect ((t, e)=> { + Gtk.Allocation allocation;+ get_allocation (out allocation);+ + glyph_canvas.allocation.width = allocation.width;+ glyph_canvas.allocation.height = allocation.height;+ glyph_canvas.allocation.y = allocation.x;+ glyph_canvas.allocation.y = allocation.y;+ + if (unlikely (allocation != alloc && alloc.width != 0)) {+ // Set size of glyph widget to an even number and notify + // set new allocation for glyph+ bool ug = false;+ + if (allocation.height % 2 != 0) {+ MainWindow.native_window.toggle_expanded_margin_bottom ();+ ug = true;+ }+ + if (allocation.width % 2 != 0) {+ MainWindow.native_window.toggle_expanded_margin_right ();+ ug = true;+ } + + if (ug) {+ //redraw_area (1, 1, 2, 2);+ } else if (unlikely (allocation.width % 2 != 0 || allocation.height % 2 != 0)) {+ warning (@"\nGlyph canvas is not divisible by two.\nWidth: $(allocation.width)\nHeight: $(allocation.height)");+ }+ + Supplement.current_glyph.resized ();+ }+ + alloc = allocation;+ + Context cw = cairo_create (get_window());+ + Surface s = new Surface.similar (cw.get_target (), Cairo.Content.COLOR_ALPHA, allocation.width, allocation.height);+ Context c = new Context (s); ++ glyph_canvas.current_display.draw (glyph_canvas.allocation, c);++ cw.save ();+ cw.set_source_surface (c.get_target (), 0, 0);+ cw.paint ();+ cw.restore ();+ + return true;+ });++ button_press_event.connect ((t, e)=> {+ if (e.type == EventType.BUTTON_PRESS) {+ glyph_canvas.current_display.button_press (e.button, e.x, e.y); + } else if (e.type == EventType.2BUTTON_PRESS) {+ glyph_canvas.current_display.double_click (e.button, e.x, e.y);+ }+ + return true;+ });+ + button_release_event.connect ((t, e)=> {+ glyph_canvas.current_display.button_release ((int) e.button, e.x, e.y);+ return true;+ });+ + motion_notify_event.connect ((t, e)=> {+ glyph_canvas.current_display.motion_notify (e.x, e.y); + return true;+ });+ + scroll_event.connect ((t, e)=> {+ if (e.direction == Gdk.ScrollDirection.UP) {+ glyph_canvas.current_display.scroll_wheel_up (e.x, e.y);+ } else if (e.direction == Gdk.ScrollDirection.DOWN) {+ glyph_canvas.current_display.scroll_wheel_down (e.x, e.y);+ }+ + return true;+ }); + }+}++public class TooltipCanvas : DrawingArea {+ TooltipArea tooltip_area;+ + public TooltipCanvas (TooltipArea ta) {+ tooltip_area = ta;++ expose_event.connect ((t, e)=> {+ Allocation allocation = {0, 0, 0, 0};+ Gtk.Allocation alloc;+ Context cr = cairo_create (get_window ());+ + get_allocation (out alloc);++ allocation.width = alloc.width;+ allocation.height = alloc.height;+ allocation.y = alloc.x;+ allocation.y = alloc.y;+ + tooltip_area.draw (cr, allocation);++ return true;+ });+ + tooltip_area.redraw.connect (() => {+ Gtk.Allocation alloc;+ get_allocation (out alloc);+ queue_draw_area (0, 0, alloc.width, alloc.height);+ });+ + set_size_request (10, 20);+ }++ +}++}@@ -73,10 +73,6 @@ public static const uint CTRL = 1 << 0; public static const uint ALT = 1 << 2; public static const uint SHIFT = 1 << 3; -public bool is_mod (EventKey e) {- return (e.keyval == Key.CTRL_RIGHT || e.keyval == Key.CTRL_LEFT || e.keyval == Key.ALT_RIGHT || e.keyval == Key.ALT_LEFT);-}- /** A list of all valid key bindings. */ public class BindingList { static ShortCut[]? nc = null;@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; namespace Supplement { @@ -15,9 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gdk; -using Gtk; - namespace Supplement { public class MainWindow { @@ -31,9 +28,7 @@ public class MainWindow { public static OverView over_view; public static TabBar tabs; public static NativeWindow native_window; - - static List<uint> key_pressed = new List<uint> (); - + public MainWindow () { singleton = this; @@ -132,25 +127,6 @@ public class MainWindow { return singleton; } - public static int global_key_bindings (Widget grab_widget, EventKey event, void* data) { - MainWindow window = get_singleton (); - - foreach (uint k in key_pressed) { - if (k == event.keyval) { - key_pressed.remove_all (k); - window.glyph_canvas.key_release (event.keyval); - window.key_bindings.key_release (event.keyval); - return 0; - } - } - - key_pressed.append (event.keyval); - window.glyph_canvas.key_press (event.keyval); - window.key_bindings.key_press (event.keyval); - - return 0; - } - public static string? file_chooser (string title) { return get_singleton ().native_window.file_chooser (title); } @@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; namespace Supplement { @@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Math; namespace Supplement {@@ -15,8 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;-using Gdk; using Cairo; namespace Supplement {@@ -16,8 +16,6 @@ */ using Cairo;-using Gdk;-using Gtk; namespace Supplement { @@ -15,8 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk;- namespace Supplement { // TODO contrast@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; namespace Supplement { @@ -15,7 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -using Gtk; using Supplement; using Birdfont; @@ -21,40 +21,28 @@ using Gtk; namespace Supplement { -public class TooltipArea : DrawingArea {+public class TooltipArea : GLib.Object { string tool_tip;+ public signal void redraw (); public TooltipArea () { set_text_from_tool ();- - expose_event.connect ((t, e)=> {- Allocation alloc;- Context cr = cairo_create (get_window ());- - get_allocation (out alloc);- allocation = alloc;- - draw (cr, alloc);- return true;- });- - set_size_request (10, 20); } public void update_text () { set_text_from_current_tool ();- queue_draw_area (0, 0, allocation.width, allocation.height);+ redraw (); } public void show_text (string text) { tool_tip = text;- queue_draw_area (0, 0, allocation.width, allocation.height);+ redraw (); } public void set_text_from_tool () { set_text_from_current_tool ();- queue_draw_area (0, 0, allocation.width, allocation.height);+ redraw (); } private void set_text_from_current_tool () {@@ -16,8 +16,6 @@ */ using Cairo;-using Gtk;-using Gdk; using Math; namespace Supplement {@@ -75,8 +75,8 @@ def build (bld): bld.shlib ( target = 'birdfont', param = PARAM,- packages = 'gtk+-2.0 libxml-2.0',- uselib = 'GTK GLIB GIO XML WEB',+ packages = 'libxml-2.0',+ uselib = 'CAIRO GLIB GIO PIXBUF XML', source = BIRDFONT, name = "libbirdfont" )@@ -88,9 +88,9 @@ def build (bld): ) bld (- rule = 'valac -C ./src/birdfont.vapi ../src/Main.vala ../src/GtkInterface.vala -X ../build/src/libbirdfont.so -X ./birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0',+ rule = 'valac -C ./src/birdfont.vapi ../src/Main.vala ../src/GtkWindow.vala -X ../build/src/libbirdfont.so -X ./birdfont.h --pkg gtk+-2.0 --pkg libxml-2.0 --pkg gdk-2.0 --pkg webkit-1.0', name = 'main_c',- source = ['../src/Main.vala', '../src/GtkInterface.vala'],+ source = ['../src/Main.vala', '../src/GtkWindow.vala'], target = '../Main.c', depends = 'libbirdfont' )@@ -103,7 +103,7 @@ def build (bld): ) bld (- rule = 'gcc ../build/Main.c ../build/GtkInterface.c -I ../build/ -I ../build/src -L ../build/src -l birdfont -o ${TGT} \+ rule = 'gcc ../build/Main.c ../build/GtkWindow.c -I ../build/ -I ../build/src -L ../build/src -l birdfont -o ${TGT} \ $(pkg-config --cflags --libs glib-2.0) \ $(pkg-config --cflags --libs libxml-2.0) \ $(pkg-config --cflags --libs gio-2.0) \@@ -16,8 +16,10 @@ def options(opt): def configure(conf): conf.load('compiler_c vala') - conf.check_cfg(package='glib-2.0', uselib_store='GLIB',atleast_version='2.16.0', mandatory=1, args='--cflags --libs') + conf.check_cfg(package='cairo', uselib_store='CAIRO', mandatory=1, args='--cflags --libs') + conf.check_cfg(package='gdk-pixbuf-2.0', uselib_store='PIXBUF', mandatory=1, args='--cflags --libs') conf.check_cfg(package='gio-2.0', uselib_store='GIO', atleast_version='2.16.0', mandatory=1, args='--cflags --libs') + conf.check_cfg(package='glib-2.0', uselib_store='GLIB',atleast_version='2.16.0', mandatory=1, args='--cflags --libs') conf.check_cfg(package='gtk+-2.0', uselib_store='GTK', atleast_version='2.16.0', mandatory=1, args='--cflags --libs') conf.check_cfg(package='libxml-2.0', uselib_store='XML', mandatory=1, args='--cflags --libs') conf.check_cfg(package='webkit-1.0', uselib_store='WEB', mandatory=1, args='--cflags --libs')