Show "Apply pixel ratio" option in File > Export only when needed (#4308)

If the sprite doesn't have a custom pixel aspect ratio configured
there is no need to show this option.
This commit is contained in:
David Capello 2024-03-12 15:13:35 -03:00
parent a0e469624a
commit 30f55d196b
3 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
@ -56,7 +56,17 @@ ExportFileWindow::ExportFileWindow(const Doc* doc)
fill_layers_combobox(m_doc->sprite(), layers(), m_docPref.saveCopy.layer(), m_docPref.saveCopy.layerIndex());
fill_frames_combobox(m_doc->sprite(), frames(), m_docPref.saveCopy.frameTag());
fill_anidir_combobox(anidir(), m_docPref.saveCopy.aniDir());
pixelRatio()->setSelected(m_docPref.saveCopy.applyPixelRatio());
if (doc->sprite()->hasPixelRatio()) {
pixelRatio()->setSelected(m_docPref.saveCopy.applyPixelRatio());
}
else {
// Hide "Apply pixel ratio" checkbox when there is no pixel aspect
// ratio to apply.
pixelRatio()->setSelected(false);
pixelRatio()->setVisible(false);
}
forTwitter()->setSelected(m_docPref.saveCopy.forTwitter());
adjustResize()->setVisible(false);
playSubtags()->setSelected(m_docPref.saveCopy.playSubtags());

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -198,6 +198,11 @@ Sprite* Sprite::MakeStdTilemapSpriteWithTileset(const ImageSpec& spec,
//////////////////////////////////////////////////////////////////////
// Main properties
bool Sprite::hasPixelRatio() const
{
return m_pixelRatio != PixelRatio(1, 1);
}
void Sprite::setPixelFormat(PixelFormat format)
{
m_spec.setColorMode((ColorMode)format);

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -93,6 +93,7 @@ namespace doc {
PixelFormat pixelFormat() const { return (PixelFormat)m_spec.colorMode(); }
ColorMode colorMode() const { return m_spec.colorMode(); }
const PixelRatio& pixelRatio() const { return m_pixelRatio; }
bool hasPixelRatio() const;
gfx::Size size() const { return m_spec.size(); }
gfx::Rect bounds() const { return m_spec.bounds(); }
int width() const { return m_spec.width(); }