#include "CanvasCommandSelectorView.h" #include "HorizontalSpacer.h" #include "Button.h" #include "Theme.h" CanvasCommandSelectorView::CanvasCommandSelectorView() : Widget() { auto circle_button = Button::Create(); auto on_circle_click = [this](Widget* self){ onCommandSelected(CanvasDrawCommand::CIRCLE); }; circle_button->setLabel("Circle"); circle_button->setBackgroundColor(Theme::getButtonPrimaryBackground()); circle_button->setMargin(2); circle_button->setOnClickFunction(on_circle_click); auto on_line_click = [this](Widget* self){ onCommandSelected(CanvasDrawCommand::LINE); }; auto line_button = Button::Create(); line_button->setLabel("Line"); line_button->setBackgroundColor(Theme::getButtonPrimaryBackground()); line_button->setMargin(2); line_button->setOnClickFunction(on_line_click); auto hspacer = HorizontalSpacer::Create(); hspacer->addWidgetWithScale(std::move(circle_button), 1); hspacer->addWidgetWithScale(std::move(line_button), 1); addWidget(std::move(hspacer)); } void CanvasCommandSelectorView::onCommandSelected(CanvasDrawCommand command) { if(mCommandSelectedCallback) { mCommandSelectedCallback(command); } }