[aseprite] 53/128: Add properties in App to access directly to timeline/contextBar/workspace

Tobias Hansen thansen at moszumanska.debian.org
Mon May 9 21:24:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 5f90ef7c9bfad12810a7d55150b80d6ece71c0da
Author: David Capello <davidcapello at gmail.com>
Date:   Fri Apr 22 13:19:06 2016 -0300

    Add properties in App to access directly to timeline/contextBar/workspace
---
 src/app/app.cpp                              | 32 ++++++++++++++++++++++++----
 src/app/app.h                                | 14 ++++++++----
 src/app/app_menus.cpp                        |  7 +++---
 src/app/commands/cmd_add_color.cpp           |  2 +-
 src/app/commands/cmd_advanced_mode.cpp       |  4 ++--
 src/app/commands/cmd_cel_properties.cpp      |  7 +++---
 src/app/commands/cmd_change_brush.cpp        |  5 ++---
 src/app/commands/cmd_clear_cel.cpp           |  5 ++---
 src/app/commands/cmd_close_file.cpp          |  9 ++++----
 src/app/commands/cmd_copy_cel.cpp            |  7 +++---
 src/app/commands/cmd_developer_console.cpp   |  4 ++--
 src/app/commands/cmd_discard_brush.cpp       |  7 +++---
 src/app/commands/cmd_duplicate_view.cpp      |  7 +++---
 src/app/commands/cmd_exit.cpp                |  4 ++--
 src/app/commands/cmd_export_sprite_sheet.cpp |  9 ++++----
 src/app/commands/cmd_flip.cpp                |  3 +--
 src/app/commands/cmd_frame_properties.cpp    |  5 ++---
 src/app/commands/cmd_goto_tab.cpp            | 11 +++++-----
 src/app/commands/cmd_home.cpp                |  6 +++---
 src/app/commands/cmd_layer_properties.cpp    |  5 ++---
 src/app/commands/cmd_link_cels.cpp           |  7 +++---
 src/app/commands/cmd_mask_content.cpp        |  4 ++--
 src/app/commands/cmd_move_cel.cpp            |  7 +++---
 src/app/commands/cmd_new_brush.cpp           |  8 +++----
 src/app/commands/cmd_new_frame.cpp           |  4 ++--
 src/app/commands/cmd_new_frame_tag.cpp       |  7 +++---
 src/app/commands/cmd_new_layer.cpp           |  4 ++--
 src/app/commands/cmd_open_file.cpp           |  6 +++---
 src/app/commands/cmd_remove_frame.cpp        |  5 ++---
 src/app/commands/cmd_remove_frame_tag.cpp    |  5 ++---
 src/app/commands/cmd_remove_layer.cpp        |  5 ++---
 src/app/commands/cmd_reverse_frames.cpp      |  8 +++----
 src/app/commands/cmd_rotate.cpp              |  7 +++---
 src/app/commands/cmd_save_file.cpp           |  4 ++--
 src/app/commands/cmd_set_ink_type.cpp        |  6 ++----
 src/app/commands/cmd_set_loop_section.cpp    |  7 +++---
 src/app/commands/cmd_set_same_ink.cpp        |  4 ++--
 src/app/commands/cmd_switch_colors.cpp       |  6 ++----
 src/app/commands/cmd_timeline.cpp            | 16 +++++++-------
 src/app/commands/cmd_toggle_preview.cpp      |  6 +++---
 src/app/commands/cmd_unlink_cel.cpp          |  5 ++---
 src/app/modules/gui.cpp                      |  6 +++---
 src/app/ui/brush_popup.cpp                   |  9 +++-----
 src/app/ui/context_bar.cpp                   |  6 +++---
 src/app/ui/editor/brush_preview.cpp          |  4 +---
 src/app/ui/editor/drawing_state.cpp          |  2 +-
 src/app/ui/editor/editor.cpp                 | 20 ++++++++---------
 src/app/ui/editor/moving_cel_state.cpp       |  2 +-
 src/app/ui/editor/moving_pixels_state.cpp    |  6 +++---
 src/app/ui/editor/select_box_state.cpp       |  6 +++---
 src/app/ui/editor/standby_state.cpp          |  2 +-
 src/app/ui/editor/tool_loop_impl.cpp         | 10 ++++-----
 src/app/ui/file_selector.cpp                 |  4 ++--
 src/app/ui/home_view.cpp                     |  8 +++----
 src/app/ui/keyboard_shortcuts.cpp            |  6 +++---
 src/app/ui/recent_listbox.cpp                |  8 +++----
 src/app/ui/toolbar.cpp                       | 28 ++++++++++++------------
 src/app/ui_context.cpp                       | 22 +++++++------------
 src/app/util/clipboard.cpp                   |  6 ++----
 59 files changed, 211 insertions(+), 228 deletions(-)

diff --git a/src/app/app.cpp b/src/app/app.cpp
index dfe0e45..c028111 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -785,7 +785,7 @@ bool App::isPortable()
   return *is_portable;
 }
 
