summaryrefslogtreecommitdiff
path: root/include/basegfx/DrawCommands.hxx
blob: f72d17011c0bd7a3640a51c114f26a6b2184d410 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_BASEGFX_DRAWCOMMANDS_H
#define INCLUDED_BASEGFX_DRAWCOMMANDS_H

#include <memory>
#include <vector>

#include <basegfx/color/bcolor.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/range/b2drange.hxx>

namespace gfx
{
class DrawBase;

class DrawCommand
{
public:
    std::vector<std::shared_ptr<DrawBase>> maChildren;
};

enum class DrawCommandType
{
    Root,
    Rectangle,
    Path
};

class DrawBase : public DrawCommand
{
private:
    DrawCommandType meType;

public:
    DrawBase(DrawCommandType eType)
        : meType(eType)
    {
    }

    DrawCommandType getType() const { return meType; }
};

class DrawRoot : public DrawBase
{
public:
    basegfx::B2DRange maRectangle;

    DrawRoot()
        : DrawBase(DrawCommandType::Root)
    {
    }
};

class DrawRectangle : public DrawBase
{
public:
    basegfx::B2DRange maRectangle;
    double mnRx;
    double mnRy;

    double mnStrokeWidth;
    double mnOpacity;
    std::shared_ptr<basegfx::BColor> mpFillColor;
    std::shared_ptr<basegfx::BColor> mpStrokeColor;

    DrawRectangle(basegfx::B2DRange const& rRectangle)
        : DrawBase(DrawCommandType::Rectangle)
        , maRectangle(rRectangle)
        , mnRx(1.0)
        , mnRy(1.0)
        , mnStrokeWidth(1.0)
        , mnOpacity(1.0)
    {
    }
};

class DrawPath : public DrawBase
{
public:
    basegfx::B2DPolyPolygon maPolyPolygon;

    double mnStrokeWidth;
    double mnOpacity;
    std::shared_ptr<basegfx::BColor> mpFillColor;
    std::shared_ptr<basegfx::BColor> mpStrokeColor;

    DrawPath(basegfx::B2DPolyPolygon const& rPolyPolygon)
        : DrawBase(DrawCommandType::Path)
        , maPolyPolygon(rPolyPolygon)
        , mnStrokeWidth(1.0)
        , mnOpacity(1.0)
    {
    }
};

} // end namespace gfx

#endif // INCLUDED_BASEGFX_DRAWCOMMANDS_H

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */