aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/CheckBox.cpp
blob: cace3dbf863c3dbd57c18354603a52928ae2ef7e (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
#include "cru/ui/controls/CheckBox.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/render/BorderRenderObject.h"

namespace cru::ui::controls {
CheckBox::CheckBox()
    : container_render_object_(new render::BorderRenderObject()),
      click_detector_(this) {
  container_render_object_->SetAttachedControl(this);

  click_detector_.ClickEvent()->AddHandler(
      [this](const helper::ClickEventArgs&) { Toggle(); });
}

CheckBox::~CheckBox() {}

void CheckBox::SetChecked(bool checked) {
  checked_ = checked;
  checked_change_event_.Raise(checked);
}

void CheckBox::ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) {
  container_render_object_->ApplyBorderStyle(style);
}
}  // namespace cru::ui::controls