Files
MuditaOS/module-gui/gui/core/renderers/RectangleRenderer.hpp
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

123 lines
5.1 KiB
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include "Color.hpp"
#include "Common.hpp"
#include "DrawCommand.hpp"
namespace gui
{
class Context;
} // namespace gui
namespace gui::renderer
{
class RectangleRenderer
{
public:
struct DrawableStyle
{
Length borderWidth{1};
Length radius{0};
Length yapSize{0};
RectangleEdge edges{RectangleEdge::All};
RectangleFlatEdge flatEdges{RectangleFlatEdge::None};
RectangleRoundedCorner roundedCorners{RectangleRoundedCorner::None};
RectangleYap yaps{RectangleYap::None};
Color borderColor{ColorFullBlack};
Color fillColor{ColorNoColor};
static auto from(const DrawRectangle &command) -> DrawableStyle;
};
static void drawFlat(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);
static void draw(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);
private:
static void fillFlatRectangle(Context *ctx, Point position, Length width, Length height, Color color);
static void fill(Context *ctx, Point startPosition, Color borderColor, Color fillColor);
static void drawSides(Context *ctx,
Point position,
Length width,
Length height,
Length penWidth,
Color color,
RectangleEdge sides);
static void drawSides(Context *ctx,
Point position,
Length width,
Length height,
Length radius,
Length yapSize,
Length penWidth,
RectangleFlatEdge flats,
RectangleYap yaps,
Color borderColor,
RectangleEdge sides);
static void drawCorners(Context *ctx,
Point position,
Length width,
Length height,
Length radius,
Length penWidth,
Color borderColor,
RectangleRoundedCorner rounded,
RectangleFlatEdge flats,
RectangleYap yaps);
static void drawTopSide(Context *ctx, Point position, Length width, Length penWidth, Color color);
static void drawTopSide(Context *ctx,
Point position,
Length width,
Length radius,
Length yapSize,
Length penWidth,
RectangleFlatEdge flat,
RectangleYap yaps,
Color borderColor);
static void drawRightSide(
Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
static void drawRightSide(Context *ctx,
Point position,
Length width,
Length height,
Length radius,
Length yapSize,
Length penWidth,
RectangleFlatEdge flat,
RectangleYap yaps,
Color borderColor);
static void drawBottomSide(
Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
static void drawBottomSide(Context *ctx,
Point position,
Length width,
Length height,
Length radius,
Length yapSize,
Length penWidth,
RectangleFlatEdge flat,
RectangleYap yaps,
Color borderColor);
static void drawLeftSide(Context *ctx, Point position, Length height, Length penWidth, Color color);
static void drawLeftSide(Context *ctx,
Point position,
Length height,
Length radius,
Length yapSize,
Length penWidth,
RectangleFlatEdge flat,
RectangleYap yaps,
Color borderColor);
};
} // namespace gui::renderer