mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:12:43 +00:00 
			
		
		
		
	Add a basic Listbox widget.
This commit is contained in:
		
							parent
							
								
									8016139430
								
							
						
					
					
						commit
						f20977c65f
					
				
					 5 changed files with 93 additions and 2 deletions
				
			
		
							
								
								
									
										24
									
								
								Widgets/ListBox.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								Widgets/ListBox.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,24 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include "Widget.h" | ||||
| 
 | ||||
| class ListBox final : public Widget { | ||||
| public: | ||||
|     explicit ListBox(Widget* parent); | ||||
|     virtual ~ListBox() override; | ||||
| 
 | ||||
|     void addItem(String&&); | ||||
|     int selectedIndex() const { return m_selectedIndex; } | ||||
| 
 | ||||
| private: | ||||
|     virtual void onPaint(PaintEvent&) override; | ||||
|     virtual void onMouseDown(MouseEvent&) override; | ||||
| 
 | ||||
|     unsigned itemHeight() const; | ||||
| 
 | ||||
|     unsigned m_scrollOffset { 0 }; | ||||
|     int m_selectedIndex { -1 }; | ||||
| 
 | ||||
|     Vector<String> m_items; | ||||
| }; | ||||
| 
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling