20 #include <vstgui4/vstgui/lib/cdrawcontext.h> 21 #include <vstgui4/vstgui/lib/cview.h> 23 #include <base/source/fstring.h> 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, std::forward<Args>(iArgs)...);
237 debugText(x, y, s.text8());
241 template<
typename... Args>
242 inline void debugTopLeft(
char const *iFormat, Args&& ...iArgs) { debugXY(0, 0, iFormat, std::forward<Args>(iArgs)...); }
245 template<
typename... Args>
246 inline void debugTopRight(
char const *iFormat, Args&& ...iArgs) { debugXY(-1, 0, iFormat, std::forward<Args>(iArgs)...); }
249 template<
typename... Args>
250 inline void debugBottomLeft(
char const *iFormat, Args&& ...iArgs) { debugXY(0, -1, iFormat, std::forward<Args>(iArgs)...); }
253 template<
typename... Args>
254 inline void debugBottomRight(
char const *iFormat, Args&& ...iArgs) { debugXY(-1, -1, iFormat, std::forward<Args>(iArgs)...); }
259 template<
typename... Args>
260 inline void debug(
char const *iFormat, Args&& ...iArgs) { debugTopLeft(iFormat, std::forward<Args>(iArgs)...); }
265 inline void debugText(
char const *iText) { debugText(0, 0, iText); }
279 CColor fDebugStringColor{kGreenCColor};
280 FontPtr fDebugStringFont{kNormalFontVerySmall};
void fillRect(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iColor)
Definition: DrawContext.h:165
CDrawContext * fDrawContext
Definition: DrawContext.h:275
RelativeView(CView const *iView)
Definition: DrawContext.h:55
AbsoluteCoord toAbsoluteX(RelativeCoord x) const
Definition: DrawContext.h:82
AbsolutePoint toAbsolutePoint(RelativeCoord x, RelativeCoord y) const
Definition: DrawContext.h:124
static T clamp(const U &iValue, const T &iLower, const T &iUpper)
Make sure that the value remains within its bounds.
Definition: Misc.h:33
RelativeView(AbsoluteRect const &iRect)
Definition: DrawContext.h:59
RelativePoint fromAbsolutePoint(AbsolutePoint const &iPoint) const
Definition: DrawContext.h:107
void fillEllipse(RelativeRect const &iRect, CColor const &iColor)
Definition: DrawContext.h:199
CPoint RelativePoint
Definition: DrawContext.h:47
Encapsulates the draw context provided by VSTGUI to reason in relative coordinates (0,...
Definition: DrawContext.h:141
void fillAndStrokeEllipse(RelativeRect const &iRect, CColor const &iFillColor, CColor const &iStrokeColor)
Definition: DrawContext.h:205
CCoord RelativeCoord
Definition: DrawContext.h:45
void fillAndStrokeRect(RelativeRect const &iRect, CColor const &iFillColor, CColor const &iStrokeColor)
Definition: DrawContext.h:176
Range getVerticalRange() const
Definition: DrawContext.h:75
RelativeCoord fromAbsoluteX(AbsoluteCoord x) const
Definition: DrawContext.h:92
AbsoluteRect const & fRect
Definition: DrawContext.h:135
RelativePoint clampAbsolutePoint(AbsolutePoint const &iPoint) const
Convert the absolute point to a relative point while making sure it is clamped (constrained) within t...
Definition: DrawContext.h:116
AbsolutePoint toAbsolutePoint(RelativePoint const &iPoint) const
Definition: DrawContext.h:102
void drawEllipse(RelativeRect const &iRect, CColor const &iStrokeColor)
Definition: DrawContext.h:188
CFontDesc * FontPtr
Definition: Types.h:53
void drawRect(RelativeRect const &iRect, CColor const &iStrokeColor)
Definition: DrawContext.h:159
CRect RelativeRect
Definition: DrawContext.h:49
Range getHorizontalRange() const
Definition: DrawContext.h:73
void drawEllipse(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iStrokeColor)
Definition: DrawContext.h:183
CRect AbsoluteRect
Definition: DrawContext.h:50
void drawRect(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iStrokeColor)
Definition: DrawContext.h:154
CPoint AbsolutePoint
Definition: DrawContext.h:48
void fillEllipse(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &iColor)
Definition: DrawContext.h:194
CCoord AbsoluteCoord
Definition: DrawContext.h:46
void drawLine(RelativeCoord x1, RelativeCoord y1, RelativeCoord x2, RelativeCoord y2, CColor const &color)
Definition: DrawContext.h:148
AbsoluteCoord toAbsoluteY(RelativeCoord y) const
Definition: DrawContext.h:87
CCoord getHeight() const
Definition: DrawContext.h:77
Definition: DrawContext.h:33
Definition: DrawContext.h:52
CCoord getWidth() const
Definition: DrawContext.h:68
void drawString(UTF8String const &iText, RelativeCoord x, RelativeCoord y, RelativeCoord iHeight, StringDrawContext &iSdc)
Definition: DrawContext.h:212
AbsoluteRect toAbsoluteRect(RelativeRect const &iRect) const
Definition: DrawContext.h:129
void fillRect(RelativeRect const &iRect, CColor const &iColor)
Definition: DrawContext.h:170
RelativeRect getViewSize() const
Definition: DrawContext.h:63
void drawString(UTF8String const &iText, StringDrawContext &iSdc)
Definition: DrawContext.h:220
RelativeDrawContext(CView *iView, CDrawContext *iDrawContext)
Definition: DrawContext.h:144
RelativeCoord fromAbsoluteY(AbsoluteCoord y) const
Definition: DrawContext.h:97