Zoom tool now can be used in PlayState

This commit is contained in:
David Capello 2017-01-06 17:44:08 -03:00
parent 7f149d4501
commit 7c6d927eb1
7 changed files with 82 additions and 48 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -36,7 +36,9 @@
#include "app/ui/editor/moving_pixels_state.h"
#include "app/ui/editor/pixels_movement.h"
#include "app/ui/editor/play_state.h"
#include "app/ui/editor/scrolling_state.h"
#include "app/ui/editor/standby_state.h"
#include "app/ui/editor/zooming_state.h"
#include "app/ui/main_window.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/status_bar.h"
@ -1687,6 +1689,46 @@ void Editor::notifyZoomChanged()
m_observers.notifyZoomChanged(this);
}
bool Editor::checkForScroll(ui::MouseMessage* msg)
{
tools::Ink* clickedInk = getCurrentEditorInk();
// Start scroll loop
if (msg->middle() || clickedInk->isScrollMovement()) { // TODO msg->middle() should be customizable
startScrollingState(msg);
return true;
}
else
return false;
}
bool Editor::checkForZoom(ui::MouseMessage* msg)
{
tools::Ink* clickedInk = getCurrentEditorInk();
// Start scroll loop
if (clickedInk->isZoom()) {
startZoomingState(msg);
return true;
}
else
return false;
}
void Editor::startScrollingState(ui::MouseMessage* msg)
{
EditorStatePtr newState(new ScrollingState);
setState(newState);
newState->onMouseDown(this, msg);
}
void Editor::startZoomingState(ui::MouseMessage* msg)
{
EditorStatePtr newState(new ZoomingState);
setState(newState);
newState->onMouseDown(this, msg);
}
void Editor::play(const bool playOnce,
const bool playAll)
{

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -203,6 +203,15 @@ namespace app {
void notifyScrollChanged();
void notifyZoomChanged();
// Returns true and changes to ScrollingState when "msg" says "the
// user wants to scroll". Same for zoom.
bool checkForScroll(ui::MouseMessage* msg);
bool checkForZoom(ui::MouseMessage* msg);
// Start Scrolling/ZoomingState
void startScrollingState(ui::MouseMessage* msg);
void startZoomingState(ui::MouseMessage* msg);
// Animation control
void play(const bool playOnce,
const bool playAll);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -239,7 +239,8 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
contextBar->updateForMovingPixels();
// Start scroll loop
if (checkForScroll(editor, msg) || checkForZoom(editor, msg))
if (editor->checkForScroll(msg) ||
editor->checkForZoom(msg))
return true;
// Call the eyedropper command

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -14,6 +14,7 @@
#include "app/commands/commands.h"
#include "app/loop_tag.h"
#include "app/pref/preferences.h"
#include "app/tools/ink.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/scrolling_state.h"
#include "app/ui_context.h"
@ -116,10 +117,12 @@ bool PlayState::onMouseDown(Editor* editor, MouseMessage* msg)
// some time, so we don't change the current frame.
m_toScroll = true;
// If the active tool is the Zoom tool, we start zooming.
if (editor->checkForZoom(msg))
return true;
// Start scroll loop
EditorStatePtr newState(new ScrollingState());
editor->setState(newState);
newState->onMouseDown(editor, msg);
editor->startScrollingState(msg);
return true;
}
@ -145,6 +148,19 @@ bool PlayState::onKeyUp(Editor* editor, KeyMessage* msg)
return false;
}
bool PlayState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
{
tools::Ink* ink = editor->getCurrentEditorInk();
if (ink) {
if (ink->isZoom()) {
editor->showMouseCursor(kMagnifierCursor);
return true;
}
}
editor->showMouseCursor(kScrollCursor);
return true;
}
void PlayState::onPlaybackTick()
{
if (m_nextFrameTime < 0)

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -34,6 +34,7 @@ namespace app {
bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
private:
void onPlaybackTick();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -124,38 +124,6 @@ void StandbyState::onActiveToolChange(Editor* editor, tools::Tool* tool)
}
}
bool StandbyState::checkForScroll(Editor* editor, MouseMessage* msg)
{
tools::Ink* clickedInk = editor->getCurrentEditorInk();
// Start scroll loop
if (msg->middle() || clickedInk->isScrollMovement()) { // TODO msg->middle() should be customizable
EditorStatePtr newState(new ScrollingState());
editor->setState(newState);
newState->onMouseDown(editor, msg);
return true;
}
else
return false;
}
bool StandbyState::checkForZoom(Editor* editor, MouseMessage* msg)
{
tools::Ink* clickedInk = editor->getCurrentEditorInk();
// Start scroll loop
if (clickedInk->isZoom()) {
EditorStatePtr newState(new ZoomingState());
editor->setState(newState);
newState->onMouseDown(editor, msg);
return true;
}
else
return false;
}
bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
{
if (editor->hasCapture())
@ -172,7 +140,8 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
context->setActiveView(editor->getDocumentView());
// Start scroll loop
if (checkForScroll(editor, msg) || checkForZoom(editor, msg))
if (editor->checkForScroll(msg) ||
editor->checkForZoom(msg))
return true;
// Move cel X,Y coordinates

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -45,10 +45,6 @@ namespace app {
void startSelectionTransformation(Editor* editor, const gfx::Point& move, double angle);
protected:
// Returns true and changes to ScrollingState when "msg" says "the
// user wants to scroll".
bool checkForScroll(Editor* editor, ui::MouseMessage* msg);
bool checkForZoom(Editor* editor, ui::MouseMessage* msg);
void callEyedropper(Editor* editor);
class Decorator : public EditorDecorator {