2013-08-09 08:01:20 +08:00
|
|
|
/* Aseprite
|
2013-01-27 23:13:13 +08:00
|
|
|
* Copyright (C) 2001-2013 David Capello
|
2007-09-19 07:57:02 +08:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
|
|
|
|
|
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"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/commands.h"
|
|
|
|
|
#include "app/commands/params.h"
|
|
|
|
|
#include "app/console.h"
|
2012-08-23 08:05:02 +08:00
|
|
|
#include "app/data_recovery.h"
|
2013-12-09 07:19:32 +08:00
|
|
|
#include "app/document_exporter.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/document_location.h"
|
|
|
|
|
#include "app/file/file.h"
|
|
|
|
|
#include "app/file/file_formats_manager.h"
|
2014-08-22 10:39:20 +08:00
|
|
|
#include "app/file/palette_file.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/file_system.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"
|
|
|
|
|
#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"
|
2014-08-11 06:51:14 +08:00
|
|
|
#include "app/settings/settings.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"
|
|
|
|
|
#include "app/ui/editor/editor.h"
|
|
|
|
|
#include "app/ui/editor/editor_view.h"
|
|
|
|
|
#include "app/ui/main_window.h"
|
|
|
|
|
#include "app/ui/status_bar.h"
|
|
|
|
|
#include "app/ui/tabs.h"
|
|
|
|
|
#include "app/ui/toolbar.h"
|
|
|
|
|
#include "app/ui_context.h"
|
|
|
|
|
#include "app/util/boundary.h"
|
|
|
|
|
#include "app/util/render.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"
|
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"
|
2007-09-19 07:57:02 +08:00
|
|
|
#include "raster/image.h"
|
2008-03-27 22:29:33 +08:00
|
|
|
#include "raster/layer.h"
|
2008-03-23 02:43:56 +08:00
|
|
|
#include "raster/palette.h"
|
2007-09-19 07:57:02 +08:00
|
|
|
#include "raster/sprite.h"
|
2012-09-09 07:10:48 +08:00
|
|
|
#include "scripting/engine.h"
|
2014-06-18 11:53:15 +08:00
|
|
|
#include "she/error.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
|
|
|
#include <memory>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
using namespace ui;
|
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
class App::Modules {
|
2009-10-14 22:09:59 +08:00
|
|
|
public:
|
2012-09-03 04:42:32 +08:00
|
|
|
ConfigModule m_configModule;
|
|
|
|
|
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;
|
2012-08-23 08:05:02 +08:00
|
|
|
app::DataRecovery m_recovery;
|
2012-09-09 07:10:48 +08:00
|
|
|
scripting::Engine m_scriptingEngine;
|
2012-08-23 08:05:02 +08:00
|
|
|
|
2012-09-09 07:10:48 +08:00
|
|
|
Modules(bool console, bool verbose)
|
2012-09-06 08:14:42 +08:00
|
|
|
: m_loggerModule(verbose)
|
2012-09-03 04:42:32 +08:00
|
|
|
, m_recovery(&m_ui_context) {
|
2012-08-23 08:05:02 +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
|
|
|
|
2010-03-01 08:09:46 +08:00
|
|
|
// Initializes the application loading the modules, setting the
|
|
|
|
|
// graphics mode, loading the configuration and resources, etc.
|
2012-09-06 08:14:42 +08:00
|
|
|
App::App(int argc, const char* argv[])
|
2012-09-03 04:42:32 +08:00
|
|
|
: 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;
|
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
AppOptions options(argc, argv);
|
2010-09-29 02:36:03 +08:00
|
|
|
|
2012-09-09 07:10:48 +08:00
|
|
|
m_modules = new Modules(!options.startUI(), options.verbose());
|
2012-09-06 08:14:42 +08:00
|
|
|
m_isGui = options.startUI();
|
2012-09-09 07:10:48 +08:00
|
|
|
m_isShell = options.startShell();
|
2010-09-19 04:36:21 +08:00
|
|
|
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
2012-09-06 08:14:42 +08:00
|
|
|
m_files = options.files();
|
2011-08-07 01:36:40 +08:00
|
|
|
|
2013-12-09 07:19:32 +08:00
|
|
|
if (options.hasExporterParams()) {
|
|
|
|
|
m_exporter.reset(new DocumentExporter);
|
|
|
|
|
|
|
|
|
|
m_exporter->setDataFilename(options.data());
|
|
|
|
|
m_exporter->setTextureFilename(options.sheet());
|
|
|
|
|
m_exporter->setScale(options.scale());
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
- 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
|
|
|
// init editor cursor
|
|
|
|
|
Editor::editor_cursor_init();
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2010-04-26 08:29:50 +08:00
|
|
|
// Load RenderEngine configuration
|
|
|
|
|
RenderEngine::loadConfig();
|
2014-08-20 20:16:59 +08:00
|
|
|
if (isPortable())
|
|
|
|
|
PRINTF("Running in portable mode\n");
|
2010-04-26 08:29:50 +08:00
|
|
|
|
2012-09-06 08:14:42 +08:00
|
|
|
// Default palette.
|
2014-04-21 06:53:27 +08:00
|
|
|
std::string palFile(!options.paletteFileName().empty() ?
|
|
|
|
|
options.paletteFileName():
|
|
|
|
|
std::string(get_config_string("GfxMode", "Palette", "")));
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-04-20 07:52:56 +08:00
|
|
|
if (palFile.empty()) {
|
|
|
|
|
// Try to use a default pixel art palette.
|
|
|
|
|
ResourceFinder rf;
|
|
|
|
|
rf.includeDataDir("palettes/db32.gpl");
|
|
|
|
|
if (rf.findFirst())
|
|
|
|
|
palFile = rf.filename();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 04:01:28 +08:00
|
|
|
if (!palFile.empty()) {
|
|
|
|
|
PRINTF("Loading custom palette file: %s\n", palFile.c_str());
|
|
|
|
|
|
2014-08-22 10:39:20 +08:00
|
|
|
base::UniquePtr<Palette> pal(load_palette(palFile.c_str()));
|
2014-04-18 00:48:33 +08:00
|
|
|
if (pal.get() != NULL) {
|
|
|
|
|
set_default_palette(pal.get());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
PRINTF("Error loading custom palette file\n");
|
|
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 07:10:48 +08:00
|
|
|
// Set system palette to the default one.
|
2010-01-31 00:43:13 +08:00
|
|
|
set_current_palette(NULL, true);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
int App::run()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2010-09-19 04:36:21 +08:00
|
|
|
// Initialize GUI interface
|
|
|
|
|
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(
|
|
|
|
|
UIContext::instance()->settings()->experimental()->useNativeCursor());
|
|
|
|
|
|
2012-08-11 10:14:54 +08:00
|
|
|
jmouse_set_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
|
|
|
|
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();
|
2013-11-20 13:12:18 +08:00
|
|
|
|
|
|
|
|
// 2013-11-19 - JRM - Force setting active view to NULL, workaround for setting
|
|
|
|
|
// window title to proper devault value. (Issue #285)
|
|
|
|
|
UIContext::instance()->setActiveView(NULL);
|
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
|
|
|
|
2010-03-26 19:45:13 +08:00
|
|
|
{
|
2013-12-09 07:19:32 +08:00
|
|
|
UIContext* context = UIContext::instance();
|
2010-03-26 19:45:13 +08:00
|
|
|
Console console;
|
2014-08-14 11:40:01 +08:00
|
|
|
for (const std::string& filename : m_files) {
|
2012-09-06 08:14:42 +08:00
|
|
|
// Load the sprite
|
2014-08-14 11:40:01 +08:00
|
|
|
Document* document = load_document(context, filename.c_str());
|
2012-09-06 08:14:42 +08:00
|
|
|
if (!document) {
|
|
|
|
|
if (!isGui())
|
2014-08-14 11:40:01 +08:00
|
|
|
console.printf("Error loading file \"%s\"\n", filename.c_str());
|
2012-09-06 08:14:42 +08:00
|
|
|
}
|
|
|
|
|
else {
|
2013-12-09 07:19:32 +08:00
|
|
|
// 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())
|
2014-08-14 11:40:01 +08:00
|
|
|
getRecentFiles()->addRecentFile(filename.c_str());
|
2013-12-09 07:19:32 +08:00
|
|
|
|
|
|
|
|
// Add the document to the exporter.
|
|
|
|
|
if (m_exporter != NULL)
|
|
|
|
|
m_exporter->addDocument(document);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 07:19:32 +08:00
|
|
|
// Export
|
|
|
|
|
if (m_exporter != NULL) {
|
|
|
|
|
PRINTF("Exporting sheet...\n");
|
|
|
|
|
|
|
|
|
|
m_exporter->exportSheet();
|
|
|
|
|
m_exporter.reset(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
2012-08-24 10:51:27 +08:00
|
|
|
app::CheckUpdateThreadLauncher checkUpdate;
|
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
|
|
|
|
2013-01-21 05:40:37 +08:00
|
|
|
// Destroy all documents in the UIContext.
|
2014-07-29 11:53:24 +08:00
|
|
|
const doc::Documents& docs = m_modules->m_ui_context.documents();
|
2014-07-29 12:29:04 +08:00
|
|
|
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;
|
|
|
|
|
}
|
2013-01-21 05:40:37 +08:00
|
|
|
|
2012-07-10 00:20:58 +08:00
|
|
|
// Destroy the window.
|
|
|
|
|
m_mainWindow.reset(NULL);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
2012-09-09 07:10:48 +08:00
|
|
|
// Start shell to execute scripts.
|
|
|
|
|
else if (m_isShell) {
|
|
|
|
|
m_systemConsole.prepareShell();
|
|
|
|
|
|
|
|
|
|
if (m_modules->m_scriptingEngine.supportEval()) {
|
|
|
|
|
Shell shell;
|
|
|
|
|
shell.run(m_modules->m_scriptingEngine);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-29 11:15:33 +08:00
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
return 0;
|
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.
|
2010-01-27 10:52:30 +08:00
|
|
|
Editor::editor_cursor_exit();
|
2009-10-14 22:09:59 +08:00
|
|
|
boundary_exit();
|
|
|
|
|
|
2010-01-29 11:15:33 +08:00
|
|
|
delete m_legacy;
|
|
|
|
|
delete m_modules;
|
2011-01-23 07:30:44 +08:00
|
|
|
|
|
|
|
|
// Destroy the loaded gui.xml file.
|
|
|
|
|
delete GuiXml::instance();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2009-10-14 22:09:59 +08:00
|
|
|
m_instance = NULL;
|
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
std::string ini_file = get_config_file();
|
|
|
|
|
app::ResourceFinder rf;
|
|
|
|
|
rf.includeBinDir("aseprite.ini");
|
|
|
|
|
return (ini_file == rf.defaultFilename());
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-18 11:28:24 +08:00
|
|
|
RecentFiles* App::getRecentFiles() const
|
|
|
|
|
{
|
|
|
|
|
ASSERT(m_modules != NULL);
|
|
|
|
|
return &m_modules->m_recent_files;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
2014-07-29 11:53:24 +08:00
|
|
|
DocumentLocation location = context->activeLocation();
|
2013-03-12 07:29:45 +08:00
|
|
|
|
|
|
|
|
if (Palette* pal = location.palette())
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2011-03-23 08:11:25 +08:00
|
|
|
void app_rebuild_documents_tabs()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2013-01-21 05:40:37 +08:00
|
|
|
App::instance()->getMainWindow()->getTabsBar()->updateTabsText();
|
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
|