The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Fix length of resize handle

These changes was commited to the Birdfont repository Sun, 19 Apr 2015 11:39:19 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 19 Apr 2015 11:39:19 +0000 (13:39 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 19 Apr 2015 12:08:05 +0000 (14:08 +0200)
commit 01b526d4529ad1483b6c9cddb56189d88feebaea
tree 81310d4f1b75df77e3c14edbec7f96641cfb7734
parent f686744b7eebf7ac8b6383c8c088acc3c8066ada
Fix length of resize handle

libbirdfont/ResizeTool.vala
libbirdfont/Theme.vala
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -104,6 +104,8 @@ rotate_path = false; move_paths = false; DrawingTools.move_tool.release (b, x, y); + update_selection_box (); + GlyphCanvas.redraw (); }); move_action.connect ((self, x, y) => { @@ -115,11 +117,8 @@ rotate (x, y); } - if (!rotate_path) { - update_selection_box (); - } - if (move_paths || rotate_path || resize_path) { + update_selection_box (); GlyphCanvas.redraw (); } @@ -134,11 +133,10 @@ handle = new Text ("resize_handle", 60 * MainWindow.units); handle.load_font ("icons.bf"); - handle.widget_x = Glyph.reverse_path_coordinate_x (p.xmax) - - handle.get_sidebearing_extent () / 2.0; - - handle.widget_y = Glyph.reverse_path_coordinate_y (p.ymax) - - handle.get_height () / 2.0; + get_reseize_handle_position (p, out handle.widget_x, out handle.widget_y); + + handle.widget_x -= handle.get_sidebearing_extent () / 2; + handle.widget_y -= handle.get_height () / 2; Theme.text_color (handle, "Highlighted 1"); handle.draw (cr); @@ -154,7 +152,24 @@ key_press_action.connect ((self, keyval) => { DrawingTools.move_tool.key_press (keyval); }); + } + + public static void get_reseize_handle_position (Path p, out double px, out double py) { + px = Glyph.reverse_path_coordinate_x (p.xmax); + py = Glyph.reverse_path_coordinate_y (p.ymax); + } + + public static double get_rotated_handle_length () { + double s, hx, hy; + double d; + + s = fmin (selection_box_width, selection_box_height) * 1.1; + d = (s / Glyph.ivz ()) / 2; + + hx = cos (rotation) * d; + hy = sin (rotation) * d; + return d; } public void signal_objects_rotated () { @@ -224,8 +239,8 @@ cx = Glyph.reverse_path_coordinate_x (selection_box_center_x); cy = Glyph.reverse_path_coordinate_y (selection_box_center_y); - hx = cos (rotation) * 75; - hy = sin (rotation) * 75; + hx = cos (rotation) * get_rotated_handle_length (); + hy = sin (rotation) * get_rotated_handle_length (); inx = x - size * MainWindow.units <= cx + hx - 2.5 <= x + size * MainWindow.units; iny = y - size * MainWindow.units <= cy + hy - 2.5 <= y + size * MainWindow.units; @@ -244,8 +259,8 @@ cr.rectangle (cx - 2.5, cy - 2.5, 5, 5); cr.fill (); - hx = cos (rotation) * 75; - hy = sin (rotation) * 75; + hx = cos (rotation) * get_rotated_handle_length (); + hy = sin (rotation) * get_rotated_handle_length (); cr.set_line_width (1); cr.move_to (cx, cy); @@ -362,8 +377,8 @@ } bool is_over_resize_handle (Path p, double x, double y) { - double handle_x = Math.fabs (Glyph.reverse_path_coordinate_x (p.xmax)); - double handle_y = Math.fabs (Glyph.reverse_path_coordinate_y (p.ymax)); + double handle_x, handle_y; + get_reseize_handle_position (p, out handle_x, out handle_y); return Path.distance (handle_x, x, handle_y, y) < 12 * MainWindow.units; }
--- a/libbirdfont/Theme.vala +++ b/libbirdfont/Theme.vala @@ -119,7 +119,7 @@ Theme.set_default_color ("Overview Glyph", 219 / 255.0, 221 / 255.0, 233 / 255.0, 1); Theme.set_default_color ("Table Background 1", 238 / 255.0, 239 / 255.0, 243 / 255.0, 1); - Theme.set_default_color ("Table Background 2", 210 / 255.0, 212 / 255.0, 223 / 255.0, 1); + Theme.set_default_color ("Table Background 2", 225 / 255.0, 227 / 255.0, 233 / 255.0, 1); Theme.set_default_color ("Selected Tab Foreground", 0, 0, 0, 1); Theme.set_default_color ("Tab Separator", 207 / 255.0, 210 / 255.0, 215 / 255.0, 1);