-tools::ToolBox* App::getToolBox() const
+tools::ToolBox* App::toolBox() const
 {
   ASSERT(m_modules != NULL);
   return &m_modules->m_toolbox;
@@ -793,15 +793,39 @@ tools::ToolBox* App::getToolBox() const
 
 tools::Tool* App::activeTool() const
 {
-  return getToolBox()->getToolById(preferences().toolBox.activeTool());
+  return toolBox()->getToolById(preferences().toolBox.activeTool());
 }
 
-RecentFiles* App::getRecentFiles() const
+RecentFiles* App::recentFiles() const
 {
   ASSERT(m_modules != NULL);
   return &m_modules->m_recent_files;
 }
 
+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;
+}
+
 Preferences& App::preferences() const
 {
   return m_coreModules->m_preferences;
@@ -856,7 +880,7 @@ void app_refresh_screen()
 void app_rebuild_documents_tabs()
 {
   if (App::instance()->isGui()) {
-    App::instance()->getMainWindow()->getWorkspace()->updateTabs();
+    App::instance()->workspace()->updateTabs();
     App::instance()->updateDisplayTitleBar();
   }
 }
diff --git a/src/app/app.h b/src/app/app.h
index d0953ff..6f3ee5e 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -28,6 +28,7 @@ namespace ui {
 namespace app {
 
   class AppOptions;
+  class ContextBar;
   class Document;
   class DocumentExporter;
   class INotificationDelegate;
@@ -37,6 +38,8 @@ namespace app {
   class MainWindow;
   class Preferences;
   class RecentFiles;
+  class Timeline;
+  class Workspace;
 
   namespace tools {
     class Tool;
@@ -64,10 +67,13 @@ namespace app {
     void initialize(const AppOptions& options);
     void run();
 
-    tools::ToolBox* getToolBox() const;
+    tools::ToolBox* toolBox() const;
     tools::Tool* activeTool() const;
-    RecentFiles* getRecentFiles() const;
-    MainWindow* getMainWindow() const { return m_mainWindow; }
+    RecentFiles* recentFiles() const;
+    MainWindow* mainWindow() const { return m_mainWindow; }
+    Workspace* workspace() const;
+    ContextBar* contextBar() const;
+    Timeline* timeline() const;
     Preferences& preferences() const;
 
     AppBrushes& brushes() {
diff --git a/src/app/app_menus.cpp b/src/app/app_menus.cpp
index 8403c9d..1cc8dc2 100644
--- a/src/app/app_menus.cpp
+++ b/src/app/app_menus.cpp
@@ -59,7 +59,7 @@ AppMenus::AppMenus()
   : m_recentListMenuitem(NULL)
 {
   m_recentFilesConn =
-    App::instance()->getRecentFiles()->Changed.connect(
+    App::instance()->recentFiles()->Changed.connect(
       base::Bind(&AppMenus::rebuildRecentList, this));
 }
 
@@ -138,9 +138,8 @@ bool AppMenus::rebuildRecentList()
     submenu = new Menu();
     list_menuitem->setSubmenu(submenu);
 
-    RecentFiles::const_iterator it = App::instance()->getRecentFiles()->files_begin();
-    RecentFiles::const_iterator end = App::instance()->getRecentFiles()->files_end();
-
+    auto it = App::instance()->recentFiles()->files_begin();
+    auto end = App::instance()->recentFiles()->files_end();
     if (it != end) {
       Params params;
 
diff --git a/src/app/commands/cmd_add_color.cpp b/src/app/commands/cmd_add_color.cpp
index 17c4f37..6cf253c 100644
--- a/src/app/commands/cmd_add_color.cpp
+++ b/src/app/commands/cmd_add_color.cpp
@@ -21,8 +21,8 @@
 #include "app/ui/color_bar.h"
 #include "app/ui/context_bar.h"
 #include "app/ui/editor/editor.h"
-#include "app/ui/main_window.h"
 #include "doc/palette.h"
+#include "ui/manager.h"
 
 namespace app {
 
diff --git a/src/app/commands/cmd_advanced_mode.cpp b/src/app/commands/cmd_advanced_mode.cpp
index 9114cf3..fc053b0 100644
--- a/src/app/commands/cmd_advanced_mode.cpp
+++ b/src/app/commands/cmd_advanced_mode.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -43,7 +43,7 @@ AdvancedModeCommand::AdvancedModeCommand()
 void AdvancedModeCommand::onExecute(Context* context)
 {
   // Switch advanced mode.
-  MainWindow* mainWindow = App::instance()->getMainWindow();
+  MainWindow* mainWindow = App::instance()->mainWindow();
   MainWindow::Mode oldMode = mainWindow->getMode();
   MainWindow::Mode newMode = oldMode;
 
diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp
index 1cd879b..5332288 100644
--- a/src/app/commands/cmd_cel_properties.cpp
+++ b/src/app/commands/cmd_cel_properties.cpp
@@ -19,7 +19,6 @@
 #include "app/document_range.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/ui/user_data_popup.h"
 #include "app/ui_context.h"
@@ -78,7 +77,7 @@ public:
     m_timer.stop();
     m_document = doc;
     m_cel = cel;
-    m_range = App::instance()->getMainWindow()->getTimeline()->range();
+    m_range = App::instance()->timeline()->range();
 
     if (m_document)
       m_document->addObserver(this);
@@ -182,7 +181,7 @@ private:
 
             // Redraw timeline because the cel's user data/color
             // might have changed.
-            App::instance()->getMainWindow()->getTimeline()->invalidate();
+            App::instance()->timeline()->invalidate();
           }
         }
         else if (m_range.enabled()) {
@@ -200,7 +199,7 @@ private:
 
                 // Redraw timeline because the cel's user data/color
                 // might have changed.
-                App::instance()->getMainWindow()->getTimeline()->invalidate();
+                App::instance()->timeline()->invalidate();
               }
             }
           }
diff --git a/src/app/commands/cmd_change_brush.cpp b/src/app/commands/cmd_change_brush.cpp
index 3eaf68f..33c2818 100644
--- a/src/app/commands/cmd_change_brush.cpp
+++ b/src/app/commands/cmd_change_brush.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -18,7 +18,6 @@
 #include "app/pref/preferences.h"
 #include "app/tools/tool.h"
 #include "app/ui/context_bar.h"
-#include "app/ui/main_window.h"
 #include "base/convert_to.h"
 #include "doc/brush.h"
 
@@ -98,7 +97,7 @@ void ChangeBrushCommand::onExecute(Context* context)
         brush.angle(brush.angle()-1);
       break;
     case CustomBrush:
-      App::instance()->getMainWindow()->getContextBar()
+      App::instance()->contextBar()
         ->setActiveBrushBySlot(m_slot);
       break;
   }
diff --git a/src/app/commands/cmd_clear_cel.cpp b/src/app/commands/cmd_clear_cel.cpp
index 21a8425..c20d835 100644
--- a/src/app/commands/cmd_clear_cel.cpp
+++ b/src/app/commands/cmd_clear_cel.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/document_api.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/timeline.h"
 #include "doc/cel.h"
@@ -55,7 +54,7 @@ void ClearCelCommand::onExecute(Context* context)
     Transaction transaction(writer.context(), "Clear Cel");
 
     // TODO the range of selected frames should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     if (range.enabled()) {
       Sprite* sprite = writer.sprite();
 
diff --git a/src/app/commands/cmd_close_file.cpp b/src/app/commands/cmd_close_file.cpp
index 5425a52..93095d8 100644
--- a/src/app/commands/cmd_close_file.cpp
+++ b/src/app/commands/cmd_close_file.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -16,7 +16,6 @@
 #include "app/document_access.h"
 #include "app/modules/editors.h"
 #include "app/ui/document_view.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/workspace.h"
 #include "app/ui_context.h"
@@ -42,13 +41,13 @@ public:
 protected:
 
   bool onEnabled(Context* context) override {
-    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+    Workspace* workspace = App::instance()->workspace();
     WorkspaceView* view = workspace->activeView();
     return (view != nullptr);
   }
 
   void onExecute(Context* context) override {
-    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+    Workspace* workspace = App::instance()->workspace();
     WorkspaceView* view = workspace->activeView();
     if (view)
       workspace->closeView(view);
@@ -68,7 +67,7 @@ public:
 protected:
 
   void onExecute(Context* context) override {
-    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+    Workspace* workspace = App::instance()->workspace();
 
     // Collect all document views
     DocumentViews docViews;
diff --git a/src/app/commands/cmd_copy_cel.cpp b/src/app/commands/cmd_copy_cel.cpp
index a6f6366..31b18ca 100644
--- a/src/app/commands/cmd_copy_cel.cpp
+++ b/src/app/commands/cmd_copy_cel.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -13,7 +13,6 @@
 #include "app/commands/command.h"
 #include "app/context_access.h"
 #include "app/ui/timeline.h"
-#include "app/ui/main_window.h"
 #include "ui/base.h"
 
 namespace app {
@@ -37,12 +36,12 @@ CopyCelCommand::CopyCelCommand()
 
 bool CopyCelCommand::onEnabled(Context* context)
 {
-  return App::instance()->getMainWindow()->getTimeline()->isMovingCel();
+  return App::instance()->timeline()->isMovingCel();
 }
 
 void CopyCelCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->getTimeline()->dropRange(Timeline::kCopy);
+  App::instance()->timeline()->dropRange(Timeline::kCopy);
 }
 
 Command* CommandFactory::createCopyCelCommand()
diff --git a/src/app/commands/cmd_developer_console.cpp b/src/app/commands/cmd_developer_console.cpp
index 48b7ce8..27b6e6c 100644
--- a/src/app/commands/cmd_developer_console.cpp
+++ b/src/app/commands/cmd_developer_console.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -39,7 +39,7 @@ DeveloperConsoleCommand::~DeveloperConsoleCommand()
 
 void DeveloperConsoleCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->showDevConsole();
+  App::instance()->mainWindow()->showDevConsole();
 }
 
 Command* CommandFactory::createDeveloperConsoleCommand()
diff --git a/src/app/commands/cmd_discard_brush.cpp b/src/app/commands/cmd_discard_brush.cpp
index ff51eec..6085d23 100644
--- a/src/app/commands/cmd_discard_brush.cpp
+++ b/src/app/commands/cmd_discard_brush.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/context_access.h"
 #include "app/tools/tool_box.h"
 #include "app/ui/context_bar.h"
-#include "app/ui/main_window.h"
 #include "app/ui_context.h"
 #include "app/util/new_image_from_mask.h"
 
@@ -40,13 +39,13 @@ DiscardBrushCommand::DiscardBrushCommand()
 
 bool DiscardBrushCommand::onEnabled(Context* context)
 {
-  ContextBar* ctxBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* ctxBar = App::instance()->contextBar();
   return (ctxBar->activeBrush()->type() == kImageBrushType);
 }
 
 void DiscardBrushCommand::onExecute(Context* context)
 {
-  ContextBar* ctxBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* ctxBar = App::instance()->contextBar();
   ctxBar->discardActiveBrush();
 }
 
diff --git a/src/app/commands/cmd_duplicate_view.cpp b/src/app/commands/cmd_duplicate_view.cpp
index b2ed331..39d0970 100644
--- a/src/app/commands/cmd_duplicate_view.cpp
+++ b/src/app/commands/cmd_duplicate_view.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -12,7 +12,6 @@
 #include "app/commands/command.h"
 
 #include "app/app.h"
-#include "app/ui/main_window.h"
 #include "app/ui/workspace.h"
 
 #include <cstdio>
@@ -40,14 +39,14 @@ DuplicateViewCommand::DuplicateViewCommand()
 
 bool DuplicateViewCommand::onEnabled(Context* context)
 {
-  Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+  Workspace* workspace = App::instance()->workspace();
   WorkspaceView* view = workspace->activeView();
   return (view != nullptr);
 }
 
 void DuplicateViewCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->getWorkspace()->duplicateActiveView();
+  App::instance()->workspace()->duplicateActiveView();
 }
 
 Command* CommandFactory::createDuplicateViewCommand()
diff --git a/src/app/commands/cmd_exit.cpp b/src/app/commands/cmd_exit.cpp
index fb8c3c9..d7508ca 100644
--- a/src/app/commands/cmd_exit.cpp
+++ b/src/app/commands/cmd_exit.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -53,7 +53,7 @@ void ExitCommand::onExecute(Context* context)
   }
 
   // Close the window
-  App::instance()->getMainWindow()->closeWindow(NULL);
+  App::instance()->mainWindow()->closeWindow(NULL);
 }
 
 Command* CommandFactory::createExitCommand()
diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp
index b199705..78c7a01 100644
--- a/src/app/commands/cmd_export_sprite_sheet.cpp
+++ b/src/app/commands/cmd_export_sprite_sheet.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -21,7 +21,6 @@
 #include "app/modules/editors.h"
 #include "app/pref/preferences.h"
 #include "app/ui/editor/editor.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/timeline.h"
 #include "base/bind.h"
@@ -163,7 +162,7 @@ namespace {
   public:
     static frame_t From() {
       // TODO the range of selected frames should be in doc::Site.
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled()) {
         return range.frameBegin();
       }
@@ -175,7 +174,7 @@ namespace {
     }
 
     static frame_t To() {
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled()) {
         return range.frameEnd();
       }
@@ -215,7 +214,7 @@ namespace {
 
     void showSelectedLayers(Sprite* sprite) {
       // TODO the range of selected frames should be in doc::Site.
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (!range.enabled()) {
         if (current_editor) {
           ASSERT(current_editor->sprite() == sprite);
diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp
index b1347bd..e76036d 100644
--- a/src/app/commands/cmd_flip.cpp
+++ b/src/app/commands/cmd_flip.cpp
@@ -21,7 +21,6 @@
 #include "app/document_range.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/util/range_utils.h"
 #include "doc/algorithm/flip_image.h"
@@ -81,7 +80,7 @@ void FlipCommand::onExecute(Context* context)
       CelList cels;
 
       Site site = *writer.site();
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled())
         cels = get_unique_cels(sprite, range);
       else if (writer.cel())
diff --git a/src/app/commands/cmd_frame_properties.cpp b/src/app/commands/cmd_frame_properties.cpp
index d1b34fe..dd52bbc 100644
--- a/src/app/commands/cmd_frame_properties.cpp
+++ b/src/app/commands/cmd_frame_properties.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -14,7 +14,6 @@
 #include "app/commands/params.h"
 #include "app/context_access.h"
 #include "app/document_api.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/transaction.h"
 #include "base/convert_to.h"
@@ -94,7 +93,7 @@ void FramePropertiesCommand::onExecute(Context* context)
 
     case CURRENT_RANGE: {
       // TODO the range of selected frames should be in doc::Site.
-      Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled()) {
         firstFrame = range.frameBegin();
         lastFrame = range.frameEnd();
diff --git a/src/app/commands/cmd_goto_tab.cpp b/src/app/commands/cmd_goto_tab.cpp
index 9c337bb..3b4a6a5 100644
--- a/src/app/commands/cmd_goto_tab.cpp
+++ b/src/app/commands/cmd_goto_tab.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -12,7 +12,6 @@
 #include "app/commands/command.h"
 
 #include "app/app.h"
-#include "app/ui/main_window.h"
 #include "app/ui/workspace.h"
 
 namespace app {
@@ -36,12 +35,12 @@ GotoNextTabCommand::GotoNextTabCommand()
 
 bool GotoNextTabCommand::onEnabled(Context* context)
 {
-  return App::instance()->getMainWindow()->getWorkspace()->canSelectOtherTab();
+  return App::instance()->workspace()->canSelectOtherTab();
 }
 
 void GotoNextTabCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->getWorkspace()->selectNextTab();
+  App::instance()->workspace()->selectNextTab();
 }
 
 class GotoPreviousTabCommand : public Command {
@@ -63,12 +62,12 @@ GotoPreviousTabCommand::GotoPreviousTabCommand()
 
 bool GotoPreviousTabCommand::onEnabled(Context* context)
 {
-  return App::instance()->getMainWindow()->getWorkspace()->canSelectOtherTab();
+  return App::instance()->workspace()->canSelectOtherTab();
 }
 
 void GotoPreviousTabCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->getWorkspace()->selectPreviousTab();
+  App::instance()->workspace()->selectPreviousTab();
 }
 
 Command* CommandFactory::createGotoNextTabCommand()
diff --git a/src/app/commands/cmd_home.cpp b/src/app/commands/cmd_home.cpp
index 84f03d0..bd38ccf 100644
--- a/src/app/commands/cmd_home.cpp
+++ b/src/app/commands/cmd_home.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -40,12 +40,12 @@ HomeCommand::~HomeCommand()
 
 void HomeCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->showHome();
+  App::instance()->mainWindow()->showHome();
 }
 
 bool HomeCommand::onEnabled(Context* context)
 {
-  return !App::instance()->getMainWindow()->isHomeSelected();
+  return !App::instance()->mainWindow()->isHomeSelected();
 }
 
 Command* CommandFactory::createHomeCommand()
diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp
index ac8c18d..3481735 100644
--- a/src/app/commands/cmd_layer_properties.cpp
+++ b/src/app/commands/cmd_layer_properties.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -19,7 +19,6 @@
 #include "app/context_access.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/ui/user_data_popup.h"
 #include "app/ui_context.h"
@@ -200,7 +199,7 @@ private:
 
           // Redraw timeline because the layer's user data/color
           // might have changed.
-          App::instance()->getMainWindow()->getTimeline()->invalidate();
+          App::instance()->timeline()->invalidate();
         }
 
         transaction.commit();
diff --git a/src/app/commands/cmd_link_cels.cpp b/src/app/commands/cmd_link_cels.cpp
index 7f79103..db88263 100644
--- a/src/app/commands/cmd_link_cels.cpp
+++ b/src/app/commands/cmd_link_cels.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/context_access.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/timeline.h"
 #include "doc/cel.h"
@@ -45,7 +44,7 @@ bool LinkCelsCommand::onEnabled(Context* context)
 {
   if (context->checkFlags(ContextFlags::ActiveDocumentIsWritable)) {
     // TODO the range of selected frames should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     return (range.enabled() && range.frames() > 1);
   }
   else
@@ -59,7 +58,7 @@ void LinkCelsCommand::onExecute(Context* context)
   bool nonEditableLayers = false;
   {
     // TODO the range of selected frames should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     if (!range.enabled())
       return;
 
diff --git a/src/app/commands/cmd_mask_content.cpp b/src/app/commands/cmd_mask_content.cpp
index 61ecba2..dfe64e0 100644
--- a/src/app/commands/cmd_mask_content.cpp
+++ b/src/app/commands/cmd_mask_content.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -89,7 +89,7 @@ void MaskContentCommand::onExecute(Context* context)
   }
 
   // Select marquee tool
-  if (tools::Tool* tool = App::instance()->getToolBox()
+  if (tools::Tool* tool = App::instance()->toolBox()
       ->getToolById(tools::WellKnownTools::RectangularMarquee)) {
     ToolBar::instance()->selectTool(tool);
   }
diff --git a/src/app/commands/cmd_move_cel.cpp b/src/app/commands/cmd_move_cel.cpp
index ba212a6..22c1c7e 100644
--- a/src/app/commands/cmd_move_cel.cpp
+++ b/src/app/commands/cmd_move_cel.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -12,7 +12,6 @@
 #include "app/app.h"
 #include "app/commands/command.h"
 #include "app/context_access.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "ui/base.h"
 
@@ -37,12 +36,12 @@ MoveCelCommand::MoveCelCommand()
 
 bool MoveCelCommand::onEnabled(Context* context)
 {
-  return App::instance()->getMainWindow()->getTimeline()->isMovingCel();
+  return App::instance()->timeline()->isMovingCel();
 }
 
 void MoveCelCommand::onExecute(Context* context)
 {
-  App::instance()->getMainWindow()->getTimeline()->dropRange(Timeline::kMove);
+  App::instance()->timeline()->dropRange(Timeline::kMove);
 }
 
 Command* CommandFactory::createMoveCelCommand()
diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp
index 1657703..d0c5532 100644
--- a/src/app/commands/cmd_new_brush.cpp
+++ b/src/app/commands/cmd_new_brush.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -23,7 +23,6 @@
 #include "app/ui/editor/editor.h"
 #include "app/ui/editor/select_box_state.h"
 #include "app/ui/keyboard_shortcuts.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui_context.h"
 #include "app/util/new_image_from_mask.h"
@@ -127,8 +126,7 @@ void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::M
   // Update the context bar
   // TODO find a way to avoid all these singletons. Maybe a simple
   // signal in the context like "brush has changed" could be enough.
-  App::instance()->getMainWindow()->getContextBar()
-    ->updateForCurrentTool();
+  App::instance()->contextBar()->updateForCurrentTool();
 
   editor->backToPreviousState();
 }
@@ -149,7 +147,7 @@ void NewBrushCommand::createBrush(const Site& site, const Mask* mask)
   brush->setImage(image.get());
   brush->setPatternOrigin(mask->bounds().origin());
 
-  ContextBar* ctxBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* ctxBar = App::instance()->contextBar();
   int slot = App::instance()->brushes().addBrushSlot(
     BrushSlot(BrushSlot::Flags::BrushType, brush));
   ctxBar->setActiveBrush(brush);
diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp
index 53f2c82..99fb04f 100644
--- a/src/app/commands/cmd_new_frame.cpp
+++ b/src/app/commands/cmd_new_frame.cpp
@@ -107,7 +107,7 @@ void NewFrameCommand::onExecute(Context* context)
       case Content::DUPLICATE_CELS:
       case Content::DUPLICATE_CELS_BLOCK: {
         // TODO the range of selected frames should be in doc::Site.
-        Timeline* timeline = App::instance()->getMainWindow()->getTimeline();
+        Timeline* timeline = App::instance()->timeline();
         Timeline::Range range = timeline->range();
         if (range.enabled()) {
           std::map<CelData*, Cel*> relatedCels;
@@ -184,7 +184,7 @@ void NewFrameCommand::onExecute(Context* context)
               (int)context->activeSite().frame()+1,
               (int)sprite->totalFrames());
 
-  App::instance()->getMainWindow()->popTimeline();
+  App::instance()->mainWindow()->popTimeline();
 }
 
 std::string NewFrameCommand::onGetFriendlyName() const
diff --git a/src/app/commands/cmd_new_frame_tag.cpp b/src/app/commands/cmd_new_frame_tag.cpp
index 5d54b04..a7b5af3 100644
--- a/src/app/commands/cmd_new_frame_tag.cpp
+++ b/src/app/commands/cmd_new_frame_tag.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -16,7 +16,6 @@
 #include "app/context_access.h"
 #include "app/transaction.h"
 #include "app/ui/frame_tag_window.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "doc/frame_tag.h"
 
@@ -56,7 +55,7 @@ void NewFrameTagCommand::onExecute(Context* context)
   frame_t from = reader.frame();
   frame_t to = reader.frame();
 
-  Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+  auto range = App::instance()->timeline()->range();
   if (range.enabled() &&
       (range.type() == DocumentRange::kFrames ||
        range.type() == DocumentRange::kCels)) {
@@ -83,7 +82,7 @@ void NewFrameTagCommand::onExecute(Context* context)
     transaction.commit();
   }
 
-  App::instance()->getMainWindow()->getTimeline()->invalidate();
+  App::instance()->timeline()->invalidate();
 }
 
 Command* CommandFactory::createNewFrameTagCommand()
diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp
index 8c6b16b..3350efb 100644
--- a/src/app/commands/cmd_new_layer.cpp
+++ b/src/app/commands/cmd_new_layer.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -121,7 +121,7 @@ void NewLayerCommand::onExecute(Context* context)
   StatusBar::instance()->invalidate();
   StatusBar::instance()->showTip(1000, "Layer `%s' created", name.c_str());
 
-  App::instance()->getMainWindow()->popTimeline();
+  App::instance()->mainWindow()->popTimeline();
 }
 
 static std::string get_unique_layer_name(Sprite* sprite)
diff --git a/src/app/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp
index 145b2e2..7b751cf 100644
--- a/src/app/commands/cmd_open_file.cpp
+++ b/src/app/commands/cmd_open_file.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -143,7 +143,7 @@ void OpenFileCommand::onExecute(Context* context)
         Document* document = fop->document();
         if (document) {
           if (context->isUIAvailable())
-            App::instance()->getRecentFiles()->addRecentFile(fop->filename().c_str());
+            App::instance()->recentFiles()->addRecentFile(fop->filename().c_str());
 
           document->setContext(context);
         }
@@ -155,7 +155,7 @@ void OpenFileCommand::onExecute(Context* context)
       // so we can remove it from the recent-file list
       if (unrecent) {
         if (context->isUIAvailable())
-          App::instance()->getRecentFiles()->removeRecentFile(m_filename.c_str());
+          App::instance()->recentFiles()->removeRecentFile(m_filename.c_str());
       }
     }
     else {
diff --git a/src/app/commands/cmd_remove_frame.cpp b/src/app/commands/cmd_remove_frame.cpp
index 7b65ffb..81554bf 100644
--- a/src/app/commands/cmd_remove_frame.cpp
+++ b/src/app/commands/cmd_remove_frame.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -14,7 +14,6 @@
 #include "app/context_access.h"
 #include "app/document_api.h"
 #include "app/modules/gui.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/transaction.h"
 #include "doc/sprite.h"
@@ -58,7 +57,7 @@ void RemoveFrameCommand::onExecute(Context* context)
     DocumentApi api = document->getApi(transaction);
 
     // TODO the range of selected frames should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     if (range.enabled()) {
       for (frame_t frame = range.frameEnd(),
              begin = range.frameBegin()-1;
diff --git a/src/app/commands/cmd_remove_frame_tag.cpp b/src/app/commands/cmd_remove_frame_tag.cpp
index ab4d2d3..539d007 100644
--- a/src/app/commands/cmd_remove_frame_tag.cpp
+++ b/src/app/commands/cmd_remove_frame_tag.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -17,7 +17,6 @@
 #include "app/context_access.h"
 #include "app/loop_tag.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "base/convert_to.h"
 #include "doc/frame_tag.h"
@@ -85,7 +84,7 @@ void RemoveFrameTagCommand::onExecute(Context* context)
   transaction.execute(new cmd::RemoveFrameTag(sprite, foundTag));
   transaction.commit();
 
-  App::instance()->getMainWindow()->getTimeline()->invalidate();
+  App::instance()->timeline()->invalidate();
 }
 
 Command* CommandFactory::createRemoveFrameTagCommand()
diff --git a/src/app/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp
index 79c2923..5b82c1c 100644
--- a/src/app/commands/cmd_remove_layer.cpp
+++ b/src/app/commands/cmd_remove_layer.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -14,7 +14,6 @@
 #include "app/context_access.h"
 #include "app/document_api.h"
 #include "app/modules/gui.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/timeline.h"
 #include "app/transaction.h"
@@ -63,7 +62,7 @@ void RemoveLayerCommand::onExecute(Context* context)
     DocumentApi api = document->getApi(transaction);
 
     // TODO the range of selected layer should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     if (range.enabled()) {
       if (range.layers() == sprite->countLayers()) {
         ui::Alert::show("Error<<You cannot delete all layers.||&OK");
diff --git a/src/app/commands/cmd_reverse_frames.cpp b/src/app/commands/cmd_reverse_frames.cpp
index 34ebf43..46dd2f4 100644
--- a/src/app/commands/cmd_reverse_frames.cpp
+++ b/src/app/commands/cmd_reverse_frames.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -13,7 +13,6 @@
 #include "app/commands/command.h"
 #include "app/context_access.h"
 #include "app/modules/gui.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/document_range_ops.h"
 
@@ -38,8 +37,7 @@ ReverseFramesCommand::ReverseFramesCommand()
 
 bool ReverseFramesCommand::onEnabled(Context* context)
 {
-  DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
-
+  auto range = App::instance()->timeline()->range();
   return
     context->checkFlags(ContextFlags::ActiveDocumentIsWritable) &&
     range.enabled() &&
@@ -48,7 +46,7 @@ bool ReverseFramesCommand::onEnabled(Context* context)
 
 void ReverseFramesCommand::onExecute(Context* context)
 {
-  DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+  auto range = App::instance()->timeline()->range();
   if (!range.enabled())
     return;                     // Nothing to do
 
diff --git a/src/app/commands/cmd_rotate.cpp b/src/app/commands/cmd_rotate.cpp
index 493cbf7..125cc75 100644
--- a/src/app/commands/cmd_rotate.cpp
+++ b/src/app/commands/cmd_rotate.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -22,7 +22,6 @@
 #include "app/transaction.h"
 #include "app/ui/color_bar.h"
 #include "app/ui/editor/editor.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "app/ui/toolbar.h"
 #include "app/util/range_utils.h"
@@ -193,7 +192,7 @@ void RotateCommand::onExecute(Context* context)
 
     // Flip the mask or current cel
     if (m_flipMask) {
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled())
         cels = get_unique_cels(site.sprite(), range);
       else if (site.cel()) {
@@ -201,7 +200,7 @@ void RotateCommand::onExecute(Context* context)
         // we can go to MovingPixelsState.
         if (static_cast<app::Document*>(site.document())->isMaskVisible()) {
           // Select marquee tool
-          if (tools::Tool* tool = App::instance()->getToolBox()
+          if (tools::Tool* tool = App::instance()->toolBox()
               ->getToolById(tools::WellKnownTools::RectangularMarquee)) {
             ToolBar::instance()->selectTool(tool);
             current_editor->startSelectionTransformation(gfx::Point(0, 0), m_angle);
diff --git a/src/app/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp
index 6fad7a4..f6fb4cc 100644
--- a/src/app/commands/cmd_save_file.cpp
+++ b/src/app/commands/cmd_save_file.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -121,7 +121,7 @@ static void save_document_in_background(const Context* context,
     const_cast<Document*>(document)->impossibleToBackToSavedState();
   }
   else if (context->isUIAvailable()) {
-    App::instance()->getRecentFiles()->addRecentFile(document->filename().c_str());
+    App::instance()->recentFiles()->addRecentFile(document->filename().c_str());
     if (mark_as_saved)
       const_cast<Document*>(document)->markAsSaved();
 
diff --git a/src/app/commands/cmd_set_ink_type.cpp b/src/app/commands/cmd_set_ink_type.cpp
index fe2eec1..2d1adc1 100644
--- a/src/app/commands/cmd_set_ink_type.cpp
+++ b/src/app/commands/cmd_set_ink_type.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/commands/params.h"
 #include "app/tools/ink_type.h"
 #include "app/ui/context_bar.h"
-#include "app/ui/main_window.h"
 
 namespace app {
 
@@ -68,8 +67,7 @@ bool SetInkTypeCommand::onChecked(Context* context)
 void SetInkTypeCommand::onExecute(Context* context)
 {
   App::instance()
-    ->getMainWindow()
-    ->getContextBar()
+    ->contextBar()
     ->setInkType(m_type);
 }
 
diff --git a/src/app/commands/cmd_set_loop_section.cpp b/src/app/commands/cmd_set_loop_section.cpp
index d984c5d..9d20f81 100644
--- a/src/app/commands/cmd_set_loop_section.cpp
+++ b/src/app/commands/cmd_set_loop_section.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -19,7 +19,6 @@
 #include "app/context_access.h"
 #include "app/loop_tag.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/timeline.h"
 #include "doc/frame_tag.h"
 
@@ -84,7 +83,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
   switch (m_action) {
 
     case Action::Auto: {
-      Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
       if (range.enabled() && (range.frames() > 1)) {
         begin = range.frameBegin();
         end = range.frameEnd();
@@ -137,7 +136,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
     }
   }
 
-  App::instance()->getMainWindow()->getTimeline()->invalidate();
+  App::instance()->timeline()->invalidate();
 }
 
 Command* CommandFactory::createSetLoopSectionCommand()
diff --git a/src/app/commands/cmd_set_same_ink.cpp b/src/app/commands/cmd_set_same_ink.cpp
index 95b3dd2..122f302 100644
--- a/src/app/commands/cmd_set_same_ink.cpp
+++ b/src/app/commands/cmd_set_same_ink.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -52,7 +52,7 @@ void SetSameInkCommand::onExecute(Context* context)
     tools::InkType inkType = pref.tool(activeTool).ink();
     int opacity = pref.tool(activeTool).opacity();
 
-    for (tools::Tool* tool : *App::instance()->getToolBox()) {
+    for (tools::Tool* tool : *App::instance()->toolBox()) {
       if (tool != activeTool) {
         pref.tool(tool).ink(inkType);
         pref.tool(tool).opacity(opacity);
diff --git a/src/app/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp
index 3aa7f00..9b98bf1 100644
--- a/src/app/commands/cmd_switch_colors.cpp
+++ b/src/app/commands/cmd_switch_colors.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/ui/color_bar.h"
 #include "app/ui/context_bar.h"
 #include "app/ui/editor/editor.h"
-#include "app/ui/main_window.h"
 #include "ui/base.h"
 
 namespace app {
@@ -51,8 +50,7 @@ void SwitchColorsCommand::onExecute(Context* context)
   if (tool) {
     const auto& toolPref(Preferences::instance().tool(tool));
     if (toolPref.ink() == tools::InkType::SHADING) {
-      App::instance()->getMainWindow()->
-        getContextBar()->reverseShadeColors();
+      App::instance()->contextBar()->reverseShadeColors();
     }
   }
 
diff --git a/src/app/commands/cmd_timeline.cpp b/src/app/commands/cmd_timeline.cpp
index f38249b..f9fd8b0 100644
--- a/src/app/commands/cmd_timeline.cpp
+++ b/src/app/commands/cmd_timeline.cpp
@@ -29,7 +29,7 @@ protected:
   void onLoadParams(const Params& params) override;
   void onExecute(Context* context) override;
   bool onChecked(Context* ctx) override;
-  
+
   bool m_open;
   bool m_close;
   bool m_switch;
@@ -62,7 +62,7 @@ void TimelineCommand::onLoadParams(const Params& params)
 
 void TimelineCommand::onExecute(Context* context)
 {
-  bool visible = App::instance()->getMainWindow()->getTimelineVisibility();
+  bool visible = App::instance()->mainWindow()->getTimelineVisibility();
   bool newVisible = visible;
 
   if (m_switch)
@@ -73,16 +73,16 @@ void TimelineCommand::onExecute(Context* context)
     newVisible = true;
 
   if (visible != newVisible)
-    App::instance()->getMainWindow()->setTimelineVisibility(newVisible);
+    App::instance()->mainWindow()->setTimelineVisibility(newVisible);
 }
 
 bool TimelineCommand::onChecked(Context* ctx) {
-    MainWindow* mainWin = App::instance()->getMainWindow();
-    if (!mainWin)
-      return false;
+  MainWindow* mainWin = App::instance()->mainWindow();
+  if (!mainWin)
+    return false;
 
-    Timeline* timelineWin = mainWin->getTimeline();
-    return (timelineWin && timelineWin->isVisible());
+  Timeline* timelineWin = mainWin->getTimeline();
+  return (timelineWin && timelineWin->isVisible());
 }
 
 Command* CommandFactory::createTimelineCommand()
diff --git a/src/app/commands/cmd_toggle_preview.cpp b/src/app/commands/cmd_toggle_preview.cpp
index 3528410..e6a65c0 100644
--- a/src/app/commands/cmd_toggle_preview.cpp
+++ b/src/app/commands/cmd_toggle_preview.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -43,7 +43,7 @@ bool TogglePreviewCommand::onEnabled(Context* context)
 
 bool TogglePreviewCommand::onChecked(Context* context)
 {
-  MainWindow* mainWin = App::instance()->getMainWindow();
+  MainWindow* mainWin = App::instance()->mainWindow();
   if (!mainWin)
     return false;
 
@@ -54,7 +54,7 @@ bool TogglePreviewCommand::onChecked(Context* context)
 void TogglePreviewCommand::onExecute(Context* context)
 {
   PreviewEditorWindow* previewWin =
-    App::instance()->getMainWindow()->getPreviewEditor();
+    App::instance()->mainWindow()->getPreviewEditor();
 
   bool state = previewWin->isPreviewEnabled();
   previewWin->setPreviewEnabled(!state);
diff --git a/src/app/commands/cmd_unlink_cel.cpp b/src/app/commands/cmd_unlink_cel.cpp
index 64dbf6e..274c4a1 100644
--- a/src/app/commands/cmd_unlink_cel.cpp
+++ b/src/app/commands/cmd_unlink_cel.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -15,7 +15,6 @@
 #include "app/context_access.h"
 #include "app/modules/gui.h"
 #include "app/transaction.h"
-#include "app/ui/main_window.h"
 #include "app/ui/status_bar.h"
 #include "app/ui/timeline.h"
 #include "doc/cel.h"
@@ -55,7 +54,7 @@ void UnlinkCelCommand::onExecute(Context* context)
     Transaction transaction(writer.context(), "Unlink Cel");
 
     // TODO the range of selected frames should be in doc::Site.
-    Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
+    auto range = App::instance()->timeline()->range();
     if (range.enabled()) {
       Sprite* sprite = writer.sprite();
 
diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp
index cefa0bb..49eb8e6 100644
--- a/src/app/modules/gui.cpp
+++ b/src/app/modules/gui.cpp
@@ -397,14 +397,14 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg)
       for (const Key* key : *KeyboardShortcuts::instance()) {
         if (key->isPressed(msg)) {
           // Cancel menu-bar loops (to close any popup menu)
-          App::instance()->getMainWindow()->getMenuBar()->cancelMenuLoop();
+          App::instance()->mainWindow()->getMenuBar()->cancelMenuLoop();
 
           switch (key->type()) {
 
             case KeyType::Tool: {
               tools::Tool* current_tool = App::instance()->activeTool();
               tools::Tool* select_this_tool = key->tool();
-              tools::ToolBox* toolbox = App::instance()->getToolBox();
+              tools::ToolBox* toolbox = App::instance()->toolBox();
               std::vector<tools::Tool*> possibles;
 
               // Collect all tools with the pressed keyboard-shortcut
@@ -455,7 +455,7 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg)
                   break;
                 }
                 // Is it the desktop and the top-window=
-                else if (child->isDesktop() && child == App::instance()->getMainWindow()) {
+                else if (child->isDesktop() && child == App::instance()->mainWindow()) {
                   // OK, so we can execute the command represented
                   // by the pressed-key in the message...
                   UIContext::instance()->executeCommand(
diff --git a/src/app/ui/brush_popup.cpp b/src/app/ui/brush_popup.cpp
index 9f6e598..a7bd4bd 100644
--- a/src/app/ui/brush_popup.cpp
+++ b/src/app/ui/brush_popup.cpp
@@ -90,8 +90,7 @@ public:
 
 private:
   void onClick() override {
-    ContextBar* contextBar =
-      App::instance()->getMainWindow()->getContextBar();
+    ContextBar* contextBar = App::instance()->contextBar();
 
     if (m_slot >= 0)
       contextBar->setActiveBrushBySlot(m_slot);
@@ -209,8 +208,7 @@ private:
 private:
 
   void onSaveBrush() {
-    ContextBar* contextBar =
-      App::instance()->getMainWindow()->getContextBar();
+    ContextBar* contextBar = App::instance()->contextBar();
 
     m_brushes.setBrushSlot(
       m_slot, contextBar->createBrushSlotFromPreferences());
@@ -251,8 +249,7 @@ public:
 
 private:
   void onClick() override {
-    ContextBar* contextBar =
-      App::instance()->getMainWindow()->getContextBar();
+    ContextBar* contextBar = App::instance()->contextBar();
 
     auto& brushes = App::instance()->brushes();
     int slot = brushes.addBrushSlot(
diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp
index 5b1f49b..4e69ce9 100644
--- a/src/app/ui/context_bar.cpp
+++ b/src/app/ui/context_bar.cpp
@@ -314,7 +314,7 @@ public:
     Preferences& pref = Preferences::instance();
 
     if (pref.shared.shareInk()) {
-      for (Tool* tool : *App::instance()->getToolBox())
+      for (Tool* tool : *App::instance()->toolBox())
         pref.tool(tool).ink(inkType);
     }
     else {
@@ -793,7 +793,7 @@ protected:
     int newValue = getValue();
     Preferences& pref = Preferences::instance();
     if (pref.shared.shareInk()) {
-      for (Tool* tool : *App::instance()->getToolBox())
+      for (Tool* tool : *App::instance()->toolBox())
         pref.tool(tool).opacity(newValue);
     }
     else {
@@ -1602,7 +1602,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
 
 void ContextBar::updateForMovingPixels()
 {
-  tools::Tool* tool = App::instance()->getToolBox()->getToolById(
+  tools::Tool* tool = App::instance()->toolBox()->getToolById(
     tools::WellKnownTools::RectangularMarquee);
   if (tool)
     updateForTool(tool);
diff --git a/src/app/ui/editor/brush_preview.cpp b/src/app/ui/editor/brush_preview.cpp
index c4a1546..6e1946f 100644
--- a/src/app/ui/editor/brush_preview.cpp
+++ b/src/app/ui/editor/brush_preview.cpp
@@ -24,7 +24,6 @@
 #include "app/ui/context_bar.h"
 #include "app/ui/editor/editor.h"
 #include "app/ui/editor/tool_loop_impl.h"
-#include "app/ui/main_window.h"
 #include "app/ui_context.h"
 #include "doc/algo.h"
 #include "doc/blend_internals.h"
@@ -56,8 +55,7 @@ BrushPreview::~BrushPreview()
 BrushRef BrushPreview::getCurrentBrush()
 {
   return App::instance()
-    ->getMainWindow()
-    ->getContextBar()
+    ->contextBar()
     ->activeBrush(m_editor->getCurrentEditorTool());
 }
 
diff --git a/src/app/ui/editor/drawing_state.cpp b/src/app/ui/editor/drawing_state.cpp
index a6703be..8fee64b 100644
--- a/src/app/ui/editor/drawing_state.cpp
+++ b/src/app/ui/editor/drawing_state.cpp
@@ -152,7 +152,7 @@ bool DrawingState::onMouseUp(Editor* editor, MouseMessage* msg)
   editor->releaseMouse();
 
   // Update the timeline. TODO make this state observable by the timeline.
-  App::instance()->getMainWindow()->getTimeline()->updateUsingEditor(editor);
+  App::instance()->timeline()->updateUsingEditor(editor);
   return true;
 }
 
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index 471fcba..1d66ba5 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -183,7 +183,7 @@ Editor::Editor(Document* document, EditorFlags flags)
       base::Bind<void>(&Editor::onFgColorChange, this));
 
   m_contextBarBrushChangeConn =
-    App::instance()->getMainWindow()->getContextBar()->BrushChange.connect(
+    App::instance()->contextBar()->BrushChange.connect(
       base::Bind<void>(&Editor::onContextBarBrushChange, this));
 
   // Restore last site in preferences
@@ -922,7 +922,7 @@ tools::Tool* Editor::getCurrentEditorTool()
 
   // Eraser tip
   if (m_lastPointerType == ui::PointerType::Eraser) {
-    tools::ToolBox* toolbox = App::instance()->getToolBox();
+    tools::ToolBox* toolbox = App::instance()->toolBox();
     return toolbox->getToolById(tools::WellKnownTools::Eraser);
   }
 
@@ -930,7 +930,7 @@ tools::Tool* Editor::getCurrentEditorTool()
 
   if (m_secondaryButton &&
       isCurrentToolAffectedByRightClickMode()) {
-    tools::ToolBox* toolbox = App::instance()->getToolBox();
+    tools::ToolBox* toolbox = App::instance()->toolBox();
 
     switch (Preferences::instance().editor.rightClickMode()) {
       case app::gen::RightClickMode::PAINT_BGCOLOR:
@@ -968,7 +968,7 @@ tools::Ink* Editor::getCurrentEditorInk()
   if (m_secondaryButton &&
       rightClickMode != app::gen::RightClickMode::DEFAULT &&
       isCurrentToolAffectedByRightClickMode()) {
-    tools::ToolBox* toolbox = App::instance()->getToolBox();
+    tools::ToolBox* toolbox = App::instance()->toolBox();
 
     switch (rightClickMode) {
       case app::gen::RightClickMode::DEFAULT:
@@ -1018,7 +1018,7 @@ tools::Ink* Editor::getCurrentEditorInk()
     }
 
     if (id)
-      ink = App::instance()->getToolBox()->getInkById(id);
+      ink = App::instance()->toolBox()->getInkById(id);
   }
 
   return ink;
@@ -1158,16 +1158,14 @@ void Editor::updateQuicktool()
 
       updateStatusBar();
 
-      App::instance()->getMainWindow()->getContextBar()
-        ->updateForTool(getCurrentEditorTool());
+      App::instance()->contextBar()->updateForTool(getCurrentEditorTool());
     }
   }
 }
 
 void Editor::updateContextBar()
 {
-  App::instance()->getMainWindow()->getContextBar()
-    ->updateForTool(getCurrentEditorTool());
+  App::instance()->contextBar()->updateForTool(getCurrentEditorTool());
 }
 
 void Editor::updateToolLoopModifiersIndicators()
@@ -1218,7 +1216,7 @@ void Editor::updateToolLoopModifiersIndicators()
     }
   }
 
-  ContextBar* ctxBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* ctxBar = App::instance()->contextBar();
 
   if (int(m_toolLoopModifiers) != modifiers) {
     m_toolLoopModifiers = tools::ToolLoopModifiers(modifiers);
@@ -1618,7 +1616,7 @@ void Editor::pasteImage(const Image* image, const Mask* mask)
   // the extra cel.
   if (!getCurrentEditorInk()->isSelection()) {
     tools::Tool* defaultSelectionTool =
-      App::instance()->getToolBox()->getToolById(tools::WellKnownTools::RectangularMarquee);
+      App::instance()->toolBox()->getToolById(tools::WellKnownTools::RectangularMarquee);
 
     ToolBar::instance()->selectTool(defaultSelectionTool);
   }
diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp
index ffbc33e..4851565 100644
--- a/src/app/ui/editor/moving_cel_state.cpp
+++ b/src/app/ui/editor/moving_cel_state.cpp
@@ -38,7 +38,7 @@ MovingCelState::MovingCelState(Editor* editor, MouseMessage* msg)
 {
   ContextWriter writer(UIContext::instance(), 500);
   Document* document = editor->document();
-  DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+  auto range = App::instance()->timeline()->range();
   LayerImage* layer = static_cast<LayerImage*>(editor->layer());
   ASSERT(layer->isImage());
 
diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp
index c214e96..b178e5f 100644
--- a/src/app/ui/editor/moving_pixels_state.cpp
+++ b/src/app/ui/editor/moving_pixels_state.cpp
@@ -101,14 +101,14 @@ MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMo
   m_editor->addObserver(this);
   m_observingEditor = true;
 
-  ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* contextBar = App::instance()->contextBar();
   contextBar->updateForMovingPixels();
   contextBar->addObserver(this);
 }
 
 MovingPixelsState::~MovingPixelsState()
 {
-  ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* contextBar = App::instance()->contextBar();
   contextBar->removeObserver(this);
   contextBar->updateForCurrentTool();
 
@@ -221,7 +221,7 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
   UIContext* ctx = UIContext::instance();
   ctx->setActiveView(editor->getDocumentView());
 
-  ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* contextBar = App::instance()->contextBar();
   contextBar->updateForMovingPixels();
 
   // Start scroll loop
diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp
index 41af6b2..d7793c8 100644
--- a/src/app/ui/editor/select_box_state.cpp
+++ b/src/app/ui/editor/select_box_state.cpp
@@ -40,7 +40,7 @@ SelectBoxState::SelectBoxState(SelectBoxDelegate* delegate, const gfx::Rect& rc,
 
 SelectBoxState::~SelectBoxState()
 {
-  ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* contextBar = App::instance()->contextBar();
   contextBar->updateForCurrentTool();
 }
 
@@ -229,7 +229,7 @@ bool SelectBoxState::requireBrushPreview()
 tools::Ink* SelectBoxState::getStateInk()
 {
   if (hasFlag(Flags::QuickBox))
-    return App::instance()->getToolBox()->getInkById(
+    return App::instance()->toolBox()->getInkById(
       tools::WellKnownInks::Selection);
   else
     return nullptr;
@@ -330,7 +330,7 @@ void SelectBoxState::getInvalidDecoratoredRegion(Editor* editor, gfx::Region& re
 
 void SelectBoxState::updateContextBar()
 {
-  ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+  ContextBar* contextBar = App::instance()->contextBar();
   contextBar->updateForSelectingBox(m_delegate->onGetContextBarHelp());
 }
 
diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp
index 22d2b55..a38be6d 100644
--- a/src/app/ui/editor/standby_state.cpp
+++ b/src/app/ui/editor/standby_state.cpp
@@ -188,7 +188,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
       ColorPicker picker;
       picker.pickColor(site, cursor, ColorPicker::FromComposition);
 
-      DocumentRange range = App::instance()->getMainWindow()->getTimeline()->range();
+      auto range = App::instance()->timeline()->range();
 
       // Change layer only when the layer is diffrent from current one, and
       // the range we selected is not with multiple cels.
diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp
index 0f8d547..cc4a245 100644
--- a/src/app/ui/editor/tool_loop_impl.cpp
+++ b/src/app/ui/editor/tool_loop_impl.cpp
@@ -97,7 +97,7 @@ public:
                const app::Color& bgColor)
     : m_editor(editor)
     , m_tool(tool)
-    , m_brush(App::instance()->getMainWindow()->getContextBar()->activeBrush(m_tool))
+    , m_brush(App::instance()->contextBar()->activeBrush(m_tool))
     , m_document(document)
     , m_sprite(editor->sprite())
     , m_layer(editor->layer())
@@ -124,7 +124,7 @@ public:
 
     if (m_tracePolicy == tools::TracePolicy::Accumulate ||
         m_tracePolicy == tools::TracePolicy::AccumulateUpdateLast) {
-      tools::ToolBox* toolbox = App::instance()->getToolBox();
+      tools::ToolBox* toolbox = App::instance()->toolBox();
 
       switch (algorithm) {
         case tools::FreehandAlgorithm::DEFAULT:
@@ -169,7 +169,7 @@ public:
 
     if (m_toolPref.ink() == tools::InkType::SHADING) {
       m_shadingRemap.reset(
-        App::instance()->getMainWindow()->getContextBar()->createShadeRemap(
+        App::instance()->contextBar()->createShadeRemap(
           button == tools::ToolLoop::Left));
     }
   }
@@ -504,11 +504,11 @@ public:
 
     // Avoid preview for spray and flood fill like tools
     if (m_pointShape->isSpray()) {
-      m_pointShape = App::instance()->getToolBox()->getPointShapeById(
+      m_pointShape = App::instance()->toolBox()->getPointShapeById(
         tools::WellKnownPointShapes::Brush);
     }
     else if (m_pointShape->isFloodFill()) {
-      m_pointShape = App::instance()->getToolBox()->getPointShapeById(
+      m_pointShape = App::instance()->toolBox()->getPointShapeById(
         tools::WellKnownPointShapes::Pixel);
     }
   }
diff --git a/src/app/ui/file_selector.cpp b/src/app/ui/file_selector.cpp
index 23bf371..966bf07 100644
--- a/src/app/ui/file_selector.cpp
+++ b/src/app/ui/file_selector.cpp
@@ -640,8 +640,8 @@ void FileSelector::updateLocation()
     location()->addItem("");
     location()->addItem("-------- Recent Paths --------");
 
-    RecentFiles::const_iterator it = App::instance()->getRecentFiles()->paths_begin();
-    RecentFiles::const_iterator end = App::instance()->getRecentFiles()->paths_end();
+    auto it = App::instance()->recentFiles()->paths_begin();
+    auto end = App::instance()->recentFiles()->paths_end();
     for (; it != end; ++it)
       location()->addItem(new CustomFolderNameItem(it->c_str()));
   }
diff --git a/src/app/ui/home_view.cpp b/src/app/ui/home_view.cpp
index c3fd28d..690b5b9 100644
--- a/src/app/ui/home_view.cpp
+++ b/src/app/ui/home_view.cpp
@@ -1,5 +1,5 @@
 // Aseprite
-// Copyright (C) 2001-2015  David Capello
+// Copyright (C) 2001-2016  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
@@ -65,7 +65,7 @@ HomeView::~HomeView()
 #ifdef ENABLE_DATA_RECOVERY
   if (m_dataRecoveryView) {
     if (m_dataRecoveryView->parent())
-      App::instance()->getMainWindow()->getWorkspace()->removeView(m_dataRecoveryView);
+      App::instance()->workspace()->removeView(m_dataRecoveryView);
     delete m_dataRecoveryView;
   }
 #endif
@@ -185,9 +185,9 @@ void HomeView::onRecoverSprites()
   }
 
   if (!m_dataRecoveryView->parent())
-    App::instance()->getMainWindow()->getWorkspace()->addView(m_dataRecoveryView);
+    App::instance()->workspace()->addView(m_dataRecoveryView);
 
-  App::instance()->getMainWindow()->getTabsBar()->selectTab(m_dataRecoveryView);
+  App::instance()->mainWindow()->getTabsBar()->selectTab(m_dataRecoveryView);
 #endif
 }
 
diff --git a/src/app/ui/keyboard_shortcuts.cpp b/src/app/ui/keyboard_shortcuts.cpp
index 53c6f77..d0cc2a6 100644
--- a/src/app/ui/keyboard_shortcuts.cpp
+++ b/src/app/ui/keyboard_shortcuts.cpp
@@ -380,7 +380,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
     bool removed = bool_attr_is_true(xmlKey, "removed");
 
     if (tool_id) {
-      tools::Tool* tool = App::instance()->getToolBox()->getToolById(tool_id);
+      tools::Tool* tool = App::instance()->toolBox()->getToolById(tool_id);
       if (tool) {
         Key* key = this->tool(tool);
         if (key && tool_key) {
@@ -408,7 +408,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
     bool removed = bool_attr_is_true(xmlKey, "removed");
 
     if (tool_id) {
-      tools::Tool* tool = App::instance()->getToolBox()->getToolById(tool_id);
+      tools::Tool* tool = App::instance()->toolBox()->getToolById(tool_id);
       if (tool) {
         Key* key = this->quicktool(tool);
         if (key && tool_key) {
@@ -689,7 +689,7 @@ tools::Tool* KeyboardShortcuts::getCurrentQuicktool(tools::Tool* currentTool)
       return NULL;
   }
 
-  tools::ToolBox* toolbox = App::instance()->getToolBox();
+  tools::ToolBox* toolbox = App::instance()->toolBox();
 
   // Iterate over all tools
   for (tools::Tool* tool : *toolbox) {
diff --git a/src/app/ui/recent_listbox.cpp b/src/app/ui/recent_listbox.cpp
index 5826f62..91fb246 100644
--- a/src/app/ui/recent_listbox.cpp
+++ b/src/app/ui/recent_listbox.cpp
@@ -92,7 +92,7 @@ private:
 RecentListBox::RecentListBox()
 {
   m_recentFilesConn =
-    App::instance()->getRecentFiles()->Changed.connect(
+    App::instance()->recentFiles()->Changed.connect(
       base::Bind(&RecentListBox::rebuildList, this));
 }
 
@@ -120,8 +120,7 @@ RecentFilesListBox::RecentFilesListBox()
 
 void RecentFilesListBox::onRebuildList()
 {
-  RecentFiles* recent = App::instance()->getRecentFiles();
-
+  auto recent = App::instance()->recentFiles();
   auto it = recent->files_begin();
   auto end = recent->files_end();
   for (; it != end; ++it)
@@ -146,8 +145,7 @@ RecentFoldersListBox::RecentFoldersListBox()
 
 void RecentFoldersListBox::onRebuildList()
 {
-  RecentFiles* recent = App::instance()->getRecentFiles();
-
+  auto recent = App::instance()->recentFiles();
   auto it = recent->paths_begin();
   auto end = recent->paths_end();
   for (; it != end; ++it)
diff --git a/src/app/ui/toolbar.cpp b/src/app/ui/toolbar.cpp
index ce06e6a..1ee298a 100644
--- a/src/app/ui/toolbar.cpp
+++ b/src/app/ui/toolbar.cpp
@@ -95,7 +95,7 @@ ToolBar::ToolBar()
   m_tipWindow = NULL;
   m_tipOpened = false;
 
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
     Tool* tool = *it;
     if (m_selectedInGroup.find(tool->getGroup()) == m_selectedInGroup.end())
@@ -120,7 +120,7 @@ bool ToolBar::onProcessMessage(Message* msg)
 
     case kMouseDownMessage: {
       MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
-      ToolBox* toolbox = App::instance()->getToolBox();
+      ToolBox* toolbox = App::instance()->toolBox();
       int groups = toolbox->getGroupsCount();
       Rect toolrc;
 
@@ -148,7 +148,7 @@ bool ToolBar::onProcessMessage(Message* msg)
           mouseMsg->position().y < toolrc.y+toolrc.h) {
         // Toggle preview visibility
         PreviewEditorWindow* preview =
-          App::instance()->getMainWindow()->getPreviewEditor();
+          App::instance()->mainWindow()->getPreviewEditor();
         bool state = preview->isPreviewEnabled();
         preview->setPreviewEnabled(!state);
       }
@@ -157,7 +157,7 @@ bool ToolBar::onProcessMessage(Message* msg)
 
     case kMouseMoveMessage: {
       MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
-      ToolBox* toolbox = App::instance()->getToolBox();
+      ToolBox* toolbox = App::instance()->toolBox();
       int groups = toolbox->getGroupsCount();
       Tool* new_hot_tool = NULL;
       int new_hot_index = NoneIndex;
@@ -292,7 +292,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
   SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
   gfx::Color normalFace = theme->colors.buttonNormalFace();
   gfx::Color hotFace = theme->colors.buttonHotFace();
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   ToolGroupList::iterator it = toolbox->begin_group();
   int groups = toolbox->getGroupsCount();
   Rect toolrc;
@@ -332,7 +332,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
   toolrc = getToolGroupBounds(PreviewVisibilityIndex);
   toolrc.offset(-origin());
   bool isHot = (m_hotIndex == PreviewVisibilityIndex ||
-    App::instance()->getMainWindow()->getPreviewEditor()->isPreviewEnabled());
+    App::instance()->mainWindow()->getPreviewEditor()->isPreviewEnabled());
   theme->drawRect(
     g,
     toolrc,
@@ -350,7 +350,7 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
 
 int ToolBar::getToolGroupIndex(ToolGroup* group)
 {
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   ToolGroupList::iterator it = toolbox->begin_group();
   int groups = toolbox->getGroupsCount();
 
@@ -384,7 +384,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
   closeTipWindow();
 
   // If this group contains only one tool, do not show the popup
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   int count = 0;
   for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
     Tool* tool = *it;
@@ -433,7 +433,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
 
 Rect ToolBar::getToolGroupBounds(int group_index)
 {
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   int groups = toolbox->getGroupsCount();
   Size iconsize = getToolIconSize(this);
   Rect rc(bounds());
@@ -458,7 +458,7 @@ Rect ToolBar::getToolGroupBounds(int group_index)
 
 Point ToolBar::getToolPositionInGroup(int group_index, Tool* tool)
 {
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   Size iconsize = getToolIconSize(this);
   int nth = 0;
 
@@ -500,7 +500,7 @@ void ToolBar::openTipWindow(int group_index, Tool* tool)
     }
   }
   else if (group_index == PreviewVisibilityIndex) {
-    if (App::instance()->getMainWindow()->getPreviewEditor()->isPreviewEnabled())
+    if (App::instance()->mainWindow()->getPreviewEditor()->isPreviewEnabled())
       tooltip = "Hide Preview";
     else
       tooltip = "Show Preview";
@@ -595,7 +595,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
     case kMouseMoveMessage: {
       MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
       gfx::Point mousePos = mouseMsg->position();
-      ToolBox* toolbox = App::instance()->getToolBox();
+      ToolBox* toolbox = App::instance()->toolBox();
       Tool* hot_tool = NULL;
       Rect toolrc;
       int index = 0;
@@ -660,7 +660,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
 
 void ToolBar::ToolStrip::onSizeHint(SizeHintEvent& ev)
 {
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   int c = 0;
 
   for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
@@ -678,7 +678,7 @@ void ToolBar::ToolStrip::onPaint(PaintEvent& ev)
 {
   Graphics* g = ev.graphics();
   SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
-  ToolBox* toolbox = App::instance()->getToolBox();
+  ToolBox* toolbox = App::instance()->toolBox();
   Rect toolrc;
   int index = 0;
 
diff --git a/src/app/ui_context.cpp b/src/app/ui_context.cpp
index f5b5b8a..88fedeb 100644
--- a/src/app/ui_context.cpp
+++ b/src/app/ui_context.cpp
@@ -65,11 +65,7 @@ DocumentView* UIContext::activeView() const
   if (!isUIAvailable())
     return nullptr;
 
-  MainWindow* mainWindow = App::instance()->getMainWindow();
-  if (!mainWindow)
-    return nullptr;
-
-  Workspace* workspace = mainWindow->getWorkspace();
+  Workspace* workspace = App::instance()->workspace();
   if (!workspace)
     return nullptr;
 
@@ -82,7 +78,7 @@ DocumentView* UIContext::activeView() const
 
 void UIContext::setActiveView(DocumentView* docView)
 {
-  MainWindow* mainWin = App::instance()->getMainWindow();
+  MainWindow* mainWin = App::instance()->mainWindow();
 
   // Prioritize workspace for user input.
   App::instance()->inputChain().prioritize(mainWin->getWorkspace());
@@ -143,12 +139,10 @@ void UIContext::setActiveDocument(Document* document)
 
 DocumentView* UIContext::getFirstDocumentView(doc::Document* document) const
 {
-  MainWindow* mainWindow = App::instance()->getMainWindow();
-  if (!mainWindow) // Main window can be null if we are in --batch mode
+  Workspace* workspace = App::instance()->workspace();
+  if (!workspace) // Workspace (main window) can be null if we are in --batch mode
     return nullptr;
 
-  Workspace* workspace = mainWindow->getWorkspace();
-
   for (WorkspaceView* view : *workspace) {
     if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
       if (docView->document() == document) {
@@ -162,7 +156,7 @@ DocumentView* UIContext::getFirstDocumentView(doc::Document* document) const
 
 DocumentViews UIContext::getAllDocumentViews(doc::Document* document) const
 {
-  Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+  Workspace* workspace = App::instance()->workspace();
   DocumentViews docViews;
 
   for (WorkspaceView* view : *workspace) {
@@ -197,10 +191,10 @@ void UIContext::onAddDocument(doc::Document* doc)
   DocumentView* view = new DocumentView(
     m_lastSelectedDoc,
     DocumentView::Normal,
-    App::instance()->getMainWindow()->getPreviewEditor());
+    App::instance()->mainWindow()->getPreviewEditor());
 
   // Add a tab with the new view for the document
-  App::instance()->getMainWindow()->getWorkspace()->addView(view);
+  App::instance()->workspace()->addView(view);
 
   setActiveView(view);
   view->editor()->setDefaultScroll();
@@ -213,7 +207,7 @@ void UIContext::onRemoveDocument(doc::Document* doc)
 
   // We don't destroy views in batch mode.
   if (isUIAvailable()) {
-    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
+    Workspace* workspace = App::instance()->workspace();
 
     for (DocumentView* docView : getAllDocumentViews(doc)) {
       workspace->removeView(docView);
diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp
index 4714ca3..993cd35 100644
--- a/src/app/util/clipboard.cpp
+++ b/src/app/util/clipboard.cpp
@@ -24,7 +24,6 @@
 #include "app/transaction.h"
 #include "app/ui/color_bar.h"
 #include "app/ui/editor/editor.h"
-#include "app/ui/main_window.h"
 #include "app/ui/skin/skin_theme.h"
 #include "app/ui/timeline.h"
 #include "app/ui_context.h"
@@ -248,8 +247,7 @@ void copy_range(const ContextReader& reader, const DocumentRange& range)
 
   // TODO Replace this with a signal, because here the timeline
   // depends on the clipboard and the clipboard on the timeline.
-  App::instance()->getMainWindow()
-    ->getTimeline()->activateClipboardRange();
+  App::instance()->timeline()->activateClipboardRange();
 }
 
 void copy_image(const Image* image, const Mask* mask, const Palette* pal)
@@ -341,7 +339,7 @@ void paste()
           // We can use a document range op (copy_range) to copy/paste
           // cels in the same document.
           if (srcDoc == dstDoc) {
-            Timeline* timeline = App::instance()->getMainWindow()->getTimeline();
+            Timeline* timeline = App::instance()->timeline();
             DocumentRange dstRange = timeline->range();
             LayerIndex dstLayer = srcSpr->layerToIndex(editor->layer());
             frame_t dstFrame = editor->frame();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list