File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,6 +184,9 @@ impl<'a> AppState<'a> {
184184 self . size . height ,
185185 )
186186 {
187+ println ! ( "pressed" ) ;
188+ self . revision_stack . move_shape ( shape_id, orig_coord) ;
189+
187190 // Found a circle - select it and start dragging
188191 self . mouse_state . set_selected_shape ( Some ( circle_index) ) ;
189192 self . mouse_state . set_dragging_shape ( true ) ;
@@ -214,6 +217,7 @@ impl<'a> AppState<'a> {
214217 }
215218 }
216219 ( true , false ) => {
220+ println ! ( "stopped" ) ;
217221 // Mouse release - stop dragging
218222 self . mouse_state . set_dragging_shape ( false ) ;
219223 }
Original file line number Diff line number Diff line change 33pub enum Action {
44 Move {
55 shape_id : usize ,
6- orig_x : f32 ,
7- orig_y : f32 ,
6+ orig_coord : Coordinate ,
87 } ,
98 Draw {
109 shape_id : usize ,
@@ -27,6 +26,13 @@ impl RevisionStack {
2726 self . stack . push ( Action :: Draw { shape_id : id } ) ;
2827 }
2928
29+ pub fn move_shape ( & mut self , shape_id : usize , orig_coord : Coordinate ) {
30+ self . stack . push ( Action :: Move {
31+ shape_id,
32+ orig_coord,
33+ } )
34+ }
35+
3036 pub fn undo ( & mut self ) {
3137 if let Some ( last_action) = self . stack . last ( ) {
3238 match last_action {
You can’t perform that action at this time.
0 commit comments