Commit d45a73e
Fix dialog layout and set absolute path when saving fonts
Changed files (9)
modifiedlibbirdfont/LicenseDialog.valamodifiedlibbirdfont/OverwriteBfFile.valamodifiedlibbirdfont/OverwriteDialog.valamodifiedlibbirdfont/QuestionDialog.valamodifiedlibbirdfont/Renderer/TextArea.valamodifiedlibbirdfont/SaveCallback.valamodifiedlibbirdfont/SaveDialog.valamodifiedlibbirdfont/TabContent.valamodifiedlibbirdfont/Widget.vala
Diff
@@ -50,7 +50,7 @@ public class LicenseDialog : Dialog { height = 240; } - void layout () {+ public override void layout () { double cx = 0; double cy = (allocation.height - height) / 2.0; double center;@@ -22,7 +22,7 @@ public class OverwriteBfFile : QuestionDialog { Button cancel; public OverwriteBfFile (SaveCallback save_callback) {- base(t_("This file already exists. Do you want to replace it?"), 200);+ base(t_("This file already exists. Do you want to replace it?")); replace = new Button (t_("Replace")); replace.action.connect (() => {@@ -58,7 +58,7 @@ public class OverwriteDialog : Dialog { height = 90 * MainWindow.units; } - void layout () {+ public override void layout () { double cx = 0; double cy = (allocation.height - height) / 2.0; double center;@@ -19,23 +19,22 @@ namespace BirdFont { public class QuestionDialog : Dialog { TextArea question; public Gee.ArrayList<Button> buttons;-- double width = 0;- double height; static const double font_size = 20; static const double margin = 20;+ static const double margin_small = 5;+ + double width = 300;+ double height = 0; - public QuestionDialog (string message, int height) {+ public QuestionDialog (string message) { question = new TextArea (font_size); question.min_width = 300;+ question.min_height = font_size; question.set_editable (false); question.draw_border = false; question.text_color = Theme.get_color ("Text Tool Box"); question.set_text (message);- - this.height = height;- buttons = new Gee.ArrayList<Button> (); } @@ -43,9 +42,9 @@ public class QuestionDialog : Dialog { buttons.add (button); } - void layout () {+ public override void layout () { double cx = 0;- double cy = (allocation.height - height) / 2.0;+ double cy; double center; double h; @@ -60,23 +59,34 @@ public class QuestionDialog : Dialog { center = (allocation.width - width) / 2.0; question.widget_x = margin + center;- question.widget_y = cy + margin;- question.allocation = new WidgetAllocation.for_area (0, 0, 300, 450);+ question.allocation = new WidgetAllocation.for_area (0, 0, 3000, 3000); question.layout (); h = question.get_height () + margin;-+ print (@"question.get_height (): $(question.get_height ())\n");+ foreach (Button button in buttons) { button.widget_x += center;- button.widget_y = cy + h + margin; }+ + height = h + margin + margin_small;+ + if (buttons.size > 0) {+ height += buttons.get (0).get_height ();+ }+ + cy = (allocation.height - height) / 2.0;++ foreach (Button button in buttons) {+ button.widget_y = cy + h + margin_small;+ }+ + question.widget_y = cy + margin; } public override void draw (Context cr) { double cx, cy; - layout ();- cx = (allocation.width - width) / 2.0; cy = (allocation.height - height) / 2.0; @@ -880,7 +880,7 @@ public class TextArea : Widget { } /** @return offset to click in text. */- public void layout () {+ public override void layout () { double p; double tx, ty; string w;@@ -19,7 +19,7 @@ public class SaveCallback : GLib.Object { public signal void file_saved (); public bool is_done = false; - public string file_name = "";+ public string font_file_path = ""; public SaveCallback () { file_saved.connect (() => {@@ -38,11 +38,13 @@ public class SaveCallback : GLib.Object { string f; File file; OverwriteBfFile dialog;+ string file_name; if (fn != null) { f = (!) fn; #if MAC+ font_file_path = f; save (); #else if (!f.has_suffix (".bf")) {@@ -51,6 +53,7 @@ public class SaveCallback : GLib.Object { file_name = @"$(f)"; file = File.new_for_path (file_name);+ font_file_path = (!) file.get_path (); if (!file.query_exists ()) { save (); } else {@@ -75,10 +78,13 @@ public class SaveCallback : GLib.Object { } f = BirdFont.get_current_font ();-- Preferences.add_recent_files (file_name);- f.font_file = file_name;- + + if (font_file_path != "") {+ f.font_file = font_file_path;+ }+ + Preferences.add_recent_files (f.get_path ());+ if (f.is_bfp ()) { MainWindow.native_window.save (); } else {@@ -56,7 +56,7 @@ public class SaveDialog : Dialog { height = 90 * MainWindow.units; } - void layout () {+ public override void layout () { double cx = 0; double cy = (allocation.height - height) / 2.0; double center;@@ -96,6 +96,7 @@ public class TabContent : GLib.Object { if (dialog.visible) { dialog.allocation = allocation;+ dialog.layout (); dialog.draw (cr); } else if (menu.show_menu) { menu.draw (allocation, cr);@@ -43,6 +43,9 @@ public abstract class Widget : GLib.Object { cr.close_path (); } + public virtual void layout () {+ }+ public bool is_over (double x, double y) { return widget_x <= x <= widget_x + get_width () && widget_y <= y <= widget_y + get_height ();