Files
MuditaOS/module-gui/gui/widgets/Circle.cpp
Maciej Janicki e6fdf0e22c [EGD-5333] Change renderer to follow command design pattern
Changes draw command implementation to properly follow
command design pattern. All drawing commands have been
moved to separate inheriting draw commands from renderer.

Other changes:
- New draw methods overloads have been added to pixel renderer.
 Now pixel rendering methods are in one class.
- Simplified draw commands naming.
- Changed variable naming in draw commands to be more verbose.
- Changed {x,y} pairs to Points where possible.
2021-02-03 16:24:48 +01:00

90 lines
2.7 KiB
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <module-utils/log/log.hpp>
#include "Circle.hpp"
#include "DrawCommand.hpp"
namespace gui
{
Circle::ShapeParams &Circle::ShapeParams::setCenterPoint(Point _center) noexcept
{
center = _center;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setRadius(Length _radius) noexcept
{
radius = _radius;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setBorderColor(Color _color) noexcept
{
borderColor = _color;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setFocusBorderColor(Color _color) noexcept
{
focusBorderColor = _color;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setPenWidth(std::uint8_t _width) noexcept
{
penWidth = _width;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setFocusPenWidth(std::uint8_t _width) noexcept
{
focusPenWidth = _width;
return *this;
}
Circle::ShapeParams &Circle::ShapeParams::setFillColor(Color _color) noexcept
{
isFilled = true;
fillColor = _color;
return *this;
}
Circle::Circle(Item *parent, const Circle::ShapeParams &params)
: Circle{parent,
params.center,
params.radius,
params.borderColor,
params.focusBorderColor,
params.penWidth,
params.focusPenWidth,
params.isFilled,
params.fillColor}
{}
Circle::Circle(Item *parent,
Point _center,
Length _radius,
Color _borderColor,
Color _focusBorderColor,
std::uint8_t _penWidth,
std::uint8_t _focusPenWidth,
bool _filled,
Color _fillColor)
: Arc{parent, _center, _radius, 0, trigonometry::FullAngle, _borderColor, _penWidth, _focusPenWidth},
isFilled{_filled}, fillColor{_fillColor}, focusBorderColor{_focusBorderColor}
{}
void Circle::buildDrawListImplementation(std::list<Command> &commands)
{
auto circle = std::make_unique<DrawCircle>(
center, radius, focus ? focusPenWidth : penWidth, focus ? focusBorderColor : color, isFilled, fillColor);
circle->areaX = widgetArea.x;
circle->areaY = widgetArea.y;
circle->areaW = widgetArea.w;
circle->areaH = widgetArea.h;
commands.emplace_back(std::move(circle));
}
} // namespace gui