mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Move doc::Context to app::Context (#378)
We've moved everything related to Context/active site/observable documents from "doc" namespace to "app" namespace.
This commit is contained in:
parent
612ad98392
commit
457a9999b5
@ -503,6 +503,7 @@ add_library(app-lib
|
||||
document_range.cpp
|
||||
document_range_ops.cpp
|
||||
document_undo.cpp
|
||||
documents.cpp
|
||||
extensions.cpp
|
||||
extra_cel.cpp
|
||||
file/file.cpp
|
||||
@ -534,6 +535,7 @@ add_library(app-lib
|
||||
resource_finder.cpp
|
||||
restore_visible_layers.cpp
|
||||
shade.cpp
|
||||
site.cpp
|
||||
snap_to_grid.cpp
|
||||
sprite_job.cpp
|
||||
thumbnail_generator.cpp
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "app/recent_files.h"
|
||||
#include "app/resource_finder.h"
|
||||
#include "app/send_crash.h"
|
||||
#include "app/site.h"
|
||||
#include "app/tools/active_tool.h"
|
||||
#include "app/tools/tool_box.h"
|
||||
#include "app/ui/backup_indicator.h"
|
||||
@ -56,7 +57,6 @@
|
||||
#include "base/scoped_lock.h"
|
||||
#include "base/split_string.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
#include "render/render.h"
|
||||
@ -361,9 +361,9 @@ void App::run()
|
||||
#endif // ENABLE_SCRIPTING
|
||||
|
||||
// Destroy all documents in the UIContext.
|
||||
const doc::Documents& docs = m_modules->m_context.documents();
|
||||
const Documents& docs = m_modules->m_context.documents();
|
||||
while (!docs.empty()) {
|
||||
doc::Document* doc = docs.back();
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,12 +9,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/disable_copying.h"
|
||||
#include "doc/sprite_position.h"
|
||||
#include "undo/undo_command.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
|
||||
class Cmd : public undo::UndoCommand {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,12 +10,12 @@
|
||||
|
||||
#include "app/cmd/add_cel.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "base/serialization.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cel_data_io.h"
|
||||
#include "doc/cel_io.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/image_io.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/subobjects_io.h"
|
||||
@ -93,7 +93,7 @@ void AddCel::addCel(Layer* layer, Cel* cel)
|
||||
static_cast<LayerImage*>(layer)->addCel(cel);
|
||||
layer->incrementVersion();
|
||||
|
||||
Document* doc = cel->document();
|
||||
auto doc = static_cast<Document*>(cel->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
@ -103,7 +103,7 @@ void AddCel::addCel(Layer* layer, Cel* cel)
|
||||
|
||||
void AddCel::removeCel(Layer* layer, Cel* cel)
|
||||
{
|
||||
Document* doc = cel->document();
|
||||
auto doc = static_cast<app::Document*>(cel->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -11,9 +11,9 @@
|
||||
#include "app/cmd/add_frame.h"
|
||||
|
||||
#include "app/cmd/add_cel.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/sprite.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/add_frame_tag.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/frame_tag_io.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -37,7 +37,7 @@ void AddFrameTag::onExecute()
|
||||
sprite->incrementVersion();
|
||||
|
||||
// Notify observers about the new frame.
|
||||
Document* doc = sprite->document();
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
ev.frameTag(frameTag);
|
||||
@ -53,7 +53,7 @@ void AddFrameTag::onUndo()
|
||||
|
||||
// Notify observers about the new frame.
|
||||
{
|
||||
Document* doc = sprite->document();
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
ev.frameTag(frameTag);
|
||||
@ -78,7 +78,7 @@ void AddFrameTag::onRedo()
|
||||
m_size = 0;
|
||||
|
||||
// Notify observers about the new frame.
|
||||
Document* doc = sprite->document();
|
||||
Document* doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
ev.frameTag(frameTag);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/add_layer.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/layer_io.h"
|
||||
#include "doc/subobjects_io.h"
|
||||
@ -69,7 +69,7 @@ void AddLayer::addLayer(Layer* group, Layer* newLayer, Layer* afterThis)
|
||||
group->incrementVersion();
|
||||
group->sprite()->incrementVersion();
|
||||
|
||||
Document* doc = group->sprite()->document();
|
||||
auto doc = static_cast<Document*>(group->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(group->sprite());
|
||||
ev.layer(newLayer);
|
||||
@ -78,7 +78,7 @@ void AddLayer::addLayer(Layer* group, Layer* newLayer, Layer* afterThis)
|
||||
|
||||
void AddLayer::removeLayer(Layer* group, Layer* layer)
|
||||
{
|
||||
Document* doc = group->sprite()->document();
|
||||
auto doc = static_cast<Document*>(group->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -24,7 +24,7 @@ using namespace doc;
|
||||
ClearCel::ClearCel(Cel* cel)
|
||||
: WithCel(cel)
|
||||
{
|
||||
app::Document* doc = static_cast<app::Document*>(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
|
||||
if (cel->layer()->isBackground()) {
|
||||
Image* image = cel->image();
|
||||
|
@ -27,7 +27,7 @@ using namespace doc;
|
||||
ClearMask::ClearMask(Cel* cel)
|
||||
: WithCel(cel)
|
||||
{
|
||||
app::Document* doc = static_cast<app::Document*>(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
|
||||
// If the mask is empty or is not visible then we have to clear the
|
||||
// entire image in the cel.
|
||||
@ -86,7 +86,7 @@ void ClearMask::clear()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
Image* image = m_dstImage->image();
|
||||
app::Document* doc = static_cast<app::Document*>(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
Mask* mask = doc->mask();
|
||||
|
||||
doc::algorithm::fill_selection(image, m_offset, mask, m_bgcolor);
|
||||
|
@ -42,7 +42,7 @@ ClearRect::ClearRect(Cel* cel, const gfx::Rect& bounds)
|
||||
|
||||
m_dstImage.reset(new WithImage(image));
|
||||
|
||||
app::Document* doc = static_cast<app::Document*>(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
m_bgcolor = doc->bgColor(cel->layer());
|
||||
|
||||
m_copy.reset(crop_image(image,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -24,7 +24,7 @@ namespace cmd {
|
||||
|
||||
FlipMaskedCel::FlipMaskedCel(Cel* cel, doc::algorithm::FlipType flipType)
|
||||
{
|
||||
app::Document* doc = static_cast<app::Document*>(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
color_t bgcolor = doc->bgColor(cel->layer());
|
||||
Image* image = cel->image();
|
||||
Mask* mask = doc->mask();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/move_layer.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -92,7 +92,7 @@ void MoveLayer::onUndo()
|
||||
void MoveLayer::onFireNotifications()
|
||||
{
|
||||
Layer* layer = m_layer.layer();
|
||||
doc::Document* doc = layer->sprite()->document();
|
||||
Document* doc = static_cast<Document*>(layer->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "app/cmd/remove_frame.h"
|
||||
|
||||
#include "app/cmd/remove_cel.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cels_range.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -35,7 +35,7 @@ RemoveFrame::RemoveFrame(Sprite* sprite, frame_t frame)
|
||||
void RemoveFrame::onExecute()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
Document* doc = sprite->document();
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
|
||||
if (m_firstTime) {
|
||||
m_firstTime = false;
|
||||
@ -64,7 +64,7 @@ void RemoveFrame::onExecute()
|
||||
void RemoveFrame::onUndo()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
Document* doc = sprite->document();
|
||||
Document* doc = static_cast<Document*>(sprite->document());
|
||||
|
||||
if (m_frameRemoved)
|
||||
sprite->addFrame(m_frame);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "app/cmd/set_cel_bounds.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/doc_event.h"
|
||||
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
@ -41,10 +41,11 @@ void SetCelBoundsF::onUndo()
|
||||
void SetCelBoundsF::onFireNotifications()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
DocEvent ev(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(cel->sprite());
|
||||
ev.cel(cel);
|
||||
cel->document()->notify_observers<DocEvent&>(&DocObserver::onCelPositionChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onCelPositionChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "app/cmd/set_cel_frame.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -45,7 +45,7 @@ void SetCelFrame::onUndo()
|
||||
void SetCelFrame::onFireNotifications()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
doc::Document* doc = cel->sprite()->document();
|
||||
auto doc = static_cast<Document*>(cel->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(cel->layer()->sprite());
|
||||
ev.layer(cel->layer());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "app/cmd.h"
|
||||
#include "app/cmd/with_cel.h"
|
||||
#include "doc/frame.h"
|
||||
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "app/cmd/set_cel_opacity.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/doc_event.h"
|
||||
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
@ -41,10 +41,11 @@ void SetCelOpacity::onUndo()
|
||||
void SetCelOpacity::onFireNotifications()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
DocEvent ev(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(cel->sprite());
|
||||
ev.cel(cel);
|
||||
cel->document()->notify_observers<DocEvent&>(&DocObserver::onCelOpacityChange, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onCelOpacityChange, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "app/cmd/set_cel_position.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/doc_event.h"
|
||||
|
||||
namespace app {
|
||||
namespace cmd {
|
||||
@ -43,10 +43,11 @@ void SetCelPosition::onUndo()
|
||||
void SetCelPosition::onFireNotifications()
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
DocEvent ev(cel->document());
|
||||
Document* doc = static_cast<Document*>(cel->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(cel->sprite());
|
||||
ev.cel(cel);
|
||||
cel->document()->notify_observers<DocEvent&>(&DocObserver::onCelPositionChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onCelPositionChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_frame_duration.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -40,7 +40,7 @@ void SetFrameDuration::onUndo()
|
||||
void SetFrameDuration::onFireNotifications()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
doc::Document* doc = sprite->document();
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
ev.frame(m_frame);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_layer_blend_mode.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -40,7 +40,7 @@ void SetLayerBlendMode::onUndo()
|
||||
void SetLayerBlendMode::onFireNotifications()
|
||||
{
|
||||
Layer* layer = this->layer();
|
||||
doc::Document* doc = layer->sprite()->document();
|
||||
auto doc = static_cast<Document*>(layer->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_layer_name.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -40,7 +40,7 @@ void SetLayerName::onUndo()
|
||||
void SetLayerName::onFireNotifications()
|
||||
{
|
||||
Layer* layer = this->layer();
|
||||
doc::Document* doc = layer->sprite()->document();
|
||||
Document* doc = static_cast<Document*>(layer->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_layer_opacity.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -40,7 +40,7 @@ void SetLayerOpacity::onUndo()
|
||||
void SetLayerOpacity::onFireNotifications()
|
||||
{
|
||||
Layer* layer = this->layer();
|
||||
doc::Document* doc = layer->sprite()->document();
|
||||
auto doc = static_cast<Document*>(layer->sprite()->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(layer->sprite());
|
||||
ev.layer(layer);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -14,11 +14,11 @@
|
||||
#include "app/cmd/replace_image.h"
|
||||
#include "app/cmd/set_cel_opacity.h"
|
||||
#include "app/cmd/set_palette.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cels_range.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/palette.h"
|
||||
@ -148,13 +148,13 @@ void SetPixelFormat::setFormat(PixelFormat format)
|
||||
sprite->incrementVersion();
|
||||
|
||||
// Regenerate extras
|
||||
static_cast<app::Document*>(sprite->document())
|
||||
->setExtraCel(ExtraCelRef(nullptr));
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
doc->setExtraCel(ExtraCelRef(nullptr));
|
||||
|
||||
// Generate notification
|
||||
DocEvent ev(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
sprite->document()->notify_observers<DocEvent&>(&DocObserver::onPixelFormatChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onPixelFormatChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,9 +10,9 @@
|
||||
|
||||
#include "app/cmd/set_pixel_ratio.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -44,9 +44,10 @@ void SetPixelRatio::onUndo()
|
||||
void SetPixelRatio::onFireNotifications()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
DocEvent ev(sprite->document());
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
sprite->document()->notify_observers<DocEvent&>(&DocObserver::onSpritePixelRatioChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onSpritePixelRatioChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2017 David Capello
|
||||
// Copyright (C) 2017-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#include "app/cmd/set_slice_name.h"
|
||||
|
||||
#include "doc/doc_event.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/slice.h"
|
||||
#include "doc/sprite.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_sprite_size.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -45,9 +45,10 @@ void SetSpriteSize::onUndo()
|
||||
void SetSpriteSize::onFireNotifications()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
DocEvent ev(sprite->document());
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
sprite->document()->notify_observers<DocEvent&>(&DocObserver::onSpriteSizeChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onSpriteSizeChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_total_frames.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -41,7 +41,7 @@ void SetTotalFrames::onUndo()
|
||||
void SetTotalFrames::onFireNotifications()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
doc::Document* doc = sprite->document();
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
ev.frame(sprite->totalFrames());
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,8 +10,8 @@
|
||||
|
||||
#include "app/cmd/set_transparent_color.h"
|
||||
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -41,9 +41,10 @@ void SetTransparentColor::onUndo()
|
||||
void SetTransparentColor::onFireNotifications()
|
||||
{
|
||||
Sprite* sprite = this->sprite();
|
||||
DocEvent ev(sprite->document());
|
||||
auto doc = static_cast<Document*>(sprite->document());
|
||||
DocEvent ev(doc);
|
||||
ev.sprite(sprite);
|
||||
sprite->document()->notify_observers<DocEvent&>(&DocObserver::onSpriteTransparentColorChanged, ev);
|
||||
doc->notify_observers<DocEvent&>(&DocObserver::onSpriteTransparentColorChanged, ev);
|
||||
}
|
||||
|
||||
} // namespace cmd
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -41,7 +41,7 @@ void ShiftMaskedCel::shift(int dx, int dy)
|
||||
{
|
||||
Cel* cel = this->cel();
|
||||
Image* image = cel->image();
|
||||
Mask* mask = static_cast<app::Document*>(cel->document())->mask();
|
||||
Mask* mask = static_cast<Document*>(cel->document())->mask();
|
||||
ASSERT(mask->bitmap());
|
||||
if (!mask->bitmap())
|
||||
return;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "app/cmd_transaction.h"
|
||||
|
||||
#include "app/context.h"
|
||||
#include "doc/site.h"
|
||||
#include "app/site.h"
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
#include "app/app.h"
|
||||
@ -119,10 +119,10 @@ size_t CmdTransaction::onMemSize() const
|
||||
return size;
|
||||
}
|
||||
|
||||
doc::SpritePosition CmdTransaction::calcSpritePosition() const
|
||||
SpritePosition CmdTransaction::calcSpritePosition() const
|
||||
{
|
||||
doc::Site site = context()->activeSite();
|
||||
return doc::SpritePosition(site.layer(), site.frame());
|
||||
Site site = context()->activeSite();
|
||||
return SpritePosition(site.layer(), site.frame());
|
||||
}
|
||||
|
||||
bool CmdTransaction::isDocumentRangeEnabled() const
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "app/cmd_sequence.h"
|
||||
#include "app/document_range.h"
|
||||
#include "app/sprite_position.h"
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@ -26,8 +27,8 @@ namespace app {
|
||||
void setNewDocumentRange(const DocumentRange& range);
|
||||
void commit();
|
||||
|
||||
doc::SpritePosition spritePositionBeforeExecute() const { return m_spritePositionBefore; }
|
||||
doc::SpritePosition spritePositionAfterExecute() const { return m_spritePositionAfter; }
|
||||
SpritePosition spritePositionBeforeExecute() const { return m_spritePositionBefore; }
|
||||
SpritePosition spritePositionAfterExecute() const { return m_spritePositionAfter; }
|
||||
|
||||
std::istream* documentRangeBeforeExecute() const;
|
||||
std::istream* documentRangeAfterExecute() const;
|
||||
@ -40,7 +41,7 @@ namespace app {
|
||||
size_t onMemSize() const override;
|
||||
|
||||
private:
|
||||
doc::SpritePosition calcSpritePosition() const;
|
||||
SpritePosition calcSpritePosition() const;
|
||||
bool isDocumentRangeEnabled() const;
|
||||
DocumentRange calcDocumentRange() const;
|
||||
|
||||
@ -49,8 +50,8 @@ namespace app {
|
||||
std::stringstream m_after;
|
||||
};
|
||||
|
||||
doc::SpritePosition m_spritePositionBefore;
|
||||
doc::SpritePosition m_spritePositionAfter;
|
||||
SpritePosition m_spritePositionBefore;
|
||||
SpritePosition m_spritePositionAfter;
|
||||
std::unique_ptr<Ranges> m_ranges;
|
||||
std::string m_label;
|
||||
bool m_changeSavedState;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -12,11 +12,11 @@
|
||||
|
||||
#include "app/document.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/site.h"
|
||||
#include "app/util/wrap_point.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/point.h"
|
||||
#include "render/get_sprite_pixel.h"
|
||||
@ -60,7 +60,7 @@ ColorPicker::ColorPicker()
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPicker::pickColor(const doc::Site& site,
|
||||
void ColorPicker::pickColor(const Site& site,
|
||||
const gfx::PointF& _pos,
|
||||
const render::Projection& proj,
|
||||
const Mode mode)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -12,15 +12,12 @@
|
||||
#include "doc/layer.h"
|
||||
#include "gfx/point.h"
|
||||
|
||||
namespace doc {
|
||||
class Site;
|
||||
}
|
||||
|
||||
namespace render {
|
||||
class Projection;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class Site;
|
||||
|
||||
class ColorPicker {
|
||||
public:
|
||||
@ -32,7 +29,7 @@ namespace app {
|
||||
|
||||
ColorPicker();
|
||||
|
||||
void pickColor(const doc::Site& site,
|
||||
void pickColor(const Site& site,
|
||||
const gfx::PointF& pos,
|
||||
const render::Projection& proj,
|
||||
const Mode mode);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -14,6 +14,7 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/document_range.h"
|
||||
#include "app/modules/gui.h"
|
||||
@ -26,7 +27,6 @@
|
||||
#include "base/scoped_value.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/cels_range.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -41,9 +41,9 @@ using namespace ui;
|
||||
class CelPropertiesWindow;
|
||||
static CelPropertiesWindow* g_window = nullptr;
|
||||
|
||||
class CelPropertiesWindow : public app::gen::CelProperties
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocObserver {
|
||||
class CelPropertiesWindow : public app::gen::CelProperties,
|
||||
public ContextObserver,
|
||||
public DocObserver {
|
||||
public:
|
||||
CelPropertiesWindow()
|
||||
: m_timer(250, this)
|
||||
@ -224,7 +224,7 @@ private:
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const Site& site) override {
|
||||
if (isVisible())
|
||||
setCel(static_cast<app::Document*>(const_cast<doc::Document*>(site.document())),
|
||||
setCel(const_cast<Document*>(site.document()),
|
||||
const_cast<Cel*>(site.cel()));
|
||||
else if (m_document)
|
||||
setCel(nullptr, nullptr);
|
||||
|
@ -16,13 +16,13 @@
|
||||
#include "app/commands/params.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/site.h"
|
||||
#include "app/tools/tool.h"
|
||||
#include "app/tools/tool_box.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/system.h"
|
||||
@ -37,7 +37,7 @@ EyedropperCommand::EyedropperCommand()
|
||||
m_background = false;
|
||||
}
|
||||
|
||||
void EyedropperCommand::pickSample(const doc::Site& site,
|
||||
void EyedropperCommand::pickSample(const Site& site,
|
||||
const gfx::PointF& pixelPos,
|
||||
const render::Projection& proj,
|
||||
app::Color& color)
|
||||
|
@ -12,16 +12,13 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "gfx/point.h"
|
||||
|
||||
namespace doc {
|
||||
class Site;
|
||||
}
|
||||
|
||||
namespace render {
|
||||
class Projection;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class Editor;
|
||||
class Site;
|
||||
|
||||
class EyedropperCommand : public Command {
|
||||
public:
|
||||
@ -29,7 +26,7 @@ namespace app {
|
||||
Command* clone() const override { return new EyedropperCommand(*this); }
|
||||
|
||||
// Returns the color in the given sprite pos.
|
||||
void pickSample(const doc::Site& site,
|
||||
void pickSample(const Site& site,
|
||||
const gfx::PointF& pixelPos,
|
||||
const render::Projection& proj,
|
||||
app::Color& color);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016-2017 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -70,7 +70,7 @@ void LayerOpacityCommand::onExecute(Context* context)
|
||||
{
|
||||
Transaction transaction(writer.context(), "Set Layer Opacity");
|
||||
|
||||
// TODO the range of selected frames should be in doc::Site.
|
||||
// TODO the range of selected frames should be in app::Site.
|
||||
SelectedLayers selLayers;
|
||||
auto range = App::instance()->timeline()->range();
|
||||
if (range.enabled()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -16,6 +16,8 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/separator_in_view.h"
|
||||
@ -24,8 +26,6 @@
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -51,9 +51,9 @@ protected:
|
||||
class LayerPropertiesWindow;
|
||||
static LayerPropertiesWindow* g_window = nullptr;
|
||||
|
||||
class LayerPropertiesWindow : public app::gen::LayerProperties
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocObserver {
|
||||
class LayerPropertiesWindow : public app::gen::LayerProperties,
|
||||
public ContextObserver,
|
||||
public DocObserver {
|
||||
public:
|
||||
class BlendModeItem : public ListItem {
|
||||
public:
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -11,6 +11,7 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/site.h"
|
||||
#include "app/util/new_image_from_mask.h"
|
||||
#include "base/fs.h"
|
||||
#include "doc/cel.h"
|
||||
@ -18,7 +19,6 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
@ -12,17 +12,17 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context.h"
|
||||
#include "app/context_observer.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_access.h"
|
||||
#include "app/document_undo.h"
|
||||
#include "app/document_undo_observer.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "app/site.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/mem_utils.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/site.h"
|
||||
#include "ui/listitem.h"
|
||||
#include "ui/message.h"
|
||||
#include "undo/undo_state.h"
|
||||
@ -32,9 +32,9 @@
|
||||
namespace app {
|
||||
|
||||
class UndoHistoryWindow : public app::gen::UndoHistory,
|
||||
public doc::ContextObserver,
|
||||
public doc::DocumentsObserver,
|
||||
public app::DocumentUndoObserver {
|
||||
public ContextObserver,
|
||||
public DocumentsObserver,
|
||||
public DocumentUndoObserver {
|
||||
public:
|
||||
class Item : public ui::ListItem {
|
||||
public:
|
||||
@ -117,19 +117,17 @@ private:
|
||||
}
|
||||
|
||||
// ContextObserver
|
||||
void onActiveSiteChange(const doc::Site& site) override {
|
||||
void onActiveSiteChange(const Site& site) override {
|
||||
m_frame = site.frame();
|
||||
|
||||
if (m_document == site.document())
|
||||
return;
|
||||
|
||||
attachDocument(
|
||||
static_cast<app::Document*>(
|
||||
const_cast<doc::Document*>(site.document())));
|
||||
attachDocument(const_cast<Document*>(site.document()));
|
||||
}
|
||||
|
||||
// DocumentsObserver
|
||||
void onRemoveDocument(doc::Document* doc) override {
|
||||
void onRemoveDocument(Document* doc) override {
|
||||
if (m_document && m_document == doc)
|
||||
detachDocument();
|
||||
}
|
||||
@ -171,7 +169,7 @@ private:
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void attachDocument(app::Document* document) {
|
||||
void attachDocument(Document* document) {
|
||||
detachDocument();
|
||||
|
||||
m_document = document;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Params;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "app/find_widget.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/load_widget.h"
|
||||
#include "app/site.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/color_button.h"
|
||||
#include "app/ui/keyboard_shortcuts.h"
|
||||
@ -28,7 +29,6 @@
|
||||
#include "base/bind.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "filters/replace_color_filter.h"
|
||||
#include "ui/ui.h"
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "app/ini_file.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/palettes.h"
|
||||
#include "app/site.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
@ -32,7 +33,6 @@
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "filters/filter.h"
|
||||
#include "ui/manager.h"
|
||||
|
@ -9,12 +9,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/commands/filters/cels_target.h"
|
||||
#include "app/site.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/image_impl.h"
|
||||
#include "doc/image_ref.h"
|
||||
#include "doc/pixel_format.h"
|
||||
#include "doc/site.h"
|
||||
#include "filters/filter_indexed_data.h"
|
||||
#include "filters/filter_manager.h"
|
||||
#include "gfx/rect.h"
|
||||
@ -35,6 +35,7 @@ namespace filters {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Document;
|
||||
class Transaction;
|
||||
@ -132,7 +133,7 @@ namespace app {
|
||||
void redrawColorPalette();
|
||||
|
||||
Context* m_context;
|
||||
doc::Site m_site;
|
||||
Site m_site;
|
||||
Filter* m_filter;
|
||||
doc::Cel* m_cel;
|
||||
doc::ImageRef m_src;
|
||||
|
@ -15,7 +15,8 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/console.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/site.h"
|
||||
#include "app/site.h"
|
||||
#include "doc/layer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
@ -23,25 +24,41 @@
|
||||
namespace app {
|
||||
|
||||
Context::Context()
|
||||
: m_lastSelectedDoc(nullptr)
|
||||
: m_docs(this)
|
||||
, m_lastSelectedDoc(nullptr)
|
||||
{
|
||||
m_docs.add_observer(this);
|
||||
}
|
||||
|
||||
void Context::sendDocumentToTop(doc::Document* document)
|
||||
Context::~Context()
|
||||
{
|
||||
m_docs.remove_observer(this);
|
||||
}
|
||||
|
||||
void Context::sendDocumentToTop(Document* document)
|
||||
{
|
||||
ASSERT(document != NULL);
|
||||
|
||||
documents().move(document, 0);
|
||||
}
|
||||
|
||||
void Context::setActiveDocument(doc::Document* document)
|
||||
Site Context::activeSite() const
|
||||
{
|
||||
onSetActiveDocument(document);
|
||||
Site site;
|
||||
onGetActiveSite(&site);
|
||||
return site;
|
||||
}
|
||||
|
||||
app::Document* Context::activeDocument() const
|
||||
Document* Context::activeDocument() const
|
||||
{
|
||||
return static_cast<app::Document*>(doc::Context::activeDocument());
|
||||
Site site;
|
||||
onGetActiveSite(&site);
|
||||
return site.document();
|
||||
}
|
||||
|
||||
void Context::setActiveDocument(Document* document)
|
||||
{
|
||||
onSetActiveDocument(document);
|
||||
}
|
||||
|
||||
bool Context::hasModifiedDocuments() const
|
||||
@ -52,6 +69,12 @@ bool Context::hasModifiedDocuments() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Context::notifyActiveSiteChanged()
|
||||
{
|
||||
Site site = activeSite();
|
||||
notify_observers<const Site&>(&ContextObserver::onActiveSiteChange, site);
|
||||
}
|
||||
|
||||
void Context::executeCommand(const char* commandName)
|
||||
{
|
||||
Command* cmd = Commands::instance()->byId(commandName);
|
||||
@ -122,23 +145,23 @@ void Context::executeCommand(Command* command, const Params& params)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Context::onCreateDocument(doc::CreateDocumentArgs* args)
|
||||
void Context::onCreateDocument(CreateDocumentArgs* args)
|
||||
{
|
||||
args->setDocument(new app::Document(NULL));
|
||||
args->setDocument(new app::Document(nullptr));
|
||||
}
|
||||
|
||||
void Context::onAddDocument(doc::Document* doc)
|
||||
void Context::onAddDocument(Document* doc)
|
||||
{
|
||||
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
||||
m_lastSelectedDoc = doc;
|
||||
}
|
||||
|
||||
void Context::onRemoveDocument(doc::Document* doc)
|
||||
void Context::onRemoveDocument(Document* doc)
|
||||
{
|
||||
if (doc == m_lastSelectedDoc)
|
||||
m_lastSelectedDoc = nullptr;
|
||||
}
|
||||
|
||||
void Context::onGetActiveSite(doc::Site* site) const
|
||||
void Context::onGetActiveSite(Site* site) const
|
||||
{
|
||||
// Default/dummy site (maybe for batch/command line mode)
|
||||
if (Document* doc = m_lastSelectedDoc) {
|
||||
@ -149,9 +172,9 @@ void Context::onGetActiveSite(doc::Site* site) const
|
||||
}
|
||||
}
|
||||
|
||||
void Context::onSetActiveDocument(doc::Document* doc)
|
||||
void Context::onSetActiveDocument(Document* doc)
|
||||
{
|
||||
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
||||
m_lastSelectedDoc = doc;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -10,9 +10,12 @@
|
||||
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context_flags.h"
|
||||
#include "app/context_observer.h"
|
||||
#include "app/documents.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "base/disable_copying.h"
|
||||
#include "base/exception.h"
|
||||
#include "doc/context.h"
|
||||
#include "obs/observable.h"
|
||||
#include "obs/signal.h"
|
||||
|
||||
#include <vector>
|
||||
@ -48,9 +51,14 @@ namespace app {
|
||||
bool m_canceled;
|
||||
};
|
||||
|
||||
class Context : public doc::Context {
|
||||
class Context : public obs::observable<ContextObserver>,
|
||||
public DocumentsObserver {
|
||||
public:
|
||||
Context();
|
||||
virtual ~Context();
|
||||
|
||||
const Documents& documents() const { return m_docs; }
|
||||
Documents& documents() { return m_docs; }
|
||||
|
||||
virtual bool isUIAvailable() const { return false; }
|
||||
virtual bool isRecordingMacro() const { return false; }
|
||||
@ -60,16 +68,18 @@ namespace app {
|
||||
bool checkFlags(uint32_t flags) const { return m_flags.check(flags); }
|
||||
void updateFlags() { m_flags.update(this); }
|
||||
|
||||
void sendDocumentToTop(doc::Document* document);
|
||||
void sendDocumentToTop(Document* document);
|
||||
|
||||
void setActiveDocument(doc::Document* document);
|
||||
app::Document* activeDocument() const;
|
||||
Site activeSite() const;
|
||||
Document* activeDocument() const;
|
||||
void setActiveDocument(Document* document);
|
||||
bool hasModifiedDocuments() const;
|
||||
void notifyActiveSiteChanged();
|
||||
|
||||
void executeCommand(const char* commandName);
|
||||
virtual void executeCommand(Command* command, const Params& params = Params());
|
||||
|
||||
virtual DocumentView* getFirstDocumentView(doc::Document* document) const {
|
||||
virtual DocumentView* getFirstDocumentView(Document* document) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -77,17 +87,19 @@ namespace app {
|
||||
obs::signal<void (CommandExecutionEvent&)> AfterCommandExecution;
|
||||
|
||||
protected:
|
||||
void onCreateDocument(doc::CreateDocumentArgs* args) override;
|
||||
void onAddDocument(doc::Document* doc) override;
|
||||
void onRemoveDocument(doc::Document* doc) override;
|
||||
void onGetActiveSite(doc::Site* site) const override;
|
||||
virtual void onSetActiveDocument(doc::Document* doc);
|
||||
// DocumentsObserver impl
|
||||
void onCreateDocument(CreateDocumentArgs* args) override;
|
||||
void onAddDocument(Document* doc) override;
|
||||
void onRemoveDocument(Document* doc) override;
|
||||
|
||||
virtual void onGetActiveSite(Site* site) const;
|
||||
virtual void onSetActiveDocument(Document* doc);
|
||||
|
||||
Document* lastSelectedDoc() { return m_lastSelectedDoc; }
|
||||
|
||||
private:
|
||||
// Last updated flags.
|
||||
ContextFlags m_flags;
|
||||
Documents m_docs;
|
||||
ContextFlags m_flags; // Last updated flags.
|
||||
Document* m_lastSelectedDoc;
|
||||
|
||||
DISABLE_COPYING(Context);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/document_access.h"
|
||||
#include "doc/site.h"
|
||||
#include "app/site.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/site.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,13 +10,10 @@
|
||||
|
||||
#include "base/ints.h"
|
||||
|
||||
namespace doc {
|
||||
class Site;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Site;
|
||||
|
||||
class ContextFlags {
|
||||
public:
|
||||
@ -43,7 +40,7 @@ namespace app {
|
||||
void update(Context* context);
|
||||
|
||||
private:
|
||||
void updateFlagsFromSite(const doc::Site& site);
|
||||
void updateFlagsFromSite(const Site& site);
|
||||
|
||||
uint32_t m_flags;
|
||||
};
|
||||
|
24
src/app/context_observer.h
Normal file
24
src/app/context_observer.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef APP_CONTEXT_OBSERVER_H_INCLUDED
|
||||
#define APP_CONTEXT_OBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace app {
|
||||
|
||||
class Document;
|
||||
class Site;
|
||||
|
||||
class ContextObserver {
|
||||
public:
|
||||
virtual ~ContextObserver() { }
|
||||
virtual void onActiveSiteChange(const Site& site) { }
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -1,18 +1,15 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2014 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "tests/test.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "doc/context.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
|
||||
using namespace app;
|
||||
using namespace doc;
|
||||
|
||||
namespace doc {
|
||||
@ -20,13 +17,13 @@ namespace doc {
|
||||
std::ostream& operator<<(std::ostream& os, ColorMode mode) {
|
||||
return os << (int)mode;
|
||||
}
|
||||
|
||||
|
||||
} // namespace doc
|
||||
|
||||
TEST(Context, AddDocument)
|
||||
{
|
||||
Context ctx;
|
||||
Document* doc = ctx.documents().add(32, 28);
|
||||
auto doc = ctx.documents().add(32, 28);
|
||||
ASSERT_TRUE(doc != NULL);
|
||||
|
||||
EXPECT_EQ(32, doc->width());
|
||||
@ -37,8 +34,8 @@ TEST(Context, AddDocument)
|
||||
TEST(Context, DeleteDocuments)
|
||||
{
|
||||
Context ctx;
|
||||
Document* doc1 = ctx.documents().add(2, 2);
|
||||
Document* doc2 = ctx.documents().add(4, 4);
|
||||
auto doc1 = ctx.documents().add(2, 2);
|
||||
auto doc2 = ctx.documents().add(4, 4);
|
||||
EXPECT_EQ(2, ctx.documents().size());
|
||||
|
||||
delete doc1;
|
||||
@ -52,8 +49,8 @@ TEST(Context, CloseAndDeleteDocuments)
|
||||
Context ctx;
|
||||
EXPECT_EQ(0, ctx.documents().size());
|
||||
|
||||
Document* doc1 = ctx.documents().add(2, 2);
|
||||
Document* doc2 = ctx.documents().add(4, 4);
|
||||
auto doc1 = ctx.documents().add(2, 2);
|
||||
auto doc2 = ctx.documents().add(4, 4);
|
||||
EXPECT_EQ(2, ctx.documents().size());
|
||||
|
||||
doc1->close();
|
||||
@ -67,8 +64,8 @@ TEST(Context, CloseAndDeleteDocuments)
|
||||
TEST(Context, SwitchContext)
|
||||
{
|
||||
Context ctx1, ctx2;
|
||||
Document* doc1 = new Document();
|
||||
Document* doc2 = new Document();
|
||||
auto doc1 = new app::Document(nullptr);
|
||||
auto doc2 = new app::Document(nullptr);
|
||||
doc1->setContext(&ctx1);
|
||||
doc2->setContext(&ctx2);
|
||||
EXPECT_EQ(&ctx1, doc1->context());
|
||||
@ -86,9 +83,3 @@ TEST(Context, SwitchContext)
|
||||
EXPECT_EQ(&ctx1, doc1->context());
|
||||
EXPECT_EQ(&ctx2, doc2->context());
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
#include "app/crash/backup_observer.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/context.h"
|
||||
#include "app/crash/session.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_access.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "base/chrono.h"
|
||||
#include "base/remove_from_container.h"
|
||||
#include "base/scoped_lock.h"
|
||||
#include "doc/context.h"
|
||||
|
||||
#ifdef TEST_BACKUP_INTEGRITY
|
||||
#include "ui/system.h"
|
||||
@ -54,7 +54,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
BackupObserver::BackupObserver(Session* session, doc::Context* ctx)
|
||||
BackupObserver::BackupObserver(Session* session, Context* ctx)
|
||||
: m_session(session)
|
||||
, m_ctx(ctx)
|
||||
, m_done(false)
|
||||
@ -76,14 +76,14 @@ void BackupObserver::stop()
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
void BackupObserver::onAddDocument(doc::Document* document)
|
||||
void BackupObserver::onAddDocument(Document* document)
|
||||
{
|
||||
TRACE("RECO: Observe document %p\n", document);
|
||||
base::scoped_lock hold(m_mutex);
|
||||
m_documents.push_back(static_cast<app::Document*>(document));
|
||||
}
|
||||
|
||||
void BackupObserver::onRemoveDocument(doc::Document* document)
|
||||
void BackupObserver::onRemoveDocument(Document* document)
|
||||
{
|
||||
TRACE("RECO: Remove document %p\n", document);
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -8,42 +8,39 @@
|
||||
#define APP_CRASH_BACKUP_OBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/context_observer.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "base/mutex.h"
|
||||
#include "base/thread.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace doc {
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class Context;
|
||||
class Document;
|
||||
namespace crash {
|
||||
class Session;
|
||||
|
||||
class BackupObserver : public doc::ContextObserver
|
||||
, public doc::DocumentsObserver
|
||||
, public doc::DocObserver {
|
||||
class BackupObserver : public ContextObserver
|
||||
, public DocumentsObserver
|
||||
, public DocObserver {
|
||||
public:
|
||||
BackupObserver(Session* session, doc::Context* ctx);
|
||||
BackupObserver(Session* session, Context* ctx);
|
||||
~BackupObserver();
|
||||
|
||||
void stop();
|
||||
|
||||
void onAddDocument(doc::Document* document) override;
|
||||
void onRemoveDocument(doc::Document* document) override;
|
||||
void onAddDocument(Document* document) override;
|
||||
void onRemoveDocument(Document* document) override;
|
||||
|
||||
private:
|
||||
void backgroundThread();
|
||||
|
||||
Session* m_session;
|
||||
base::mutex m_mutex;
|
||||
doc::Context* m_ctx;
|
||||
std::vector<app::Document*> m_documents;
|
||||
Context* m_ctx;
|
||||
std::vector<Document*> m_documents;
|
||||
bool m_done;
|
||||
base::thread m_thread;
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -21,7 +21,7 @@
|
||||
namespace app {
|
||||
namespace crash {
|
||||
|
||||
DataRecovery::DataRecovery(doc::Context* ctx)
|
||||
DataRecovery::DataRecovery(Context* ctx)
|
||||
: m_inProgress(nullptr)
|
||||
, m_backup(nullptr)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -13,11 +13,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace doc {
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class Context;
|
||||
namespace crash {
|
||||
class BackupObserver;
|
||||
|
||||
@ -25,7 +22,7 @@ namespace crash {
|
||||
public:
|
||||
typedef std::vector<SessionPtr> Sessions;
|
||||
|
||||
DataRecovery(doc::Context* context);
|
||||
DataRecovery(Context* context);
|
||||
~DataRecovery();
|
||||
|
||||
Session* activeSession() { return m_inProgress.get(); }
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2017 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_DOC_EVENT_H_INCLUDED
|
||||
#define DOC_DOC_EVENT_H_INCLUDED
|
||||
#ifndef APP_DOC_EVENT_H_INCLUDED
|
||||
#define APP_DOC_EVENT_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "gfx/region.h"
|
||||
@ -20,7 +20,7 @@ namespace doc {
|
||||
class Sprite;
|
||||
}
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
class Document;
|
||||
|
||||
using namespace doc;
|
@ -1,14 +1,14 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2017 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_DOC_OBSERVER_H_INCLUDED
|
||||
#define DOC_DOC_OBSERVER_H_INCLUDED
|
||||
#ifndef APP_DOC_OBSERVER_H_INCLUDED
|
||||
#define APP_DOC_OBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
class Document;
|
||||
class DocEvent;
|
||||
|
||||
@ -70,6 +70,6 @@ namespace doc {
|
||||
virtual void dispose() { }
|
||||
};
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -14,6 +14,9 @@
|
||||
#include "app/color_target.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/context.h"
|
||||
#include "app/context.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/document_undo.h"
|
||||
#include "app/file/format_options.h"
|
||||
@ -23,9 +26,6 @@
|
||||
#include "base/memory.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/context.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/mask.h"
|
||||
@ -42,7 +42,8 @@ using namespace base;
|
||||
using namespace doc;
|
||||
|
||||
Document::Document(Sprite* sprite)
|
||||
: m_flags(kMaskVisible)
|
||||
: m_ctx(nullptr)
|
||||
, m_flags(kMaskVisible)
|
||||
, m_undo(new DocumentUndo)
|
||||
// Information about the file format used to load/save this document
|
||||
, m_format_options(nullptr)
|
||||
@ -58,12 +59,21 @@ Document::Document(Sprite* sprite)
|
||||
|
||||
Document::~Document()
|
||||
{
|
||||
// We cannot be in a context at this moment. If we were in a
|
||||
// context, doc::~Document() would remove the document from the
|
||||
// context and it would generate onRemoveDocument() notifications,
|
||||
// which could result in serious problems for observers expecting a
|
||||
// fully created app::Document.
|
||||
ASSERT(context() == NULL);
|
||||
removeFromContext();
|
||||
}
|
||||
|
||||
void Document::setContext(Context* ctx)
|
||||
{
|
||||
if (ctx == m_ctx)
|
||||
return;
|
||||
|
||||
removeFromContext();
|
||||
|
||||
m_ctx = ctx;
|
||||
if (ctx)
|
||||
ctx->documents().add(this);
|
||||
|
||||
onContextChanged();
|
||||
}
|
||||
|
||||
DocumentApi Document::getApi(Transaction& transaction)
|
||||
@ -98,62 +108,62 @@ color_t Document::bgColor(Layer* layer) const
|
||||
|
||||
void Document::notifyGeneralUpdate()
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onGeneralUpdate, ev);
|
||||
DocEvent ev(this);
|
||||
notify_observers<DocEvent&>(&DocObserver::onGeneralUpdate, ev);
|
||||
}
|
||||
|
||||
void Document::notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region, frame_t frame)
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
DocEvent ev(this);
|
||||
ev.sprite(sprite);
|
||||
ev.region(region);
|
||||
ev.frame(frame);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onSpritePixelsModified, ev);
|
||||
notify_observers<DocEvent&>(&DocObserver::onSpritePixelsModified, ev);
|
||||
}
|
||||
|
||||
void Document::notifyExposeSpritePixels(Sprite* sprite, const gfx::Region& region)
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
DocEvent ev(this);
|
||||
ev.sprite(sprite);
|
||||
ev.region(region);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onExposeSpritePixels, ev);
|
||||
notify_observers<DocEvent&>(&DocObserver::onExposeSpritePixels, ev);
|
||||
}
|
||||
|
||||
void Document::notifyLayerMergedDown(Layer* srcLayer, Layer* targetLayer)
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
DocEvent ev(this);
|
||||
ev.sprite(srcLayer->sprite());
|
||||
ev.layer(srcLayer);
|
||||
ev.targetLayer(targetLayer);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onLayerMergedDown, ev);
|
||||
notify_observers<DocEvent&>(&DocObserver::onLayerMergedDown, ev);
|
||||
}
|
||||
|
||||
void Document::notifyCelMoved(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame)
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
DocEvent ev(this);
|
||||
ev.sprite(fromLayer->sprite());
|
||||
ev.layer(fromLayer);
|
||||
ev.frame(fromFrame);
|
||||
ev.targetLayer(toLayer);
|
||||
ev.targetFrame(toFrame);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onCelMoved, ev);
|
||||
notify_observers<DocEvent&>(&DocObserver::onCelMoved, ev);
|
||||
}
|
||||
|
||||
void Document::notifyCelCopied(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame)
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
DocEvent ev(this);
|
||||
ev.sprite(fromLayer->sprite());
|
||||
ev.layer(fromLayer);
|
||||
ev.frame(fromFrame);
|
||||
ev.targetLayer(toLayer);
|
||||
ev.targetFrame(toFrame);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onCelCopied, ev);
|
||||
notify_observers<DocEvent&>(&DocObserver::onCelCopied, ev);
|
||||
}
|
||||
|
||||
void Document::notifySelectionChanged()
|
||||
{
|
||||
doc::DocEvent ev(this);
|
||||
notify_observers<doc::DocEvent&>(&doc::DocObserver::onSelectionChanged, ev);
|
||||
DocEvent ev(this);
|
||||
notify_observers<DocEvent&>(&DocObserver::onSelectionChanged, ev);
|
||||
}
|
||||
|
||||
bool Document::isModified() const
|
||||
@ -446,11 +456,31 @@ Document* Document::duplicate(DuplicateType type) const
|
||||
return documentCopy.release();
|
||||
}
|
||||
|
||||
void Document::close()
|
||||
{
|
||||
removeFromContext();
|
||||
}
|
||||
|
||||
void Document::onFileNameChange()
|
||||
{
|
||||
notify_observers(&DocObserver::onFileNameChanged, this);
|
||||
}
|
||||
|
||||
void Document::onContextChanged()
|
||||
{
|
||||
m_undo->setContext(context());
|
||||
}
|
||||
|
||||
void Document::removeFromContext()
|
||||
{
|
||||
if (m_ctx) {
|
||||
m_ctx->documents().remove(this);
|
||||
m_ctx = nullptr;
|
||||
|
||||
onContextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
gfx::Point Document::NoLastDrawingPoint()
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define APP_DOCUMENT_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/extra_cel.h"
|
||||
#include "app/file/format_options.h"
|
||||
#include "app/transformation.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#include "doc/frame.h"
|
||||
#include "doc/pixel_format.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "obs/observable.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -38,6 +40,8 @@ namespace gfx {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class DocumentApi;
|
||||
class DocumentUndo;
|
||||
class Transaction;
|
||||
@ -52,7 +56,8 @@ namespace app {
|
||||
// An application document. It is the class used to contain one file
|
||||
// opened and being edited by the user (a sprite).
|
||||
class Document : public doc::Document,
|
||||
public base::RWLock {
|
||||
public base::RWLock,
|
||||
public obs::observable<DocObserver> {
|
||||
enum Flags {
|
||||
kAssociatedToFile = 1, // This sprite is associated to a file in the file-system
|
||||
kMaskVisible = 2, // The mask wasn't hidden by the user
|
||||
@ -62,6 +67,9 @@ namespace app {
|
||||
Document(Sprite* sprite);
|
||||
~Document();
|
||||
|
||||
Context* context() const { return m_ctx; }
|
||||
void setContext(Context* ctx);
|
||||
|
||||
// Returns a high-level API: observable and undoable methods.
|
||||
DocumentApi getApi(Transaction& transaction);
|
||||
|
||||
@ -173,10 +181,16 @@ namespace app {
|
||||
void copyLayerContent(const Layer* sourceLayer, Document* destDoc, Layer* destLayer) const;
|
||||
Document* duplicate(DuplicateType type) const;
|
||||
|
||||
void close();
|
||||
|
||||
protected:
|
||||
virtual void onContextChanged() override;
|
||||
void onFileNameChange() override;
|
||||
virtual void onContextChanged();
|
||||
|
||||
private:
|
||||
void removeFromContext();
|
||||
|
||||
Context* m_ctx;
|
||||
int m_flags;
|
||||
|
||||
// Undo and redo information about the document.
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "app/cmd/set_transparent_color.h"
|
||||
#include "app/color_target.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_undo.h"
|
||||
#include "app/transaction.h"
|
||||
@ -49,7 +50,6 @@
|
||||
#include "doc/algorithm/flip_image.h"
|
||||
#include "doc/algorithm/shrink_bounds.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/context.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/frame_tags.h"
|
||||
#include "doc/mask.h"
|
||||
|
@ -9,12 +9,12 @@
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/test_context.h"
|
||||
#include "app/transaction.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/test_context.h"
|
||||
|
||||
using namespace app;
|
||||
using namespace doc;
|
||||
|
@ -29,6 +29,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Document;
|
||||
|
||||
|
@ -12,10 +12,10 @@
|
||||
#include "app/document_range.h"
|
||||
#include "app/document_range_ops.h"
|
||||
#include "app/document_undo.h"
|
||||
#include "app/test_context.h"
|
||||
#include "app/transaction.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/test_context.h"
|
||||
|
||||
using namespace app;
|
||||
using namespace doc;
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include "app/app.h"
|
||||
#include "app/cmd.h"
|
||||
#include "app/cmd_transaction.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document_undo_observer.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "base/mem_utils.h"
|
||||
#include "doc/context.h"
|
||||
#include "undo/undo_history.h"
|
||||
#include "undo/undo_state.h"
|
||||
|
||||
@ -37,7 +37,7 @@ DocumentUndo::DocumentUndo()
|
||||
{
|
||||
}
|
||||
|
||||
void DocumentUndo::setContext(doc::Context* ctx)
|
||||
void DocumentUndo::setContext(Context* ctx)
|
||||
{
|
||||
m_ctx = ctx;
|
||||
}
|
||||
|
@ -9,24 +9,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/document_range.h"
|
||||
#include "app/sprite_position.h"
|
||||
#include "base/disable_copying.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/sprite_position.h"
|
||||
#include "obs/observable.h"
|
||||
#include "undo/undo_history.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
namespace doc {
|
||||
class Context;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
using namespace doc;
|
||||
|
||||
class Cmd;
|
||||
class CmdTransaction;
|
||||
class Context;
|
||||
class DocumentUndoObserver;
|
||||
|
||||
class DocumentUndo : public obs::observable<DocumentUndoObserver>,
|
||||
@ -36,7 +33,7 @@ namespace app {
|
||||
|
||||
size_t totalUndoSize() const { return m_totalUndoSize; }
|
||||
|
||||
void setContext(doc::Context* ctx);
|
||||
void setContext(Context* ctx);
|
||||
|
||||
void add(CmdTransaction* cmd);
|
||||
|
||||
@ -76,7 +73,7 @@ namespace app {
|
||||
void onDeleteUndoState(undo::UndoState* state) override;
|
||||
|
||||
undo::UndoHistory m_undoHistory;
|
||||
doc::Context* m_ctx;
|
||||
Context* m_ctx;
|
||||
size_t m_totalUndoSize;
|
||||
|
||||
// This counter is equal to 0 if we are in the "saved state", i.e.
|
||||
|
@ -1,22 +1,23 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "doc/documents.h"
|
||||
#include "app/documents.h"
|
||||
|
||||
#include "app/document.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/mutex.h"
|
||||
#include "doc/document.h"
|
||||
#include "base/unique_ptr.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
|
||||
Documents::Documents(Context* ctx)
|
||||
: m_ctx(ctx)
|
||||
@ -36,7 +37,7 @@ Document* Documents::add(int width, int height, ColorMode mode, int ncolors)
|
||||
CreateDocumentArgs args;
|
||||
notify_observers(&DocumentsObserver::onCreateDocument, &args);
|
||||
if (!args.document())
|
||||
args.setDocument(new Document());
|
||||
args.setDocument(new Document(nullptr));
|
||||
|
||||
base::UniquePtr<Document> doc(args.document());
|
||||
doc->sprites().add(width, height, mode, ncolors);
|
||||
@ -122,4 +123,4 @@ void Documents::deleteAll()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
@ -1,22 +1,23 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_DOCUMENTS_H_INCLUDED
|
||||
#define DOC_DOCUMENTS_H_INCLUDED
|
||||
#ifndef APP_DOCUMENTS_H_INCLUDED
|
||||
#define APP_DOCUMENTS_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/documents_observer.h"
|
||||
#include "base/disable_copying.h"
|
||||
#include "doc/color_mode.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/object_id.h"
|
||||
#include "obs/observable.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Document;
|
||||
|
||||
@ -41,7 +42,9 @@ namespace doc {
|
||||
bool empty() const { return m_docs.empty(); }
|
||||
|
||||
// Add a new documents to the list.
|
||||
Document* add(int width, int height, ColorMode mode = ColorMode::RGB, int ncolors = 256);
|
||||
Document* add(int width, int height,
|
||||
doc::ColorMode mode = doc::ColorMode::RGB,
|
||||
int ncolors = 256);
|
||||
Document* add(Document* doc);
|
||||
|
||||
// Removes a document from the list without deleting it. You must
|
||||
@ -54,7 +57,7 @@ namespace doc {
|
||||
void move(Document* doc, int index);
|
||||
|
||||
Document* operator[](int index) const { return m_docs[index]; }
|
||||
Document* getById(ObjectId id) const;
|
||||
Document* getById(doc::ObjectId id) const;
|
||||
Document* getByName(const std::string& name) const;
|
||||
Document* getByFileName(const std::string& filename) const;
|
||||
|
||||
@ -68,6 +71,6 @@ namespace doc {
|
||||
DISABLE_COPYING(Documents);
|
||||
};
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -1,14 +1,14 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_DOCUMENTS_OBSERVER_H_INCLUDED
|
||||
#define DOC_DOCUMENTS_OBSERVER_H_INCLUDED
|
||||
#ifndef APP_DOCUMENTS_OBSERVER_H_INCLUDED
|
||||
#define APP_DOCUMENTS_OBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
class Document;
|
||||
|
||||
class CreateDocumentArgs {
|
||||
@ -28,6 +28,6 @@ namespace doc {
|
||||
virtual void onRemoveDocument(Document* doc) { }
|
||||
};
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -43,6 +43,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class Context;
|
||||
class Document;
|
||||
class FileFormat;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -32,7 +32,7 @@ TEST(File, SeveralSizes)
|
||||
std::sprintf(&fn[0], "test.ase");
|
||||
|
||||
{
|
||||
base::UniquePtr<doc::Document> doc(ctx.documents().add(w, h, doc::ColorMode::INDEXED, 256));
|
||||
base::UniquePtr<app::Document> doc(ctx.documents().add(w, h, doc::ColorMode::INDEXED, 256));
|
||||
doc->setFilename(&fn[0]);
|
||||
|
||||
// Random pixels
|
||||
|
@ -140,7 +140,7 @@ bool save_palette(const char* filename, const Palette* pal, int columns)
|
||||
int h = (pal->size() / w) + (pal->size() % w > 0 ? 1: 0);
|
||||
|
||||
app::Context tmpContext;
|
||||
doc::Document* doc = tmpContext.documents().add(
|
||||
Document* doc = tmpContext.documents().add(
|
||||
w, h, (pal->size() <= 256 ? doc::ColorMode::INDEXED:
|
||||
doc::ColorMode::RGB), pal->size());
|
||||
|
||||
|
@ -138,7 +138,7 @@ DocumentPreferences& Preferences::document(const app::Document* doc)
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::removeDocument(doc::Document* doc)
|
||||
void Preferences::removeDocument(Document* doc)
|
||||
{
|
||||
ASSERT(dynamic_cast<app::Document*>(doc));
|
||||
|
||||
@ -150,12 +150,12 @@ void Preferences::removeDocument(doc::Document* doc)
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::onRemoveDocument(doc::Document* doc)
|
||||
void Preferences::onRemoveDocument(Document* doc)
|
||||
{
|
||||
removeDocument(doc);
|
||||
}
|
||||
|
||||
std::string Preferences::docConfigFileName(const app::Document* doc)
|
||||
std::string Preferences::docConfigFileName(const Document* doc)
|
||||
{
|
||||
if (!doc)
|
||||
return "";
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "app/color.h"
|
||||
#include "app/commands/filters/cels_target.h"
|
||||
#include "app/document_exporter.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "app/pref/option.h"
|
||||
#include "app/sprite_sheet_type.h"
|
||||
#include "app/tools/freehand_algorithm.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "doc/algorithm/resize_image.h"
|
||||
#include "doc/anidir.h"
|
||||
#include "doc/brush_pattern.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/frame.h"
|
||||
#include "doc/layer_list.h"
|
||||
#include "filters/tiled_mode.h"
|
||||
@ -44,8 +44,8 @@ namespace app {
|
||||
typedef app::gen::ToolPref ToolPreferences;
|
||||
typedef app::gen::DocPref DocumentPreferences;
|
||||
|
||||
class Preferences : public app::gen::GlobalPref
|
||||
, public doc::DocumentsObserver {
|
||||
class Preferences : public app::gen::GlobalPref,
|
||||
public app::DocumentsObserver {
|
||||
public:
|
||||
static Preferences& instance();
|
||||
|
||||
@ -60,23 +60,23 @@ namespace app {
|
||||
bool isSet(OptionBase& opt) const;
|
||||
|
||||
ToolPreferences& tool(tools::Tool* tool);
|
||||
DocumentPreferences& document(const app::Document* doc);
|
||||
DocumentPreferences& document(const Document* doc);
|
||||
|
||||
// Remove one document explicitly (this can be used if the
|
||||
// document used in Preferences::document() function wasn't member
|
||||
// of UIContext.
|
||||
void removeDocument(doc::Document* doc);
|
||||
void removeDocument(Document* doc);
|
||||
|
||||
protected:
|
||||
void onRemoveDocument(doc::Document* doc) override;
|
||||
void onRemoveDocument(Document* doc) override;
|
||||
|
||||
private:
|
||||
std::string docConfigFileName(const app::Document* doc);
|
||||
std::string docConfigFileName(const Document* doc);
|
||||
|
||||
void serializeDocPref(const app::Document* doc, app::DocumentPreferences* docPref, bool save);
|
||||
void serializeDocPref(const Document* doc, app::DocumentPreferences* docPref, bool save);
|
||||
|
||||
std::map<std::string, app::ToolPreferences*> m_tools;
|
||||
std::map<const app::Document*, app::DocumentPreferences*> m_docs;
|
||||
std::map<const Document*, DocumentPreferences*> m_docs;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include "app/file/palette_file.h"
|
||||
#include "app/script/app_scripting.h"
|
||||
#include "app/script/sprite_wrap.h"
|
||||
#include "app/site.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "script/engine.h"
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
#include "app/document.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/script/image_wrap.h"
|
||||
#include "app/site.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -85,7 +85,7 @@ ImageWrap* SpriteWrap::activeImage()
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
doc::Site site;
|
||||
Site site;
|
||||
m_view->getSite(&site);
|
||||
return wrapImage(site.image());
|
||||
#else
|
||||
|
@ -1,25 +1,27 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "doc/site.h"
|
||||
#include "app/site.h"
|
||||
|
||||
#include "base/base.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
|
||||
using namespace doc;
|
||||
|
||||
Palette* Site::palette()
|
||||
{
|
||||
return (m_sprite ? m_sprite->palette(m_frame): NULL);
|
||||
return (m_sprite ? m_sprite->palette(m_frame): nullptr);
|
||||
}
|
||||
|
||||
const Cel* Site::cel() const
|
||||
@ -27,7 +29,7 @@ const Cel* Site::cel() const
|
||||
if (m_layer)
|
||||
return m_layer->cel(m_frame);
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Cel* Site::cel()
|
||||
@ -35,12 +37,12 @@ Cel* Site::cel()
|
||||
if (m_layer)
|
||||
return m_layer->cel(m_frame);
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Image* Site::image(int* x, int* y, int* opacity) const
|
||||
{
|
||||
Image* image = NULL;
|
||||
Image* image = nullptr;
|
||||
|
||||
if (m_sprite) {
|
||||
if (const Cel* cel = this->cel()) {
|
||||
@ -56,7 +58,7 @@ Image* Site::image(int* x, int* y, int* opacity) const
|
||||
|
||||
Palette* Site::palette() const
|
||||
{
|
||||
return (m_sprite ? m_sprite->palette(m_frame): NULL);
|
||||
return (m_sprite ? m_sprite->palette(m_frame): nullptr);
|
||||
}
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
@ -1,11 +1,11 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_SITE_H_INCLUDED
|
||||
#define DOC_SITE_H_INCLUDED
|
||||
#ifndef APP_SITE_H_INCLUDED
|
||||
#define APP_SITE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/frame.h"
|
||||
@ -13,13 +13,15 @@
|
||||
#include "doc/selected_layers.h"
|
||||
|
||||
namespace doc {
|
||||
|
||||
class Cel;
|
||||
class Document;
|
||||
class Image;
|
||||
class Layer;
|
||||
class Palette;
|
||||
class Sprite;
|
||||
} // namespace doc
|
||||
|
||||
namespace app {
|
||||
class Document;
|
||||
|
||||
// Specifies the current location in a context. E.g. the location in
|
||||
// the current Editor (current document, sprite, layer, frame,
|
||||
@ -54,46 +56,46 @@ namespace doc {
|
||||
bool inTimeline() const { return (inLayers() || inFrames() || inCels()); }
|
||||
|
||||
const Document* document() const { return m_document; }
|
||||
const Sprite* sprite() const { return m_sprite; }
|
||||
const Layer* layer() const { return m_layer; }
|
||||
frame_t frame() const { return m_frame; }
|
||||
const Cel* cel() const;
|
||||
const doc::Sprite* sprite() const { return m_sprite; }
|
||||
const doc::Layer* layer() const { return m_layer; }
|
||||
doc::frame_t frame() const { return m_frame; }
|
||||
const doc::Cel* cel() const;
|
||||
|
||||
Document* document() { return m_document; }
|
||||
Sprite* sprite() { return m_sprite; }
|
||||
Layer* layer() { return m_layer; }
|
||||
Cel* cel();
|
||||
doc::Sprite* sprite() { return m_sprite; }
|
||||
doc::Layer* layer() { return m_layer; }
|
||||
doc::Cel* cel();
|
||||
|
||||
void focus(Focus focus) { m_focus = focus; }
|
||||
void document(Document* document) { m_document = document; }
|
||||
void sprite(Sprite* sprite) { m_sprite = sprite; }
|
||||
void layer(Layer* layer) { m_layer = layer; }
|
||||
void frame(frame_t frame) { m_frame = frame; }
|
||||
void sprite(doc::Sprite* sprite) { m_sprite = sprite; }
|
||||
void layer(doc::Layer* layer) { m_layer = layer; }
|
||||
void frame(doc::frame_t frame) { m_frame = frame; }
|
||||
|
||||
const SelectedLayers& selectedLayers() const { return m_selectedLayers; }
|
||||
SelectedLayers& selectedLayers() { return m_selectedLayers; }
|
||||
void selectedLayers(const SelectedLayers& selectedLayers) {
|
||||
const doc::SelectedLayers& selectedLayers() const { return m_selectedLayers; }
|
||||
doc::SelectedLayers& selectedLayers() { return m_selectedLayers; }
|
||||
void selectedLayers(const doc::SelectedLayers& selectedLayers) {
|
||||
m_selectedLayers = selectedLayers;
|
||||
}
|
||||
|
||||
const SelectedFrames& selectedFrames() const { return m_selectedFrames; }
|
||||
SelectedFrames& selectedFrames() { return m_selectedFrames; }
|
||||
void selectedFrames(const SelectedFrames& selectedFrames) {
|
||||
const doc::SelectedFrames& selectedFrames() const { return m_selectedFrames; }
|
||||
doc::SelectedFrames& selectedFrames() { return m_selectedFrames; }
|
||||
void selectedFrames(const doc::SelectedFrames& selectedFrames) {
|
||||
m_selectedFrames = selectedFrames;
|
||||
}
|
||||
|
||||
Palette* palette();
|
||||
Image* image(int* x = nullptr, int* y = nullptr, int* opacity = nullptr) const;
|
||||
Palette* palette() const;
|
||||
doc::Palette* palette();
|
||||
doc::Image* image(int* x = nullptr, int* y = nullptr, int* opacity = nullptr) const;
|
||||
doc::Palette* palette() const;
|
||||
|
||||
private:
|
||||
Focus m_focus;
|
||||
Document* m_document;
|
||||
Sprite* m_sprite;
|
||||
Layer* m_layer;
|
||||
frame_t m_frame;
|
||||
SelectedLayers m_selectedLayers;
|
||||
SelectedFrames m_selectedFrames;
|
||||
doc::Sprite* m_sprite;
|
||||
doc::Layer* m_layer;
|
||||
doc::frame_t m_frame;
|
||||
doc::SelectedLayers m_selectedLayers;
|
||||
doc::SelectedFrames m_selectedFrames;
|
||||
};
|
||||
|
||||
} // namespace app
|
56
src/app/sprite_position.h
Normal file
56
src/app/sprite_position.h
Normal file
@ -0,0 +1,56 @@
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_SPRITE_POSITION_H_INCLUDED
|
||||
#define DOC_SPRITE_POSITION_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/frame.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/object.h"
|
||||
#include "doc/object_id.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class SpritePosition {
|
||||
public:
|
||||
SpritePosition()
|
||||
: m_layerId(doc::NullId)
|
||||
, m_frame(0) {
|
||||
}
|
||||
|
||||
SpritePosition(const doc::Layer* layer, doc::frame_t frame)
|
||||
: m_layerId(layer ? layer->id(): doc::NullId)
|
||||
, m_frame(frame) {
|
||||
}
|
||||
|
||||
doc::Layer* layer() const { return doc::get<doc::Layer>(m_layerId); }
|
||||
doc::ObjectId layerId() const { return m_layerId; }
|
||||
doc::frame_t frame() const { return m_frame; }
|
||||
|
||||
void layer(doc::Layer* layer) {
|
||||
m_layerId = (layer ? layer->id(): doc::NullId);
|
||||
}
|
||||
|
||||
void layerId(doc::ObjectId layerId) {
|
||||
m_layerId = layerId;
|
||||
}
|
||||
|
||||
void frame(doc::frame_t frame) {
|
||||
m_frame = frame;
|
||||
}
|
||||
|
||||
bool operator==(const SpritePosition& o) const { return m_layerId == o.m_layerId && m_frame == o.m_frame; }
|
||||
bool operator!=(const SpritePosition& o) const { return m_layerId != o.m_layerId || m_frame != o.m_frame; }
|
||||
|
||||
private:
|
||||
doc::ObjectId m_layerId;
|
||||
doc::frame_t m_frame;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -1,20 +1,20 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef DOC_TEST_CONTEXT_H_INCLUDED
|
||||
#define DOC_TEST_CONTEXT_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/context.h"
|
||||
#include "doc/document.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/site.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace doc {
|
||||
namespace app {
|
||||
|
||||
template<typename Base>
|
||||
class TestContextT : public Base {
|
||||
@ -53,6 +53,6 @@ namespace doc {
|
||||
|
||||
typedef TestContextT<Context> TestContext;
|
||||
|
||||
} // namespace doc
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -1,8 +1,8 @@
|
||||
// Aseprite Gfx Library
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -420,13 +420,13 @@ void ColorBar::setEditMode(bool state)
|
||||
m_paletteView.deselect();
|
||||
}
|
||||
|
||||
void ColorBar::onActiveSiteChange(const doc::Site& site)
|
||||
void ColorBar::onActiveSiteChange(const Site& site)
|
||||
{
|
||||
if (m_lastDocument != site.document()) {
|
||||
if (m_lastDocument)
|
||||
m_lastDocument->remove_observer(this);
|
||||
|
||||
m_lastDocument = const_cast<doc::Document*>(site.document());
|
||||
m_lastDocument = const_cast<Document*>(site.document());
|
||||
|
||||
if (m_lastDocument)
|
||||
m_lastDocument->add_observer(this);
|
||||
@ -435,7 +435,7 @@ void ColorBar::onActiveSiteChange(const doc::Site& site)
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBar::onGeneralUpdate(doc::DocEvent& ev)
|
||||
void ColorBar::onGeneralUpdate(DocEvent& ev)
|
||||
{
|
||||
// TODO Observe palette changes only
|
||||
invalidate();
|
||||
@ -474,7 +474,7 @@ void ColorBar::onAfterExecuteCommand(CommandExecutionEvent& ev)
|
||||
// If the sprite isn't Indexed anymore (e.g. because we've just
|
||||
// undone a "RGB -> Indexed" conversion), we hide the "Remap"
|
||||
// button.
|
||||
doc::Site site = UIContext::instance()->activeSite();
|
||||
Site site = UIContext::instance()->activeSite();
|
||||
if (site.sprite() &&
|
||||
site.sprite()->pixelFormat() != IMAGE_INDEXED) {
|
||||
hideRemap();
|
||||
@ -947,7 +947,7 @@ void ColorBar::setAscending(bool ascending)
|
||||
|
||||
void ColorBar::showRemap()
|
||||
{
|
||||
doc::Site site = UIContext::instance()->activeSite();
|
||||
Site site = UIContext::instance()->activeSite();
|
||||
if (site.sprite() &&
|
||||
site.sprite()->pixelFormat() == IMAGE_INDEXED) {
|
||||
if (!m_oldPalette) {
|
||||
|
@ -9,14 +9,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/context_observer.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "app/ui/button_set.h"
|
||||
#include "app/ui/color_button.h"
|
||||
#include "app/ui/input_chain_element.h"
|
||||
#include "app/ui/palette_view.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/pixel_format.h"
|
||||
#include "doc/sort_palette.h"
|
||||
#include "obs/connection.h"
|
||||
@ -32,7 +32,6 @@ namespace ui {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class ColorButton;
|
||||
class ColorSpectrum;
|
||||
class ColorTintShadeTone;
|
||||
@ -44,9 +43,9 @@ namespace app {
|
||||
|
||||
class ColorBar : public ui::Box
|
||||
, public PaletteViewDelegate
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocObserver
|
||||
, public app::InputChainElement {
|
||||
, public ContextObserver
|
||||
, public DocObserver
|
||||
, public InputChainElement {
|
||||
static ColorBar* m_instance;
|
||||
public:
|
||||
enum class ColorSelector {
|
||||
@ -84,10 +83,10 @@ namespace app {
|
||||
ColorButton* bgColorButton() { return &m_bgColor; }
|
||||
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const doc::Site& site) override;
|
||||
void onActiveSiteChange(const Site& site) override;
|
||||
|
||||
// DocObserver impl
|
||||
void onGeneralUpdate(doc::DocEvent& ev) override;
|
||||
void onGeneralUpdate(DocEvent& ev) override;
|
||||
|
||||
// InputChainElement impl
|
||||
void onNewInputPriority(InputChainElement* element,
|
||||
@ -188,7 +187,7 @@ namespace app {
|
||||
bool m_fromBgButton;
|
||||
|
||||
base::UniquePtr<doc::Palette> m_oldPalette;
|
||||
doc::Document* m_lastDocument;
|
||||
Document* m_lastDocument;
|
||||
bool m_ascending;
|
||||
obs::scoped_connection m_beforeCmdConn;
|
||||
obs::scoped_connection m_afterCmdConn;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -15,6 +15,7 @@
|
||||
#include "app/color_utils.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/site.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/color_popup.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/rect_io.h"
|
||||
#include "ui/ui.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,9 +9,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/context_observer.h"
|
||||
#include "app/ui/color_button_options.h"
|
||||
#include "app/ui/color_source.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/pixel_format.h"
|
||||
#include "obs/signal.h"
|
||||
#include "ui/button.h"
|
||||
@ -24,9 +24,9 @@ namespace ui {
|
||||
namespace app {
|
||||
class ColorPopup;
|
||||
|
||||
class ColorButton : public ui::ButtonBase
|
||||
, public doc::ContextObserver
|
||||
, public IColorSource {
|
||||
class ColorButton : public ui::ButtonBase,
|
||||
public ContextObserver,
|
||||
public IColorSource {
|
||||
public:
|
||||
ColorButton(const app::Color& color,
|
||||
const PixelFormat pixelFormat,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document_access.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/modules/editors.h"
|
||||
@ -35,7 +36,6 @@
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "base/fs.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
@ -361,25 +361,25 @@ bool DocumentView::onProcessMessage(Message* msg)
|
||||
return Box::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void DocumentView::onGeneralUpdate(doc::DocEvent& ev)
|
||||
void DocumentView::onGeneralUpdate(DocEvent& ev)
|
||||
{
|
||||
if (m_editor->isVisible())
|
||||
m_editor->updateEditor();
|
||||
}
|
||||
|
||||
void DocumentView::onSpritePixelsModified(doc::DocEvent& ev)
|
||||
void DocumentView::onSpritePixelsModified(DocEvent& ev)
|
||||
{
|
||||
if (m_editor->isVisible() &&
|
||||
m_editor->frame() == ev.frame())
|
||||
m_editor->drawSpriteClipped(ev.region());
|
||||
}
|
||||
|
||||
void DocumentView::onLayerMergedDown(doc::DocEvent& ev)
|
||||
void DocumentView::onLayerMergedDown(DocEvent& ev)
|
||||
{
|
||||
m_editor->setLayer(ev.targetLayer());
|
||||
}
|
||||
|
||||
void DocumentView::onAddLayer(doc::DocEvent& ev)
|
||||
void DocumentView::onAddLayer(DocEvent& ev)
|
||||
{
|
||||
if (current_editor == m_editor) {
|
||||
ASSERT(ev.layer() != NULL);
|
||||
@ -387,7 +387,7 @@ void DocumentView::onAddLayer(doc::DocEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentView::onBeforeRemoveLayer(doc::DocEvent& ev)
|
||||
void DocumentView::onBeforeRemoveLayer(DocEvent& ev)
|
||||
{
|
||||
Sprite* sprite = ev.sprite();
|
||||
Layer* layer = ev.layer();
|
||||
@ -410,7 +410,7 @@ void DocumentView::onBeforeRemoveLayer(doc::DocEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentView::onAddFrame(doc::DocEvent& ev)
|
||||
void DocumentView::onAddFrame(DocEvent& ev)
|
||||
{
|
||||
if (current_editor == m_editor)
|
||||
m_editor->setFrame(ev.frame());
|
||||
@ -418,7 +418,7 @@ void DocumentView::onAddFrame(doc::DocEvent& ev)
|
||||
m_editor->setFrame(m_editor->frame()+1);
|
||||
}
|
||||
|
||||
void DocumentView::onRemoveFrame(doc::DocEvent& ev)
|
||||
void DocumentView::onRemoveFrame(DocEvent& ev)
|
||||
{
|
||||
// Adjust current frame of all editors that are in a frame more
|
||||
// advanced that the removed one.
|
||||
@ -433,24 +433,24 @@ void DocumentView::onRemoveFrame(doc::DocEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentView::onAddCel(doc::DocEvent& ev)
|
||||
void DocumentView::onAddCel(DocEvent& ev)
|
||||
{
|
||||
UIContext::instance()->notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
void DocumentView::onRemoveCel(doc::DocEvent& ev)
|
||||
void DocumentView::onRemoveCel(DocEvent& ev)
|
||||
{
|
||||
UIContext::instance()->notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
void DocumentView::onTotalFramesChanged(doc::DocEvent& ev)
|
||||
void DocumentView::onTotalFramesChanged(DocEvent& ev)
|
||||
{
|
||||
if (m_editor->frame() >= m_editor->sprite()->totalFrames()) {
|
||||
m_editor->setFrame(m_editor->sprite()->lastFrame());
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentView::onLayerRestacked(doc::DocEvent& ev)
|
||||
void DocumentView::onLayerRestacked(DocEvent& ev)
|
||||
{
|
||||
m_editor->invalidate();
|
||||
}
|
||||
|
@ -8,16 +8,12 @@
|
||||
#define APP_UI_DOCUMENT_VIEW_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/ui/input_chain_element.h"
|
||||
#include "app/ui/tabs.h"
|
||||
#include "app/ui/workspace_view.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "ui/box.h"
|
||||
|
||||
namespace doc {
|
||||
class Site;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
class View;
|
||||
}
|
||||
@ -25,6 +21,7 @@ namespace ui {
|
||||
namespace app {
|
||||
class Document;
|
||||
class Editor;
|
||||
class Site;
|
||||
|
||||
class DocumentViewPreviewDelegate {
|
||||
public:
|
||||
@ -34,11 +31,11 @@ namespace app {
|
||||
virtual void onPreviewOtherEditor(Editor* editor) = 0;
|
||||
};
|
||||
|
||||
class DocumentView : public ui::Box
|
||||
, public TabView
|
||||
, public doc::DocObserver
|
||||
, public WorkspaceView
|
||||
, public app::InputChainElement {
|
||||
class DocumentView : public ui::Box,
|
||||
public TabView,
|
||||
public app::DocObserver,
|
||||
public WorkspaceView,
|
||||
public app::InputChainElement {
|
||||
public:
|
||||
enum Type {
|
||||
Normal,
|
||||
@ -52,7 +49,7 @@ namespace app {
|
||||
Document* document() const { return m_document; }
|
||||
Editor* editor() { return m_editor; }
|
||||
ui::View* viewWidget() const { return m_view; }
|
||||
void getSite(doc::Site* site) const;
|
||||
void getSite(Site* site) const;
|
||||
|
||||
bool isPreview() { return m_type == Preview; }
|
||||
|
||||
@ -71,17 +68,17 @@ namespace app {
|
||||
InputChainElement* onGetInputChainElement() override { return this; }
|
||||
|
||||
// DocObserver implementation
|
||||
void onGeneralUpdate(doc::DocEvent& ev) override;
|
||||
void onSpritePixelsModified(doc::DocEvent& ev) override;
|
||||
void onLayerMergedDown(doc::DocEvent& ev) override;
|
||||
void onAddLayer(doc::DocEvent& ev) override;
|
||||
void onBeforeRemoveLayer(doc::DocEvent& ev) override;
|
||||
void onAddFrame(doc::DocEvent& ev) override;
|
||||
void onRemoveFrame(doc::DocEvent& ev) override;
|
||||
void onAddCel(doc::DocEvent& ev) override;
|
||||
void onRemoveCel(doc::DocEvent& ev) override;
|
||||
void onTotalFramesChanged(doc::DocEvent& ev) override;
|
||||
void onLayerRestacked(doc::DocEvent& ev) override;
|
||||
void onGeneralUpdate(DocEvent& ev) override;
|
||||
void onSpritePixelsModified(DocEvent& ev) override;
|
||||
void onLayerMergedDown(DocEvent& ev) override;
|
||||
void onAddLayer(DocEvent& ev) override;
|
||||
void onBeforeRemoveLayer(DocEvent& ev) override;
|
||||
void onAddFrame(DocEvent& ev) override;
|
||||
void onRemoveFrame(DocEvent& ev) override;
|
||||
void onAddCel(DocEvent& ev) override;
|
||||
void onRemoveCel(DocEvent& ev) override;
|
||||
void onTotalFramesChanged(DocEvent& ev) override;
|
||||
void onLayerRestacked(DocEvent& ev) override;
|
||||
|
||||
// InputChainElement impl
|
||||
void onNewInputPriority(InputChainElement* element,
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "app/color.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/document.h"
|
||||
#include "app/site.h"
|
||||
#include "app/tools/controller.h"
|
||||
#include "app/tools/ink.h"
|
||||
#include "app/tools/intertwine.h"
|
||||
@ -32,7 +33,6 @@
|
||||
#include "doc/image_impl.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "doc/site.h"
|
||||
#include "render/render.h"
|
||||
#include "she/display.h"
|
||||
#include "ui/manager.h"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "app/commands/params.h"
|
||||
#include "app/commands/quick_command.h"
|
||||
#include "app/console.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/modules/editors.h"
|
||||
@ -54,7 +55,6 @@
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/conversion_she.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/mask_boundaries.h"
|
||||
#include "doc/slice.h"
|
||||
#include "she/surface.h"
|
||||
@ -1926,13 +1926,13 @@ void Editor::onShowExtrasChange()
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Editor::onExposeSpritePixels(doc::DocEvent& ev)
|
||||
void Editor::onExposeSpritePixels(DocEvent& ev)
|
||||
{
|
||||
if (m_state && ev.sprite() == m_sprite)
|
||||
m_state->onExposeSpritePixels(ev.region());
|
||||
}
|
||||
|
||||
void Editor::onSpritePixelRatioChanged(doc::DocEvent& ev)
|
||||
void Editor::onSpritePixelRatioChanged(DocEvent& ev)
|
||||
{
|
||||
m_proj.setPixelRatio(ev.sprite()->pixelRatio());
|
||||
invalidate();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/document.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/tools/active_tool_observer.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "app/ui/editor/editor_observers.h"
|
||||
#include "app/ui/editor/editor_state.h"
|
||||
#include "app/ui/editor/editor_states_history.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/frame.h"
|
||||
#include "doc/image_buffer.h"
|
||||
#include "filters/tiled_mode.h"
|
||||
@ -35,7 +35,6 @@
|
||||
|
||||
namespace doc {
|
||||
class Layer;
|
||||
class Site;
|
||||
class Sprite;
|
||||
}
|
||||
namespace gfx {
|
||||
@ -53,6 +52,7 @@ namespace app {
|
||||
class EditorCustomizationDelegate;
|
||||
class EditorRender;
|
||||
class PixelsMovement;
|
||||
class Site;
|
||||
|
||||
namespace tools {
|
||||
class Ink;
|
||||
@ -64,10 +64,10 @@ namespace app {
|
||||
ScrollDir,
|
||||
};
|
||||
|
||||
class Editor : public ui::Widget
|
||||
, public doc::DocObserver
|
||||
, public IColorSource
|
||||
, public tools::ActiveToolObserver {
|
||||
class Editor : public ui::Widget,
|
||||
public app::DocObserver,
|
||||
public IColorSource,
|
||||
public tools::ActiveToolObserver {
|
||||
public:
|
||||
enum EditorFlags {
|
||||
kNoneFlag = 0,
|
||||
@ -281,8 +281,8 @@ namespace app {
|
||||
void onShowExtrasChange();
|
||||
|
||||
// DocObserver impl
|
||||
void onExposeSpritePixels(doc::DocEvent& ev) override;
|
||||
void onSpritePixelRatioChanged(doc::DocEvent& ev) override;
|
||||
void onExposeSpritePixels(DocEvent& ev) override;
|
||||
void onSpritePixelRatioChanged(DocEvent& ev) override;
|
||||
void onBeforeRemoveLayer(DocEvent& ev) override;
|
||||
void onRemoveCel(DocEvent& ev) override;
|
||||
void onAddFrameTag(DocEvent& ev) override;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -20,6 +20,7 @@
|
||||
#include "app/document_api.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/site.h"
|
||||
#include "app/snap_to_grid.h"
|
||||
#include "app/ui/editor/pivot_helpers.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
@ -36,7 +37,6 @@
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/region.h"
|
||||
#include "render/render.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
#include "app/context_access.h"
|
||||
#include "app/extra_cel.h"
|
||||
#include "app/site.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/editor/handle_type.h"
|
||||
#include "base/shared_ptr.h"
|
||||
#include "doc/algorithm/flip_type.h"
|
||||
#include "doc/site.h"
|
||||
#include "gfx/size.h"
|
||||
#include "obs/connection.h"
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "app/document.h"
|
||||
#include "app/file/file.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/site.h"
|
||||
#include "app/ui/layer_frame_comboboxes.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "base/string.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/selected_frames.h"
|
||||
#include "doc/site.h"
|
||||
#include "fmt/format.h"
|
||||
#include "ui/alert.h"
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
#include "app/ui/layer_frame_comboboxes.h"
|
||||
|
||||
#include "app/restore_visible_layers.h"
|
||||
#include "app/site.h"
|
||||
#include "doc/anidir.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/selected_frames.h"
|
||||
#include "doc/selected_layers.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/combobox.h"
|
||||
|
||||
@ -109,7 +109,7 @@ void fill_anidir_combobox(ui::ComboBox* anidir, doc::AniDir defAnidir)
|
||||
anidir->setSelectedItemIndex(int(defAnidir));
|
||||
}
|
||||
|
||||
void calculate_visible_layers(doc::Site& site,
|
||||
void calculate_visible_layers(Site& site,
|
||||
const std::string& layersValue,
|
||||
RestoreVisibleLayers& layersVisibility)
|
||||
{
|
||||
@ -134,7 +134,7 @@ void calculate_visible_layers(doc::Site& site,
|
||||
}
|
||||
}
|
||||
|
||||
doc::FrameTag* calculate_selected_frames(const doc::Site& site,
|
||||
doc::FrameTag* calculate_selected_frames(const Site& site,
|
||||
const std::string& framesValue,
|
||||
doc::SelectedFrames& selFrames)
|
||||
{
|
||||
|
@ -18,7 +18,6 @@ namespace doc {
|
||||
class Layer;
|
||||
class SelectedFrames;
|
||||
class SelectedLayers;
|
||||
class Site;
|
||||
class Sprite;
|
||||
}
|
||||
|
||||
@ -27,8 +26,8 @@ namespace ui {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
class RestoreVisibleLayers;
|
||||
class Site;
|
||||
|
||||
extern const char* kAllLayers;
|
||||
extern const char* kAllFrames;
|
||||
@ -56,11 +55,11 @@ namespace app {
|
||||
void fill_frames_combobox(const doc::Sprite* sprite, ui::ComboBox* frames, const std::string& defFrame);
|
||||
void fill_anidir_combobox(ui::ComboBox* anidir, doc::AniDir defAnidir);
|
||||
|
||||
void calculate_visible_layers(doc::Site& site,
|
||||
void calculate_visible_layers(Site& site,
|
||||
const std::string& layersValue,
|
||||
RestoreVisibleLayers& layersVisibility);
|
||||
|
||||
doc::FrameTag* calculate_selected_frames(const doc::Site& site,
|
||||
doc::FrameTag* calculate_selected_frames(const Site& site,
|
||||
const std::string& framesValue,
|
||||
doc::SelectedFrames& selFrames);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document_access.h"
|
||||
#include "app/document_range.h"
|
||||
#include "app/modules/editors.h"
|
||||
@ -35,7 +36,6 @@
|
||||
#include "app/util/range_utils.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/string.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -759,7 +759,7 @@ void StatusBar::onResize(ResizeEvent& ev)
|
||||
updateSnapToGridWindowPosition();
|
||||
}
|
||||
|
||||
void StatusBar::onActiveSiteChange(const doc::Site& site)
|
||||
void StatusBar::onActiveSiteChange(const Site& site)
|
||||
{
|
||||
if (m_doc && site.document() != m_doc) {
|
||||
m_doc->remove_observer(this);
|
||||
@ -768,7 +768,7 @@ void StatusBar::onActiveSiteChange(const doc::Site& site)
|
||||
|
||||
if (site.document() && site.sprite()) {
|
||||
if (!m_doc) {
|
||||
m_doc = const_cast<doc::Document*>(site.document());
|
||||
m_doc = const_cast<Document*>(site.document());
|
||||
m_doc->add_observer(this);
|
||||
}
|
||||
else {
|
||||
@ -793,7 +793,7 @@ void StatusBar::onActiveSiteChange(const doc::Site& site)
|
||||
layout();
|
||||
}
|
||||
|
||||
void StatusBar::onRemoveDocument(doc::Document* doc)
|
||||
void StatusBar::onRemoveDocument(Document* doc)
|
||||
{
|
||||
if (m_doc &&
|
||||
m_doc == doc) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,11 +9,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/context_observer.h"
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "app/tools/active_tool_observer.h"
|
||||
#include "base/time.h"
|
||||
#include "doc/context_observer.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/box.h"
|
||||
|
||||
@ -42,9 +42,9 @@ namespace app {
|
||||
}
|
||||
|
||||
class StatusBar : public ui::HBox
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocumentsObserver
|
||||
, public doc::DocObserver
|
||||
, public ContextObserver
|
||||
, public DocumentsObserver
|
||||
, public DocObserver
|
||||
, public tools::ActiveToolObserver {
|
||||
static StatusBar* m_instance;
|
||||
public:
|
||||
@ -73,10 +73,10 @@ namespace app {
|
||||
void onResize(ui::ResizeEvent& ev) override;
|
||||
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const doc::Site& site) override;
|
||||
void onActiveSiteChange(const Site& site) override;
|
||||
|
||||
// DocObservers impl
|
||||
void onRemoveDocument(doc::Document* doc) override;
|
||||
void onRemoveDocument(Document* doc) override;
|
||||
|
||||
// DocObserver impl
|
||||
void onPixelFormatChanged(DocEvent& ev) override;
|
||||
@ -104,7 +104,7 @@ namespace app {
|
||||
ui::Entry* m_currentFrame; // Current frame and go to frame entry
|
||||
ui::Button* m_newFrame; // Button to create a new frame
|
||||
ZoomEntry* m_zoomEntry;
|
||||
doc::Document* m_doc; // Document used to show the cel slider
|
||||
Document* m_doc; // Document used to show the cel slider
|
||||
|
||||
// Tip window
|
||||
class CustomizedTipWindow;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "app/commands/params.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_event.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/document_range_ops.h"
|
||||
@ -46,7 +47,6 @@
|
||||
#include "base/scoped_value.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/doc_event.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
@ -1638,14 +1638,14 @@ void Timeline::onAfterCommandExecution(CommandExecutionEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onActiveSiteChange(const doc::Site& site)
|
||||
void Timeline::onActiveSiteChange(const Site& site)
|
||||
{
|
||||
if (hasMouse()) {
|
||||
updateStatusBarForFrame(site.frame(), nullptr, site.cel());
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::onRemoveDocument(doc::Document* document)
|
||||
void Timeline::onRemoveDocument(Document* document)
|
||||
{
|
||||
if (document == m_document) {
|
||||
detachDocument();
|
||||
@ -1657,7 +1657,7 @@ void Timeline::onGeneralUpdate(DocEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onAddLayer(doc::DocEvent& ev)
|
||||
void Timeline::onAddLayer(DocEvent& ev)
|
||||
{
|
||||
ASSERT(ev.layer() != NULL);
|
||||
|
||||
@ -1669,7 +1669,7 @@ void Timeline::onAddLayer(doc::DocEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onAfterRemoveLayer(doc::DocEvent& ev)
|
||||
void Timeline::onAfterRemoveLayer(DocEvent& ev)
|
||||
{
|
||||
Sprite* sprite = ev.sprite();
|
||||
Layer* layer = ev.layer();
|
||||
@ -1697,7 +1697,7 @@ void Timeline::onAfterRemoveLayer(doc::DocEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onAddFrame(doc::DocEvent& ev)
|
||||
void Timeline::onAddFrame(DocEvent& ev)
|
||||
{
|
||||
setFrame(ev.frame(), false);
|
||||
|
||||
@ -1706,7 +1706,7 @@ void Timeline::onAddFrame(doc::DocEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onRemoveFrame(doc::DocEvent& ev)
|
||||
void Timeline::onRemoveFrame(DocEvent& ev)
|
||||
{
|
||||
// Adjust current frame of all editors that are in a frame more
|
||||
// advanced that the removed one.
|
||||
@ -1729,13 +1729,13 @@ void Timeline::onRemoveFrame(doc::DocEvent& ev)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Timeline::onSelectionChanged(doc::DocEvent& ev)
|
||||
void Timeline::onSelectionChanged(DocEvent& ev)
|
||||
{
|
||||
if (m_rangeLocks == 0)
|
||||
clearAndInvalidateRange();
|
||||
}
|
||||
|
||||
void Timeline::onLayerNameChange(doc::DocEvent& ev)
|
||||
void Timeline::onLayerNameChange(DocEvent& ev)
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
|
@ -8,15 +8,16 @@
|
||||
#define APP_UI_TIMELINE_TIMELINE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/doc_observer.h"
|
||||
#include "app/document_range.h"
|
||||
#include "app/documents_observer.h"
|
||||
#include "app/loop_tag.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/editor/editor_observer.h"
|
||||
#include "app/ui/input_chain_element.h"
|
||||
#include "app/ui/timeline/ani_controls.h"
|
||||
#include "doc/doc_observer.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "doc/frame.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/selected_frames.h"
|
||||
#include "doc/selected_layers.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -52,14 +53,14 @@ namespace app {
|
||||
class Document;
|
||||
class Editor;
|
||||
|
||||
class Timeline : public ui::Widget
|
||||
, public ui::ScrollableViewDelegate
|
||||
, public doc::ContextObserver
|
||||
, public doc::DocumentsObserver
|
||||
, public doc::DocObserver
|
||||
, public app::EditorObserver
|
||||
, public app::InputChainElement
|
||||
, public app::FrameTagProvider {
|
||||
class Timeline : public ui::Widget,
|
||||
public ui::ScrollableViewDelegate,
|
||||
public ContextObserver,
|
||||
public DocumentsObserver,
|
||||
public DocObserver,
|
||||
public EditorObserver,
|
||||
public InputChainElement,
|
||||
public FrameTagProvider {
|
||||
public:
|
||||
typedef DocumentRange Range;
|
||||
|
||||
@ -137,12 +138,12 @@ namespace app {
|
||||
|
||||
// DocObserver impl.
|
||||
void onGeneralUpdate(DocEvent& ev) override;
|
||||
void onAddLayer(doc::DocEvent& ev) override;
|
||||
void onAfterRemoveLayer(doc::DocEvent& ev) override;
|
||||
void onAddFrame(doc::DocEvent& ev) override;
|
||||
void onRemoveFrame(doc::DocEvent& ev) override;
|
||||
void onSelectionChanged(doc::DocEvent& ev) override;
|
||||
void onLayerNameChange(doc::DocEvent& ev) override;
|
||||
void onAddLayer(DocEvent& ev) override;
|
||||
void onAfterRemoveLayer(DocEvent& ev) override;
|
||||
void onAddFrame(DocEvent& ev) override;
|
||||
void onRemoveFrame(DocEvent& ev) override;
|
||||
void onSelectionChanged(DocEvent& ev) override;
|
||||
void onLayerNameChange(DocEvent& ev) override;
|
||||
void onAddFrameTag(DocEvent& ev) override;
|
||||
void onRemoveFrameTag(DocEvent& ev) override;
|
||||
|
||||
@ -150,10 +151,10 @@ namespace app {
|
||||
void onAfterCommandExecution(CommandExecutionEvent& ev);
|
||||
|
||||
// ContextObserver impl
|
||||
void onActiveSiteChange(const doc::Site& site) override;
|
||||
void onActiveSiteChange(const Site& site) override;
|
||||
|
||||
// DocumentsObserver impl.
|
||||
void onRemoveDocument(doc::Document* document) override;
|
||||
void onRemoveDocument(Document* document) override;
|
||||
|
||||
// EditorObserver impl.
|
||||
void onStateChanged(Editor* editor) override;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "app/document.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/site.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
@ -24,7 +25,6 @@
|
||||
#include "app/ui/workspace_tabs.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/mutex.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
namespace app {
|
||||
@ -120,7 +120,7 @@ void UIContext::setActiveView(DocumentView* docView)
|
||||
notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
void UIContext::onSetActiveDocument(doc::Document* document)
|
||||
void UIContext::onSetActiveDocument(Document* document)
|
||||
{
|
||||
bool notify = (lastSelectedDoc() != document);
|
||||
app::Context::onSetActiveDocument(document);
|
||||
@ -135,7 +135,7 @@ void UIContext::onSetActiveDocument(doc::Document* document)
|
||||
notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
DocumentView* UIContext::getFirstDocumentView(doc::Document* document) const
|
||||
DocumentView* UIContext::getFirstDocumentView(Document* document) const
|
||||
{
|
||||
Workspace* workspace = App::instance()->workspace();
|
||||
if (!workspace) // Workspace (main window) can be null if we are in --batch mode
|
||||
@ -152,7 +152,7 @@ DocumentView* UIContext::getFirstDocumentView(doc::Document* document) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DocumentViews UIContext::getAllDocumentViews(doc::Document* document) const
|
||||
DocumentViews UIContext::getAllDocumentViews(Document* document) const
|
||||
{
|
||||
Workspace* workspace = App::instance()->workspace();
|
||||
DocumentViews docViews;
|
||||
@ -177,7 +177,7 @@ Editor* UIContext::activeEditor()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void UIContext::onAddDocument(doc::Document* doc)
|
||||
void UIContext::onAddDocument(Document* doc)
|
||||
{
|
||||
app::Context::onAddDocument(doc);
|
||||
|
||||
@ -198,7 +198,7 @@ void UIContext::onAddDocument(doc::Document* doc)
|
||||
view->editor()->setDefaultScroll();
|
||||
}
|
||||
|
||||
void UIContext::onRemoveDocument(doc::Document* doc)
|
||||
void UIContext::onRemoveDocument(Document* doc)
|
||||
{
|
||||
app::Context::onRemoveDocument(doc);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015, 2018 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/context.h"
|
||||
#include "doc/documents_observer.h"
|
||||
#include "app/documents_observer.h"
|
||||
|
||||
namespace app {
|
||||
class DocumentView;
|
||||
@ -29,8 +29,8 @@ namespace app {
|
||||
DocumentView* activeView() const;
|
||||
void setActiveView(DocumentView* documentView);
|
||||
|
||||
DocumentView* getFirstDocumentView(doc::Document* document) const override;
|
||||
DocumentViews getAllDocumentViews(doc::Document* document) const;
|
||||
DocumentView* getFirstDocumentView(Document* document) const override;
|
||||
DocumentViews getAllDocumentViews(Document* document) const;
|
||||
|
||||
// Returns the current editor. It can be null.
|
||||
Editor* activeEditor();
|
||||
@ -40,10 +40,10 @@ namespace app {
|
||||
Editor* getEditorFor(Document* document);
|
||||
|
||||
protected:
|
||||
void onAddDocument(doc::Document* doc) override;
|
||||
void onRemoveDocument(doc::Document* doc) override;
|
||||
void onGetActiveSite(doc::Site* site) const override;
|
||||
void onSetActiveDocument(doc::Document* doc) override;
|
||||
void onAddDocument(Document* doc) override;
|
||||
void onRemoveDocument(Document* doc) override;
|
||||
void onGetActiveSite(Site* site) const override;
|
||||
void onSetActiveDocument(Document* doc) override;
|
||||
|
||||
private:
|
||||
DocumentView* m_lastSelectedView;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user