1// Aseprite
2// Copyright (C) 2021-2022 Igara Studio S.A.
3// Copyright (C) 2001-2018 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_COMMANDS_CMD_SAVE_FILE_H_INCLUDED
9#define APP_COMMANDS_CMD_SAVE_FILE_H_INCLUDED
10#pragma once
11
12#include "app/commands/command.h"
13#include "app/commands/new_params.h"
14#include "doc/anidir.h"
15#include "doc/selected_frames.h"
16#include "gfx/point.h"
17#include "gfx/rect.h"
18
19#include <string>
20
21namespace app {
22 class Doc;
23
24 struct SaveFileParams : public NewParams {
25 Param<bool> ui { this, true, { "ui", "useUI" } };
26 Param<std::string> filename { this, std::string(), "filename" };
27 Param<std::string> filenameFormat { this, std::string(), { "filenameFormat", "filename-format" } };
28 Param<std::string> tag { this, std::string(), { "tag", "frame-tag" } };
29 Param<doc::AniDir> aniDir { this, doc::AniDir::FORWARD, { "aniDir", "ani-dir" } };
30 Param<std::string> slice { this, std::string(), "slice" };
31 Param<doc::frame_t> fromFrame { this, 0, { "fromFrame", "from-frame" } };
32 Param<doc::frame_t> toFrame { this, 0, { "toFrame", "to-frame" } };
33 Param<bool> ignoreEmpty { this, false, "ignoreEmpty" };
34 Param<double> scale { this, 1.0, "scale" };
35 Param<gfx::Rect> bounds { this, gfx::Rect(), "bounds" };
36 };
37
38 class SaveFileBaseCommand : public CommandWithNewParams<SaveFileParams> {
39 public:
40 enum class MarkAsSaved { Off, On };
41 enum class SaveInBackground { Off, On };
42 enum class ResizeOnTheFly { Off, On };
43
44 SaveFileBaseCommand(const char* id, CommandFlags flags);
45
46 protected:
47 void onLoadParams(const Params& params) override;
48 bool onEnabled(Context* context) override;
49
50 std::string saveAsDialog(
51 Context* context,
52 const std::string& dlgTitle,
53 const std::string& filename,
54 const MarkAsSaved markAsSaved,
55 const SaveInBackground saveInBackground = SaveInBackground::On,
56 const std::string& forbiddenFilename = std::string());
57 void saveDocumentInBackground(
58 const Context* context,
59 Doc* document,
60 const std::string& filename,
61 const MarkAsSaved markAsSaved,
62 const ResizeOnTheFly resizeOnTheFly = ResizeOnTheFly::Off,
63 const gfx::PointF& scale = gfx::PointF(1.0, 1.0));
64
65 doc::SelectedFrames m_selFrames;
66 bool m_adjustFramesByTag;
67 };
68
69} // namespace app
70
71#endif
72