The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Set position of resize handles

These changes was commited to the Birdfont repository Mon, 27 Jun 2016 09:30:49 +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>
Mon, 27 Jun 2016 09:30:49 +0000 (11:30 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 27 Jun 2016 09:30:49 +0000 (11:30 +0200)
commit 0fce48563ad36a259abc249a489c3d914dbc777b
tree a0bff1c67dbd16edc1ffe75102480e1a6d510c17
parent affdf0024498517245ee1fc0516b00840d2f54e0
Set position of resize handles

libbirdfont/DrawingTools.vala
libbirdfont/MoveTool.vala
libbirdfont/ResizeTool.vala
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -432,7 +432,7 @@ GlyphCanvas.redraw (); }); draw_tool_modifiers.add_tool (width); - + // height height = new SpinButton ("height", t_("Height")); height.set_big_number (true);
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -284,8 +284,6 @@ top = 10000; left = 10000; - glyph.layers.update_boundaries_for_object (); - foreach (SvgBird.Object o in glyph.active_paths) { if (top > o.top) { top = o.top;
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -35,6 +35,11 @@ static double selection_box_left = 0; static double selection_box_top = 0; + static double resized_width = 0; + static double resized_height = 0; + static double resized_top = 0; + static double resized_left = 0; + static bool rotate_path = false; static double last_rotate_y; static double rotation = 0; @@ -207,14 +212,14 @@ } public static void get_resize_handle_position (out double px, out double py) { - px = Glyph.reverse_path_coordinate_x (selection_box_center_x + selection_box_width / 2); - py = Glyph.reverse_path_coordinate_y (selection_box_center_y + selection_box_height / 2); + px = Glyph.reverse_path_coordinate_x (resized_left + resized_width); + py = Glyph.reverse_path_coordinate_y (-resized_top); } public static void get_horizontal_reseize_handle_position (out double px, out double py) { - px = Glyph.reverse_path_coordinate_x (selection_box_center_x + selection_box_width / 2); + px = Glyph.reverse_path_coordinate_x (resized_left + resized_width); px += 40; - py = Glyph.reverse_path_coordinate_y (selection_box_center_y); + py = Glyph.reverse_path_coordinate_y (-resized_top - resized_width / 2); } public static double get_rotated_handle_length () { @@ -384,9 +389,10 @@ path.transform (matrix); } } - + if (glyph.active_paths.size > 0) { - objects_resized (selection_box_width, selection_box_height); + update_resized_boundaries (); + objects_resized (resized_width, resized_height); } if (!selected) { @@ -401,10 +407,43 @@ } public static void update_selection_box () { + update_resized_boundaries (); MoveTool.update_boundaries_for_selection (); MoveTool.get_selection_box_boundaries (out selection_box_center_x, out selection_box_center_y, out selection_box_width, out selection_box_height, out selection_box_left, out selection_box_top); + } + + static void update_resized_boundaries () { + Glyph glyph = MainWindow.get_current_glyph (); + + double left = 10000; + double top = 10000; + double bottom = -10000; + double right = -10000; + + foreach (SvgBird.Object o in glyph.active_paths) { + if (top > o.top) { + top = o.top; + } + + if (left > o.left) { + left = o.left; + } + + if (right < o.right) { + right = o.right; + } + + if (bottom < o.bottom) { + bottom = o.bottom; + } + } + + resized_top = top; + resized_left = left; + resized_width = right - left; + resized_height = bottom - top; } /** Move resize handle to pixel x,y. */