mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	 82e85172e5
			
		
	
	
		82e85172e5
		
	
	
	
	
		
			
			This change fixes the initial tool selection when pixelpaint is started with a path. Previously an already existing editor was expected when the default tool was initially propagated - which was not the case if pixelpaint was launched to directly load an existing image.
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			954 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			954 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 | |
|  * Copyright (c) 2022, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibGUI/ActionGroup.h>
 | |
| #include <LibGUI/Widget.h>
 | |
| 
 | |
| namespace PixelPaint {
 | |
| 
 | |
| class Tool;
 | |
| 
 | |
| class ToolboxWidget final : public GUI::Widget {
 | |
|     C_OBJECT(ToolboxWidget);
 | |
| 
 | |
| public:
 | |
|     virtual ~ToolboxWidget() override = default;
 | |
| 
 | |
|     Function<void(Tool*)> on_tool_selection;
 | |
| 
 | |
|     template<typename Callback>
 | |
|     void for_each_tool(Callback callback)
 | |
|     {
 | |
|         for (auto& tool : m_tools)
 | |
|             callback(*tool);
 | |
|     }
 | |
| 
 | |
|     Tool* active_tool() const { return m_active_tool; }
 | |
|     void ensure_tool_selection();
 | |
| 
 | |
| private:
 | |
|     friend class ToolButton;
 | |
| 
 | |
|     void setup_tools();
 | |
| 
 | |
|     explicit ToolboxWidget();
 | |
|     RefPtr<GUI::Toolbar> m_toolbar;
 | |
|     GUI::ActionGroup m_action_group;
 | |
|     Vector<NonnullOwnPtr<Tool>> m_tools;
 | |
|     Tool* m_active_tool { nullptr };
 | |
| };
 | |
| 
 | |
| }
 |