1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:47:47 +00:00

Add a basic Listbox widget.

This commit is contained in:
Andreas Kling 2018-10-13 00:20:44 +02:00
parent 8016139430
commit f20977c65f
5 changed files with 93 additions and 2 deletions

24
Widgets/ListBox.h Normal file
View 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;
};