Add a focus style to the little screenshot previews to make keyboard navigation less confusing

This commit is contained in:
Henrik Rydgard 2015-02-02 10:05:23 +01:00
parent feb96f0573
commit 682ef7d083
3 changed files with 11 additions and 2 deletions

View file

@ -590,6 +590,7 @@ void EmuScreen::CreateViews() {
saveStatePreview_->SetFixedSize(160, 90);
saveStatePreview_->SetColor(0x90FFFFFF);
saveStatePreview_->SetVisibility(V_GONE);
saveStatePreview_->SetCanBeFocused(false);
root_->Add(saveStatePreview_);
root_->Add(new OnScreenMessagesView(new AnchorLayoutParams((Size)bounds.w, (Size)bounds.h)));
}

View file

@ -82,6 +82,10 @@ void AsyncImageFileView::Draw(UIContext &dc) {
textureFailed_ = true;
}
if (HasFocus()) {
dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3));
}
// TODO: involve sizemode
if (texture_) {
dc.Flush();
@ -126,7 +130,7 @@ protected:
virtual void CreatePopupContents(UI::ViewGroup *parent) {
// TODO: Find an appropriate size for the image view
parent->Add(new AsyncImageFileView(filename_, UI::IS_DEFAULT, NULL, new UI::LayoutParams(480, 272)));
parent->Add(new AsyncImageFileView(filename_, UI::IS_DEFAULT, NULL, new UI::LayoutParams(480, 272)))->SetCanBeFocused(false);
}
private:

View file

@ -67,7 +67,7 @@ class PrioritizedWorkQueue;
class AsyncImageFileView : public UI::Clickable {
public:
AsyncImageFileView(const std::string &filename, UI::ImageSizeMode sizeMode, PrioritizedWorkQueue *wq, UI::LayoutParams *layoutParams = 0)
: UI::Clickable(layoutParams), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), texture_(NULL), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
: UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), texture_(NULL), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
~AsyncImageFileView() {
delete texture_;
}
@ -80,10 +80,14 @@ public:
void SetColor(uint32_t color) { color_ = color; }
void SetOverlayText(std::string text) { text_ = text; }
void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; }
void SetCanBeFocused(bool can) { canFocus_ = can; }
bool CanBeFocused() const override { return canFocus_; }
const std::string &GetFilename() const { return filename_; }
private:
bool canFocus_;
std::string filename_;
std::string text_;
uint32_t color_;