Merge branch '1.0'

This commit is contained in:
David Capello 2014-11-08 21:21:45 -03:00
commit 995c50b811
20 changed files with 203 additions and 27 deletions

View File

@ -39,22 +39,13 @@ the source code in a directory called `aseprite-source`):
If you have Visual Studio you can generate a solution:
C:\...\aseprite-source\build>cmake .. -G "Visual Studio 8 2005"
C:\...\aseprite-source\build>cmake .. -G "Visual Studio 9 2008"
C:\...\aseprite-source\build>cmake .. -G "Visual Studio 10"
C:\...\aseprite-source\build>cmake .. -G "Visual Studio 11 2012"
C:\...\aseprite-source\build>cmake .. -G "Visual Studio 12 2013"
If you are on Linux:
/.../aseprite-source/build$ cmake .. -G "Unix Makefiles"
If you have MinGW + MSYS:
C:\...\aseprite-source\build>cmake .. -G "MSYS Makefiles"
If you have MinGW + mingw-make:
C:\...\aseprite-source\build>cmake .. -G "MinGW Makefiles"
For more information in [CMake wiki](http://www.vtk.org/Wiki/CMake_Generator_Specific_Information).
3. After you have executed one of the `cmake .. -G <generator>`

View File

@ -91,6 +91,7 @@
<key command="ShowGrid" shortcut="Shift+G" />
<key command="ShowPixelGrid" shortcut="Alt+Shift+G" />
<key command="SnapToGrid" shortcut="Shift+S" />
<key command="SetLoopSection" shortcut="F2" />
<key command="ShowOnionSkin" shortcut="F3" />
<key command="Timeline" shortcut="Tab">
<param name="switch" value="true" />
@ -557,6 +558,7 @@
<item command="SnapToGrid" text="&amp;Snap to Grid" />
<item command="GridSettings" text="Gri&amp;d Settings" />
<separator />
<item command="SetLoopSection" text="Set &amp;Loop Section" />
<item command="ShowOnionSkin" text="Show &amp;Onion Skin" />
<separator />
<item command="Timeline" text="&amp;Timeline">

View File

@ -79,6 +79,7 @@ add_library(app-lib
commands/cmd_save_mask.cpp
commands/cmd_save_palette.cpp
commands/cmd_scroll.cpp
commands/cmd_set_loop_section.cpp
commands/cmd_set_palette.cpp
commands/cmd_sprite_editor.cpp
commands/cmd_sprite_properties.cpp

View File

@ -0,0 +1,131 @@
/* Aseprite
* Copyright (C) 2001-2014 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/ui/main_window.h"
#include "app/ui/timeline.h"
namespace app {
class SetLoopSectionCommand : public Command {
public:
enum class Action { Auto, On, Off };
SetLoopSectionCommand();
Command* clone() const override { return new SetLoopSectionCommand(*this); }
protected:
void onLoadParams(Params* params) override;
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
Action m_action;
FrameNumber m_begin, m_end;
};
SetLoopSectionCommand::SetLoopSectionCommand()
: Command("SetLoopSection",
"Set Loop Section",
CmdRecordableFlag)
, m_action(Action::Auto)
, m_begin(0)
, m_end(0)
{
}
void SetLoopSectionCommand::onLoadParams(Params* params)
{
std::string action = params->get("action");
if (action == "on") m_action = Action::On;
else if (action == "off") m_action = Action::Off;
else m_action = Action::Auto;
std::string begin = params->get("begin");
std::string end = params->get("end");
m_begin = FrameNumber(strtol(begin.c_str(), NULL, 10));
m_end = FrameNumber(strtol(end.c_str(), NULL, 10));
}
bool SetLoopSectionCommand::onEnabled(Context* ctx)
{
return ctx->checkFlags(ContextFlags::HasActiveDocument);
}
void SetLoopSectionCommand::onExecute(Context* ctx)
{
Document* doc = ctx->activeDocument();
if (!doc)
return;
IDocumentSettings* docSets = ctx->settings()->getDocumentSettings(doc);
if (!docSets)
return;
FrameNumber begin = m_begin;
FrameNumber end = m_end;
bool on = false;
switch (m_action) {
case Action::Auto: {
Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
if (range.enabled() && (range.frames() > 1)) {
begin = range.frameBegin();
end = range.frameEnd();
on = true;
}
else {
on = false;
}
break;
}
case Action::On:
on = true;
break;
case Action::Off:
on = false;
break;
}
if (on) {
docSets->setLoopAnimation(true);
docSets->setLoopRange(begin, end);
}
else
docSets->setLoopAnimation(false);
}
Command* CommandFactory::createSetLoopSectionCommand()
{
return new SetLoopSectionCommand;
}
} // namespace app

View File

@ -100,6 +100,7 @@ FOR_EACH_COMMAND(SaveFileCopyAs)
FOR_EACH_COMMAND(SaveMask)
FOR_EACH_COMMAND(SavePalette)
FOR_EACH_COMMAND(Scroll)
FOR_EACH_COMMAND(SetLoopSection)
FOR_EACH_COMMAND(SetPalette)
FOR_EACH_COMMAND(ShowGrid)
FOR_EACH_COMMAND(ShowOnionSkin)

View File

@ -95,6 +95,7 @@ namespace app {
Document* document() { return m_location.document(); }
Sprite* sprite() { return m_location.sprite(); }
Layer* layer() { return m_location.layer(); }
FrameNumber frame() { return m_location.frame(); }
Image* destinationImage() const { return m_dst; }
// Updates the current editor to show the progress of the preview.

View File

@ -77,11 +77,12 @@ bool FilterPreview::onProcessMessage(Message* msg)
case kOpenMessage:
RenderEngine::setPreviewImage(
m_filterMgr->layer(),
m_filterMgr->frame(),
m_filterMgr->destinationImage());
break;
case kCloseMessage:
RenderEngine::setPreviewImage(NULL, NULL);
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
// Stop the preview timer.
m_timer.stop();

View File

@ -23,6 +23,7 @@
#include "app/context.h"
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/console.h"
#include "app/document.h"
#include "app/document_location.h"
@ -69,6 +70,15 @@ DocumentLocation Context::activeLocation() const
return location;
}
void Context::executeCommand(const char* commandName)
{
Command* cmd = CommandsModule::instance()->getCommandByName(commandName);
if (cmd)
executeCommand(cmd);
else
throw std::runtime_error("Invalid command name");
}
void Context::executeCommand(Command* command, Params* params)
{
Console console;

View File

@ -63,6 +63,7 @@ namespace app {
app::Document* activeDocument() const;
DocumentLocation activeLocation() const;
void executeCommand(const char* commandName);
virtual void executeCommand(Command* command, Params* params = NULL);
Signal1<void, Command*> BeforeCommandExecution;

View File

@ -22,6 +22,7 @@
#include "app/settings/selection_mode.h"
#include "app/tools/trace_policy.h"
#include "doc/frame_number.h"
#include "filters/tiled_mode.h"
#include "gfx/point.h"
@ -82,6 +83,9 @@ namespace app {
// Returns the layer that will be modified if the tool paints
virtual Layer* getLayer() = 0;
// Returns the frame where we're paiting
virtual FrameNumber getFrame() = 0;
// Should return an image where we can read pixels (readonly image)
virtual Image* getSrcImage() = 0;

View File

@ -74,13 +74,14 @@ void ToolLoopManager::prepareLoop(const Pointer& pointer)
// in the tool-loop time, so we can see what we are drawing)
RenderEngine::setPreviewImage(
m_toolLoop->getLayer(),
m_toolLoop->getFrame(),
m_toolLoop->getDstImage());
}
void ToolLoopManager::releaseLoop(const Pointer& pointer)
{
// No more preview image
RenderEngine::setPreviewImage(NULL, NULL);
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
}
void ToolLoopManager::pressKey(ui::KeyScancode key)

View File

@ -29,6 +29,7 @@
#include "app/load_widget.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/commands/commands.h"
#include "app/ui/main_window.h"
#include "app/ui/timeline.h"
#include "app/ui_context.h"
@ -184,14 +185,7 @@ void ConfigureTimelinePopup::onResetOnionskin()
void ConfigureTimelinePopup::onSetLoopSection()
{
IDocumentSettings* docSet = docSettings();
if (docSet) {
Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
if (range.enabled() && (range.frames() >= 1)) {
docSet->setLoopAnimation(true);
docSet->setLoopRange(range.frameBegin(), range.frameEnd());
}
}
UIContext::instance()->executeCommand(CommandId::SetLoopSection);
}
void ConfigureTimelinePopup::onResetLoopSection()

View File

@ -38,6 +38,7 @@
#include "doc/sprite.h"
#include "ui/accelerator.h"
#include "ui/message.h"
#include "ui/system.h"
#include "ui/view.h"
namespace app {
@ -109,6 +110,32 @@ public:
return isKeyActionPressed(KeyAction::SubtractSelection);
}
protected:
bool onProcessMessage(Message* msg) override {
switch (msg->type()) {
case kKeyDownMessage:
case kKeyUpMessage:
if (static_cast<KeyMessage*>(msg)->repeat() == 0) {
Key* lmb = KeyboardShortcuts::instance()->action(KeyAction::LeftMouseButton);
Key* rmb = KeyboardShortcuts::instance()->action(KeyAction::RightMouseButton);
// Convert action keys into mouse messages.
if (lmb->isPressed(msg) || rmb->isPressed(msg)) {
MouseMessage mouseMsg(
(msg->type() == kKeyDownMessage ? kMouseDownMessage: kMouseUpMessage),
(lmb->isPressed(msg) ? kButtonLeft: kButtonRight),
gfx::Point(jmouse_x(0), jmouse_y(0)));
sendMessage(&mouseMsg);
return true;
}
}
break;
}
return Editor::onProcessMessage(msg);
}
private:
bool isKeyActionPressed(KeyAction action) {
if (Key* key = KeyboardShortcuts::instance()->action(action))

View File

@ -680,6 +680,8 @@ void Editor::flashCurrentLayer()
int x, y;
const Image* src_image = loc.image(&x, &y);
if (src_image) {
RenderEngine::setPreviewImage(NULL, FrameNumber(0), NULL);
m_document->prepareExtraCel(0, 0, m_sprite->width(), m_sprite->height(), 255);
Image* flash_image = m_document->getExtraCelImage();

View File

@ -216,6 +216,7 @@ public:
Document* getDocument() override { return m_document; }
Sprite* sprite() override { return m_sprite; }
Layer* getLayer() override { return m_layer; }
FrameNumber getFrame() override { return m_frame; }
Image* getSrcImage() override { return m_expandCelCanvas.getSourceCanvas(); }
Image* getDstImage() override { return m_expandCelCanvas.getDestCanvas(); }
RgbMap* getRgbMap() override { return m_sprite->getRgbMap(m_frame); }

View File

@ -57,6 +57,8 @@ namespace {
{ "LockAxis" , "Lock Axis" , app::KeyAction::LockAxis },
{ "AddSelection" , "Add Selection" , app::KeyAction::AddSelection },
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
{ "LeftMouseButton" , "Trigger Left Mouse Button" , app::KeyAction::LeftMouseButton },
{ "RightMouseButton" , "Trigger Right Mouse Button" , app::KeyAction::RightMouseButton },
{ NULL , NULL , app::KeyAction::None }
};

View File

@ -67,6 +67,8 @@ namespace app {
LockAxis,
AddSelection,
SubtractSelection,
LeftMouseButton,
RightMouseButton
};
class Key {

View File

@ -251,6 +251,7 @@ void MiniEditorWindow::updateUsingEditor(Editor* editor)
}
miniEditor->centerInSpritePoint(pt.x, pt.y);
miniEditor->setLayer(editor->layer());
miniEditor->setFrame(editor->frame());
}

View File

@ -289,6 +289,7 @@ static app::Color checked_bg_color2;
static int global_opacity = 255;
static const Layer* selected_layer = NULL;
static FrameNumber selected_frame(0);
static Image* preview_image = NULL;
// static
@ -367,9 +368,10 @@ RenderEngine::RenderEngine(const Document* document,
}
// static
void RenderEngine::setPreviewImage(const Layer* layer, Image* image)
void RenderEngine::setPreviewImage(const Layer* layer, FrameNumber frame, Image* image)
{
selected_layer = layer;
selected_frame = frame;
preview_image = image;
}
@ -586,8 +588,8 @@ void RenderEngine::renderLayer(
Image* src_image;
// Is the 'preview_image' set to be used with this layer?
if ((frame == m_currentFrame) &&
(selected_layer == layer) &&
if ((selected_layer == layer) &&
(selected_frame == frame) &&
(preview_image != NULL)) {
src_image = preview_image;
}
@ -635,8 +637,9 @@ void RenderEngine::renderLayer(
}
// Draw extras
if (layer == m_currentLayer &&
m_document->getExtraCel() != NULL) {
if (m_document->getExtraCel() &&
layer == m_currentLayer &&
frame == m_currentFrame) {
Cel* extraCel = m_document->getExtraCel();
if (extraCel->opacity() > 0) {
Image* extraImage = m_document->getExtraCelImage();

View File

@ -63,7 +63,7 @@ namespace app {
//////////////////////////////////////////////////////////////////////
// Preview image
static void setPreviewImage(const Layer* layer, Image* drawable);
static void setPreviewImage(const Layer* layer, FrameNumber frame, Image* drawable);
//////////////////////////////////////////////////////////////////////
// Main function used by sprite-editors to render the sprite