mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 63e6b09816
			
		
	
	
		63e6b09816
		
	
	
	
	
		
			
			It's now possible to add a GMenu as a submenu of another GMenu. Simply use the GMenu::add_submenu(NonnullOwnPtr<GMenu>) API :^) The WindowServer now keeps track of a stack of open menus rather than just one "current menu". This code needs a bit more work, but the basic functionality is now here!
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			855 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			855 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <AK/Function.h>
 | |
| #include <AK/NonnullOwnPtrVector.h>
 | |
| #include <AK/NonnullRefPtr.h>
 | |
| #include <LibGUI/GMenuItem.h>
 | |
| 
 | |
| class GAction;
 | |
| class Point;
 | |
| 
 | |
| class GMenu {
 | |
| public:
 | |
|     explicit GMenu(const StringView& name);
 | |
|     ~GMenu();
 | |
| 
 | |
|     static GMenu* from_menu_id(int);
 | |
| 
 | |
|     const String& name() const { return m_name; }
 | |
| 
 | |
|     GAction* action_at(int);
 | |
| 
 | |
|     void add_action(NonnullRefPtr<GAction>);
 | |
|     void add_separator();
 | |
|     void add_submenu(NonnullOwnPtr<GMenu>);
 | |
| 
 | |
|     void popup(const Point& screen_position);
 | |
|     void dismiss();
 | |
| 
 | |
|     Function<void(unsigned)> on_item_activation;
 | |
| 
 | |
| private:
 | |
|     friend class GMenuBar;
 | |
| 
 | |
|     int menu_id() const { return m_menu_id; }
 | |
|     int realize_menu();
 | |
|     void unrealize_menu();
 | |
|     void realize_if_needed();
 | |
| 
 | |
|     int m_menu_id { -1 };
 | |
|     String m_name;
 | |
|     NonnullOwnPtrVector<GMenuItem> m_items;
 | |
| };
 |