Clone in a terminal:
Commit efb2585
Johan Mattsson - 2015-05-09T10:02:08+00:00
efb2585413d03e0f1db25f94fd39f97d67e18840johan.mattsson.m@gmail.com

Fix color in character set selection

Changed files (1)

Diff

diff --git a/libbirdfont/LanguageSelectionTab.vala b/libbirdfont/LanguageSelectionTab.valaindex 99064c0..0e628a1 100644--- a/libbirdfont/LanguageSelectionTab.vala+++ b/libbirdfont/LanguageSelectionTab.vala@@ -16,14 +16,32 @@ using Math;  namespace BirdFont { -public class LanguageSelectionTab : FontDisplay {-	-	int scroll = 0;-	int visible_rows = 0;-	WidgetAllocation allocation;+public class LanguageSelectionTab : Table { 	 	public LanguageSelectionTab () {-		allocation = new WidgetAllocation ();+	}+	+	public override Gee.ArrayList<Row> get_rows () {+		Gee.ArrayList<Row> rows = new Gee.ArrayList<Row> ();+		int i = 0;++		rows.add (new Row.headline (t_("Character Sets")));++		foreach (string language in DefaultLanguages.names) {+			Row r = new Row.columns_1 (language, i, false);+			rows.add (r);+			i++;+		}+		+		return rows;+	}++	public override void update_rows () {+		redraw_area (0, 0, allocation.width, allocation.height);+	}++	public override void selected_row (Row row, int column, bool delete_button) {+		select_language (row.get_index ()); 	}  	void select_language (int row) {@@ -37,57 +55,7 @@ public class LanguageSelectionTab : FontDisplay { 		tb.close_display (this); 		Toolbox.select_tool_by_name ("custom_character_set"); 	}--	public override void button_release (int button, double ex, double ey) {-		int r = (int) rint ((ey - 17) / 18.0);-		if (button == 1 && 0 <= r < DefaultLanguages.codes.size) {-			select_language (r + scroll);-		}-	} 	-	public override void draw (WidgetAllocation allocation, Context cr) {-		int y = 20;-		int s = 0;-		bool color = (scroll % 2) == 0;-		-		this.allocation = allocation;-		-		visible_rows = (int) (allocation.height / 18.0);-		-		cr.save ();-		Theme.color (cr, "Table Background 1");-		cr.rectangle (0, 0, allocation.width, allocation.height);-		cr.fill ();-		cr.restore ();-		-		cr.save ();-		Theme.color (cr, "Table Background 2");-		cr.set_font_size (12);-		-		foreach (string language in DefaultLanguages.names) {-			if (s++ >= scroll) {-				draw_row (allocation, cr, language, color, y);-				y += 18;-				color = !color;-			}-		}-		cr.restore ();-	}	--	private static void draw_row (WidgetAllocation allocation, Context cr, string language, bool color, double y) {--		if (color) {-			cr.save ();-			Theme.color (cr, "Table Background 2");-			cr.rectangle (0, y - 14, allocation.width, 18);-			cr.fill ();-			cr.restore ();-		}-		-		cr.move_to (30, y);-		cr.show_text (language);-	}- 	public override string get_label () { 		return t_("Character Set"); 	}@@ -95,65 +63,6 @@ public class LanguageSelectionTab : FontDisplay { 	public override string get_name () { 		return "Character Set"; 	}--	public override bool has_scrollbar () {-		return true;-	}-	-	public override void scroll_wheel_down (double x, double y) {-		uint rows = DefaultLanguages.names.size;-		scroll += 3;--		if (scroll + visible_rows > rows) {-			scroll = (int) (rows - visible_rows);-		}-		-		if (scroll < 0) {-			scroll = 0;-		}-		-		update_scrollbar ();-		redraw_area (0, 0, allocation.width, allocation.height);-	}-	-	public override void scroll_wheel_up (double x, double y) {-		scroll -= 3;-		-		if (scroll < 0) {-			scroll = 0;-		}-		-		update_scrollbar ();-		redraw_area (0, 0, allocation.width, allocation.height);-	}--	public override void selected_canvas () {-		update_scrollbar ();-		redraw_area (0, 0, allocation.width, allocation.height);-	}-	-	public override void update_scrollbar () {-		uint rows = DefaultLanguages.names.size;--		if (rows == 0 || visible_rows == 0) {-			MainWindow.set_scrollbar_size (0);-			MainWindow.set_scrollbar_position (0);-		} else {-			MainWindow.set_scrollbar_size ((double) visible_rows / rows);-			MainWindow.set_scrollbar_position ((double) scroll /  rows);-		}-	}--	public override void scroll_to (double percent) {-		uint rows = DefaultLanguages.names.size;-		scroll = (int) (percent * rows);-		-		if (scroll > rows - visible_rows) {-			scroll = (int) (rows - visible_rows);-		}-		-		redraw_area (0, 0, allocation.width, allocation.height);-	} }  }

Contact

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