aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/button.cpp
blob: d4537f54fee880dd4cdd36d56fad83082bead7da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "button.hpp"

#include "graph/graph.hpp"
#include "ui/ui_manager.hpp"

namespace cru::ui::controls
{
    Button::Button() :
        normal_border_{UiManager::GetInstance()->GetPredefineResources()->button_normal_border},
        pressed_border_{UiManager::GetInstance()->GetPredefineResources()->button_press_border}
    {
        SetBordered(true);
        GetBorderProperty() = normal_border_;

        SetCursor(cursors::hand);
    }

    StringView Button::GetControlType() const
    {
        return control_type;
    }

    void Button::OnMouseClickBegin(MouseButton button)
    {
        GetBorderProperty() = pressed_border_;
        UpdateBorder();
    }

    void Button::OnMouseClickEnd(MouseButton button)
    {
        GetBorderProperty() = normal_border_;
        UpdateBorder();
    }
}