2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2016-01-30 20:13:46 +08:00
|
|
|
// Copyright (C) 2001-2016 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.
|
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
|
|
|
|
2011-07-27 10:25:02 +08:00
|
|
|
#include "app/check_update.h"
|
2016-05-31 06:03:28 +08:00
|
|
|
#include "app/cli/app_options.h"
|
|
|
|
|
#include "app/cli/cli_processor.h"
|
|
|
|
|
#include "app/cli/default_cli_delegate.h"
|
|
|
|
|
#include "app/cli/preview_cli_delegate.h"
|
2010-08-25 11:26:37 +08:00
|
|
|
#include "app/color_utils.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/commands.h"
|
|
|
|
|
#include "app/console.h"
|
2015-04-06 05:51:43 +08:00
|
|
|
#include "app/crash/data_recovery.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"
|
|
|
|
|
#include "app/gui_xml.h"
|
|
|
|
|
#include "app/ini_file.h"
|
|
|
|
|
#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"
|
2016-04-07 02:37:13 +08:00
|
|
|
#include "app/script/app_scripting.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"
|
2016-04-26 02:20:53 +08:00
|
|
|
#include "app/tools/active_tool.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#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"
|
2016-01-30 20:13:46 +08:00
|
|
|
#include "app/util/clipboard.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"
|
2011-03-23 08:11:25 +08:00
|
|
|
#include "base/unique_ptr.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"
|
2016-04-07 02:37:13 +08:00
|
|
|
#include "script/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
|
|
|
|
2016-02-25 00:21:37 +08:00
|
|
|
#ifdef ENABLE_STEAM
|
|
|
|
|
#include "steam/steam.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2016-04-26 02:20:53 +08:00
|
|
|
tools::ActiveToolManager m_activeToolManager;
|
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;
|
2016-01-30 20:13:46 +08:00
|
|
|
clipboard::ClipboardManager m_clipboardManager;
|
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
|
|
|
|
2016-02-27 04:08:42 +08:00
|
|
|
Modules(bool createLogInDesktop)
|
|
|
|
|
: m_loggerModule(createLogInDesktop)
|
2016-04-26 02:20:53 +08:00
|
|
|
, m_activeToolManager(&m_toolbox)
|
2016-02-27 04:08:42 +08:00
|
|
|
, m_recovery(nullptr) {
|
|
|
|
|
}
|
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
|
|
|
|
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)
|
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
|
|
|
{
|
2016-05-31 06:03:28 +08:00
|
|
|
m_isGui = options.startUI() && !options.previewCLI();
|
2015-04-23 06:28:24 +08:00
|
|
|
m_isShell = options.startShell();
|
|
|
|
|
if (m_isGui)
|
2015-09-01 21:18:47 +08:00
|
|
|
m_uiSystem.reset(new ui::UISystem);
|
2010-09-29 02:36:03 +08:00
|
|
|
|
2014-12-15 07:19:31 +08:00
|
|
|
m_coreModules = new CoreModules;
|
2016-02-27 03:13:54 +08:00
|
|
|
|
2016-02-27 04:08:42 +08:00
|
|
|
bool createLogInDesktop = false;
|
2016-02-27 03:13:54 +08:00
|
|
|
switch (options.verboseLevel()) {
|
|
|
|
|
case AppOptions::kNoVerbose:
|
|
|
|
|
base::set_log_level(ERROR);
|
|
|
|
|
break;
|
|
|
|
|
case AppOptions::kVerbose:
|
|
|
|
|
base::set_log_level(INFO);
|
|
|
|
|
break;
|
|
|
|
|
case AppOptions::kHighlyVerbose:
|
|
|
|
|
base::set_log_level(VERBOSE);
|
2016-02-27 04:08:42 +08:00
|
|
|
createLogInDesktop = true;
|
2016-02-27 03:13:54 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-27 04:08:42 +08:00
|
|
|
m_modules = new Modules(createLogInDesktop);
|
2010-09-19 04:36:21 +08:00
|
|
|
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
2015-12-23 07:04:44 +08:00
|
|
|
m_brushes.reset(new AppBrushes);
|
2011-08-07 01:36:40 +08:00
|
|
|
|
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();
|
|
|
|
|
|
2014-08-20 20:16:59 +08:00
|
|
|
if (isPortable())
|
2015-08-29 07:48:49 +08:00
|
|
|
LOG("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
|
|
|
|
|
if (isGui()) {
|
2015-08-29 07:48:49 +08:00
|
|
|
LOG("GUI mode\n");
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-11 06:51:14 +08:00
|
|
|
// Setup the GUI cursor and redraw screen
|
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
ui::set_use_native_cursors(preferences().cursor.useNativeCursor());
|
|
|
|
|
ui::set_mouse_cursor_scale(preferences().cursor.cursorScale());
|
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
|
2015-08-29 07:48:49 +08:00
|
|
|
LOG("Processing options...\n");
|
2016-05-31 06:03:28 +08:00
|
|
|
{
|
|
|
|
|
base::UniquePtr<CliDelegate> delegate;
|
|
|
|
|
if (options.previewCLI())
|
|
|
|
|
delegate.reset(new PreviewCliDelegate);
|
|
|
|
|
else
|
|
|
|
|
delegate.reset(new DefaultCliDelegate);
|
|
|
|
|
|
|
|
|
|
CliProcessor cli(delegate.get(), options);
|
|
|
|
|
cli.process();
|
2013-12-09 07:19:32 +08:00
|
|
|
}
|
2016-04-12 06:15:42 +08:00
|
|
|
|
|
|
|
|
she::instance()->finishLaunching();
|
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()) {
|
2016-02-29 19:32:10 +08:00
|
|
|
// Initialize Steam API
|
2016-02-25 00:21:37 +08:00
|
|
|
#ifdef ENABLE_STEAM
|
|
|
|
|
steam::SteamAPI steam;
|
2016-06-08 01:47:59 +08:00
|
|
|
if (steam.initialized())
|
|
|
|
|
she::instance()->activateApp();
|
2016-02-25 00:21:37 +08:00
|
|
|
#endif
|
|
|
|
|
|
2016-07-01 22:21:40 +08:00
|
|
|
#if _DEBUG
|
|
|
|
|
// On OS X, when we compile Aseprite on Debug mode, we're using it
|
|
|
|
|
// outside an app bundle, so we must active the app explicitly.
|
|
|
|
|
she::instance()->activateApp();
|
|
|
|
|
#endif
|
|
|
|
|
|
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
|
2015-07-30 05:12:35 +08:00
|
|
|
ui::Manager::getDefault()->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) {
|
2016-05-31 06:03:28 +08:00
|
|
|
script::StdoutEngineDelegate delegate;
|
2015-08-26 22:30:33 +08:00
|
|
|
AppScripting engine(&delegate);
|
2016-04-07 03:56:10 +08:00
|
|
|
engine.printLastResult();
|
2015-06-20 07:01:30 +08:00
|
|
|
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
|
2015-08-29 07:48:49 +08:00
|
|
|
LOG("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
|
|
|
|
2015-12-23 07:04:44 +08:00
|
|
|
// Save brushes
|
|
|
|
|
m_brushes.reset(nullptr);
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-04-23 00:19:06 +08:00
|
|
|
tools::ToolBox* App::toolBox() 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
|
|
|
|
|
{
|
2016-04-26 02:20:53 +08:00
|
|
|
return m_modules->m_activeToolManager.activeTool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tools::ActiveToolManager* App::activeToolManager() const
|
|
|
|
|
{
|
|
|
|
|
return &m_modules->m_activeToolManager;
|
2015-05-19 03:53:25 +08:00
|
|
|
}
|
|
|
|
|
|
2016-04-23 00:19:06 +08:00
|
|
|
RecentFiles* App::recentFiles() const
|
2010-09-18 11:28:24 +08:00
|
|
|
{
|
|
|
|
|
ASSERT(m_modules != NULL);
|
|
|
|
|
return &m_modules->m_recent_files;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-23 00:19:06 +08:00
|
|
|
Workspace* App::workspace() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainWindow)
|
|
|
|
|
return m_mainWindow->getWorkspace();
|
|
|
|
|
else
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContextBar* App::contextBar() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainWindow)
|
|
|
|
|
return m_mainWindow->getContextBar();
|
|
|
|
|
else
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Timeline* App::timeline() const
|
|
|
|
|
{
|
|
|
|
|
if (m_mainWindow)
|
|
|
|
|
return m_mainWindow->getTimeline();
|
|
|
|
|
else
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
2016-02-13 12:33:43 +08:00
|
|
|
title += docView->document()->name();
|
2014-09-03 11:39:15 +08:00
|
|
|
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
|
|
|
{
|
2015-09-11 03:44:33 +08:00
|
|
|
if (App::instance()->isGui()) {
|
2016-04-23 00:19:06 +08:00
|
|
|
App::instance()->workspace()->updateTabs();
|
2015-09-11 03:44:33 +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
|