2023-12-26 23:44:40 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../../core/widget.h"
|
|
|
|
#include <vector>
|
2023-12-29 01:16:18 +00:00
|
|
|
#include <functional>
|
2023-12-26 23:44:40 +00:00
|
|
|
|
2024-01-03 01:39:20 +00:00
|
|
|
class Scrollbar;
|
|
|
|
|
2023-12-26 23:44:40 +00:00
|
|
|
class ListView : public Widget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ListView(Widget* parent = nullptr);
|
|
|
|
|
|
|
|
void AddItem(const std::string& text);
|
2023-12-29 01:16:18 +00:00
|
|
|
int GetSelectedItem() const { return selectedItem; }
|
2024-01-04 23:23:17 +00:00
|
|
|
void SetSelectedItem(int index);
|
2024-01-03 01:39:20 +00:00
|
|
|
void ScrollToItem(int index);
|
2023-12-29 01:16:18 +00:00
|
|
|
|
|
|
|
void Activate();
|
|
|
|
|
|
|
|
std::function<void()> OnActivated;
|
2023-12-26 23:44:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void OnPaint(Canvas* canvas) override;
|
|
|
|
void OnPaintFrame(Canvas* canvas) override;
|
2023-12-27 03:46:14 +00:00
|
|
|
void OnMouseDown(const Point& pos, int key) override;
|
|
|
|
void OnMouseDoubleclick(const Point& pos, int key) override;
|
2024-01-03 01:39:20 +00:00
|
|
|
void OnMouseWheel(const Point& pos, EInputKey key) override;
|
2023-12-27 03:46:14 +00:00
|
|
|
void OnKeyDown(EInputKey key) override;
|
2024-01-03 01:39:20 +00:00
|
|
|
void OnGeometryChanged() override;
|
|
|
|
void OnScrollbarScroll();
|
|
|
|
|
|
|
|
Scrollbar* scrollbar = nullptr;
|
2023-12-26 23:44:40 +00:00
|
|
|
|
|
|
|
std::vector<std::string> items;
|
2023-12-27 03:46:14 +00:00
|
|
|
int selectedItem = 0;
|
2023-12-26 23:44:40 +00:00
|
|
|
};
|