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.
This commit is contained in:
Leon Styhre 2020-12-17 20:49:20 +01:00
parent bddc87bbcc
commit ade0160ffe
6 changed files with 24 additions and 2 deletions

View file

@ -106,6 +106,11 @@ GuiMetaDataEd::GuiMetaDataEd(
switch (iter->type) {
case MD_BOOL: {
ed = std::make_shared<SwitchComponent>(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)

View file

@ -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(); };

View file

@ -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.

View file

@ -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) {

View file

@ -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;

View file

@ -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.