mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	PixelPaint: Make ImageEditor::m_undo_stack a regular value member
This commit is contained in:
		
							parent
							
								
									490d385d01
								
							
						
					
					
						commit
						1a54ac262a
					
				
					 2 changed files with 10 additions and 12 deletions
				
			
		|  | @ -23,12 +23,10 @@ namespace PixelPaint { | |||
| 
 | ||||
| ImageEditor::ImageEditor(NonnullRefPtr<Image> image) | ||||
|     : m_image(move(image)) | ||||
|     , m_undo_stack(make<GUI::UndoStack>()) | ||||
|     , m_selection(*this) | ||||
| { | ||||
|     set_focus_policy(GUI::FocusPolicy::StrongFocus); | ||||
|     m_undo_stack = make<GUI::UndoStack>(); | ||||
|     m_undo_stack->push(make<ImageUndoCommand>(*m_image)); | ||||
|     m_undo_stack.push(make<ImageUndoCommand>(*m_image)); | ||||
|     m_image->add_client(*this); | ||||
| 
 | ||||
|     m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15); | ||||
|  | @ -45,12 +43,12 @@ ImageEditor::~ImageEditor() | |||
| 
 | ||||
| void ImageEditor::did_complete_action() | ||||
| { | ||||
|     m_undo_stack->push(make<ImageUndoCommand>(*m_image)); | ||||
|     m_undo_stack.push(make<ImageUndoCommand>(*m_image)); | ||||
| } | ||||
| 
 | ||||
| bool ImageEditor::undo() | ||||
| { | ||||
|     if (!m_undo_stack->can_undo()) | ||||
|     if (!m_undo_stack.can_undo()) | ||||
|         return false; | ||||
| 
 | ||||
|     /* Without this you need to undo twice to actually start undoing stuff.
 | ||||
|  | @ -63,19 +61,19 @@ bool ImageEditor::undo() | |||
|      * This works because UndoStack::undo first decrements the stack pointer and then restores the snapshot, | ||||
|      * while UndoStack::redo first restores the snapshot and then increments the stack pointer. | ||||
|      */ | ||||
|     m_undo_stack->undo(); | ||||
|     m_undo_stack->undo(); | ||||
|     m_undo_stack->redo(); | ||||
|     m_undo_stack.undo(); | ||||
|     m_undo_stack.undo(); | ||||
|     m_undo_stack.redo(); | ||||
|     layers_did_change(); | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| bool ImageEditor::redo() | ||||
| { | ||||
|     if (!m_undo_stack->can_redo()) | ||||
|     if (!m_undo_stack.can_redo()) | ||||
|         return false; | ||||
| 
 | ||||
|     m_undo_stack->redo(); | ||||
|     m_undo_stack.redo(); | ||||
|     layers_did_change(); | ||||
|     return true; | ||||
| } | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ public: | |||
|     bool undo(); | ||||
|     bool redo(); | ||||
| 
 | ||||
|     auto& undo_stack() { return *m_undo_stack; } | ||||
|     auto& undo_stack() { return m_undo_stack; } | ||||
| 
 | ||||
|     void add_guide(NonnullRefPtr<Guide> guide) { m_guides.append(guide); } | ||||
|     void remove_guide(Guide const& guide) | ||||
|  | @ -153,7 +153,7 @@ private: | |||
| 
 | ||||
|     NonnullRefPtr<Image> m_image; | ||||
|     RefPtr<Layer> m_active_layer; | ||||
|     OwnPtr<GUI::UndoStack> m_undo_stack; | ||||
|     GUI::UndoStack m_undo_stack; | ||||
| 
 | ||||
|     NonnullRefPtrVector<Guide> m_guides; | ||||
|     bool m_show_guides { true }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling