Remove lots of now-unnecessary ".c_str()"

This commit is contained in:
Henrik Rydgård committed 2024-05-24 22:53:13 +02:00
1 parent ccbcf1369b
commit 306c28c2cc
10 files changed
+58 -58

No files matched your search

+20 -20
View File
@@ -524,14 +524,14 @@ void Choice::Draw(UIContext &dc) {
}
if (centered_) {
dc.DrawTextRectSqueeze(text_.c_str(), bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT | drawTextFlags_);
dc.DrawTextRectSqueeze(text_, bounds_, style.fgColor, ALIGN_CENTER | FLAG_WRAP_TEXT | drawTextFlags_);
} else {
if (rightIconImage_.isValid()) {
uint32_t col = rightIconKeepColor_ ? 0xffffffff : style.fgColor; // Don't apply theme to gold icon
dc.Draw()->DrawImageRotated(rightIconImage_, bounds_.x2() - 32 - paddingX, bounds_.centerY(), rightIconScale_, rightIconRot_, col, rightIconFlipH_);
}
Bounds textBounds(bounds_.x + paddingX + textPadding_.left, bounds_.y, availWidth, bounds_.h);
dc.DrawTextRectSqueeze(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT | drawTextFlags_);
dc.DrawTextRectSqueeze(text_, textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT | drawTextFlags_);
}
dc.SetFontScale(1.0f, 1.0f);
}
@@ -583,10 +583,10 @@ void InfoItem::Draw(UIContext &dc) {
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_, padBounds, &leftWidth, &leftHeight, ALIGN_VCENTER);
dc.SetFontStyle(dc.theme->uiFont);
dc.DrawTextRect(text_.c_str(), padBounds, style.fgColor, ALIGN_VCENTER);
dc.DrawTextRect(text_, padBounds, style.fgColor, ALIGN_VCENTER);
Bounds rightBounds(padBounds.x + leftWidth, padBounds.y, padBounds.w - leftWidth, padBounds.h);
dc.DrawTextRect(rightText_.c_str(), rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
dc.DrawTextRect(rightText_, rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
}
std::string InfoItem::DescribeText() const {
@@ -602,7 +602,7 @@ ItemHeader::ItemHeader(std::string_view text, LayoutParams *layoutParams)
void ItemHeader::Draw(UIContext &dc) {
dc.SetFontStyle(large_ ? dc.theme->uiFont : dc.theme->uiFontSmall);
dc.DrawText(text_.c_str(), bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.DrawText(text_, bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
}
@@ -641,7 +641,7 @@ void CollapsibleHeader::Draw(UIContext &dc) {
float xoff = 37.0f;
dc.SetFontStyle(dc.theme->uiFontSmall);
dc.DrawText(text_.c_str(), bounds_.x + 4 + xoff, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.DrawText(text_, bounds_.x + 4 + xoff, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2() - 2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
if (hasSubItems_) {
dc.Draw()->DrawImageRotated(ImageID("I_ARROW"), bounds_.x + 20.0f, bounds_.y + 20.0f, 1.0f, *toggle_ ? -M_PI / 2 : M_PI);
@@ -703,7 +703,7 @@ void PopupHeader::Draw(UIContext &dc) {
float tw, th;
dc.SetFontStyle(dc.theme->uiFont);
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text_.c_str(), &tw, &th, 0);
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text_, &tw, &th, 0);
float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f;
@@ -717,7 +717,7 @@ void PopupHeader::Draw(UIContext &dc) {
dc.PushScissor(tb);
}
dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->itemStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.DrawText(text_, bounds_.x + tx, bounds_.centerY(), dc.theme->itemStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->itemStyle.fgColor);
if (availableWidth < tw) {
@@ -798,7 +798,7 @@ void CheckBox::Draw(UIContext &dc) {
if (!text_.empty()) {
Bounds textBounds(bounds_.x + paddingX, bounds_.y, availWidth, bounds_.h);
dc.DrawTextRectSqueeze(text_.c_str(), textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
dc.DrawTextRectSqueeze(text_, textBounds, style.fgColor, ALIGN_VCENTER | FLAG_WRAP_TEXT);
}
dc.Draw()->DrawImage(image, bounds_.x2() - paddingX, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
dc.SetFontScale(1.0f, 1.0f);
@@ -885,7 +885,7 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
if (!text_.empty() && !ignoreText_) {
float width = 0.0f;
float height = 0.0f;
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &width, &height);
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &width, &height);
w += width;
if (imageID_.isValid()) {
@@ -922,7 +922,7 @@ void Button::Draw(UIContext &dc) {
// dc.Draw()->DrawImage4Grid(style.image, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y2(), style.bgColor);
DrawBG(dc, style);
float tw, th;
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &tw, &th);
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &tw, &th);
tw *= scale_;
th *= scale_;
@@ -942,7 +942,7 @@ void Button::Draw(UIContext &dc) {
textX += img->w / 2.0f;
}
}
dc.DrawText(text_.c_str(), textX, bounds_.centerY(), style.fgColor, ALIGN_CENTER);
dc.DrawText(text_, textX, bounds_.centerY(), style.fgColor, ALIGN_CENTER);
}
dc.SetFontScale(1.0f, 1.0f);
@@ -956,7 +956,7 @@ void RadioButton::GetContentDimensions(const UIContext &dc, float &w, float &h)
h = 0.0f;
if (!text_.empty()) {
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &w, &h);
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &w, &h);
}
// Add some internal padding to not look totally ugly
@@ -996,7 +996,7 @@ void RadioButton::Draw(UIContext &dc) {
dc.Begin();
float tw, th;
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), &tw, &th);
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text_, &tw, &th);
if (tw > bounds_.w) {
dc.PushScissor(bounds_);
@@ -1006,7 +1006,7 @@ void RadioButton::Draw(UIContext &dc) {
if (!text_.empty()) {
float textX = bounds_.x + paddingW_ * 2.0f + radioRadius_ * 2.0f;
dc.DrawText(text_.c_str(), textX, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
dc.DrawText(text_, textX, bounds_.centerY(), style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
}
if (tw > bounds_.w) {
@@ -1091,9 +1091,9 @@ void TextView::Draw(UIContext &dc) {
if (shadow_) {
uint32_t shadowColor = 0x80000000;
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
dc.DrawTextRect(text_, textBounds.Offset(1.0f + pad_, 1.0f + pad_), shadowColor, textAlign_);
}
dc.DrawTextRect(text_.c_str(), textBounds.Offset(pad_, pad_), textColor, textAlign_);
dc.DrawTextRect(text_, textBounds.Offset(pad_, pad_), textColor, textAlign_);
if (small_) {
// If we changed font style, reset it.
dc.SetFontStyle(dc.theme->uiFont);
@@ -1133,10 +1133,10 @@ void TextEdit::Draw(UIContext &dc) {
if (text_.empty()) {
if (placeholderText_.size()) {
uint32_t c = textColor & 0x50FFFFFF;
dc.DrawTextRect(placeholderText_.c_str(), bounds_, c, ALIGN_CENTER);
dc.DrawTextRect(placeholderText_, bounds_, c, ALIGN_CENTER);
}
} else {
dc.DrawTextRect(text_.c_str(), textBounds, textColor, ALIGN_VCENTER | ALIGN_LEFT | align_);
dc.DrawTextRect(text_, textBounds, textColor, ALIGN_VCENTER | ALIGN_LEFT | align_);
}
if (HasFocus()) {
@@ -1156,7 +1156,7 @@ void TextEdit::Draw(UIContext &dc) {
}
void TextEdit::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, !text_.empty() ? text_.c_str() : "Wj", &w, &h, align_);
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, !text_.empty() ? text_ : "Wj", &w, &h, align_);
w += 2;
h += 2;
}