Clone in a terminal:
Commit f4c8007
Johan Mattsson - 2014-07-12T22:58:17+00:00
f4c8007ade4bca17ad2b01afedd6e6c3e6bb3cccjohan.mattsson.m@gmail.com

Hide tool box

Changed files (10)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 1d46663..16428f4 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -941,6 +941,14 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		MenuTab.stop_background_thread (); 		return null; 	}++	public void hide_tool_box () {	+		toolbox.hide ();+	}	++	public void show_tool_box () {+		toolbox.show ();+	}	 }  class TabbarCanvas : DrawingArea {diff --git a/fonts/Downstream.bf b/fonts/Downstream.bfindex 436970a..517d812 100644--- a/fonts/Downstream.bf+++ b/fonts/Downstream.bf@@ -21,7 +21,7 @@ 	<bottom_limit>-27.0000000000</bottom_limit> </horizontal> -<grid width="4.000"/>+<grid width="2.000"/> <grid width="2.000"/>  <background scale="1.000" />@@ -139,8 +139,8 @@ <collection unicode="U+36"> 	<selected id="1"/> 	<glyph id="1" left="-28" right="28">-		<path stroke="0" data="S 16.0374376040,59.9975041597 Q 11.7061883544,60.0273752397 9.1550195134,59.9369060453 Q -7.6889335813,59.5439090240 -7.3835274542,43.0058236273 Q 3.5083440409,51.7258255660 16.4966722130,45.7612312812 Q 28.0975773773,39.9673487371 27.9775374376,24.0241264559 T Q 27.7978022583,0.1524223957 -0.0357737105,-0.0091514143 Q -28.0490848586,-0.0091514143 -28.0490848586,35.9642262895 Q -28.0490848586,76.0707154742 16.0374376040,71.9376039933 Q 16.0374376040,65.9675540765 16.0374376040,59.9975041597" />-		<path stroke="0" data="S 6.3935108153,24.6364392679 Q 6.4152567378,36.0605978804 -0.3419301165,35.8111480865 T Q -3.7140223681,35.6866631884 -7.5182811427,34.6271703003 L -7.3835274542,24.4833610649 Q -7.3096606909,12.8742458253 -0.8011647255,12.6963394343 Q 7.0817728300,12.3589226200 6.3935108153,24.6364392679" />+		<path stroke="0" data="S 16.0374376040,59.9975041597 Q 11.7061883544,60.0273752397 9.1550195134,59.9369060453 Q -7.6889335813,59.5439090240 -7.3835274542,43.0058236273 Q 5.2292073503,51.0639550624 16.8937945152,45.7612312812 Q 28.0975773773,40.4968451400 27.9775374376,24.0241264559 Q 27.7978022583,0.1524223957 -0.0357737105,-0.0091514143 Q -28.0490848586,-0.0091514143 -28.0490848586,35.9642262895 Q -28.0490848586,76.0707154742 16.0374376040,71.9376039933 Q 16.0374376040,65.9675540765 16.0374376040,59.9975041597" />+		<path stroke="0" data="S 6.3935108153,24.6364392679 Q 6.4152567378,36.0605978803 -0.3419301165,35.8111480865 Q -3.7140223681,35.6866631884 -7.5182811427,34.6271703003 L -7.3835274542,24.4833610649 Q -7.3096606909,12.8742458253 -0.8011647255,12.6963394343 Q 7.0817728300,12.3589226200 6.3935108153,24.6364392679" /> 	</glyph> </collection> <collection unicode="U+3a">diff --git a/graphics/tools_and_buttons.svg b/graphics/tools_and_buttons.svgindex ea140c7..e2dd7bb 100644--- a/graphics/tools_and_buttons.svg+++ b/graphics/tools_and_buttons.svg@@ -648,9 +648,9 @@      borderopacity="1.0"      inkscape:pageopacity="0.0"      inkscape:pageshadow="2"-     inkscape:zoom="4.7795181"-     inkscape:cx="165.77656"-     inkscape:cy="765.14379"+     inkscape:zoom="1.1948795"+     inkscape:cx="442.58637"+     inkscape:cy="605.78832"      inkscape:current-layer="layer1"      inkscape:document-units="px"      showgrid="false"@@ -2373,5 +2373,23 @@          style="fill:#b6b6b6;stroke-width:0px"          inkscape:connector-curvature="0" />     </g>+    <path+       style="fill:#f2f1f0;fill-opacity:1;stroke:#858585;stroke-width:0.68529391;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"+       d="m 410.45108,13.973977 c -8.31509,0 -15.05505,6.73996 -15.05505,15.05505 0,8.3151 6.73996,15.05506 15.05505,15.05506 0.28852,0 0.57211,-0.005 0.85662,-0.0214 l 0,-30.06728 c -0.28462,-0.016 -0.56799,-0.0214 -0.85662,-0.0214 z"+       id="path3007"+       inkscape:connector-curvature="0"+       sodipodi:nodetypes="csscccc"+       inkscape:export-filename="/home/johan/birdfont/icons/show_tool_box.png"+       inkscape:export-xdpi="320"+       inkscape:export-ydpi="320" />+    <path+       style="fill:#ffffff;fill-opacity:1;stroke:#858585;stroke-width:0.73220468px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+       d="m 409.77124,26.808417 -4.11674,-0.0204 0.14258,-2.26087 -5.92715,4.05327 5.92715,4.25695 -0.16295,-2.42381 4.13711,0.0204 z"+       id="path3811-4"+       inkscape:connector-curvature="0"+       sodipodi:nodetypes="cccccccc"+       inkscape:export-filename="/home/johan/birdfont/icons/show_tool_box.png"+       inkscape:export-xdpi="320"+       inkscape:export-ydpi="320" />   </g> </svg>diff --git a/icons/hide_toolbox.png b/icons/hide_toolbox.pngnew file mode 100644index 0000000..50fad26Binary files /dev/null and b/icons/hide_toolbox.png differdiff --git a/icons/show_tool_box.png b/icons/show_tool_box.pngnew file mode 100644index 0000000..d834931Binary files /dev/null and b/icons/show_tool_box.png differdiff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 2e33668..8c40903 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -35,6 +35,8 @@ public class DrawingTools : ToolCollection  { 	public static Tool move_tool; 	public static PenTool pen_tool; +	Tool hide_tool_box;+ 	PointTool point_tool; 	ZoomTool zoom_tool; 	Tool resize_tool;@@ -65,7 +67,8 @@ public class DrawingTools : ToolCollection  { 		 		draw_tools = new Expander (); 		shape_tools = new Expander ();-			+		+		Expander file_tools = new Expander (); 		Expander path_tool_modifiers = new Expander (); 		Expander draw_tool_modifiers = new Expander (); 		Expander edit_point_modifiers = new Expander ();@@ -80,6 +83,15 @@ public class DrawingTools : ToolCollection  { 		 		grid_expander = grid; +		// Hide tool box+		hide_tool_box = new Tool ("hide_toolbox", t_("Hide tool box"));+		hide_tool_box.select_action.connect ((self) => {+			MainWindow.get_toolbox ().set_visibility (false);+			MainWindow.native_window.hide_tool_box ();+			update_drawing_and_background_tools (self);+		});+		file_tools.add_tool (hide_tool_box);	+ 		// Draw tools 		pen_tool = new PenTool ("pen_tool"); 		pen_tool.select_action.connect ((self) => {@@ -778,6 +790,7 @@ public class DrawingTools : ToolCollection  { #endif  		// selection policy+		file_tools.set_open (true); 		draw_tools.set_open (true); 		draw_tool_modifiers.set_open (true); 		edit_point_modifiers.set_open (true);@@ -791,6 +804,7 @@ public class DrawingTools : ToolCollection  { 		background_tools.set_open (true); 		style_tools.set_open (true); 		+		add_expander (file_tools); 		add_expander (draw_tools); 		add_expander (draw_tool_modifiers); 		add_expander (edit_point_modifiers);@@ -808,7 +822,10 @@ public class DrawingTools : ToolCollection  { 		if (BirdFont.has_argument ("--test")) { 			add_expander (test_tools); 		}-		++		draw_tools.set_persistent (false);+		draw_tools.set_unique (false);+				 		draw_tools.set_persistent (true); 		draw_tools.set_unique (false); 		diff --git a/libbirdfont/NativeWindow.vala b/libbirdfont/NativeWindow.valaindex be01812..e1875fc 100644--- a/libbirdfont/NativeWindow.vala+++ b/libbirdfont/NativeWindow.vala@@ -67,6 +67,13 @@ public interface NativeWindow : GLib.Object { 	 	/** Load images in a background thread. */ 	public abstract void load_background_image ();++	/** Hide tool box widget */+	public abstract void hide_tool_box ();	++	/** Show tool box widget */+	public abstract void show_tool_box ();	+ }  }diff --git a/libbirdfont/TabContent.vala b/libbirdfont/TabContent.valaindex 970e868..8578e22 100644--- a/libbirdfont/TabContent.vala+++ b/libbirdfont/TabContent.vala@@ -13,12 +13,18 @@ */  using Cairo;+using Math;  namespace BirdFont {  /** Interface for events from native window to the current tab. */ public class TabContent : GLib.Object { 	+	private static ImageSurface? tool_box_button = null;+	private static bool tool_box_button_active = false;+	private static bool tool_box_button_pressed = false;+	private static WidgetAllocation allocation = new WidgetAllocation ();+	 	public static bool has_scrollbar () { 		if (MenuTab.suppress_event) { 			return false;@@ -43,7 +49,41 @@ public class TabContent : GLib.Object { 			cr.fill (); 			cr.restore (); 		} else {+			TabContent.allocation = allocation;+			 			GlyphCanvas.current_display.draw (allocation, cr);+			+			if (!MainWindow.get_toolbox ().is_visible ()) {+				draw_tool_box_button (allocation, cr);+			}+		}+	}+	+	static double distance_from_tool_box_button (double x , double y) {+		return sqrt (pow (fabs (allocation.width - x), 2) + pow (fabs (allocation.height / 2.0 - y), 2));+	}+	+	static void draw_tool_box_button (WidgetAllocation allocation, Context cr) {+		ImageSurface b;+		double x, y;+		double scale = Toolbox.get_icon_scale ();++		if (unlikely (tool_box_button == null)) {	+			tool_box_button = Icons.get_icon ("show_tool_box.png");+		}+		+		if (tool_box_button != null) {+			b = (!) tool_box_button;+			+			x = allocation.width / scale - b.get_width ();			+			y = (allocation.height / scale) / 2.0;+			y -= b.get_height () / 2.0;+				+			cr.save ();+			cr.scale (scale, scale);+			cr.set_source_surface (b, x, y);+			cr.paint ();+			cr.restore (); 		} 	} 	@@ -74,10 +114,19 @@ public class TabContent : GLib.Object { 	} 	 	public static void motion_notify (double x, double y) {+		bool b;+		 		if (MenuTab.suppress_event) { 			return; 		} 		+		b = tool_box_button_active;+		tool_box_button_active = distance_from_tool_box_button (x, y) <= get_tool_box_button_width ();++		if (b != tool_box_button_active) {+			GlyphCanvas.redraw ();+		}+		 		GlyphCanvas.current_display.motion_notify (x, y); 	} 	@@ -86,15 +135,25 @@ public class TabContent : GLib.Object { 			return; 		} 		-		GlyphCanvas.current_display.button_release (button, x, y);+		if (tool_box_button_active && tool_box_button_pressed) {+			MainWindow.native_window.show_tool_box ();+			MainWindow.get_toolbox ().set_visibility (true);+		} else {+			GlyphCanvas.current_display.button_release (button, x, y);+		} 	} 	 	public static void button_press (uint button, double x, double y) { 		if (MenuTab.suppress_event) { 			return; 		}-		-		GlyphCanvas.current_display.button_press (button, x, y);++		if (tool_box_button_active) {+			tool_box_button_pressed = true;+		} else {+			tool_box_button_pressed = false;+			GlyphCanvas.current_display.button_press (button, x, y);+		} 	}  	public static void double_click (uint button, double ex, double ey) {@@ -154,6 +213,18 @@ public class TabContent : GLib.Object { 		 		return uri; 	}++	private static double get_tool_box_button_width () {+		double w;+		+		if (tool_box_button != null) {+			w = ((!) tool_box_button).get_width ();+			w *= Toolbox.get_icon_scale ();+			return w;+		}+			+		return 0;+	} }  }diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 9fb8024..aed0384 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -41,7 +41,9 @@ public class Toolbox : GLib.Object  { 	double scroll_y = 0;  	private List<ToolCollection> tool_sets = new List<ToolCollection> ();-		+	+	bool visible = true;+	 	public Toolbox (GlyphCanvas glyph_canvas, TabBar tab_bar) { 		current_tool = new Tool ("no_icon"); 		press_tool = new Tool (null);@@ -73,6 +75,14 @@ public class Toolbox : GLib.Object  { 		update_expanders (); 	} +	public void set_visibility (bool v) {+		visible = v;+	}++	public bool is_visible () {+		return visible;+	}+ 	public static Tool get_move_tool () { 		return DrawingTools.move_tool; 	}@@ -364,6 +374,11 @@ public class Toolbox : GLib.Object  { 		return Toolbox.allocation_width / 160.0; 	} 	+	/** Scale icons to 320  */+	public static double get_icon_scale () {+		return 30 / 111.0;+	}+	 	public void update_expanders () { 		double pos; 		diff --git a/scripts/export.sh b/scripts/export.shindex c7e0c97..90b86fd 100755--- a/scripts/export.sh+++ b/scripts/export.sh@@ -25,7 +25,7 @@ version=$(cat ../../scripts/version.py | grep "VERSION = '" | grep -v "SO_VERSIO  rm -rf birdfont-$version -git clone --depth 1 --no-hardlinks --local $rep+git clone --no-hardlinks --local $rep   mv birdfont birdfont-$version

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112