From 0a73828042c7b78923e2056cf89a4e33bc5365c1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 26 Mar 2017 08:57:04 -0700 Subject: [PATCH] UI: Use theme colors in more places. Hopefully everywhere. --- UI/MiscScreens.cpp | 23 ++++++++++--------- UI/NativeApp.cpp | 7 ++++++ UI/SavedataScreen.cpp | 15 ++++++++----- ext/native/ui/ui_screen.cpp | 25 ++++++++++++++++----- ext/native/ui/view.cpp | 45 ++++++++++++++++++++----------------- ext/native/ui/view.h | 10 +++++++-- 6 files changed, 82 insertions(+), 43 deletions(-) diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d7b31db865..a823c6a20d 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -487,6 +487,7 @@ void LogoScreen::render() { float alphaText = alpha; if (t > 2.0f) alphaText = 3.0f - t; + uint32_t textColor = colorAlpha(dc.theme->infoStyle.fgColor, alphaText); ::DrawBackground(dc, alpha); @@ -495,24 +496,24 @@ void LogoScreen::render() { // Manually formatting utf-8 is fun. \xXX doesn't work everywhere. snprintf(temp, sizeof(temp), "%s Henrik Rydg%c%crd", cr->T("created", "Created by"), 0xC3, 0xA5); #ifdef GOLD - dc.Draw()->DrawImage(I_ICONGOLD, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_ICONGOLD, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); #else - dc.Draw()->DrawImage(I_ICON, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_ICON, bounds.centerX() - 120, bounds.centerY() - 30, 1.2f, textColor, ALIGN_CENTER); #endif - dc.Draw()->DrawImage(I_LOGO, bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); - //dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", xres / 2, yres / 2 - 30, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.Draw()->DrawImage(I_LOGO, bounds.centerX() + 40, bounds.centerY() - 30, 1.5f, textColor, ALIGN_CENTER); + //dc.Draw()->DrawTextShadow(UBUNTU48, "PPSSPP", xres / 2, yres / 2 - 30, textColor, ALIGN_CENTER); dc.SetFontScale(1.0f, 1.0f); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, bounds.centerX(), bounds.centerY() + 40, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); - dc.DrawText(cr->T("license", "Free Software under GPL 2.0+"), bounds.centerX(), bounds.centerY() + 70, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); - dc.DrawText("www.ppsspp.org", bounds.centerX(), yres / 2 + 130, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawText(temp, bounds.centerX(), bounds.centerY() + 40, textColor, ALIGN_CENTER); + dc.DrawText(cr->T("license", "Free Software under GPL 2.0+"), bounds.centerX(), bounds.centerY() + 70, textColor, ALIGN_CENTER); + dc.DrawText("www.ppsspp.org", bounds.centerX(), yres / 2 + 130, textColor, ALIGN_CENTER); if (boot_filename.size()) { - dc.DrawTextShadow(boot_filename.c_str(), bounds.centerX(), bounds.centerY() + 180, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawTextShadow(boot_filename.c_str(), bounds.centerX(), bounds.centerY() + 180, textColor, ALIGN_CENTER); } #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) // Draw the graphics API, except on UWP where it's always D3D11 - dc.DrawText(screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME).c_str(), bounds.centerX(), bounds.y2() - 100, colorAlpha(0xFFFFFFFF, alphaText), ALIGN_CENTER); + dc.DrawText(screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME).c_str(), bounds.centerX(), bounds.y2() - 100, textColor, ALIGN_CENTER); #endif dc.End(); @@ -717,9 +718,11 @@ void CreditsScreen::render() { int y = bounds.y2() - (frames_ % totalHeight); for (int i = 0; i < numItems; i++) { float alpha = linearInOut(y+32, 64, bounds.y2() - 192, 64); + uint32_t textColor = colorAlpha(dc.theme->infoStyle.fgColor, alpha); + if (alpha > 0.0f) { dc.SetFontScale(ease(alpha), ease(alpha)); - dc.DrawText(credits[i], dc.GetBounds().centerX(), y, whiteAlpha(alpha), ALIGN_HCENTER); + dc.DrawText(credits[i], dc.GetBounds().centerX(), y, textColor, ALIGN_HCENTER); dc.SetFontScale(1.0f, 1.0f); } y += itemHeight; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9482d7db09..874d733447 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -565,6 +565,7 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { ui_theme.itemStyle.background = UI::Drawable(0x55000000); ui_theme.itemStyle.fgColor = 0xFFFFFFFF; ui_theme.itemFocusedStyle.background = UI::Drawable(0xFFedc24c); + ui_theme.itemFocusedStyle.fgColor = ui_theme.itemStyle.fgColor; ui_theme.itemDownStyle.background = UI::Drawable(0xFFbd9939); ui_theme.itemDownStyle.fgColor = 0xFFFFFFFF; ui_theme.itemDisabledStyle.background = UI::Drawable(0x55E0D4AF); @@ -578,7 +579,13 @@ void NativeInitGraphics(GraphicsContext *graphicsContext) { ui_theme.buttonDisabledStyle = ui_theme.itemDisabledStyle; ui_theme.buttonHighlightedStyle = ui_theme.itemHighlightedStyle; + ui_theme.headerStyle.fgColor = 0xFFFFFFFF; + ui_theme.infoStyle.fgColor = 0xFFFFFFFF; + ui_theme.infoStyle.background = UI::Drawable(0x00000000); + ui_theme.popupTitle.fgColor = 0xFFE3BE59; + ui_theme.popupStyle.fgColor = 0xFFFFFFFF; + ui_theme.popupStyle.background = UI::Drawable(0xFF303030); uiTexture = CreateTextureFromFile(g_draw, "ui_atlas.zim", ImageFileType::ZIM); if (!uiTexture) { diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index d9fff6f708..9c99816397 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -67,6 +67,9 @@ public: void CreatePopupContents(UI::ViewGroup *parent) override { using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); + const Style &textStyle = dc.theme->popupStyle; + GameInfo *ginfo = g_gameInfoCache->GetInfo(screenManager()->getDrawContext(), savePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); LinearLayout *content = new LinearLayout(ORIENT_VERTICAL); parent->Add(content); @@ -85,12 +88,12 @@ public: } LinearLayout *topright = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1.0f)); topright->SetSpacing(1.0f); - topright->Add(new TextView(savedata_title, ALIGN_LEFT | FLAG_WRAP_TEXT, false)); - topright->Add(new TextView(StringFromFormat("%d kB", ginfo->gameSize / 1024), 0, true)); - topright->Add(new TextView(GetFileDateAsString(savePath_ + "/PARAM.SFO"), 0, true)); + topright->Add(new TextView(savedata_title, ALIGN_LEFT | FLAG_WRAP_TEXT, false))->SetTextColor(textStyle.fgColor); + topright->Add(new TextView(StringFromFormat("%d kB", ginfo->gameSize / 1024), 0, true))->SetTextColor(textStyle.fgColor); + topright->Add(new TextView(GetFileDateAsString(savePath_ + "/PARAM.SFO"), 0, true))->SetTextColor(textStyle.fgColor); toprow->Add(topright); content->Add(new Spacer(3.0)); - content->Add(new TextView(ReplaceAll(savedata_detail, "\r", ""), ALIGN_LEFT | FLAG_WRAP_TEXT, true, new LinearLayoutParams(Margins(10, 0)))); + content->Add(new TextView(ReplaceAll(savedata_detail, "\r", ""), ALIGN_LEFT | FLAG_WRAP_TEXT, true, new LinearLayoutParams(Margins(10, 0))))->SetTextColor(textStyle.fgColor); content->Add(new Spacer(3.0)); } else { std::string image_path = ReplaceAll(savePath_, ".ppst", ".jpg"); @@ -98,9 +101,9 @@ public: PrioritizedWorkQueue *wq = g_gameInfoCache->WorkQueue(); toprow->Add(new AsyncImageFileView(image_path, IS_DEFAULT, wq, new LinearLayoutParams(480, 272, Margins(10, 0)))); } else { - toprow->Add(new TextView(sa->T("No screenshot"), new LinearLayoutParams(Margins(10, 5)))); + toprow->Add(new TextView(sa->T("No screenshot"), new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor); } - content->Add(new TextView(GetFileDateAsString(savePath_), 0, true, new LinearLayoutParams(Margins(10, 5)))); + content->Add(new TextView(GetFileDateAsString(savePath_), 0, true, new LinearLayoutParams(Margins(10, 5))))->SetTextColor(textStyle.fgColor); } I18NCategory *di = GetI18NCategory("Dialog"); diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index 45726a3745..c2e788e990 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -306,7 +306,6 @@ void PopupScreen::TriggerFinish(DialogResult result) { void PopupScreen::CreateViews() { using namespace UI; - UIContext &dc = *screenManager()->getUIContext(); AnchorLayout *anchor = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); @@ -319,7 +318,7 @@ void PopupScreen::CreateViews() { new AnchorLayoutParams(PopupWidth(), FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), dc.GetBounds().centerY(), NONE, NONE, true)); root_->Add(box_); - box_->SetBG(UI::Drawable(0xFF303030)); + box_->SetBG(dc.theme->popupStyle.background); box_->SetHasDropShadow(true); // Since we scale a bit, make the dropshadow bleed past the edges. box_->SetDropShadowExpand(std::max(dp_xres, dp_yres)); @@ -354,10 +353,13 @@ void PopupScreen::CreateViews() { } void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) { + using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); + std::vector messageLines; SplitString(message_, '\n', messageLines); for (const auto& lineOfText : messageLines) - parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false)); + parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false))->SetTextColor(dc.theme->popupStyle.fgColor); } void MessagePopupScreen::OnCompleted(DialogResult result) { @@ -621,23 +623,29 @@ EventReturn SliderPopupScreen::OnTextChange(EventParams ¶ms) { void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); + sliderValue_ = *value_; LinearLayout *vert = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(UI::Margins(10, 10)))); slider_ = new Slider(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 10))); slider_->OnChange.Handle(this, &SliderPopupScreen::OnSliderChange); vert->Add(slider_); + LinearLayout *lin = vert->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(UI::Margins(10, 10)))); lin->Add(new Button(" - "))->OnClick.Handle(this, &SliderPopupScreen::OnDecrease); lin->Add(new Button(" + "))->OnClick.Handle(this, &SliderPopupScreen::OnIncrease); + char temp[64]; sprintf(temp, "%d", sliderValue_); edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f)); edit_->SetMaxLen(16); + edit_->SetTextColor(dc.theme->popupStyle.fgColor); edit_->OnTextChange.Handle(this, &SliderPopupScreen::OnTextChange); changing_ = false; lin->Add(edit_); + if (!units_.empty()) - lin->Add(new TextView(units_, new LinearLayoutParams(10.0f))); + lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->popupStyle.fgColor); if (IsFocusMovementEnabled()) UI::SetFocusedView(slider_); @@ -645,23 +653,28 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); + sliderValue_ = *value_; LinearLayout *vert = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(UI::Margins(10, 10)))); slider_ = new SliderFloat(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 10))); slider_->OnChange.Handle(this, &SliderFloatPopupScreen::OnSliderChange); vert->Add(slider_); + LinearLayout *lin = vert->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(UI::Margins(10, 10)))); lin->Add(new Button(" - "))->OnClick.Handle(this, &SliderFloatPopupScreen::OnDecrease); lin->Add(new Button(" + "))->OnClick.Handle(this, &SliderFloatPopupScreen::OnIncrease); + char temp[64]; sprintf(temp, "%0.3f", sliderValue_); edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f)); edit_->SetMaxLen(16); + edit_->SetTextColor(dc.theme->popupStyle.fgColor); edit_->OnTextChange.Handle(this, &SliderFloatPopupScreen::OnTextChange); changing_ = false; lin->Add(edit_); if (!units_.empty()) - lin->Add(new TextView(units_, new LinearLayoutParams(10.0f))); + lin->Add(new TextView(units_, new LinearLayoutParams(10.0f)))->SetTextColor(dc.theme->popupStyle.fgColor); // slider_ = parent->Add(new SliderFloat(&sliderValue_, minValue_, maxValue_, new LinearLayoutParams(UI::Margins(10, 5)))); if (IsFocusMovementEnabled()) @@ -778,11 +791,13 @@ EventReturn PopupTextInputChoice::HandleChange(EventParams &e) { void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; + UIContext &dc = *screenManager()->getUIContext(); textEditValue_ = *value_; LinearLayout *lin = parent->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams((UI::Size)300, WRAP_CONTENT))); edit_ = new TextEdit(textEditValue_, placeholder_, new LinearLayoutParams(1.0f)); edit_->SetMaxLen(maxLen_); + edit_->SetTextColor(dc.theme->popupStyle.fgColor); lin->Add(edit_); if (IsFocusMovementEnabled()) diff --git a/ext/native/ui/view.cpp b/ext/native/ui/view.cpp index fd458c2fb0..ce4763d5d8 100644 --- a/ext/native/ui/view.cpp +++ b/ext/native/ui/view.cpp @@ -522,16 +522,16 @@ void Choice::Draw(UIContext &dc) { void InfoItem::Draw(UIContext &dc) { Item::Draw(dc); - if (HasFocus()) { - UI::Style style = dc.theme->itemFocusedStyle; - style.background.color &= 0x7fffffff; - dc.FillRect(style.background, bounds_); - } + + UI::Style style = HasFocus() ? dc.theme->itemFocusedStyle : dc.theme->infoStyle; + style.background.color &= 0x7fffffff; + dc.FillRect(style.background, bounds_); + int paddingX = 12; dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER); - dc.DrawText(rightText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_RIGHT); + dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER); + dc.DrawText(rightText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT); // dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y + 2, dc.theme->itemDownStyle.bgColor); } @@ -543,8 +543,8 @@ ItemHeader::ItemHeader(const std::string &text, LayoutParams *layoutParams) void ItemHeader::Draw(UIContext &dc) { dc.SetFontStyle(dc.theme->uiFontSmall); - dc.DrawText(text_.c_str(), bounds_.x + 4, bounds_.centerY(), 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER); - dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), 0xFFFFFFFF); + dc.DrawText(text_.c_str(), bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER); + dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor); } void PopupHeader::Draw(UIContext &dc) { @@ -756,14 +756,16 @@ void TextView::Draw(UIContext &dc) { uint32_t shadowColor = 0x80000000; dc.DrawTextRect(text_.c_str(), bounds_, shadowColor, textAlign_); } - dc.DrawTextRect(text_.c_str(), bounds_, textColor_, textAlign_); + uint32_t textColor = hasTextColor_ ? textColor_ : dc.theme->infoStyle.fgColor; + dc.DrawTextRect(text_.c_str(), bounds_, textColor, textAlign_); if (clip) { dc.PopScissor(); } } TextEdit::TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams) - : View(layoutParams), text_(text), undo_(text), placeholderText_(placeholderText), maxLen_(255), ctrlDown_(false) { + : View(layoutParams), text_(text), undo_(text), placeholderText_(placeholderText), + textColor_(0xFFFFFFFF), maxLen_(255) { caret_ = (int)text_.size(); } @@ -772,6 +774,7 @@ void TextEdit::Draw(UIContext &dc) { dc.SetFontStyle(dc.theme->uiFont); dc.FillRect(HasFocus() ? UI::Drawable(0x80000000) : UI::Drawable(0x30000000), bounds_); + uint32_t textColor = hasTextColor_ ? textColor_ : dc.theme->infoStyle.fgColor; float textX = bounds_.x; float w, h; @@ -780,10 +783,11 @@ void TextEdit::Draw(UIContext &dc) { if (text_.empty()) { if (placeholderText_.size()) { - dc.DrawTextRect(placeholderText_.c_str(), bounds_, 0x50FFFFFF, ALIGN_CENTER); + uint32_t c = textColor & 0x50FFFFFF; + dc.DrawTextRect(placeholderText_.c_str(), bounds_, c, ALIGN_CENTER); } } else { - dc.DrawTextRect(text_.c_str(), textBounds, 0xFFFFFFFF, ALIGN_VCENTER | ALIGN_LEFT); + dc.DrawTextRect(text_.c_str(), textBounds, textColor, ALIGN_VCENTER | ALIGN_LEFT); } if (HasFocus()) { @@ -796,7 +800,7 @@ void TextEdit::Draw(UIContext &dc) { // Scroll text to the left if the caret won't fit. Not ideal but looks better than not scrolling it. textX -= caretX - bounds_.w; } - dc.FillRect(UI::Drawable(0xFFFFFFFF), Bounds(caretX - 1, bounds_.y + 2, 3, bounds_.h - 4)); + dc.FillRect(UI::Drawable(textColor), Bounds(caretX - 1, bounds_.y + 2, 3, bounds_.h - 4)); } dc.PopScissor(); } @@ -1094,18 +1098,19 @@ void Slider::Clamp() { void Slider::Draw(UIContext &dc) { bool focus = HasFocus(); uint32_t linecolor = dc.theme->popupTitle.fgColor; - uint32_t knobcolor = (down_ || focus) ? dc.theme->popupTitle.fgColor : 0xFFFFFFFF; + Style knobStyle = (down_ || focus) ? dc.theme->popupTitle : dc.theme->popupStyle; + float knobX = ((float)(*value_) - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_); dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); dc.FillRect(Drawable(0xFF808080), Bounds(knobX, bounds_.centerY() - 2, (bounds_.x + bounds_.w - paddingRight_ - knobX), 4)); - dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobcolor, ALIGN_CENTER); + dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobStyle.fgColor, ALIGN_CENTER); char temp[64]; if (showPercent_) sprintf(temp, "%i%%", *value_); else sprintf(temp, "%i", *value_); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER); + dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER); } void Slider::Update() { @@ -1205,16 +1210,16 @@ void SliderFloat::Clamp() { void SliderFloat::Draw(UIContext &dc) { bool focus = HasFocus(); uint32_t linecolor = dc.theme->popupTitle.fgColor; - uint32_t knobcolor = (down_ || focus) ? dc.theme->popupTitle.fgColor : 0xFFFFFFFF; + Style knobStyle = (down_ || focus) ? dc.theme->popupTitle : dc.theme->popupStyle; float knobX = (*value_ - minValue_) / (maxValue_ - minValue_) * (bounds_.w - paddingLeft_ - paddingRight_) + (bounds_.x + paddingLeft_); dc.FillRect(Drawable(linecolor), Bounds(bounds_.x + paddingLeft_, bounds_.centerY() - 2, knobX - (bounds_.x + paddingLeft_), 4)); dc.FillRect(Drawable(0xFF808080), Bounds(knobX, bounds_.centerY() - 2, (bounds_.x + bounds_.w - paddingRight_ - knobX), 4)); - dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobcolor, ALIGN_CENTER); + dc.Draw()->DrawImage(dc.theme->sliderKnob, knobX, bounds_.centerY(), 1.0f, knobStyle.fgColor, ALIGN_CENTER); char temp[64]; sprintf(temp, "%0.2f", *value_); dc.SetFontStyle(dc.theme->uiFont); - dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER); + dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER); } void SliderFloat::Update() { diff --git a/ext/native/ui/view.h b/ext/native/ui/view.h index ce924bd3df..b2afb6fb72 100644 --- a/ext/native/ui/view.h +++ b/ext/native/ui/view.h @@ -117,8 +117,10 @@ struct Theme { Style itemHighlightedStyle; Style headerStyle; + Style infoStyle; Style popupTitle; + Style popupStyle; }; // The four cardinal directions should be enough, plus Prev/Next in "element order". @@ -759,7 +761,7 @@ public: void SetText(const std::string &text) { text_ = text; } const std::string &GetText() const { return text_; } void SetSmall(bool small) { small_ = small; } - void SetTextColor(uint32_t color) { textColor_ = color; } + void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; } void SetShadow(bool shadow) { shadow_ = shadow; } void SetFocusable(bool focusable) { focusable_ = focusable; } void SetClip(bool clip) { clip_ = clip; } @@ -770,6 +772,7 @@ private: std::string text_; int textAlign_; uint32_t textColor_; + bool hasTextColor_ = false; bool small_; bool shadow_; bool focusable_; @@ -780,6 +783,7 @@ class TextEdit : public View { public: TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams = 0); void SetText(const std::string &text) { text_ = text; caret_ = (int)text_.size(); } + void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; } const std::string &GetText() const { return text_; } void SetMaxLen(size_t maxLen) { maxLen_ = maxLen; } @@ -797,9 +801,11 @@ private: std::string text_; std::string undo_; std::string placeholderText_; + uint32_t textColor_; + bool hasTextColor_ = false; int caret_; size_t maxLen_; - bool ctrlDown_; // TODO: Make some global mechanism for this. + bool ctrlDown_ = false; // TODO: Make some global mechanism for this. // TODO: Selections };