diff options
| author | 杨宇千 <crupest@outlook.com> | 2019-03-28 20:39:36 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-28 20:39:36 +0800 |
| commit | c45a6e62298e972f5945f5f3461ed723aea80317 (patch) | |
| tree | f46ef303ee87a8e3814ea8743bd7062d432bfee3 /src/ui/controls/list_item.cpp | |
| parent | b028e74a48de181ca078ad3bf4ababf4fa146cd3 (diff) | |
| parent | 37216f211b0e22205a3a0d3373d985fc68aea59b (diff) | |
| download | cru-c45a6e62298e972f5945f5f3461ed723aea80317.tar.gz cru-c45a6e62298e972f5945f5f3461ed723aea80317.tar.bz2 cru-c45a6e62298e972f5945f5f3461ed723aea80317.zip | |
Merge pull request #37 from crupest/render
Refactor.
Diffstat (limited to 'src/ui/controls/list_item.cpp')
| -rw-r--r-- | src/ui/controls/list_item.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/ui/controls/list_item.cpp b/src/ui/controls/list_item.cpp deleted file mode 100644 index e0ca28a9..00000000 --- a/src/ui/controls/list_item.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "list_item.hpp" - -#include "ui/ui_manager.hpp" -#include "ui/convert_util.hpp" - -namespace cru::ui::controls -{ - ListItem::ListItem() - { - const auto predefine_resources = UiManager::GetInstance()->GetPredefineResources(); - - brushes_[State::Normal].border_brush = predefine_resources->list_item_normal_border_brush; - brushes_[State::Normal].fill_brush = predefine_resources->list_item_normal_fill_brush; - brushes_[State::Hover] .border_brush = predefine_resources->list_item_hover_border_brush; - brushes_[State::Hover] .fill_brush = predefine_resources->list_item_hover_fill_brush; - brushes_[State::Select].border_brush = predefine_resources->list_item_select_border_brush; - brushes_[State::Select].fill_brush = predefine_resources->list_item_select_fill_brush; - - draw_foreground_event.AddHandler([this](events::DrawEventArgs& args) - { - const auto device_context = args.GetDeviceContext(); - const auto rect = Rect(Point::Zero(), GetRect(RectRange::Padding).GetSize()); - device_context->FillRectangle(Convert(rect), brushes_[state_].fill_brush.Get()); - device_context->DrawRectangle(Convert(rect.Shrink(Thickness(0.5))), brushes_[state_].border_brush.Get(), 1); - }); - - mouse_enter_event.direct.AddHandler([this](events::MouseEventArgs& args) - { - if (GetState() == State::Select) - return; - - if (IsAnyMouseButtonDown()) - return; - - SetState(State::Hover); - }); - - mouse_leave_event.direct.AddHandler([this](events::MouseEventArgs& args) - { - if (GetState() == State::Select) - return; - - SetState(State::Normal); - }); - - mouse_click_event.direct.AddHandler([this](events::MouseButtonEventArgs& args) - { - if (args.GetMouseButton() == MouseButton::Left) - SetState(State::Select); - }); - } - - StringView ListItem::GetControlType() const - { - return control_type; - } - - void ListItem::SetState(const State state) - { - state_ = state; - InvalidateDraw(); - } -} |
