From 256a6bc2ea6ec2cc0d6c3256915b0fea7a5d960b Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 3 Jan 2019 09:07:56 -0300 Subject: [PATCH] Add the AppMod to modify the main window --- src/app/app.cpp | 18 +++++++++++------- src/app/app.h | 7 +++++-- src/app/app_mod.h | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 src/app/app_mod.h diff --git a/src/app/app.cpp b/src/app/app.cpp index df047f9f3..45b8f03c0 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018 Igara Studio S.A. +// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -11,6 +11,7 @@ #include "app/app.h" +#include "app/app_mod.h" #include "app/check_update.h" #include "app/cli/app_options.h" #include "app/cli/cli_processor.h" @@ -174,12 +175,13 @@ public: }; -App* App::m_instance = NULL; +App* App::m_instance = nullptr; -App::App() - : m_coreModules(NULL) - , m_modules(NULL) - , m_legacy(NULL) +App::App(AppMod* mod) + : m_mod(mod) + , m_coreModules(nullptr) + , m_modules(nullptr) + , m_legacy(nullptr) , m_isGui(false) , m_isShell(false) #ifdef ENABLE_UI @@ -261,8 +263,10 @@ void App::initialize(const AppOptions& options) ui::Manager::getDefault()->invalidate(); - // Create the main window and show it. + // Create the main window. m_mainWindow.reset(new MainWindow); + if (m_mod) + m_mod->modMainWindow(m_mainWindow.get()); // Default status of the main window. app_rebuild_documents_tabs(); diff --git a/src/app/app.h b/src/app/app.h index f33bb3175..8ed5c6bdb 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018 Igara Studio S.A. +// Copyright (C) 2018-2019 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -37,6 +37,7 @@ namespace app { } #endif + class AppMod; class AppOptions; class BackupIndicator; class Context; @@ -67,7 +68,7 @@ namespace app { class App { public: - App(); + App(AppMod* mod = nullptr); ~App(); static App* instance() { return m_instance; } @@ -86,6 +87,7 @@ namespace app { void initialize(const AppOptions& options); void run(); + AppMod* mod() const { return m_mod; } tools::ToolBox* toolBox() const; tools::Tool* activeTool() const; tools::ActiveToolManager* activeToolManager() const; @@ -127,6 +129,7 @@ namespace app { static App* m_instance; + AppMod* m_mod; std::unique_ptr m_uiSystem; CoreModules* m_coreModules; Modules* m_modules; diff --git a/src/app/app_mod.h b/src/app/app_mod.h new file mode 100644 index 000000000..07b053f6d --- /dev/null +++ b/src/app/app_mod.h @@ -0,0 +1,22 @@ +// Aseprite +// Copyright (C) 2019 Igara Studio S.A. +// +// This program is distributed under the terms of +// the End-User License Agreement for Aseprite. + +#ifndef APP_APP_MOD_H_INCLUDED +#define APP_APP_MOD_H_INCLUDED +#pragma once + +namespace app { + class MainWindow; + + class AppMod { + public: + virtual ~AppMod() { } + virtual void modMainWindow(MainWindow* mainWindow) = 0; + }; + +} // namespace app + +#endif