2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
|
|
|
|
// Copyright (C) 2001-2015 David Capello
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
// published by the Free Software Foundation.
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-09-19 07:57:02 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
2011-03-23 08:11:25 +08:00
|
|
|
|
2012-09-06 08:14:42 +08:00
|
|
|
#include "app/app_options.h"
|
2011-07-27 10:25:02 +08:00
|
|
|
#include "app/check_update.h"
|
2010-08-25 11:26:37 +08:00
|
|
|
#include "app/color_utils.h"
|
2014-11-07 08:04:32 +08:00
|
|
|
#include "app/commands/cmd_save_file.h"
|
|
|
|
|
#include "app/commands/cmd_sprite_size.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/commands.h"
|
|
|
|
|
#include "app/commands/params.h"
|
|
|
|
|
#include "app/console.h"
|
2015-04-06 05:51:43 +08:00
|
|
|
#include "app/crash/data_recovery.h"
|
2013-12-09 07:19:32 +08:00
|
|
|
#include "app/document_exporter.h"
|
2015-02-03 22:05:33 +08:00
|
|
|
#include "app/document_undo.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/file/file.h"
|
|
|
|
|
#include "app/file/file_formats_manager.h"
|
|
|
|
|
#include "app/file_system.h"
|
2015-01-26 09:36:32 +08:00
|
|
|
#include "app/filename_formatter.h"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "app/find_widget.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/gui_xml.h"
|
|
|
|
|
#include "app/ini_file.h"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "app/load_widget.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/log.h"
|
|
|
|
|
#include "app/modules.h"
|
|
|
|
|
#include "app/modules/gfx.h"
|
|
|
|
|
#include "app/modules/gui.h"
|
|
|
|
|
#include "app/modules/palettes.h"
|
2014-12-15 07:19:31 +08:00
|
|
|
#include "app/pref/preferences.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/recent_files.h"
|
2014-04-20 07:52:56 +08:00
|
|
|
#include "app/resource_finder.h"
|
2014-08-20 11:11:19 +08:00
|
|
|
#include "app/send_crash.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/shell.h"
|
|
|
|
|
#include "app/tools/tool_box.h"
|
|
|
|
|
#include "app/ui/color_bar.h"
|
2014-09-03 11:39:15 +08:00
|
|
|
#include "app/ui/document_view.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/editor/editor.h"
|
|
|
|
|
#include "app/ui/editor/editor_view.h"
|
2015-05-10 06:55:33 +08:00
|
|
|
#include "app/ui/input_chain.h"
|
2014-10-29 22:58:03 +08:00
|
|
|
#include "app/ui/keyboard_shortcuts.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/main_window.h"
|
|
|
|
|
#include "app/ui/status_bar.h"
|
|
|
|
|
#include "app/ui/toolbar.h"
|
2015-05-05 02:52:00 +08:00
|
|
|
#include "app/ui/workspace.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui_context.h"
|
2013-03-31 11:36:00 +08:00
|
|
|
#include "app/webserver.h"
|
2011-01-21 10:33:57 +08:00
|
|
|
#include "base/exception.h"
|
2014-08-24 11:09:01 +08:00
|
|
|
#include "base/fs.h"
|
|
|
|
|
#include "base/path.h"
|
2015-04-02 01:59:49 +08:00
|
|
|
#include "base/split_string.h"
|
2011-03-23 08:11:25 +08:00
|
|
|
#include "base/unique_ptr.h"
|
2014-07-29 11:53:24 +08:00
|
|
|
#include "doc/document_observer.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/image.h"
|
|
|
|
|
#include "doc/layer.h"
|
|
|
|
|
#include "doc/palette.h"
|
2015-04-21 03:27:09 +08:00
|
|
|
#include "doc/site.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/sprite.h"
|
2014-12-28 22:06:11 +08:00
|
|
|
#include "render/render.h"
|
2012-09-09 07:10:48 +08:00
|
|
|
#include "scripting/engine.h"
|
2015-06-20 07:01:30 +08:00
|
|
|
#include "scripting/engine_delegate.h"
|
2014-09-03 11:39:15 +08:00
|
|
|
#include "she/display.h"
|
2014-06-18 11:53:15 +08:00
|
|
|
#include "she/error.h"
|
2014-09-03 11:39:15 +08:00
|
|
|
#include "she/system.h"
|
2012-06-18 09:49:58 +08:00
|
|
|
#include "ui/intern.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2012-09-09 07:10:48 +08:00
|
|
|
#include <iostream>
|
2011-03-23 08:11:25 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
using namespace ui;
|
|
|
|
|
|
2014-12-15 07:19:31 +08:00
|
|
|
class App::CoreModules {
|
2009-10-14 22:09:59 +08:00
|
|
|
public:
|
2012-09-03 04:42:32 +08:00
|
|
|
ConfigModule m_configModule;
|
2014-12-15 07:19:31 +08:00
|
|
|
Preferences m_preferences;
|
2015-05-22 03:31:20 +08:00
|
|
|
|
|
|
|
|
CoreModules() {
|
|
|
|
|
// Reset the active tool ("pencil" is the default one).
|
|
|
|
|
// We don't want to keep the selected tool from previous session.
|
|
|
|
|
m_preferences.toolBox.activeTool(tools::WellKnownTools::Pencil);
|
|
|
|
|
}
|
2014-12-15 07:19:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class App::Modules {
|
|
|
|
|
public:
|
2012-09-03 04:42:32 +08:00
|
|
|
LoggerModule m_loggerModule;
|
2010-01-29 11:15:33 +08:00
|
|
|
FileSystemModule m_file_system_module;
|
2011-04-02 21:47:03 +08:00
|
|
|
tools::ToolBox m_toolbox;
|
2009-10-14 22:09:59 +08:00
|
|
|
CommandsModule m_commands_modules;
|
|
|
|
|
UIContext m_ui_context;
|
2010-09-18 11:28:24 +08:00
|
|
|
RecentFiles m_recent_files;
|
2015-05-10 06:55:33 +08:00
|
|
|
InputChain m_inputChain;
|
2015-04-09 07:28:30 +08:00
|
|
|
// This is a raw pointer because we want to delete this explicitly.
|
|
|
|
|
app::crash::DataRecovery* m_recovery;
|
2012-08-23 08:05:02 +08:00
|
|
|
|
2015-04-23 06:28:24 +08:00
|
|
|
Modules(bool verbose)
|
2012-09-06 08:14:42 +08:00
|
|
|
: m_loggerModule(verbose)
|
2015-04-09 07:28:30 +08:00
|
|
|
, m_recovery(nullptr) {
|
2012-08-23 08:05:02 +08:00
|
|
|
}
|
2015-04-09 07:28:30 +08:00
|
|
|
|
|
|
|
|
app::crash::DataRecovery* recovery() {
|
|
|
|
|
return m_recovery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool hasRecoverySessions() const {
|
|
|
|
|
return m_recovery && !m_recovery->sessions().empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void createDataRecovery() {
|
2015-05-10 07:18:10 +08:00
|
|
|
#ifdef ENABLE_DATA_RECOVERY
|
2015-04-09 07:28:30 +08:00
|
|
|
m_recovery = new app::crash::DataRecovery(&m_ui_context);
|
2015-05-10 07:18:10 +08:00
|
|
|
#endif
|
2015-04-09 07:28:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void deleteDataRecovery() {
|
2015-05-10 07:18:10 +08:00
|
|
|
#ifdef ENABLE_DATA_RECOVERY
|
2015-04-09 07:28:30 +08:00
|
|
|
delete m_recovery;
|
2015-05-10 07:18:10 +08:00
|
|
|
#endif
|
2015-04-09 07:28:30 +08:00
|
|
|
}
|
|
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
};
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2015-06-20 07:01:30 +08:00
|
|
|
class StdoutEngineDelegate : public scripting::EngineDelegate {
|
|
|
|
|
public:
|
|
|
|
|
void onConsolePrint(const char* text) override {
|
|
|
|
|
printf("%s\n", text);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
App* App::m_instance = NULL;
|
2008-03-23 02:43:56 +08:00
|
|
|
|
2014-11-06 20:42:09 +08:00
|
|
|
App::App()
|
2014-12-15 07:19:31 +08:00
|
|
|
: m_coreModules(NULL)
|
|
|
|
|
, m_modules(NULL)
|
2010-01-29 11:15:33 +08:00
|
|
|
, m_legacy(NULL)
|
2010-09-19 04:36:21 +08:00
|
|
|
, m_isGui(false)
|
2012-09-09 07:10:48 +08:00
|
|
|
, m_isShell(false)
|
2013-12-09 07:19:32 +08:00
|
|
|
, m_exporter(NULL)
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2010-08-04 10:33:44 +08:00
|
|
|
ASSERT(m_instance == NULL);
|
2009-10-09 09:34:06 +08:00
|
|
|
m_instance = this;
|
2014-11-06 20:42:09 +08:00
|
|
|
}
|
2009-10-09 09:34:06 +08:00
|
|
|
|
2014-12-01 08:01:54 +08:00
|
|
|
void App::initialize(const AppOptions& options)
|
2014-11-06 20:42:09 +08:00
|
|
|
{
|
2015-04-23 06:28:24 +08:00
|
|
|
m_isGui = options.startUI();
|
|
|
|
|
m_isShell = options.startShell();
|
|
|
|
|
if (m_isGui)
|
2014-12-01 08:01:54 +08:00
|
|
|
m_guiSystem.reset(new ui::GuiSystem);
|
2010-09-29 02:36:03 +08:00
|
|
|
|
2014-11-06 20:42:09 +08:00
|
|
|
// Initializes the application loading the modules, setting the
|
|
|
|
|
// graphics mode, loading the configuration and resources, etc.
|
2014-12-15 07:19:31 +08:00
|
|
|
m_coreModules = new CoreModules;
|
2015-04-23 06:28:24 +08:00
|
|
|
m_modules = new Modules(options.verbose());
|
2010-09-19 04:36:21 +08:00
|
|
|
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
2011-08-07 01:36:40 +08:00
|
|
|
|
2014-11-07 08:04:32 +08:00
|
|
|
if (options.hasExporterParams())
|
2013-12-09 07:19:32 +08:00
|
|
|
m_exporter.reset(new DocumentExporter);
|
|
|
|
|
|
2015-04-23 06:28:24 +08:00
|
|
|
// Data recovery is enabled only in GUI mode
|
|
|
|
|
if (isGui() && preferences().general.dataRecovery())
|
2015-04-09 07:28:30 +08:00
|
|
|
m_modules->createDataRecovery();
|
|
|
|
|
|
2011-01-17 04:27:18 +08:00
|
|
|
// Register well-known image file types.
|
2014-08-22 10:39:20 +08:00
|
|
|
FileFormatsManager::instance()->registerAllFormats();
|
2011-01-17 04:27:18 +08:00
|
|
|
|
2014-08-20 20:16:59 +08:00
|
|
|
if (isPortable())
|
|
|
|
|
PRINTF("Running in portable mode\n");
|
2010-04-26 08:29:50 +08:00
|
|
|
|
2015-07-06 21:59:44 +08:00
|
|
|
// Load or create the default palette, or migrate the default
|
|
|
|
|
// palette from an old format palette to the new one, etc.
|
|
|
|
|
load_default_palette(options.paletteFileName());
|
2014-09-03 11:39:15 +08:00
|
|
|
|
2010-09-19 04:36:21 +08:00
|
|
|
// Initialize GUI interface
|
2014-11-07 08:04:32 +08:00
|
|
|
UIContext* ctx = UIContext::instance();
|
2010-09-19 04:36:21 +08:00
|
|
|
if (isGui()) {
|
2007-09-19 07:57:02 +08:00
|
|
|
PRINTF("GUI mode\n");
|
|
|
|
|
|
2014-08-11 06:51:14 +08:00
|
|
|
// Setup the GUI cursor and redraw screen
|
|
|
|
|
|
|
|
|
|
ui::set_use_native_cursors(
|
2015-03-03 03:07:35 +08:00
|
|
|
preferences().experimental.useNativeCursor());
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2014-11-26 08:30:56 +08:00
|
|
|
ui::set_mouse_cursor(kArrowCursor);
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
ui::Manager::getDefault()->invalidate();
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2012-07-10 00:20:58 +08:00
|
|
|
// Create the main window and show it.
|
|
|
|
|
m_mainWindow.reset(new MainWindow);
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2013-03-28 08:19:35 +08:00
|
|
|
// Default status of the main window.
|
2013-01-21 05:40:37 +08:00
|
|
|
app_rebuild_documents_tabs();
|
2013-03-28 08:19:35 +08:00
|
|
|
app_default_statusbar_message();
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2015-04-09 07:05:05 +08:00
|
|
|
// Recover data
|
2015-04-09 07:28:30 +08:00
|
|
|
if (m_modules->hasRecoverySessions())
|
|
|
|
|
m_mainWindow->showDataRecovery(m_modules->recovery());
|
2015-04-09 07:05:05 +08:00
|
|
|
|
2012-07-10 00:20:58 +08:00
|
|
|
m_mainWindow->openWindow();
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2012-04-16 02:21:24 +08:00
|
|
|
// Redraw the whole screen.
|
2012-06-18 09:02:54 +08:00
|
|
|
ui::Manager::getDefault()->invalidate();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2012-07-10 00:20:58 +08:00
|
|
|
// Procress options
|
2007-09-24 04:13:58 +08:00
|
|
|
PRINTF("Processing options...\n");
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-11-30 21:23:11 +08:00
|
|
|
bool ignoreEmpty = false;
|
2015-02-02 21:42:07 +08:00
|
|
|
bool trim = false;
|
2015-04-02 01:59:49 +08:00
|
|
|
Params cropParams;
|
2014-11-30 21:23:11 +08:00
|
|
|
|
2014-11-06 20:42:09 +08:00
|
|
|
// Open file specified in the command line
|
2014-11-07 08:04:32 +08:00
|
|
|
if (!options.values().empty()) {
|
2010-03-26 19:45:13 +08:00
|
|
|
Console console;
|
2014-11-07 08:04:32 +08:00
|
|
|
bool splitLayers = false;
|
2014-11-10 06:46:09 +08:00
|
|
|
bool splitLayersSaveAs = false;
|
2014-11-07 08:04:32 +08:00
|
|
|
std::string importLayer;
|
2014-11-10 06:46:09 +08:00
|
|
|
std::string importLayerSaveAs;
|
2015-01-26 09:36:32 +08:00
|
|
|
std::string filenameFormat;
|
2014-11-06 20:42:09 +08:00
|
|
|
|
2014-11-07 08:04:32 +08:00
|
|
|
for (const auto& value : options.values()) {
|
|
|
|
|
const AppOptions::Option* opt = value.option();
|
|
|
|
|
|
|
|
|
|
// Special options/commands
|
|
|
|
|
if (opt) {
|
|
|
|
|
// --data <file.json>
|
|
|
|
|
if (opt == &options.data()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setDataFilename(value.value());
|
|
|
|
|
}
|
2015-04-30 23:29:31 +08:00
|
|
|
// --format <format>
|
|
|
|
|
else if (opt == &options.format()) {
|
|
|
|
|
if (m_exporter) {
|
|
|
|
|
DocumentExporter::DataFormat format = DocumentExporter::DefaultDataFormat;
|
|
|
|
|
|
|
|
|
|
if (value.value() == "json-hash")
|
|
|
|
|
format = DocumentExporter::JsonHashDataFormat;
|
|
|
|
|
else if (value.value() == "json-array")
|
|
|
|
|
format = DocumentExporter::JsonArrayDataFormat;
|
|
|
|
|
|
|
|
|
|
m_exporter->setDataFormat(format);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
// --sheet <file.png>
|
|
|
|
|
else if (opt == &options.sheet()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setTextureFilename(value.value());
|
|
|
|
|
}
|
2014-11-07 12:05:08 +08:00
|
|
|
// --sheet-width <width>
|
|
|
|
|
else if (opt == &options.sheetWidth()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setTextureWidth(strtol(value.value().c_str(), NULL, 0));
|
|
|
|
|
}
|
|
|
|
|
// --sheet-height <height>
|
|
|
|
|
else if (opt == &options.sheetHeight()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setTextureHeight(strtol(value.value().c_str(), NULL, 0));
|
|
|
|
|
}
|
2014-11-07 21:39:05 +08:00
|
|
|
// --sheet-pack
|
|
|
|
|
else if (opt == &options.sheetPack()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setTexturePack(true);
|
|
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
// --split-layers
|
|
|
|
|
else if (opt == &options.splitLayers()) {
|
|
|
|
|
splitLayers = true;
|
2014-11-10 06:46:09 +08:00
|
|
|
splitLayersSaveAs = true;
|
2014-11-07 08:04:32 +08:00
|
|
|
}
|
|
|
|
|
// --import-layer <layer-name>
|
|
|
|
|
else if (opt == &options.importLayer()) {
|
|
|
|
|
importLayer = value.value();
|
2014-11-10 06:46:09 +08:00
|
|
|
importLayerSaveAs = value.value();
|
2014-11-07 08:04:32 +08:00
|
|
|
}
|
2014-11-30 21:23:11 +08:00
|
|
|
// --ignore-empty
|
|
|
|
|
else if (opt == &options.ignoreEmpty()) {
|
|
|
|
|
ignoreEmpty = true;
|
|
|
|
|
}
|
2015-03-20 01:39:37 +08:00
|
|
|
// --border-padding
|
|
|
|
|
else if (opt == &options.borderPadding()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setBorderPadding(strtol(value.value().c_str(), NULL, 0));
|
|
|
|
|
}
|
|
|
|
|
// --shape-padding
|
|
|
|
|
else if (opt == &options.shapePadding()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setShapePadding(strtol(value.value().c_str(), NULL, 0));
|
|
|
|
|
}
|
|
|
|
|
// --inner-padding
|
|
|
|
|
else if (opt == &options.innerPadding()) {
|
|
|
|
|
if (m_exporter)
|
|
|
|
|
m_exporter->setInnerPadding(strtol(value.value().c_str(), NULL, 0));
|
|
|
|
|
}
|
2015-02-02 21:42:07 +08:00
|
|
|
// --trim
|
|
|
|
|
else if (opt == &options.trim()) {
|
|
|
|
|
trim = true;
|
|
|
|
|
}
|
2015-04-02 01:59:49 +08:00
|
|
|
// --crop
|
|
|
|
|
else if (opt == &options.crop()) {
|
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
|
base::split_string(value.value(), parts, ",");
|
|
|
|
|
if (parts.size() == 4) {
|
|
|
|
|
cropParams.set("x", parts[0].c_str());
|
|
|
|
|
cropParams.set("y", parts[1].c_str());
|
|
|
|
|
cropParams.set("width", parts[2].c_str());
|
|
|
|
|
cropParams.set("height", parts[3].c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-26 09:36:32 +08:00
|
|
|
// --filename-format
|
|
|
|
|
else if (opt == &options.filenameFormat()) {
|
|
|
|
|
filenameFormat = value.value();
|
|
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
// --save-as <filename>
|
|
|
|
|
else if (opt == &options.saveAs()) {
|
|
|
|
|
Document* doc = NULL;
|
|
|
|
|
if (!ctx->documents().empty())
|
|
|
|
|
doc = dynamic_cast<Document*>(ctx->documents().lastAdded());
|
|
|
|
|
|
|
|
|
|
if (!doc) {
|
|
|
|
|
console.printf("A document is needed before --save-as argument\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ctx->setActiveDocument(doc);
|
|
|
|
|
|
2015-01-26 09:36:32 +08:00
|
|
|
std::string format = filenameFormat;
|
|
|
|
|
|
2015-02-02 21:42:07 +08:00
|
|
|
Command* saveAsCommand = CommandsModule::instance()->getCommandByName(CommandId::SaveFileCopyAs);
|
|
|
|
|
Command* trimCommand = CommandsModule::instance()->getCommandByName(CommandId::AutocropSprite);
|
2015-04-02 01:59:49 +08:00
|
|
|
Command* cropCommand = CommandsModule::instance()->getCommandByName(CommandId::CropSprite);
|
2015-02-02 21:42:07 +08:00
|
|
|
Command* undoCommand = CommandsModule::instance()->getCommandByName(CommandId::Undo);
|
|
|
|
|
|
2014-11-10 06:46:09 +08:00
|
|
|
if (splitLayersSaveAs) {
|
|
|
|
|
std::vector<Layer*> layers;
|
|
|
|
|
doc->sprite()->getLayersList(layers);
|
|
|
|
|
|
2015-01-26 09:36:32 +08:00
|
|
|
std::string fn, fmt;
|
|
|
|
|
if (format.empty()) {
|
2015-01-26 10:10:51 +08:00
|
|
|
if (doc->sprite()->totalFrames() > frame_t(1))
|
2015-01-26 09:36:32 +08:00
|
|
|
format = "{path}/{title} ({layer}) {frame}.{extension}";
|
|
|
|
|
else
|
|
|
|
|
format = "{path}/{title} ({layer}).{extension}";
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-10 06:46:09 +08:00
|
|
|
// For each layer, hide other ones and save the sprite.
|
|
|
|
|
for (Layer* show : layers) {
|
|
|
|
|
for (Layer* hide : layers)
|
2014-11-17 10:03:30 +08:00
|
|
|
hide->setVisible(hide == show);
|
2014-11-10 06:46:09 +08:00
|
|
|
|
2015-05-01 04:02:57 +08:00
|
|
|
FilenameInfo fnInfo;
|
|
|
|
|
fnInfo
|
|
|
|
|
.filename(value.value())
|
|
|
|
|
.layerName(show->name());
|
|
|
|
|
|
|
|
|
|
fn = filename_formatter(format, fnInfo);
|
|
|
|
|
fmt = filename_formatter(format, fnInfo, false);
|
2015-01-26 09:36:32 +08:00
|
|
|
|
2015-04-02 01:59:49 +08:00
|
|
|
if (!cropParams.empty())
|
|
|
|
|
ctx->executeCommand(cropCommand, cropParams);
|
|
|
|
|
|
2015-02-02 21:42:07 +08:00
|
|
|
// TODO --trim command with --save-as doesn't make too
|
|
|
|
|
// much sense as we lost the trim rectangle
|
|
|
|
|
// information (e.g. we don't have sheet .json) Also,
|
|
|
|
|
// we should trim each frame individually (a process
|
|
|
|
|
// that can be done only in fop_operate()).
|
|
|
|
|
if (trim)
|
|
|
|
|
ctx->executeCommand(trimCommand);
|
|
|
|
|
|
2015-01-26 09:36:32 +08:00
|
|
|
Params params;
|
|
|
|
|
params.set("filename", fn.c_str());
|
|
|
|
|
params.set("filename-format", fmt.c_str());
|
2015-03-12 02:40:22 +08:00
|
|
|
ctx->executeCommand(saveAsCommand, params);
|
2015-02-02 21:42:07 +08:00
|
|
|
|
2015-02-03 22:05:33 +08:00
|
|
|
if (trim) { // Undo trim command
|
2015-02-02 21:42:07 +08:00
|
|
|
ctx->executeCommand(undoCommand);
|
2015-02-03 22:05:33 +08:00
|
|
|
|
|
|
|
|
// Just in case allow non-linear history is enabled
|
|
|
|
|
// we clear redo information
|
|
|
|
|
doc->undoHistory()->clearRedo();
|
|
|
|
|
}
|
2014-11-10 06:46:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
std::vector<Layer*> layers;
|
|
|
|
|
doc->sprite()->getLayersList(layers);
|
|
|
|
|
|
|
|
|
|
// Show only one layer
|
|
|
|
|
if (!importLayerSaveAs.empty()) {
|
|
|
|
|
for (Layer* layer : layers)
|
2014-11-17 10:03:30 +08:00
|
|
|
layer->setVisible(layer->name() == importLayerSaveAs);
|
2014-11-10 06:46:09 +08:00
|
|
|
}
|
|
|
|
|
|
2015-04-02 01:59:49 +08:00
|
|
|
if (!cropParams.empty())
|
|
|
|
|
ctx->executeCommand(cropCommand, cropParams);
|
|
|
|
|
|
2015-02-02 21:42:07 +08:00
|
|
|
if (trim)
|
|
|
|
|
ctx->executeCommand(trimCommand);
|
|
|
|
|
|
2015-01-26 09:36:32 +08:00
|
|
|
Params params;
|
|
|
|
|
params.set("filename", value.value().c_str());
|
|
|
|
|
params.set("filename-format", format.c_str());
|
2015-03-12 02:40:22 +08:00
|
|
|
ctx->executeCommand(saveAsCommand, params);
|
2015-02-02 21:42:07 +08:00
|
|
|
|
2015-02-03 22:05:33 +08:00
|
|
|
if (trim) { // Undo trim command
|
2015-02-02 21:42:07 +08:00
|
|
|
ctx->executeCommand(undoCommand);
|
2015-02-03 22:05:33 +08:00
|
|
|
|
|
|
|
|
// Just in case allow non-linear history is enabled
|
|
|
|
|
// we clear redo information
|
|
|
|
|
doc->undoHistory()->clearRedo();
|
|
|
|
|
}
|
2014-11-10 06:46:09 +08:00
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// --scale <factor>
|
|
|
|
|
else if (opt == &options.scale()) {
|
|
|
|
|
Command* command = CommandsModule::instance()->getCommandByName(CommandId::SpriteSize);
|
|
|
|
|
double scale = strtod(value.value().c_str(), NULL);
|
|
|
|
|
static_cast<SpriteSizeCommand*>(command)->setScale(scale, scale);
|
|
|
|
|
|
|
|
|
|
// Scale all sprites
|
|
|
|
|
for (auto doc : ctx->documents()) {
|
2015-04-21 03:27:09 +08:00
|
|
|
ctx->setActiveDocument(static_cast<app::Document*>(doc));
|
2014-11-07 08:04:32 +08:00
|
|
|
ctx->executeCommand(command);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-06 08:14:42 +08:00
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
// File names aren't associated to any option
|
2012-09-06 08:14:42 +08:00
|
|
|
else {
|
2014-11-07 08:04:32 +08:00
|
|
|
const std::string& filename = value.value();
|
|
|
|
|
|
|
|
|
|
// Load the sprite
|
|
|
|
|
Document* doc = load_document(ctx, filename.c_str());
|
|
|
|
|
if (!doc) {
|
|
|
|
|
if (!isGui())
|
|
|
|
|
console.printf("Error loading file \"%s\"\n", filename.c_str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Add the given file in the argument as a "recent file" only
|
|
|
|
|
// if we are running in GUI mode. If the program is executed
|
|
|
|
|
// in batch mode this is not desirable.
|
|
|
|
|
if (isGui())
|
|
|
|
|
getRecentFiles()->addRecentFile(filename.c_str());
|
|
|
|
|
|
|
|
|
|
if (m_exporter != NULL) {
|
|
|
|
|
if (!importLayer.empty()) {
|
|
|
|
|
std::vector<Layer*> layers;
|
|
|
|
|
doc->sprite()->getLayersList(layers);
|
2014-11-10 06:46:09 +08:00
|
|
|
|
|
|
|
|
Layer* foundLayer = NULL;
|
2014-11-07 08:04:32 +08:00
|
|
|
for (Layer* layer : layers) {
|
|
|
|
|
if (layer->name() == importLayer) {
|
|
|
|
|
foundLayer = layer;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (foundLayer)
|
|
|
|
|
m_exporter->addDocument(doc, foundLayer);
|
|
|
|
|
}
|
|
|
|
|
else if (splitLayers) {
|
|
|
|
|
std::vector<Layer*> layers;
|
|
|
|
|
doc->sprite()->getLayersList(layers);
|
|
|
|
|
for (auto layer : layers)
|
|
|
|
|
m_exporter->addDocument(doc, layer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
m_exporter->addDocument(doc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!importLayer.empty())
|
|
|
|
|
importLayer.clear();
|
|
|
|
|
|
|
|
|
|
if (splitLayers)
|
|
|
|
|
splitLayers = false;
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2015-01-26 09:36:32 +08:00
|
|
|
|
|
|
|
|
if (m_exporter && !filenameFormat.empty())
|
|
|
|
|
m_exporter->setFilenameFormat(filenameFormat);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2013-12-09 07:19:32 +08:00
|
|
|
// Export
|
2015-02-02 21:42:07 +08:00
|
|
|
if (m_exporter) {
|
2013-12-09 07:19:32 +08:00
|
|
|
PRINTF("Exporting sheet...\n");
|
|
|
|
|
|
2014-11-30 21:23:11 +08:00
|
|
|
if (ignoreEmpty)
|
|
|
|
|
m_exporter->setIgnoreEmptyCels(true);
|
|
|
|
|
|
2015-02-02 21:42:07 +08:00
|
|
|
if (trim)
|
|
|
|
|
m_exporter->setTrimCels(true);
|
|
|
|
|
|
2015-03-19 21:17:40 +08:00
|
|
|
base::UniquePtr<Document> spriteSheet(m_exporter->exportSheet());
|
2013-12-09 07:19:32 +08:00
|
|
|
m_exporter.reset(NULL);
|
2015-03-19 02:15:30 +08:00
|
|
|
|
|
|
|
|
PRINTF("Export sprite sheet: Done\n");
|
2013-12-09 07:19:32 +08:00
|
|
|
}
|
2014-11-06 20:42:09 +08:00
|
|
|
}
|
2013-12-09 07:19:32 +08:00
|
|
|
|
2014-11-06 20:42:09 +08:00
|
|
|
void App::run()
|
|
|
|
|
{
|
2010-03-25 04:24:28 +08:00
|
|
|
// Run the GUI
|
2010-09-19 04:36:21 +08:00
|
|
|
if (isGui()) {
|
2011-07-28 08:26:22 +08:00
|
|
|
#ifdef ENABLE_UPDATER
|
2011-07-27 10:25:02 +08:00
|
|
|
// Launch the thread to check for updates.
|
2015-02-26 23:28:26 +08:00
|
|
|
app::CheckUpdateThreadLauncher checkUpdate(
|
|
|
|
|
m_mainWindow->getCheckUpdateDelegate());
|
2011-07-27 10:25:02 +08:00
|
|
|
checkUpdate.launch();
|
2011-07-28 08:26:22 +08:00
|
|
|
#endif
|
2011-07-27 10:25:02 +08:00
|
|
|
|
2013-03-31 11:36:00 +08:00
|
|
|
#ifdef ENABLE_WEBSERVER
|
|
|
|
|
// Launch the webserver.
|
|
|
|
|
app::WebServer webServer;
|
|
|
|
|
webServer.start();
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
app::SendCrash sendCrash;
|
|
|
|
|
sendCrash.search();
|
|
|
|
|
|
2011-07-27 10:25:02 +08:00
|
|
|
// Run the GUI main message loop
|
2007-09-20 08:32:35 +08:00
|
|
|
gui_run();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
2014-11-07 08:04:32 +08:00
|
|
|
|
2012-09-09 07:10:48 +08:00
|
|
|
// Start shell to execute scripts.
|
2014-11-07 08:04:32 +08:00
|
|
|
if (m_isShell) {
|
2015-06-20 07:01:30 +08:00
|
|
|
StdoutEngineDelegate delegate;
|
|
|
|
|
scripting::Engine engine(&delegate);
|
|
|
|
|
Shell shell;
|
|
|
|
|
shell.run(engine);
|
2012-09-09 07:10:48 +08:00
|
|
|
}
|
2010-01-29 11:15:33 +08:00
|
|
|
|
2014-11-07 08:04:32 +08:00
|
|
|
// Destroy all documents in the UIContext.
|
|
|
|
|
const doc::Documents& docs = m_modules->m_ui_context.documents();
|
|
|
|
|
while (!docs.empty()) {
|
|
|
|
|
doc::Document* doc = docs.back();
|
|
|
|
|
|
|
|
|
|
// First we close the document. In this way we receive recent
|
|
|
|
|
// notifications related to the document as an app::Document. If
|
|
|
|
|
// we delete the document directly, we destroy the app::Document
|
|
|
|
|
// too early, and then doc::~Document() call
|
|
|
|
|
// DocumentsObserver::onRemoveDocument(). In this way, observers
|
|
|
|
|
// could think that they have a fully created app::Document when
|
|
|
|
|
// in reality it's a doc::Document (in the middle of a
|
|
|
|
|
// destruction process).
|
|
|
|
|
//
|
|
|
|
|
// TODO: This problem is because we're extending doc::Document,
|
|
|
|
|
// in the future, we should remove app::Document.
|
|
|
|
|
doc->close();
|
|
|
|
|
delete doc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isGui()) {
|
|
|
|
|
// Destroy the window.
|
|
|
|
|
m_mainWindow.reset(NULL);
|
|
|
|
|
}
|
2015-04-09 07:28:30 +08:00
|
|
|
|
|
|
|
|
// Delete backups (this is a normal shutdown, we are not handling
|
|
|
|
|
// exceptions, and we are not in a destructor).
|
|
|
|
|
m_modules->deleteDataRecovery();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2013-08-09 08:01:20 +08:00
|
|
|
// Finishes the Aseprite application.
|
2009-10-09 09:34:06 +08:00
|
|
|
App::~App()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2009-10-14 22:09:59 +08:00
|
|
|
try {
|
2010-08-04 10:33:44 +08:00
|
|
|
ASSERT(m_instance == this);
|
2008-03-23 02:43:56 +08:00
|
|
|
|
2013-08-09 08:01:20 +08:00
|
|
|
// Remove Aseprite handlers
|
2010-01-29 11:15:33 +08:00
|
|
|
PRINTF("ASE: Uninstalling\n");
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-05-03 10:04:04 +08:00
|
|
|
// Delete file formats.
|
|
|
|
|
FileFormatsManager::destroyInstance();
|
|
|
|
|
|
2012-08-23 08:05:02 +08:00
|
|
|
// Fire App Exit signal.
|
2010-03-01 10:36:05 +08:00
|
|
|
App::instance()->Exit();
|
2008-03-23 02:43:56 +08:00
|
|
|
|
2012-08-23 08:05:02 +08:00
|
|
|
// Finalize modules, configuration and core.
|
2015-05-21 03:23:53 +08:00
|
|
|
Editor::destroyEditorSharedInternals();
|
2009-10-14 22:09:59 +08:00
|
|
|
|
2010-01-29 11:15:33 +08:00
|
|
|
delete m_legacy;
|
|
|
|
|
delete m_modules;
|
2014-12-15 07:19:31 +08:00
|
|
|
delete m_coreModules;
|
2011-01-23 07:30:44 +08:00
|
|
|
|
2014-10-29 22:58:03 +08:00
|
|
|
// Destroy the loaded gui.xml data.
|
|
|
|
|
delete KeyboardShortcuts::instance();
|
2011-01-23 07:30:44 +08:00
|
|
|
delete GuiXml::instance();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
m_instance = NULL;
|
|
|
|
|
}
|
2014-12-28 22:06:11 +08:00
|
|
|
catch (const std::exception& e) {
|
|
|
|
|
she::error_message(e.what());
|
|
|
|
|
|
|
|
|
|
// no re-throw
|
|
|
|
|
}
|
2009-10-14 22:09:59 +08:00
|
|
|
catch (...) {
|
2014-06-18 11:53:15 +08:00
|
|
|
she::error_message("Error closing ASE.\n(uncaught exception)");
|
2008-03-23 02:43:56 +08:00
|
|
|
|
2010-03-01 10:36:05 +08:00
|
|
|
// no re-throw
|
2008-03-23 02:43:56 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 20:16:59 +08:00
|
|
|
bool App::isPortable()
|
|
|
|
|
{
|
2014-08-24 11:09:01 +08:00
|
|
|
static bool* is_portable = NULL;
|
|
|
|
|
if (!is_portable) {
|
|
|
|
|
is_portable =
|
|
|
|
|
new bool(
|
|
|
|
|
base::is_file(base::join_path(
|
|
|
|
|
base::get_file_path(base::get_app_path()),
|
|
|
|
|
"aseprite.ini")));
|
|
|
|
|
}
|
|
|
|
|
return *is_portable;
|
2014-08-20 20:16:59 +08:00
|
|
|
}
|
|
|
|
|
|
2011-04-02 21:47:03 +08:00
|
|
|
tools::ToolBox* App::getToolBox() const
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
{
|
2010-08-04 10:33:44 +08:00
|
|
|
ASSERT(m_modules != NULL);
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-08 03:47:45 +08:00
|
|
|
return &m_modules->m_toolbox;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-19 03:53:25 +08:00
|
|
|
tools::Tool* App::activeTool() const
|
|
|
|
|
{
|
|
|
|
|
return getToolBox()->getToolById(preferences().toolBox.activeTool());
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-18 11:28:24 +08:00
|
|
|
RecentFiles* App::getRecentFiles() const
|
|
|
|
|
{
|
|
|
|
|
ASSERT(m_modules != NULL);
|
|
|
|
|
return &m_modules->m_recent_files;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 07:19:31 +08:00
|
|
|
Preferences& App::preferences() const
|
|
|
|
|
{
|
|
|
|
|
return m_coreModules->m_preferences;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
void App::showNotification(INotificationDelegate* del)
|
2014-05-25 22:21:10 +08:00
|
|
|
{
|
2014-08-20 11:11:19 +08:00
|
|
|
m_mainWindow->showNotification(del);
|
2014-05-25 22:21:10 +08:00
|
|
|
}
|
|
|
|
|
|
2014-09-03 11:39:15 +08:00
|
|
|
void App::updateDisplayTitleBar()
|
|
|
|
|
{
|
|
|
|
|
std::string defaultTitle = PACKAGE " v" VERSION;
|
|
|
|
|
std::string title;
|
|
|
|
|
|
|
|
|
|
DocumentView* docView = UIContext::instance()->activeView();
|
|
|
|
|
if (docView) {
|
|
|
|
|
// Prepend the document's filename.
|
|
|
|
|
title += docView->getDocument()->name();
|
|
|
|
|
title += " - ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
title += defaultTitle;
|
|
|
|
|
she::instance()->defaultDisplay()->setTitleBar(title);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-10 06:55:33 +08:00
|
|
|
InputChain& App::inputChain()
|
|
|
|
|
{
|
|
|
|
|
return m_modules->m_inputChain;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
// Updates palette and redraw the screen.
|
|
|
|
|
void app_refresh_screen()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2013-03-12 07:29:45 +08:00
|
|
|
Context* context = UIContext::instance();
|
|
|
|
|
ASSERT(context != NULL);
|
|
|
|
|
|
2015-04-21 03:27:09 +08:00
|
|
|
Site site = context->activeSite();
|
2013-03-12 07:29:45 +08:00
|
|
|
|
2015-04-21 03:27:09 +08:00
|
|
|
if (Palette* pal = site.palette())
|
2013-03-12 07:29:45 +08:00
|
|
|
set_current_palette(pal, false);
|
2009-06-11 23:11:11 +08:00
|
|
|
else
|
|
|
|
|
set_current_palette(NULL, false);
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2012-04-16 02:21:24 +08:00
|
|
|
// Invalidate the whole screen.
|
2012-06-18 09:02:54 +08:00
|
|
|
ui::Manager::getDefault()->invalidate();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2015-05-05 02:52:00 +08:00
|
|
|
// TODO remove app_rebuild_documents_tabs() and replace it by
|
|
|
|
|
// observable events in the document (so a tab can observe if the
|
|
|
|
|
// document is modified).
|
2011-03-23 08:11:25 +08:00
|
|
|
void app_rebuild_documents_tabs()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2014-11-07 08:04:32 +08:00
|
|
|
if (App::instance()->isGui())
|
2015-05-05 02:52:00 +08:00
|
|
|
App::instance()->getMainWindow()->getWorkspace()->updateTabs();
|
2015-05-19 04:08:01 +08:00
|
|
|
|
|
|
|
|
App::instance()->updateDisplayTitleBar();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2012-02-13 10:21:06 +08:00
|
|
|
PixelFormat app_get_current_pixel_format()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2009-06-11 23:11:11 +08:00
|
|
|
Context* context = UIContext::instance();
|
2010-08-04 10:33:44 +08:00
|
|
|
ASSERT(context != NULL);
|
2009-06-11 23:11:11 +08:00
|
|
|
|
2014-07-29 11:53:24 +08:00
|
|
|
Document* document = context->activeDocument();
|
2011-03-23 08:11:25 +08:00
|
|
|
if (document != NULL)
|
2014-07-30 12:28:15 +08:00
|
|
|
return document->sprite()->pixelFormat();
|
2008-03-23 02:43:56 +08:00
|
|
|
else
|
|
|
|
|
return IMAGE_RGB;
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2008-10-01 09:27:51 +08:00
|
|
|
void app_default_statusbar_message()
|
2008-03-01 03:29:49 +08:00
|
|
|
{
|
2012-07-10 00:20:58 +08:00
|
|
|
StatusBar::instance()
|
2010-03-29 11:00:25 +08:00
|
|
|
->setStatusText(250, "%s %s | %s", PACKAGE, VERSION, COPYRIGHT);
|
2008-03-01 03:29:49 +08:00
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2010-08-25 11:26:37 +08:00
|
|
|
int app_get_color_to_clear_layer(Layer* layer)
|
2008-03-27 22:29:33 +08:00
|
|
|
{
|
2014-05-08 11:30:36 +08:00
|
|
|
ASSERT(layer != NULL);
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-05-08 11:30:36 +08:00
|
|
|
app::Color color;
|
|
|
|
|
|
|
|
|
|
// The `Background' is erased with the `Background Color'
|
2014-08-08 07:19:31 +08:00
|
|
|
if (layer->isBackground()) {
|
|
|
|
|
if (ColorBar::instance())
|
|
|
|
|
color = ColorBar::instance()->getBgColor();
|
|
|
|
|
else
|
|
|
|
|
color = app::Color::fromRgb(0, 0, 0); // TODO get background color color from doc::Settings
|
|
|
|
|
}
|
2014-05-08 11:30:36 +08:00
|
|
|
else // All transparent layers are cleared with the mask color
|
|
|
|
|
color = app::Color::fromMask();
|
2008-03-27 22:29:33 +08:00
|
|
|
|
2010-08-25 11:26:37 +08:00
|
|
|
return color_utils::color_for_layer(color, layer);
|
2008-03-27 22:29:33 +08:00
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
|
} // namespace app
|