42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#include "CanvasCommandSelectorView.h"
|
|
|
|
#include "HorizontalSpacer.h"
|
|
#include "Button.h"
|
|
|
|
#include "ThemeManager.h"
|
|
#include "PaintEvent.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->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->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);
|
|
}
|
|
}
|