Skip to content

Commit

Permalink
change CParamDisplay::drawPlatformText to take an UTF8String
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Nov 26, 2023
1 parent 73f6c10 commit 0302f3e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
4 changes: 4 additions & 0 deletions vstgui/doxygen/page_changes.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ Note: All current deprecated methods will be removed in the next version. So mak
@section code_changes Changes for existing VSTGUI code
@subsection code_changes_4_13_to_4_14 VSTGUI 4.13 -> VSTGUI 4.14
- In CParamDisplay::drawPlatformText(..) the string argument changed from IPlatformString to UTF8Text
@subsection code_changes_4_12_to_4_13 VSTGUI 4.12 -> VSTGUI 4.13
- the context argument of IFontPainter has changed to use the new platform graphics device context
Expand Down
2 changes: 1 addition & 1 deletion vstgui/lib/controls/coptionmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void COptionMenu::draw (CDrawContext *pContext)
CMenuItem* item = getEntry (currentIndex);
drawBack (pContext, inPopup ? bgWhenClick : nullptr);
if (item)
drawPlatformText (pContext, UTF8String (item->getTitle ()).getPlatformString ());
drawPlatformText (pContext, item->getTitle ());
setDirty (false);
}

Expand Down
13 changes: 8 additions & 5 deletions vstgui/lib/controls/cparamdisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void CParamDisplay::draw (CDrawContext *pContext)
}

drawBack (pContext);
drawPlatformText (pContext, UTF8String (string).getPlatformString ());
drawPlatformText (pContext, UTF8String (string));
setDirty (false);
}

Expand Down Expand Up @@ -322,13 +322,14 @@ void CParamDisplay::drawBack (CDrawContext* pContext, CBitmap* newBack)
}

//------------------------------------------------------------------------
void CParamDisplay::drawPlatformText (CDrawContext* pContext, IPlatformString* string)
void CParamDisplay::drawPlatformText (CDrawContext* pContext, const UTF8String& string)
{
drawPlatformText (pContext, string, getViewSize ());
}

//------------------------------------------------------------------------
void CParamDisplay::drawPlatformText (CDrawContext* pContext, IPlatformString* string, const CRect& size)
void CParamDisplay::drawPlatformText (CDrawContext* pContext, const UTF8String& string,
const CRect& size)
{
if (!hasBit (style, kNoTextStyle))
{
Expand All @@ -351,10 +352,12 @@ void CParamDisplay::drawPlatformText (CDrawContext* pContext, IPlatformString* s
CRect newSize (textRect);
newSize.offset (shadowTextOffset);
pContext->setFontColor (shadowColor);
pContext->drawString (string, newSize, horiTxtAlign, hasBit (style, kAntialias));
pContext->drawString (string.getPlatformString (), newSize, horiTxtAlign,
hasBit (style, kAntialias));
}
pContext->setFontColor (fontColor);
pContext->drawString (string, textRect, horiTxtAlign, hasBit (style, kAntialias));
pContext->drawString (string.getPlatformString (), textRect, horiTxtAlign,
hasBit (style, kAntialias));
});
pContext->restoreGlobalState ();
}
Expand Down
5 changes: 3 additions & 2 deletions vstgui/lib/controls/cparamdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ class CParamDisplay : public CControl
~CParamDisplay () noexcept override;
virtual void drawBack (CDrawContext* pContext, CBitmap* newBack = nullptr);

virtual void drawPlatformText (CDrawContext* pContext, IPlatformString* string);
virtual void drawPlatformText (CDrawContext* pContext, IPlatformString* string, const CRect& size);
virtual void drawPlatformText (CDrawContext* pContext, const UTF8String& string);
virtual void drawPlatformText (CDrawContext* pContext, const UTF8String& string,
const CRect& size);

virtual void drawStyleChanged ();

Expand Down
4 changes: 2 additions & 2 deletions vstgui/lib/controls/csearchtextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ void CSearchTextEdit::draw (CDrawContext *pContext)
CColor color (fontColor);
color.alpha /= 2;
setFontColor (color);
drawPlatformText (pContext, getPlaceholderString ().getPlatformString (), getTextRect ());
drawPlatformText (pContext, getPlaceholderString (), getTextRect ());
}
else
drawPlatformText (pContext, getText ().getPlatformString (), getTextRect ());
drawPlatformText (pContext, getText (), getTextRect ());

setDirty (false);
setFontColor (origFontColor);
Expand Down
6 changes: 3 additions & 3 deletions vstgui/lib/controls/ctextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void CTextEdit::draw (CDrawContext *pContext)
{
pContext->saveGlobalState ();
pContext->setGlobalAlpha (pContext->getGlobalAlpha () * 0.5f);
drawPlatformText (pContext, placeholderString.getPlatformString ());
drawPlatformText (pContext, placeholderString);
pContext->restoreGlobalState ();
}
setDirty (false);
Expand All @@ -201,7 +201,7 @@ void CTextEdit::draw (CDrawContext *pContext)
{
pContext->saveGlobalState ();
pContext->setGlobalAlpha (pContext->getGlobalAlpha () * 0.5f);
drawPlatformText (pContext, placeholderString.getPlatformString ());
drawPlatformText (pContext, placeholderString);
pContext->restoreGlobalState ();
}
}
Expand All @@ -211,7 +211,7 @@ void CTextEdit::draw (CDrawContext *pContext)
UTF8String str;
for (auto i = 0u; i < text.length (); ++i)
str += bulletCharacter;
drawPlatformText (pContext, str.getPlatformString ());
drawPlatformText (pContext, str);
}
else
CTextLabel::draw (pContext);
Expand Down
2 changes: 1 addition & 1 deletion vstgui/lib/controls/ctextlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const UTF8String& CTextLabel::getText () const
void CTextLabel::draw (CDrawContext *pContext)
{
drawBack (pContext);
drawPlatformText (pContext, truncatedText.empty () ? text.getPlatformString () : truncatedText.getPlatformString ());
drawPlatformText (pContext, truncatedText.empty () ? text : truncatedText);
setDirty (false);
}

Expand Down
2 changes: 1 addition & 1 deletion vstgui/lib/platform/common/generictextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void STBTextEditView::draw (CDrawContext* context)
calcCursorSizes ();

drawBack (context, nullptr);
drawPlatformText (context, getText ().getPlatformString ());
drawPlatformText (context, getText ());

if (!isBlinkToggle () || editState.select_start != editState.select_end)
return;
Expand Down

0 comments on commit 0302f3e

Please sign in to comment.