diff --git a/ui/view.cpp b/ui/view.cpp index 9c66334e84..e0881ce849 100644 --- a/ui/view.cpp +++ b/ui/view.cpp @@ -414,7 +414,13 @@ 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_); + } 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); diff --git a/ui/view.h b/ui/view.h index 5f6e206aff..929c6ba96c 100644 --- a/ui/view.h +++ b/ui/view.h @@ -593,6 +593,9 @@ public: void Draw(UIContext &dc) override; + // These are focusable so that long lists of them can be keybaord scrolled. + bool CanBeFocused() const override { return true; } + private: std::string text_; std::string rightText_; @@ -656,10 +659,10 @@ private: class TextView : public InertView { public: TextView(const std::string &text, LayoutParams *layoutParams = 0) - : InertView(layoutParams), text_(text), textAlign_(0), textColor_(0xFFFFFFFF), small_(false), shadow_(false) {} + : InertView(layoutParams), text_(text), textAlign_(0), textColor_(0xFFFFFFFF), small_(false), shadow_(false), focusable_(false) {} TextView(const std::string &text, int textAlign, bool small, LayoutParams *layoutParams = 0) - : InertView(layoutParams), text_(text), textAlign_(textAlign), textColor_(0xFFFFFFFF), small_(small), shadow_(false) {} + : InertView(layoutParams), text_(text), textAlign_(textAlign), textColor_(0xFFFFFFFF), small_(small), shadow_(false), focusable_(false) {} void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; void Draw(UIContext &dc) override; @@ -668,12 +671,17 @@ public: void SetSmall(bool small) { small_ = small; } void SetTextColor(uint32_t color) { textColor_ = color; } void SetShadow(bool shadow) { shadow_ = shadow; } + void SetFocusable(bool focusable) { focusable_ = focusable; } + + bool CanBeFocused() const override { return focusable_; } + private: std::string text_; int textAlign_; uint32_t textColor_; bool small_; bool shadow_; + bool focusable_; }; class TextEdit : public View {