aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/list_item.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls/list_item.hpp')
-rw-r--r--src/ui/controls/list_item.hpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/ui/controls/list_item.hpp b/src/ui/controls/list_item.hpp
index 8525e0e8..1de89b5f 100644
--- a/src/ui/controls/list_item.hpp
+++ b/src/ui/controls/list_item.hpp
@@ -1,5 +1,8 @@
#pragma once
+#include <map>
+#include <initializer_list>
+
#include "ui/control.hpp"
namespace cru::ui::controls
@@ -9,8 +12,29 @@ namespace cru::ui::controls
public:
static constexpr auto control_type = L"ListItem";
+ enum class State
+ {
+ Normal,
+ Hover,
+ Select
+ };
+
+ private:
+ struct StateBrush
+ {
+ Microsoft::WRL::ComPtr<ID2D1Brush> border_brush;
+ Microsoft::WRL::ComPtr<ID2D1Brush> fill_brush;
+ };
+
public:
- static ListItem* Create();
+ static ListItem* Create(const std::initializer_list<Control*>& children)
+ {
+ const auto list_item = new ListItem();
+ for (auto control : children)
+ list_item->AddChild(control);
+ return list_item;
+ }
+
private:
ListItem();
public:
@@ -19,5 +43,25 @@ namespace cru::ui::controls
ListItem& operator=(const ListItem& other) = delete;
ListItem& operator=(ListItem&& other) = delete;
~ListItem() override = default;
+
+ StringView GetControlType() const override;
+
+ State GetState() const
+ {
+ return state_;
+ }
+
+ void SetState(State state);
+
+ protected:
+ void OnDrawForeground(ID2D1DeviceContext* device_context) override;
+
+ void OnMouseEnterCore(events::MouseEventArgs& args) override final;
+ void OnMouseLeaveCore(events::MouseEventArgs& args) override final;
+ void OnMouseClickCore(events::MouseButtonEventArgs& args) override final;
+
+ private:
+ State state_ = State::Normal;
+ std::map<State, StateBrush> brushes_{};
};
}