2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2024-05-11 01:49:14 +08:00
|
|
|
// Copyright (C) 2021-2024 Igara Studio S.A.
|
2018-03-16 07:34:01 +08:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2014-03-30 03:58:35 +08:00
|
|
|
|
|
|
|
#ifndef APP_COMMANDS_CMD_SAVE_FILE_H_INCLUDED
|
|
|
|
#define APP_COMMANDS_CMD_SAVE_FILE_H_INCLUDED
|
2014-03-30 06:40:17 +08:00
|
|
|
#pragma once
|
2014-03-30 03:58:35 +08:00
|
|
|
|
|
|
|
#include "app/commands/command.h"
|
2022-06-14 04:04:12 +08:00
|
|
|
#include "app/commands/new_params.h"
|
|
|
|
#include "doc/anidir.h"
|
2023-12-08 04:31:49 +08:00
|
|
|
#include "doc/frames_sequence.h"
|
2022-06-15 10:19:39 +08:00
|
|
|
#include "gfx/point.h"
|
2022-08-13 07:11:25 +08:00
|
|
|
#include "gfx/rect.h"
|
2014-03-30 03:58:35 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace app {
|
2018-07-07 22:54:44 +08:00
|
|
|
class Doc;
|
2014-03-30 03:58:35 +08:00
|
|
|
|
2022-06-14 04:04:12 +08:00
|
|
|
struct SaveFileParams : public NewParams {
|
|
|
|
Param<bool> ui{
|
|
|
|
this,
|
|
|
|
true,
|
|
|
|
{ "ui", "useUI" }
|
|
|
|
};
|
2024-05-11 01:49:14 +08:00
|
|
|
Param<bool> recent{ this, true, "recent" };
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<std::string> filename{ this, std::string(), "filename" };
|
|
|
|
Param<std::string> filenameFormat{
|
2024-12-17 01:52:19 +08:00
|
|
|
this,
|
2022-06-14 04:04:12 +08:00
|
|
|
std::string(),
|
|
|
|
{ "filenameFormat", "filename-format" }
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<std::string> tag{
|
2024-12-17 01:52:19 +08:00
|
|
|
this,
|
2022-06-14 04:04:12 +08:00
|
|
|
std::string(),
|
|
|
|
{ "tag", "frame-tag" }
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<doc::AniDir> aniDir{
|
2024-12-17 01:52:19 +08:00
|
|
|
this,
|
2022-06-14 04:04:12 +08:00
|
|
|
doc::AniDir::FORWARD,
|
|
|
|
{ "aniDir", "ani-dir" }
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<std::string> slice{ this, std::string(), "slice" };
|
|
|
|
Param<doc::frame_t> fromFrame{
|
2024-12-17 01:52:19 +08:00
|
|
|
this,
|
|
|
|
0,
|
2022-06-14 04:04:12 +08:00
|
|
|
{ "fromFrame", "from-frame" }
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<doc::frame_t> toFrame{
|
2024-12-17 01:52:19 +08:00
|
|
|
this,
|
|
|
|
0,
|
2022-06-14 04:04:12 +08:00
|
|
|
{ "toFrame", "to-frame" }
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
Param<bool> ignoreEmpty{ this, false, "ignoreEmpty" };
|
2022-06-15 10:19:39 +08:00
|
|
|
Param<double> scale{ this, 1.0, "scale" };
|
2022-08-13 07:11:25 +08:00
|
|
|
Param<gfx::Rect> bounds{ this, gfx::Rect(), "bounds" };
|
2023-12-02 02:40:20 +08:00
|
|
|
Param<bool> playSubtags{ this, false, "playSubtags" };
|
2024-12-17 01:52:19 +08:00
|
|
|
};
|
2022-06-14 04:04:12 +08:00
|
|
|
|
|
|
|
class SaveFileBaseCommand : public CommandWithNewParams<SaveFileParams> {
|
2014-03-30 03:58:35 +08:00
|
|
|
public:
|
2022-06-13 23:46:11 +08:00
|
|
|
enum class MarkAsSaved { Off, On };
|
|
|
|
enum class SaveInBackground { Off, On };
|
2022-06-15 10:19:39 +08:00
|
|
|
enum class ResizeOnTheFly { Off, On };
|
2022-06-13 23:46:11 +08:00
|
|
|
|
2025-07-24 07:00:12 +08:00
|
|
|
SaveFileBaseCommand(const char* id);
|
2014-03-30 03:58:35 +08:00
|
|
|
|
|
|
|
protected:
|
2015-03-12 02:40:22 +08:00
|
|
|
void onLoadParams(const Params& params) override;
|
2014-08-15 10:07:47 +08:00
|
|
|
bool onEnabled(Context* context) override;
|
2014-03-30 03:58:35 +08:00
|
|
|
|
2018-03-16 07:34:01 +08:00
|
|
|
std::string saveAsDialog(Context* context,
|
|
|
|
const std::string& dlgTitle,
|
|
|
|
const std::string& filename,
|
2022-06-13 23:46:11 +08:00
|
|
|
const MarkAsSaved markAsSaved,
|
|
|
|
const SaveInBackground saveInBackground = SaveInBackground::On,
|
2018-03-16 07:34:01 +08:00
|
|
|
const std::string& forbiddenFilename = std::string());
|
|
|
|
void saveDocumentInBackground(const Context* context,
|
2018-07-07 22:54:44 +08:00
|
|
|
Doc* document,
|
2018-03-16 07:34:01 +08:00
|
|
|
const std::string& filename,
|
2022-06-15 10:19:39 +08:00
|
|
|
const MarkAsSaved markAsSaved,
|
|
|
|
const ResizeOnTheFly resizeOnTheFly = ResizeOnTheFly::Off,
|
|
|
|
const gfx::PointF& scale = gfx::PointF(1.0, 1.0));
|
2014-03-30 03:58:35 +08:00
|
|
|
|
2023-12-08 04:31:49 +08:00
|
|
|
doc::FramesSequence m_framesSeq;
|
2019-10-02 01:55:08 +08:00
|
|
|
bool m_adjustFramesByTag;
|
2014-03-30 03:58:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace app
|
|
|
|
|
|
|
|
#endif
|