aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/String.cpp13
-rw-r--r--src/common/StringUtil.cpp12
-rw-r--r--src/ui/ThemeManager.cpp6
-rw-r--r--src/ui/render/ScrollBar.cpp6
4 files changed, 19 insertions, 18 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp
index 8b53b16b..743a33fd 100644
--- a/src/common/String.cpp
+++ b/src/common/String.cpp
@@ -376,4 +376,17 @@ StringView StringView::substr(Index pos, Index size) {
return StringView(ptr_ + pos, std::min(size, size_ - pos));
}
+std::string StringView::ToUtf8() const { return cru::ToUtf8(ptr_, size_); }
+
+String ToLower(StringView s) {
+ String result;
+ for (auto c : s) result.push_back(ToLower(c));
+ return result;
+}
+
+String ToUpper(StringView s) {
+ String result;
+ for (auto c : s) result.push_back(ToUpper(c));
+ return result;
+}
} // namespace cru
diff --git a/src/common/StringUtil.cpp b/src/common/StringUtil.cpp
index 850524b5..c828fa21 100644
--- a/src/common/StringUtil.cpp
+++ b/src/common/StringUtil.cpp
@@ -252,16 +252,4 @@ char16_t ToUpper(char16_t c) {
}
return c;
}
-
-std::u16string ToLower(std::u16string_view s) {
- std::u16string result;
- for (auto c : s) result.push_back(ToLower(c));
- return result;
-}
-
-std::u16string ToUpper(std::u16string_view s) {
- std::u16string result;
- for (auto c : s) result.push_back(ToUpper(c));
- return result;
-}
} // namespace cru
diff --git a/src/ui/ThemeManager.cpp b/src/ui/ThemeManager.cpp
index 4a0e08a5..a5280d40 100644
--- a/src/ui/ThemeManager.cpp
+++ b/src/ui/ThemeManager.cpp
@@ -36,15 +36,15 @@ void ThemeManager::Init() {
}
gsl::not_null<std::shared_ptr<platform::graphics::IBrush>>
-ThemeManager::GetBrush(std::u16string key) {
- std::u16string k = ToLower(key);
+ThemeManager::GetBrush(StringView key) {
+ String k = ToLower(key);
auto cached_brush_iter = brushes_.find(k);
if (cached_brush_iter != brushes_.cend()) {
return cached_brush_iter->second;
}
auto color_string =
- String::FromUtf8(theme_tree_.get<std::string>(ToUtf8(key)));
+ String::FromUtf8(theme_tree_.get<std::string>(key.ToUtf8()));
auto color = Color::Parse(color_string);
if (!color) throw BadThemeResourceException("Value is not a valid color.");
std::shared_ptr<platform::graphics::IBrush> brush =
diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp
index 0d644a1f..aeecd9e2 100644
--- a/src/ui/render/ScrollBar.cpp
+++ b/src/ui/render/ScrollBar.cpp
@@ -39,9 +39,9 @@ constexpr std::array<ScrollBarAreaKind, 5> kScrollBarAreaKindList{
ScrollBarAreaKind::UpSlot, ScrollBarAreaKind::DownSlot,
ScrollBarAreaKind::Thumb};
-std::u16string GenerateScrollBarThemeColorKey(ScrollBarBrushUsageKind usage,
- ScrollBarBrushStateKind state) {
- std::u16string result = u"scrollbar.";
+String GenerateScrollBarThemeColorKey(ScrollBarBrushUsageKind usage,
+ ScrollBarBrushStateKind state) {
+ String result = u"scrollbar.";
switch (usage) {
case ScrollBarBrushUsageKind::Arrow:
result.append(u"arrow");