mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Zoom tool now can be used in PlayState
This commit is contained in:
parent
7f149d4501
commit
7c6d927eb1
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -36,7 +36,9 @@
|
|||||||
#include "app/ui/editor/moving_pixels_state.h"
|
#include "app/ui/editor/moving_pixels_state.h"
|
||||||
#include "app/ui/editor/pixels_movement.h"
|
#include "app/ui/editor/pixels_movement.h"
|
||||||
#include "app/ui/editor/play_state.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/standby_state.h"
|
||||||
|
#include "app/ui/editor/zooming_state.h"
|
||||||
#include "app/ui/main_window.h"
|
#include "app/ui/main_window.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "app/ui/status_bar.h"
|
#include "app/ui/status_bar.h"
|
||||||
@ -1687,6 +1689,46 @@ void Editor::notifyZoomChanged()
|
|||||||
m_observers.notifyZoomChanged(this);
|
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,
|
void Editor::play(const bool playOnce,
|
||||||
const bool playAll)
|
const bool playAll)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -203,6 +203,15 @@ namespace app {
|
|||||||
void notifyScrollChanged();
|
void notifyScrollChanged();
|
||||||
void notifyZoomChanged();
|
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
|
// Animation control
|
||||||
void play(const bool playOnce,
|
void play(const bool playOnce,
|
||||||
const bool playAll);
|
const bool playAll);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -239,7 +239,8 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||||||
contextBar->updateForMovingPixels();
|
contextBar->updateForMovingPixels();
|
||||||
|
|
||||||
// Start scroll loop
|
// Start scroll loop
|
||||||
if (checkForScroll(editor, msg) || checkForZoom(editor, msg))
|
if (editor->checkForScroll(msg) ||
|
||||||
|
editor->checkForZoom(msg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Call the eyedropper command
|
// Call the eyedropper command
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -14,6 +14,7 @@
|
|||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/loop_tag.h"
|
#include "app/loop_tag.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
|
#include "app/tools/ink.h"
|
||||||
#include "app/ui/editor/editor.h"
|
#include "app/ui/editor/editor.h"
|
||||||
#include "app/ui/editor/scrolling_state.h"
|
#include "app/ui/editor/scrolling_state.h"
|
||||||
#include "app/ui_context.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.
|
// some time, so we don't change the current frame.
|
||||||
m_toScroll = true;
|
m_toScroll = true;
|
||||||
|
|
||||||
|
// If the active tool is the Zoom tool, we start zooming.
|
||||||
|
if (editor->checkForZoom(msg))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Start scroll loop
|
// Start scroll loop
|
||||||
EditorStatePtr newState(new ScrollingState());
|
editor->startScrollingState(msg);
|
||||||
editor->setState(newState);
|
|
||||||
newState->onMouseDown(editor, msg);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +148,19 @@ bool PlayState::onKeyUp(Editor* editor, KeyMessage* msg)
|
|||||||
return false;
|
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()
|
void PlayState::onPlaybackTick()
|
||||||
{
|
{
|
||||||
if (m_nextFrameTime < 0)
|
if (m_nextFrameTime < 0)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -34,6 +34,7 @@ namespace app {
|
|||||||
bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
|
bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
|
||||||
bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
|
bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
|
||||||
bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
|
bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
|
||||||
|
bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onPlaybackTick();
|
void onPlaybackTick();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// 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)
|
bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||||
{
|
{
|
||||||
if (editor->hasCapture())
|
if (editor->hasCapture())
|
||||||
@ -172,7 +140,8 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||||||
context->setActiveView(editor->getDocumentView());
|
context->setActiveView(editor->getDocumentView());
|
||||||
|
|
||||||
// Start scroll loop
|
// Start scroll loop
|
||||||
if (checkForScroll(editor, msg) || checkForZoom(editor, msg))
|
if (editor->checkForScroll(msg) ||
|
||||||
|
editor->checkForZoom(msg))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Move cel X,Y coordinates
|
// Move cel X,Y coordinates
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -45,10 +45,6 @@ namespace app {
|
|||||||
void startSelectionTransformation(Editor* editor, const gfx::Point& move, double angle);
|
void startSelectionTransformation(Editor* editor, const gfx::Point& move, double angle);
|
||||||
|
|
||||||
protected:
|
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);
|
void callEyedropper(Editor* editor);
|
||||||
|
|
||||||
class Decorator : public EditorDecorator {
|
class Decorator : public EditorDecorator {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user