The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

BackgroundTab.vala in /libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Circle boundaries heads/master
1 /* 2 Copyright (C) 2014 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Math; 16 using Cairo; 17 using SvgBird; 18 19 namespace BirdFont { 20 21 public class BackgroundTab : Glyph { 22 23 static BackgroundTab singleton; 24 25 public BackgroundTab () { 26 base ("", '\0'); 27 singleton = this; 28 29 Toolbox tools = MainWindow.get_toolbox (); 30 ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); 31 z.store_current_view (); 32 33 layers.add_layer (new Layer ()); 34 } 35 36 public static BackgroundTab get_instance () { 37 if (is_null (singleton)) { 38 singleton = new BackgroundTab (); 39 } 40 return singleton; 41 } 42 43 public override string get_name () { 44 return "Backgrounds"; 45 } 46 47 public override string get_label () { 48 return t_("Background Image"); 49 } 50 51 public override void selected_canvas () { 52 base.selected_canvas (); 53 54 GlyphCanvas canvas = MainWindow.get_glyph_canvas (); 55 GlyphCollection gc = new GlyphCollection ('\0', ""); 56 57 GlyphMaster master = new GlyphMaster (); 58 master.add_glyph (this); 59 gc.add_master (master); 60 61 canvas.set_current_glyph_collection (gc, false); 62 DrawingTools.background_scale.set_tool_visibility (true); 63 ZoomTool.zoom_full_background_image (); 64 } 65 66 public override void draw (WidgetAllocation allocation, Context cr) { 67 base.draw (allocation, cr); 68 Tool t = Toolbox.background_tools.select_background; 69 t.draw_action (t, cr, this); 70 } 71 } 72 73 } 74