bWidgets
Core widget toolkit designed for Blender
bwPainter.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <memory>
4
#include <string>
5
#include <vector>
6
7
#include "
bwGradient.h
"
8
#include "
bwIconInterface.h
"
9
10
namespace
bWidgets
{
11
12
class
bwPaintEngine;
13
class
bwPolygon;
14
class
bwStyle;
15
class
bwWidgetBaseStyle;
16
17
enum
RoundboxCorner
{
18
NONE
= 0,
19
BOTTOM_LEFT
= (1 << 0),
20
BOTTOM_RIGHT
= (1 << 1),
21
TOP_LEFT
= (1 << 2),
22
TOP_RIGHT
= (1 << 3),
23
/* Convenience */
24
ALL
= (
BOTTOM_LEFT
|
BOTTOM_RIGHT
|
TOP_LEFT
|
TOP_RIGHT
),
25
};
26
27
enum class
TextAlignment
{
28
LEFT
,
29
CENTER
,
30
RIGHT
,
31
};
32
33
enum class
Direction
{
34
UP
,
35
DOWN
,
36
LEFT
,
37
RIGHT
,
38
};
39
40
class
bwPainter
{
41
public
:
42
enum class
DrawType
{
43
FILLED,
44
OUTLINE,
45
LINE,
46
};
47
48
bwPainter
();
49
50
void
drawPolygon
(
const
bwPolygon
& poly);
51
void
drawText
(
const
std::string& text,
52
const
bwRectanglePixel
& rectangle,
53
const
TextAlignment
align)
const
;
54
void
drawIcon
(
const
bwIconInterface
&,
const
bwRectanglePixel
&)
const
;
55
56
void
setActiveColor
(
const
bwColor
& color);
57
auto
getActiveColor
() const -> const
bwColor
&;
58
auto
getVertexColor
(const
size_t
vertex_index) const -> const
bwColor
&;
59
60
void
setContentMask
(const
bwRectanglePixel
& value);
61
auto
getContentMask
() const -> const
bwRectanglePixel
&;
62
63
void
enableGradient
(const
bwGradient
& gradient);
64
auto
isGradientEnabled
() const ->
bool
;
65
66
void
drawTextAndIcon
(const std::
string
& text,
67
const
bwIconInterface
* icon,
68
const
bwRectanglePixel
& rectangle,
69
const
TextAlignment
alignment,
70
float
dpi_fac) const;
71
72
// Primitives
73
void
drawRoundbox
(const
bwRectanglePixel
& rect,
unsigned
int
corners, const
float
radius);
74
void
drawRectangle
(const
bwRectanglePixel
& rect);
75
void
drawRoundboxWidgetBase
(const
bwWidgetBaseStyle
& base_style,
76
const
bwStyle
& style,
77
const
bwRectanglePixel
& rectangle,
78
const
bwGradient
& gradient,
79
const
float
radius);
80
void
drawCheckMark
(const
bwRectanglePixel
& rect);
81
void
drawTriangle
(const
bwRectanglePixel
& rect,
Direction
direction);
82
void
drawLine
(const
bwPoint
& from, const
bwPoint
& to);
83
84
static std::unique_ptr<
bwPaintEngine
>
s_paint_engine
;
85
86
bool
use_antialiasing
{
false
};
87
DrawType
active_drawtype
;
88
89
private
:
90
void
fillVertexColorsWithGradient(
const
bwPolygon
& polygon,
91
const
bwRectanglePixel
& bounding_box);
92
93
bwColor
active_color;
94
std::vector<bwColor> vert_colors;
95
std::unique_ptr<bwGradient> active_gradient;
96
bwRectanglePixel
content_mask;
97
};
98
99
}
// namespace bWidgets
bwGradient.h
bwIconInterface.h
bWidgets::bwColor
Definition:
bwColor.h:5
bWidgets::bwGradient
Simple class for calculating colors for gradient fills.
Definition:
bwGradient.h:14
bWidgets::bwIconInterface
Interface to reference icons from within bWidgets.
Definition:
bwIconInterface.h:22
bWidgets::bwPaintEngine
Main interface to implement any drawing of geometry or text.
Definition:
bwPaintEngine.h:31
bWidgets::bwPainter
Definition:
bwPainter.h:40
bWidgets::bwPainter::getVertexColor
auto getVertexColor(const size_t vertex_index) const -> const bwColor &
Definition:
bwPainter.cc:83
bWidgets::bwPainter::drawLine
void drawLine(const bwPoint &from, const bwPoint &to)
Definition:
bwPainter.cc:194
bWidgets::bwPainter::drawCheckMark
void drawCheckMark(const bwRectanglePixel &rect)
Definition:
bwPainter.cc:141
bWidgets::bwPainter::bwPainter
bwPainter()
Definition:
bwPainter.cc:20
bWidgets::bwPainter::enableGradient
void enableGradient(const bwGradient &gradient)
Definition:
bwPainter.cc:98
bWidgets::bwPainter::drawPolygon
void drawPolygon(const bwPolygon &poly)
Definition:
bwPainter.cc:34
bWidgets::bwPainter::drawRectangle
void drawRectangle(const bwRectanglePixel &rect)
Definition:
bwPainter.cc:411
bWidgets::bwPainter::drawIcon
void drawIcon(const bwIconInterface &, const bwRectanglePixel &) const
Definition:
bwPainter.cc:61
bWidgets::bwPainter::drawRoundbox
void drawRoundbox(const bwRectanglePixel &rect, unsigned int corners, const float radius)
Definition:
bwPainter.cc:388
bWidgets::bwPainter::setActiveColor
void setActiveColor(const bwColor &color)
Definition:
bwPainter.cc:72
bWidgets::bwPainter::drawTriangle
void drawTriangle(const bwRectanglePixel &rect, Direction direction)
Definition:
bwPainter.cc:159
bWidgets::bwPainter::use_antialiasing
bool use_antialiasing
Definition:
bwPainter.h:86
bWidgets::bwPainter::active_drawtype
DrawType active_drawtype
Definition:
bwPainter.h:87
bWidgets::bwPainter::drawRoundboxWidgetBase
void drawRoundboxWidgetBase(const bwWidgetBaseStyle &base_style, const bwStyle &style, const bwRectanglePixel &rectangle, const bwGradient &gradient, const float radius)
Definition:
bwPainter.cc:451
bWidgets::bwPainter::setContentMask
void setContentMask(const bwRectanglePixel &value)
Definition:
bwPainter.cc:88
bWidgets::bwPainter::getContentMask
auto getContentMask() const -> const bwRectanglePixel &
Definition:
bwPainter.cc:93
bWidgets::bwPainter::drawText
void drawText(const std::string &text, const bwRectanglePixel &rectangle, const TextAlignment align) const
Definition:
bwPainter.cc:48
bWidgets::bwPainter::DrawType
DrawType
Definition:
bwPainter.h:42
bWidgets::bwPainter::s_paint_engine
static std::unique_ptr< bwPaintEngine > s_paint_engine
Definition:
bwPainter.h:84
bWidgets::bwPainter::drawTextAndIcon
void drawTextAndIcon(const std::string &text, const bwIconInterface *icon, const bwRectanglePixel &rectangle, const TextAlignment alignment, float dpi_fac) const
Definition:
bwPainter.cc:112
bWidgets::bwPainter::getActiveColor
auto getActiveColor() const -> const bwColor &
Definition:
bwPainter.cc:78
bWidgets::bwPainter::isGradientEnabled
auto isGradientEnabled() const -> bool
Definition:
bwPainter.cc:107
bWidgets::bwPoint
Definition:
bwPoint.h:7
bWidgets::bwPolygon
Definition:
bwPolygon.h:11
bWidgets::bwRectangle< int >
bWidgets::bwStyle
Definition:
bwStyle.h:10
bWidgets::bwWidgetBaseStyle
Properties for typical widgets with roundbox corners.
Definition:
bwWidgetBaseStyle.h:14
bWidgets
Definition:
bwContext.h:3
bWidgets::Direction
Direction
Definition:
bwPainter.h:33
bWidgets::Direction::DOWN
@ DOWN
bWidgets::Direction::UP
@ UP
bWidgets::TextAlignment
TextAlignment
Definition:
bwPainter.h:27
bWidgets::TextAlignment::RIGHT
@ RIGHT
bWidgets::TextAlignment::LEFT
@ LEFT
bWidgets::TextAlignment::CENTER
@ CENTER
bWidgets::RoundboxCorner
RoundboxCorner
Definition:
bwPainter.h:17
bWidgets::TOP_RIGHT
@ TOP_RIGHT
Definition:
bwPainter.h:22
bWidgets::NONE
@ NONE
Definition:
bwPainter.h:18
bWidgets::ALL
@ ALL
Definition:
bwPainter.h:24
bWidgets::BOTTOM_LEFT
@ BOTTOM_LEFT
Definition:
bwPainter.h:19
bWidgets::BOTTOM_RIGHT
@ BOTTOM_RIGHT
Definition:
bwPainter.h:20
bWidgets::TOP_LEFT
@ TOP_LEFT
Definition:
bwPainter.h:21
bwidgets
bwPainter.h
Generated by
1.9.3