From ade0160ffe305ee6b663300260c1a201ddb494a3 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 17 Dec 2020 20:49:20 +0100 Subject: [PATCH] Made the switches slightly smaller in the metadata editor. Also made the value 'unknown' be set for some entries when clearing them individually in the metadata editor. --- es-app/src/guis/GuiMetaDataEd.cpp | 14 ++++++++++++++ es-core/src/GuiComponent.h | 1 + es-core/src/components/ImageComponent.h | 2 +- es-core/src/components/SwitchComponent.cpp | 5 +++++ es-core/src/components/SwitchComponent.h | 2 ++ es-core/src/components/VideoComponent.h | 2 +- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index b667f2d19..c943eb8d4 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -106,6 +106,11 @@ GuiMetaDataEd::GuiMetaDataEd( switch (iter->type) { case MD_BOOL: { ed = std::make_shared(window); + // Make the switches slightly smaller. + auto switchSize = ed->getSize() * 0.9; + ed->setResize(switchSize.x(), switchSize.y()); + ed->setOrigin(-0.05, -0.09); + ed->setChangedColor(ICONCOLOR_USERMARKED); row.addElement(ed, false, true); break; @@ -220,6 +225,15 @@ GuiMetaDataEd::GuiMetaDataEd( else ed->setColor(TEXTCOLOR_USERMARKED); } + else if (newVal == "" && (currentKey == "developer" || + currentKey == "publisher" || currentKey == "genre" || + currentKey == "players")) { + ed->setValue("unknown"); + if (originalValue == "unknown") + ed->setColor(DEFAULT_TEXTCOLOR); + else + ed->setColor(TEXTCOLOR_USERMARKED); + } else { ed->setValue(newVal); if (newVal == originalValue) diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 19c8d945b..26e3a2ce4 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -88,6 +88,7 @@ public: virtual Vector2f getSize() const; inline void setSize(const Vector2f& size) { setSize(size.x(), size.y()); } void setSize(float w, float h); + virtual void setResize(float width, float height) {}; virtual void onSizeChanged() {}; virtual Vector2f getRotationSize() const { return getSize(); }; diff --git a/es-core/src/components/ImageComponent.h b/es-core/src/components/ImageComponent.h index 95e9497ec..9751020aa 100644 --- a/es-core/src/components/ImageComponent.h +++ b/es-core/src/components/ImageComponent.h @@ -38,7 +38,7 @@ public: // zero, don't do any resizing. // Can be set before or after an image is loaded. // setMaxSize() and setResize() are mutually exclusive. - void setResize(float width, float height); + void setResize(float width, float height) override; inline void setResize(const Vector2f& size) { setResize(size.x(), size.y()); } // Resize the image to be as large as possible but fit within a box of this size. diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index 765bf96c2..961a0d9cf 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -30,6 +30,11 @@ void SwitchComponent::onSizeChanged() mImage.setSize(mSize); } +void SwitchComponent::setResize(float width, float height) +{ + mImage.setResize(width, height); +} + bool SwitchComponent::input(InputConfig* config, Input input) { if (config->isMappedTo("a", input) && input.value) { diff --git a/es-core/src/components/SwitchComponent.h b/es-core/src/components/SwitchComponent.h index 63a1c0b7f..94f672ead 100644 --- a/es-core/src/components/SwitchComponent.h +++ b/es-core/src/components/SwitchComponent.h @@ -22,6 +22,8 @@ public: void render(const Transform4x4f& parentTrans) override; void onSizeChanged() override; + void setResize(float width, float height) override; + bool getState() const; void setState(bool state); std::string getValue() const override; diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index 686f2147e..fc9d6ae14 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -71,7 +71,7 @@ public: // aspect ratio. If both are non-zero, potentially break the aspect ratio. If both are // zero, no resizing. This can be set before or after a video is loaded. // setMaxSize() and setResize() are mutually exclusive. - virtual void setResize(float width, float height) = 0; + virtual void setResize(float width, float height) override = 0; inline void setResize(const Vector2f& size) { setResize(size.x(), size.y()); } // Resize the video to be as large as possible but fit within a box of this size.