20 #include <vstgui4/vstgui/lib/cdrawcontext.h> 21 #include <vstgui4/vstgui/lib/cview.h> 23 #include <base/source/fstring.h> 31 using namespace VSTGUI;
35 CHoriTxtAlign fHorizTxtAlign{kCenterText};
38 CColor fFontColor{kWhiteCColor};
39 CColor fShadowColor{kBlackCColor};
40 CPoint fTextInset{0, 0};
41 CPoint fShadowTextOffset{1., 1.};
42 bool fAntialias{
true};
55 explicit RelativeView(CView
const *iView) : fRect{iView->getViewSize()}
65 return RelativeRect(0, 0, fRect.getWidth(), fRect.getHeight());
70 return fRect.getWidth();
79 return fRect.getHeight();
84 return x + fRect.left;
94 return x - fRect.left;
104 return AbsolutePoint{toAbsoluteX(iPoint.x), toAbsoluteY(iPoint.y)};
109 return RelativePoint{fromAbsoluteX(iPoint.x), fromAbsoluteY(iPoint.y)};
119 Utils::clamp(fromAbsoluteX(iPoint.x), 0.0, fRect.getWidth()),
120 Utils::clamp(fromAbsoluteY(iPoint.y), 0.0, fRect.getHeight())
126 return CPoint{x + fRect.left, y + fRect.top};
131 return CRect(toAbsolutePoint(iRect.getTopLeft()), iRect.getSize());
150 fDrawContext->setFrameColor(color);
151 fDrawContext->drawLine(toAbsolutePoint(x1, y1), toAbsolutePoint(x2, y2));
161 fDrawContext->setFrameColor(iStrokeColor);
162 fDrawContext->drawRect(toAbsoluteRect(iRect), kDrawStroked);
172 fDrawContext->setFillColor(iColor);
173 fDrawContext->drawRect(toAbsoluteRect(iRect), kDrawFilled);
178 fDrawContext->setFillColor(iFillColor);
179 fDrawContext->setFrameColor(iStrokeColor);
180 fDrawContext->drawRect(toAbsoluteRect(iRect), kDrawFilledAndStroked);
185 drawEllipse(
RelativeRect{x1, y1, x2, y2}, iStrokeColor);
190 fDrawContext->setFrameColor(iStrokeColor);
191 fDrawContext->drawEllipse(toAbsoluteRect(iRect), kDrawStroked);
201 fDrawContext->setFillColor(iColor);
202 fDrawContext->drawEllipse(toAbsoluteRect(iRect), kDrawFilled);
207 fDrawContext->setFillColor(iFillColor);
208 fDrawContext->setFrameColor(iStrokeColor);
209 fDrawContext->drawEllipse(toAbsoluteRect(iRect), kDrawFilledAndStroked);
214 CRect size{x, y, fDrawContext->getStringWidth(iText.getPlatformString()), iHeight};
215 drawString(iText, size, iSdc);
222 drawString(iText, getViewSize(), iSdc);
232 template<
typename... Args>
236 auto s = Steinberg::String().printf(iFormat, iArgs...);
237 debugText(x, y, s.text8());
241 template<
typename... Args>
242 inline void debugTopLeft(
char const *iFormat, Args... iArgs) { debugXY(0, 0, iFormat, iArgs...); }
245 template<
typename... Args>
246 inline void debugTopRight(
char const *iFormat, Args... iArgs) { debugXY(-1, 0, iFormat, iArgs...); }
249 template<
typename... Args>
250 inline void debugBottomLeft(
char const *iFormat, Args... iArgs) { debugXY(0, -1, iFormat, iArgs...); }
253 template<
typename... Args>
254 inline void debugBottomRight(
char const *iFormat, Args... iArgs) { debugXY(-1, -1, iFormat, iArgs...); }
259 template<
typename... Args>
260 inline void debug(
char const *iFormat, Args... iArgs) { debugTopLeft(iFormat, iArgs...); }
265 inline void debugText(
char const *iText) { debugText(0, 0, iText); }
279 CColor fDebugStringColor{kGreenCColor};
280 FontPtr fDebugStringFont{kNormalFontVerySmall};
RelativePoint clampAbsolutePoint(AbsolutePoint const &iPoint) const
Definition: DrawContext.h:116
Range getVerticalRange() const
Definition: DrawContext.h:75
RelativePoint fromAbsolutePoint(AbsolutePoint const &iPoint) const
Definition: DrawContext.h:107
AbsoluteCoord toAbsoluteX(RelativeCoord x) const
Definition: DrawContext.h:82
void drawString(UTF8String const &iText, StringDrawContext &iSdc)
Definition: DrawContext.h:220
static T clamp(const U &iValue, const T &iLower, const T &iUpper)
Definition: Misc.h:33
void drawRect(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iStrokeColor)
Definition: DrawContext.h:154
CPoint AbsolutePoint
Definition: DrawContext.h:48
Definition: DrawContext.h:141
void drawEllipse(RelativeRect const &iRect, CColor const &iStrokeColor)
Definition: DrawContext.h:188
AbsoluteRect toAbsoluteRect(RelativeRect const &iRect) const
Definition: DrawContext.h:129
void fillAndStrokeEllipse(RelativeRect const &iRect, CColor const &iFillColor, CColor const &iStrokeColor)
Definition: DrawContext.h:205
AbsolutePoint toAbsolutePoint(RelativeCoord x, RelativeCoord y) const
Definition: DrawContext.h:124
CCoord AbsoluteCoord
Definition: DrawContext.h:46
CCoord getWidth() const
Definition: DrawContext.h:68
RelativeView(AbsoluteRect const &iRect)
Definition: DrawContext.h:59
void drawLine(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &color)
Definition: DrawContext.h:148
CRect RelativeRect
Definition: DrawContext.h:49
CCoord RelativeCoord
Definition: DrawContext.h:45
AbsolutePoint toAbsolutePoint(RelativePoint const &iPoint) const
Definition: DrawContext.h:102
AbsoluteRect const & fRect
Definition: DrawContext.h:135
void fillEllipse(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iColor)
Definition: DrawContext.h:194
void fillRect(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iColor)
Definition: DrawContext.h:165
void fillRect(RelativeRect const &iRect, CColor const &iColor)
Definition: DrawContext.h:170
CRect AbsoluteRect
Definition: DrawContext.h:50
CCoord getHeight() const
Definition: DrawContext.h:77
void drawRect(RelativeRect const &iRect, CColor const &iStrokeColor)
Definition: DrawContext.h:159
void fillEllipse(RelativeRect const &iRect, CColor const &iColor)
Definition: DrawContext.h:199
RelativeCoord fromAbsoluteY(AbsoluteCoord y) const
Definition: DrawContext.h:97
CDrawContext * fDrawContext
Definition: DrawContext.h:275
RelativeView(CView const *iView)
Definition: DrawContext.h:55
RelativeRect getViewSize() const
Definition: DrawContext.h:63
AbsoluteCoord toAbsoluteY(RelativeCoord y) const
Definition: DrawContext.h:87
RelativeDrawContext(CView *iView, CDrawContext *iDrawContext)
Definition: DrawContext.h:144
CPoint RelativePoint
Definition: DrawContext.h:47
Definition: DrawContext.h:33
Definition: DrawContext.h:52
RelativeCoord fromAbsoluteX(AbsoluteCoord x) const
Definition: DrawContext.h:92
Range getHorizontalRange() const
Definition: DrawContext.h:73
void drawString(UTF8String const &iText, RelativeCoord x, RelativeCoord y, RelativeCoord iHeight, StringDrawContext &iSdc)
Definition: DrawContext.h:212
CFontDesc * FontPtr
Definition: Types.h:39
void fillAndStrokeRect(RelativeRect const &iRect, CColor const &iFillColor, CColor const &iStrokeColor)
Definition: DrawContext.h:176
void drawEllipse(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iStrokeColor)
Definition: DrawContext.h:183