The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Add a button for closing paths

These changes was commited to the Birdfont repository Sun, 03 May 2015 04:28:04 +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, 03 May 2015 04:28:04 +0000 (06:28 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 03 May 2015 04:28:53 +0000 (06:28 +0200)
commit bce6371684099f4d3818282fbef1e896476be31f
tree ff68df541aeb139d948a78032a6c1a921147f139
parent 0944c302f6939692ac4dd24bdba7ec50d3c358d7
Add a button for closing paths

libbirdfont/DrawingTools.vala
libbirdfont/ForesightTool.vala
resources/icons.bf
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -81,6 +81,7 @@ Tool tie_handles; Tool reflect_handle; Tool create_line; + Tool close_path_tool; Tool delete_button; public Tool insert_point_on_path_tool; @@ -560,6 +561,29 @@ reverse_path_tool = new OrientationTool ("reverse_path", t_("Create counter from outline")); draw_tool_modifiers.add_tool (reverse_path_tool); + // close path + close_path_tool = new Tool ("close_path", t_("Close path")); + close_path_tool.select_action.connect ((self) => { + Tool current; + Glyph g; + + current = MainWindow.get_toolbox ().get_current_tool (); + + if (current is ForesightTool) { + ((ForesightTool) current).stop_drawing (); + } + + PenTool.reset_stroke (); + + g = MainWindow.get_current_glyph (); + g.close_path (); + g.clear_active_paths (); + + self.set_selected (false); + GlyphCanvas.redraw (); + }); + draw_tool_modifiers.add_tool (close_path_tool); + move_layer = new Tool ("move_layer", t_("Move to path to the bottom layer")); move_layer.select_action.connect ((self) => { Glyph g = MainWindow.get_current_glyph (); @@ -1148,6 +1172,7 @@ tie_handles.set_tool_visibility (false); reflect_handle.set_tool_visibility (false); create_line.set_tool_visibility (false); + close_path_tool.set_tool_visibility (false); quadratic_points.set_tool_visibility (false); cubic_points.set_tool_visibility (false); @@ -1187,7 +1212,8 @@ tie_handles.set_tool_visibility (true); reflect_handle.set_tool_visibility (true); create_line.set_tool_visibility (true); - + close_path_tool.set_tool_visibility (true); + quadratic_points.set_tool_visibility (true); cubic_points.set_tool_visibility (true); double_points.set_tool_visibility (true);
--- a/libbirdfont/ForesightTool.vala +++ b/libbirdfont/ForesightTool.vala @@ -74,18 +74,7 @@ MainWindow.set_cursor (NativeWindow.HIDDEN); if (b == 2) { - p.release_action (p, 1, x, y); - - if (PenTool.active_path.is_open ()) { - PenTool.active_path.delete_last_point (); - } - - p.press_action (p, 2, x, y); - p.release_action (p, 2, x, y); - current_path.hide_end_handle = true; - state = NONE; - MainWindow.set_cursor (NativeWindow.VISIBLE); - MainWindow.get_current_glyph ().clear_active_paths (); + stop_drawing (); return; } @@ -109,6 +98,7 @@ } if (p.has_join_icon ()) { + // FIXME: last activa path in list ps = new PointSelection (PenTool.active_path.points.get (PenTool.active_path.points.size - 1), PenTool.active_path); ps.point.set_tie_handle (false); @@ -329,6 +319,34 @@ Tool p = PointTool.pen (); p.draw_action (p, cairo_context, glyph); }); + } + + public void stop_drawing () { + PenTool p = (PenTool) PointTool.pen (); + + if (state != NONE) { + p.release_action (p, 1, 0, 0); + + if (get_active_path ().is_open () && state != NONE) { + get_active_path ().delete_last_point (); + } + + p.press_action (p, 2, 0, 0); + p.release_action (p, 2, 0, 0); + current_path.hide_end_handle = true; + + MainWindow.set_cursor (NativeWindow.VISIBLE); + MainWindow.get_current_glyph ().clear_active_paths (); + + state = NONE; + MainWindow.set_cursor (NativeWindow.VISIBLE); + } + } + + public Path get_active_path () { + Glyph g = MainWindow.get_current_glyph (); + return_val_if_fail (g.active_paths.size > 0, new Path ()); + return g.active_paths.get (g.active_paths.size -1); } public void switch_to_line_mode () {
--- a/resources/icons.bf +++ b/resources/icons.bf @@ -210,6 +210,16 @@ <path stroke="0" skew="0" data="B 28.3602245702,27.4852661412 C 28.3602245702,11.9897661412 15.7036045702,-0.6668338588 0.2081145702,-0.6668338588 C -15.2873664298,-0.6668338588 -27.8309294298,11.9897661412 -27.8309294298,27.4852661412 C -27.8309294298,42.9807661412 -15.2873664298,55.5242661412 0.2081145702,55.5242661412 C 15.7036045702,55.5242661412 28.3602245702,42.9807661412 28.3602245702,27.4852661412" /> <path stroke="0" skew="0" data="B -24.2129884298,27.4852661412 C -24.2129884298,13.9450661412 -13.3320824298,2.9510661412 0.2081145702,2.9510661412 C 13.7483145702,2.9510661412 24.7422845702,13.9450661412 24.7422845702,27.4852661412 C 24.7422845702,41.0254661412 13.7483145702,51.9063661412 0.2081145702,51.9063661412 C -13.3320824298,51.9063661412 -24.2129884298,41.0254661412 -24.2129884298,27.4852661412" /> <path stroke="0" skew="0" data="S -1.5502645503,33.9444444444 L -1.5502645503,33.9444444444" /> + </glyph> + </collection> + <collection name="close_path"> + <selected id="1"/> + <glyph id="1" left="-28" right="28.419182948490214"> + <path stroke="0" skew="0" data="B 28.3602245702,27.4852661412 C 28.3602245702,11.9897661412 15.7036045702,-0.6668338588 0.2081145702,-0.6668338588 C -15.2873664298,-0.6668338588 -27.8309294298,11.9897661412 -27.8309294298,27.4852661412 C -27.8309294298,42.9807661412 -15.2873664298,55.5242661412 0.2081145702,55.5242661412 C 15.7036045702,55.5242661412 28.3602245702,42.9807661412 28.3602245702,27.4852661412" /> + <path stroke="0" skew="0" data="B -24.2129884298,27.4852661412 C -24.2129884298,13.9450661412 -13.3320824298,2.9510661412 0.2081145702,2.9510661412 C 13.7483145702,2.9510661412 24.7422845702,13.9450661412 24.7422845702,27.4852661412 C 24.7422845702,41.0254661412 13.7483145702,51.9063661412 0.2081145702,51.9063661412 C -13.3320824298,51.9063661412 -24.2129884298,41.0254661412 -24.2129884298,27.4852661412" /> + <path stroke="0" skew="0" data="S -1.9114391144,40.0000000000 L 2.0885608856,40.0000000000 D 2.0885608856,48.0000000000 2.0885608856,46.0000000000 2.0885608856,48.0000000000 L -1.9114391144,48.0000000000 L -1.9114391144,40.0000000000" /> + <path stroke="0" skew="0" data="S -1.9114391144,24.0000000000 L 2.0885608856,24.0000000000 L 2.0885608856,32.0000000000 L -1.9114391144,32.0000000000 L -1.9114391144,24.0000000000" /> + <path stroke="0" skew="0" data="S 2.0885608856,16.0000000000 L 2.0885608856,8.0000000000 L -1.9114391144,8.0000000000 L -1.9114391144,16.0000000000 L 2.0885608856,16.0000000000" /> </glyph> </collection> <collection name="contrast_threshold"> @@ -1054,91 +1064,92 @@ <ligature sequence="i n s e r t _ g l y p h _ f r o m _ o v e r v i e w" replacement="insert_glyph_from_overview"/> <ligature sequence="h i g h _ c o n t r a s t _ b a c k g r o u n d" replacement="high_contrast_background"/> <ligature sequence="p r e v i o u s _ k e r n i n g _ s t r i n g" replacement="previous_kerning_string"/> + <ligature sequence="g e n e r a t e _ h t m l _ d o c u m e n t" replacement="generate_html_document"/> <ligature sequence="s h o w _ x h e i g h t _ h e l p l i n e s" replacement="show_xheight_helplines"/> - <ligature sequence="g e n e r a t e _ h t m l _ d o c u m e n t" replacement="generate_html_document"/> + <ligature sequence="o r i e n t a t i o n _ c l o c k w i s e" replacement="orientation_clockwise"/> + <ligature sequence="z o o m _ b a c k g r o u n d _ i m a g e" replacement="zoom_background_image"/> + <ligature sequence="a u t o _ t r a c e _ r e s o l u t i o n" replacement="auto_trace_resolution"/> + <ligature sequence="b a c k g r o u n d _ h e l p _ l i n e s" replacement="background_help_lines"/> <ligature sequence="s h o w _ a l l _ l i n e _ h a n d l e s" replacement="show_all_line_handles"/> - <ligature sequence="b a c k g r o u n d _ h e l p _ l i n e s" replacement="background_help_lines"/> - <ligature sequence="a u t o _ t r a c e _ r e s o l u t i o n" replacement="auto_trace_resolution"/> - <ligature sequence="z o o m _ b a c k g r o u n d _ i m a g e" replacement="zoom_background_image"/> - <ligature sequence="o r i e n t a t i o n _ c l o c k w i s e" replacement="orientation_clockwise"/> + <ligature sequence="n e x t _ k e r n i n g _ s t r i n g" replacement="next_kerning_string"/> <ligature sequence="a u t o _ t r a c e _ s i m p l i f y" replacement="auto_trace_simplify"/> - <ligature sequence="n e x t _ k e r n i n g _ s t r i n g" replacement="next_kerning_string"/> - <ligature sequence="k e r n i n g _ t e x t _ i n p u t" replacement="kerning_text_input"/> <ligature sequence="c o n t r a s t _ t h r e s h o l d" replacement="contrast_threshold"/> + <ligature sequence="k e r n i n g _ t e x t _ i n p u t" replacement="kerning_text_input"/> + <ligature sequence="s t r o k e _ t o _ o u t l i n e" replacement="stroke_to_outline"/> + <ligature sequence="s e l e c t _ b a c k g r o u n d" replacement="select_background"/> + <ligature sequence="i n s e r t _ b a c k g r o u n d" replacement="insert_background"/> + <ligature sequence="n e w _ p o i n t _ o n _ p a t h" replacement="new_point_on_path"/> + <ligature sequence="d e l e t e _ b a c k g r o u n d" replacement="delete_background"/> <ligature sequence="o r i e n t a t i o n _ a r r o w" replacement="orientation_arrow"/> - <ligature sequence="d e l e t e _ b a c k g r o u n d" replacement="delete_background"/> - <ligature sequence="n e w _ p o i n t _ o n _ p a t h" replacement="new_point_on_path"/> - <ligature sequence="i n s e r t _ b a c k g r o u n d" replacement="insert_background"/> - <ligature sequence="s e l e c t _ b a c k g r o u n d" replacement="select_background"/> - <ligature sequence="s t r o k e _ t o _ o u t l i n e" replacement="stroke_to_outline"/> - <ligature sequence="s c a l e _ b a c k g r o u n d" replacement="scale_background"/> - <ligature sequence="q u a d r a t i c _ p o i n t s" replacement="quadratic_points"/> <ligature sequence="o r i e n t a t i o n _ b o t h" replacement="orientation_both"/> - <ligature sequence="m o v e _ b a c k g r o u n d" replacement="move_background"/> + <ligature sequence="q u a d r a t i c _ p o i n t s" replacement="quadratic_points"/> + <ligature sequence="s c a l e _ b a c k g r o u n d" replacement="scale_background"/> + <ligature sequence="z o o m _ b o u n d a r i e s" replacement="zoom_boundaries"/> + <ligature sequence="s h o w _ b a c k g r o u n d" replacement="show_background"/> <ligature sequence="f l i p _ h o r i z o n t a l" replacement="flip_horizontal"/> - <ligature sequence="s h o w _ b a c k g r o u n d" replacement="show_background"/> - <ligature sequence="z o o m _ b o u n d a r i e s" replacement="zoom_boundaries"/> - <ligature sequence="i n s e r t _ u n i c h a r" replacement="insert_unichar"/> - <ligature sequence="c u t _ b a c k g r o u n d" replacement="cut_background"/> - <ligature sequence="u p d a t e _ w e b v i e w" replacement="update_webview"/> + <ligature sequence="m o v e _ b a c k g r o u n d" replacement="move_background"/> <ligature sequence="f i l l _ o p e n _ p a t h" replacement="fill_open_path"/> - <ligature sequence="r e s i z e _ h a n d l e" replacement="resize_handle"/> - <ligature sequence="d r o p d o w n _ m e n u" replacement="dropdown_menu"/> - <ligature sequence="f l i p _ v e r t i c a l" replacement="flip_vertical"/> - <ligature sequence="d e l e t e _ b u t t o n" replacement="delete_button"/> - <ligature sequence="c o n v e r t _ p o i n t" replacement="convert_point"/> - <ligature sequence="d o u b l e _ p o i n t s" replacement="double_points"/> - <ligature sequence="k e r n i n g _ c l a s s" replacement="kerning_class"/> + <ligature sequence="u p d a t e _ w e b v i e w" replacement="update_webview"/> + <ligature sequence="c u t _ b a c k g r o u n d" replacement="cut_background"/> + <ligature sequence="i n s e r t _ u n i c h a r" replacement="insert_unichar"/> <ligature sequence="a d d _ n e w _ t h e m e" replacement="add_new_theme"/> - <ligature sequence="y _ c o o r d i n a t e" replacement="y_coordinate"/> - <ligature sequence="x _ c o o r d i n a t e" replacement="x_coordinate"/> - <ligature sequence="c u b i c _ p o i n t s" replacement="cubic_points"/> - <ligature sequence="r e v e r s e _ p a t h" replacement="reverse_path"/> - <ligature sequence="e x p o r t _ f o n t s" replacement="export_fonts"/> + <ligature sequence="k e r n i n g _ c l a s s" replacement="kerning_class"/> + <ligature sequence="d o u b l e _ p o i n t s" replacement="double_points"/> + <ligature sequence="c o n v e r t _ p o i n t" replacement="convert_point"/> + <ligature sequence="d e l e t e _ b u t t o n" replacement="delete_button"/> + <ligature sequence="f l i p _ v e r t i c a l" replacement="flip_vertical"/> + <ligature sequence="d r o p d o w n _ m e n u" replacement="dropdown_menu"/> + <ligature sequence="r e s i z e _ h a n d l e" replacement="resize_handle"/> <ligature sequence="a p p l y _ s t r o k e" replacement="apply_stroke"/> - <ligature sequence="r i g h t _ a r r o w" replacement="right_arrow"/> - <ligature sequence="b e z i e r _ l i n e" replacement="bezier_line"/> - <ligature sequence="c r e a t e _ l i n e" replacement="create_line"/> - <ligature sequence="s p i n _ b u t t o n" replacement="spin_button"/> + <ligature sequence="e x p o r t _ f o n t s" replacement="export_fonts"/> + <ligature sequence="r e v e r s e _ p a t h" replacement="reverse_path"/> + <ligature sequence="c u b i c _ p o i n t s" replacement="cubic_points"/> + <ligature sequence="x _ c o o r d i n a t e" replacement="x_coordinate"/> + <ligature sequence="y _ c o o r d i n a t e" replacement="y_coordinate"/> <ligature sequence="m o v e _ c a n v a s" replacement="move_canvas"/> - <ligature sequence="l e f t _ a r r o w" replacement="left_arrow"/> - <ligature sequence="h e l p _ l i n e s" replacement="help_lines"/> - <ligature sequence="m o v e _ l a y e r" replacement="move_layer"/> - <ligature sequence="s e l e c t _ a l l" replacement="select_all"/> - <ligature sequence="p o i n t _ t o o l" replacement="point_tool"/> + <ligature sequence="s p i n _ b u t t o n" replacement="spin_button"/> + <ligature sequence="c r e a t e _ l i n e" replacement="create_line"/> + <ligature sequence="b e z i e r _ l i n e" replacement="bezier_line"/> + <ligature sequence="r i g h t _ a r r o w" replacement="right_arrow"/> <ligature sequence="f u l l _ g l y p h" replacement="full_glyph"/> - <ligature sequence="s a v e _ f o n t" replacement="save_font"/> - <ligature sequence="i n f o _ i c o n" replacement="info_icon"/> - <ligature sequence="s h o w _ g r i d" replacement="show_grid"/> - <ligature sequence="a u t o t r a c e" replacement="autotrace"/> - <ligature sequence="u n d o _ t o o l" replacement="undo_tool"/> - <ligature sequence="t i e _ p o i n t" replacement="tie_point"/> - <ligature sequence="s y m m e t r i c" replacement="symmetric"/> - <ligature sequence="f o r e s i g h t" replacement="foresight"/> - <ligature sequence="z o o m _ t o o l" replacement="zoom_tool"/> - <ligature sequence="r e c t a n g l e" replacement="rectangle"/> - <ligature sequence="t t f _ u n i t s" replacement="ttf_units"/> - <ligature sequence="m e n u _ i c o n" replacement="menu_icon"/> + <ligature sequence="p o i n t _ t o o l" replacement="point_tool"/> + <ligature sequence="s e l e c t _ a l l" replacement="select_all"/> + <ligature sequence="m o v e _ l a y e r" replacement="move_layer"/> + <ligature sequence="h e l p _ l i n e s" replacement="help_lines"/> + <ligature sequence="l e f t _ a r r o w" replacement="left_arrow"/> + <ligature sequence="c l o s e _ p a t h" replacement="close_path"/> <ligature sequence="o p e n _ f o n t" replacement="open_font"/> - <ligature sequence="s e t t i n g s" replacement="settings"/> - <ligature sequence="z o o m _ o u t" replacement="zoom_out"/> - <ligature sequence="r o t a t i o n" replacement="rotation"/> - <ligature sequence="p e n _ t o o l" replacement="pen_tool"/> - <ligature sequence="z o o m _ 1 _ 1" replacement="zoom_1_1"/> - <ligature sequence="p r o g r e s s" replacement="progress"/> + <ligature sequence="m e n u _ i c o n" replacement="menu_icon"/> + <ligature sequence="t t f _ u n i t s" replacement="ttf_units"/> + <ligature sequence="r e c t a n g l e" replacement="rectangle"/> + <ligature sequence="z o o m _ t o o l" replacement="zoom_tool"/> + <ligature sequence="f o r e s i g h t" replacement="foresight"/> + <ligature sequence="s y m m e t r i c" replacement="symmetric"/> + <ligature sequence="t i e _ p o i n t" replacement="tie_point"/> + <ligature sequence="u n d o _ t o o l" replacement="undo_tool"/> + <ligature sequence="a u t o t r a c e" replacement="autotrace"/> + <ligature sequence="s h o w _ g r i d" replacement="show_grid"/> + <ligature sequence="i n f o _ i c o n" replacement="info_icon"/> + <ligature sequence="s a v e _ f o n t" replacement="save_font"/> <ligature sequence="n e w _ f o n t" replacement="new_font"/> + <ligature sequence="p r o g r e s s" replacement="progress"/> + <ligature sequence="z o o m _ 1 _ 1" replacement="zoom_1_1"/> + <ligature sequence="p e n _ t o o l" replacement="pen_tool"/> + <ligature sequence="r o t a t i o n" replacement="rotation"/> + <ligature sequence="z o o m _ o u t" replacement="zoom_out"/> + <ligature sequence="s e t t i n g s" replacement="settings"/> <ligature sequence="z o o m _ i n" replacement="zoom_in"/> - <ligature sequence="h e i g h t" replacement="height"/> - <ligature sequence="r e s i z e" replacement="resize"/> <ligature sequence="c i r c l e" replacement="circle"/> - <ligature sequence="t h e m e" replacement="theme"/> - <ligature sequence="w i d t h" replacement="width"/> + <ligature sequence="r e s i z e" replacement="resize"/> + <ligature sequence="h e i g h t" replacement="height"/> <ligature sequence="t r a c k" replacement="track"/> - <ligature sequence="s k e w" replacement="skew"/> - <ligature sequence="m o v e" replacement="move"/> - <ligature sequence="p r e v" replacement="prev"/> + <ligature sequence="w i d t h" replacement="width"/> + <ligature sequence="t h e m e" replacement="theme"/> <ligature sequence="n e x t" replacement="next"/> + <ligature sequence="p r e v" replacement="prev"/> + <ligature sequence="m o v e" replacement="move"/> + <ligature sequence="s k e w" replacement="skew"/> <kerning left="settings" right="l" hadjustment="3.8289794922" /> </font>