Clone in a terminal:
Commit c340ed2
Johan Mattsson - 2015-11-28T13:05:24+00:00
c340ed28fe6a998b5a9ae73632652c1de6309242johan.mattsson.m@gmail.com

Hide scrollbar when menu is open

Changed files (2)

Diff

diff --git a/libbirdfont/AbstractMenu.vala b/libbirdfont/AbstractMenu.valaindex 3ee76a0..19c8e3d 100644--- a/libbirdfont/AbstractMenu.vala+++ b/libbirdfont/AbstractMenu.vala@@ -36,11 +36,15 @@ public class AbstractMenu : GLib.Object { 				if (tab_name == "Preview") { 					MenuTab.select_overview (); 				}+				+				MainWindow.hide_scrollbar ();+			} else {+				MainWindow.show_scrollbar (); 			} 		} 	} 	-	public bool menu_visibility = false;+	private bool menu_visibility = false; 	public SubMenu top_menu;  	SubMenu current_menu;@@ -219,7 +223,7 @@ public class AbstractMenu : GLib.Object { 				y += height; 			} 			-			menu_visibility = false;+			show_menu = false; 			current_menu = (!) top_menu; 			GlyphCanvas.redraw (); 		}diff --git a/libbirdfont/MainWindow.vala b/libbirdfont/MainWindow.valaindex 8f32ee8..0c814fb 100644--- a/libbirdfont/MainWindow.vala+++ b/libbirdfont/MainWindow.vala@@ -36,6 +36,8 @@ public class MainWindow : GLib.Object { 	/** Number of pixels per mm */
 	public static double units = 1;
 
+	private static double scrollbar_size = -1;
+	
 	public MainWindow () {
 		singleton = this;
 		
@@ -131,10 +133,10 @@ public class MainWindow : GLib.Object { 	public static void init () {
 		singleton = new MainWindow ();
 	}
--	public static RecentFiles get_recent_files_tab () {-		return file_tab;-	}+
+	public static RecentFiles get_recent_files_tab () {
+		return file_tab;
+	}
 	
 	public static void open_recent_files_tab () {
 		// FIXME: do not idle 
@@ -250,8 +252,21 @@ public class MainWindow : GLib.Object { 		MainWindow.native_window.file_chooser (title, fc, flags);
 	}
 	
+	public static void hide_scrollbar () {
+		if (!is_null (MainWindow.native_window)) {
+			MainWindow.native_window.set_scrollbar_size (-1);
+		}
+	}	
+
+	public static void show_scrollbar () {
+		if (!is_null (MainWindow.native_window)) {
+			MainWindow.native_window.set_scrollbar_size (scrollbar_size);
+		}
+	}
+	
 	public static void set_scrollbar_size (double size) {
 		if (!is_null (MainWindow.native_window)) {
+			scrollbar_size = size;
 			MainWindow.native_window.set_scrollbar_size (size);
 		}
 	}
@@ -290,43 +305,43 @@ public class MainWindow : GLib.Object { 	public static LigatureList get_ligature_display () {
 		return ligature_display;
 	}
--	public static void next_tab () {-		TabBar tb = MainWindow.get_tab_bar ();-		int n = tb.get_selected () + 1;-			-		if (!(0 <= n < tb.get_length ())) {-			return;-		}-			-		tb.select_tab (n);-	}--	public static void previous_tab () {-		TabBar tb = MainWindow.get_tab_bar ();-		int n = tb.get_selected () - 1;--		if (!(0 <= n < tb.get_length ())) {-			return;-		}-			-		tb.select_tab (n);-	}--	public static void close_tab () {-		TabBar tb = MainWindow.get_tab_bar ();-		int n = tb.get_selected ();--		if (!(0 <= n < tb.get_length ())) {-			return;-		}-		-		tb.close_tab (n);+
+	public static void next_tab () {
+		TabBar tb = MainWindow.get_tab_bar ();
+		int n = tb.get_selected () + 1;
+			
+		if (!(0 <= n < tb.get_length ())) {
+			return;
+		}
+			
+		tb.select_tab (n);
+	}
+
+	public static void previous_tab () {
+		TabBar tb = MainWindow.get_tab_bar ();
+		int n = tb.get_selected () - 1;
+
+		if (!(0 <= n < tb.get_length ())) {
+			return;
+		}
+			
+		tb.select_tab (n);
+	}
+
+	public static void close_tab () {
+		TabBar tb = MainWindow.get_tab_bar ();
+		int n = tb.get_selected ();
+
+		if (!(0 <= n < tb.get_length ())) {
+			return;
+		}
+		
+		tb.close_tab (n);
 	}
 	
 	public static void set_toolbox (Toolbox tb) {
 		tools = tb;
-	}+	}
 }
 
 }

Contact

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