mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-26 18:41:20 +00:00
New zoom tool
This commit is contained in:
parent
1ab7de6668
commit
4c706afb90
10
data/gui.xml
10
data/gui.xml
@ -550,7 +550,7 @@
|
||||
/>
|
||||
</group>
|
||||
|
||||
<group id="helpers" text="Helpers">
|
||||
<group id="helpers_tools" text="Helpers Tools">
|
||||
<tool id="eraser"
|
||||
text="Eraser Tool"
|
||||
ink_left="eraser"
|
||||
@ -573,6 +573,14 @@
|
||||
controller="freehand"
|
||||
pointshape="pixel"
|
||||
/>
|
||||
</group>
|
||||
|
||||
<group id="view_tools" text="View Tools">
|
||||
<tool id="zoom"
|
||||
text="Zoom Tool"
|
||||
ink="zoom"
|
||||
controller="freehand"
|
||||
/>
|
||||
<tool id="hand"
|
||||
text="Hand Tool"
|
||||
ink="scroll"
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@ -103,6 +103,7 @@
|
||||
<cursor id="rotate_bl" x="240" y="208" w="16" h="16" focusx="8" focusy="8" />
|
||||
<cursor id="rotate_br" x="256" y="208" w="16" h="16" focusx="8" focusy="8" />
|
||||
<cursor id="eyedropper" x="80" y="224" w="16" h="16" focusx="0" focusy="15" />
|
||||
<cursor id="magnifier" x="80" y="240" w="16" h="16" focusx="5" focusy="5" />
|
||||
</cursors>
|
||||
|
||||
<tools>
|
||||
@ -120,6 +121,7 @@
|
||||
<tool id="eyedropper" x="160" y="32" w="16" h="16" />
|
||||
<tool id="hand" x="176" y="32" w="16" h="16" />
|
||||
<tool id="move" x="192" y="32" w="16" h="16" />
|
||||
<tool id="zoom" x="208" y="32" w="16" h="16" />
|
||||
|
||||
<tool id="paint_bucket" x="144" y="48" w="16" h="16" />
|
||||
|
||||
|
@ -172,6 +172,7 @@ add_library(app-lib
|
||||
ui/editor/standby_state.cpp
|
||||
ui/editor/tool_loop_impl.cpp
|
||||
ui/editor/transform_handles.cpp
|
||||
ui/editor/zooming_state.cpp
|
||||
ui/file_list.cpp
|
||||
ui/file_selector.cpp
|
||||
ui/hex_color_entry.cpp
|
||||
|
@ -52,6 +52,9 @@ namespace app {
|
||||
// Returns true if this ink moves the scroll only
|
||||
virtual bool isScrollMovement() const { return false; }
|
||||
|
||||
// Returns true if this ink is zoom
|
||||
virtual bool isZoom() const { return false; }
|
||||
|
||||
// Returns true if this ink moves cels
|
||||
virtual bool isCelMovement() const { return false; }
|
||||
|
||||
|
@ -130,6 +130,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class ZoomInk : public Ink {
|
||||
public:
|
||||
|
||||
bool isZoom() const { return true; }
|
||||
|
||||
void prepareInk(ToolLoop* loop)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void inkHline(int x1, int y, int x2, ToolLoop* loop)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class MoveInk : public Ink {
|
||||
public:
|
||||
bool isCelMovement() const { return true; }
|
||||
|
@ -64,6 +64,7 @@ const char* WellKnownInks::ReplaceFgWithBg = "replace_fg_with_bg";
|
||||
const char* WellKnownInks::ReplaceBgWithFg = "replace_bg_with_fg";
|
||||
const char* WellKnownInks::PickFg = "pick_fg";
|
||||
const char* WellKnownInks::PickBg = "pick_bg";
|
||||
const char* WellKnownInks::Zoom = "zoom";
|
||||
const char* WellKnownInks::Scroll = "scroll";
|
||||
const char* WellKnownInks::Move = "move";
|
||||
const char* WellKnownInks::Blur = "blur";
|
||||
@ -92,6 +93,7 @@ ToolBox::ToolBox()
|
||||
m_inks[WellKnownInks::ReplaceBgWithFg] = new EraserInk(EraserInk::ReplaceBgWithFg);
|
||||
m_inks[WellKnownInks::PickFg] = new PickInk(PickInk::Fg);
|
||||
m_inks[WellKnownInks::PickBg] = new PickInk(PickInk::Bg);
|
||||
m_inks[WellKnownInks::Zoom] = new ZoomInk();
|
||||
m_inks[WellKnownInks::Scroll] = new ScrollInk();
|
||||
m_inks[WellKnownInks::Move] = new MoveInk();
|
||||
m_inks[WellKnownInks::Blur] = new BlurInk();
|
||||
|
@ -48,6 +48,7 @@ namespace app {
|
||||
extern const char* ReplaceBgWithFg;
|
||||
extern const char* PickFg;
|
||||
extern const char* PickBg;
|
||||
extern const char* Zoom;
|
||||
extern const char* Scroll;
|
||||
extern const char* Move;
|
||||
extern const char* Blur;
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "app/ui/editor/scrolling_state.h"
|
||||
#include "app/ui/editor/tool_loop_impl.h"
|
||||
#include "app/ui/editor/transform_handles.h"
|
||||
#include "app/ui/editor/zooming_state.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/misc.h"
|
||||
@ -137,6 +138,24 @@ bool StandbyState::checkForScroll(Editor* editor, MouseMessage* msg)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StandbyState::checkForZoom(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
UIContext* context = UIContext::instance();
|
||||
tools::Tool* currentTool = editor->getCurrentEditorTool();
|
||||
tools::Ink* clickedInk = currentTool->getInk(msg->right() ? 1: 0);
|
||||
|
||||
// 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())
|
||||
@ -155,7 +174,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
context->setActiveView(editor->getDocumentView());
|
||||
|
||||
// Start scroll loop
|
||||
if (checkForScroll(editor, msg))
|
||||
if (checkForScroll(editor, msg) || checkForZoom(editor, msg))
|
||||
return true;
|
||||
|
||||
// Move cel X,Y coordinates
|
||||
@ -409,6 +428,11 @@ bool StandbyState::onSetCursor(Editor* editor)
|
||||
jmouse_set_cursor(kEyedropperCursor);
|
||||
return true;
|
||||
}
|
||||
else if (current_ink->isZoom()) {
|
||||
editor->hideDrawingCursor();
|
||||
jmouse_set_cursor(kMagnifierCursor);
|
||||
return true;
|
||||
}
|
||||
else if (current_ink->isScrollMovement()) {
|
||||
editor->hideDrawingCursor();
|
||||
jmouse_set_cursor(kScrollCursor);
|
||||
|
@ -55,6 +55,7 @@ namespace app {
|
||||
// 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);
|
||||
|
||||
class Decorator : public EditorDecorator {
|
||||
public:
|
||||
|
@ -118,8 +118,9 @@ public:
|
||||
m_tool->getText().c_str(),
|
||||
((getInk()->isSelection() ||
|
||||
getInk()->isEyedropper() ||
|
||||
getInk()->isScrollMovement()) ? undo::DoesntModifyDocument:
|
||||
undo::ModifyDocument))
|
||||
getInk()->isScrollMovement() ||
|
||||
getInk()->isZoom()) ? undo::DoesntModifyDocument:
|
||||
undo::ModifyDocument))
|
||||
, m_expandCelCanvas(m_context, m_docSettings->getTiledMode(), m_undoTransaction)
|
||||
, m_shadeTable(NULL)
|
||||
{
|
||||
|
102
src/app/ui/editor/zooming_state.cpp
Normal file
102
src/app/ui/editor/zooming_state.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 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/ui/editor/zooming_state.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "raster/sprite.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/view.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
ZoomingState::ZoomingState()
|
||||
{
|
||||
}
|
||||
|
||||
ZoomingState::~ZoomingState()
|
||||
{
|
||||
}
|
||||
|
||||
bool ZoomingState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
m_oldPos = msg->position();
|
||||
|
||||
editor->captureMouse();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZoomingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
int zoom = editor->getZoom();
|
||||
|
||||
if (msg->left() && zoom < 5)
|
||||
++zoom;
|
||||
else if (msg->right() && zoom > 0)
|
||||
--zoom;
|
||||
|
||||
editor->setZoomAndCenterInMouse(zoom, msg->position().x, msg->position().y);
|
||||
|
||||
editor->backToPreviousState();
|
||||
editor->releaseMouse();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZoomingState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZoomingState::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ZoomingState::onSetCursor(Editor* editor)
|
||||
{
|
||||
editor->hideDrawingCursor();
|
||||
jmouse_set_cursor(kMagnifierCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZoomingState::onKeyDown(Editor* editor, KeyMessage* msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ZoomingState::onKeyUp(Editor* editor, KeyMessage* msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ZoomingState::onUpdateStatusBar(Editor* editor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace app
|
49
src/app/ui/editor/zooming_state.h
Normal file
49
src/app/ui/editor/zooming_state.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 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
|
||||
*/
|
||||
|
||||
#ifndef APP_UI_EDITOR_ZOOMING_STATE_H_INCLUDED
|
||||
#define APP_UI_EDITOR_ZOOMING_STATE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/editor/editor_state.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "gfx/point.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class ZoomingState : public EditorState {
|
||||
public:
|
||||
ZoomingState();
|
||||
virtual ~ZoomingState();
|
||||
virtual bool isTemporalState() const OVERRIDE { return true; }
|
||||
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
|
||||
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
|
||||
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
|
||||
virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE;
|
||||
virtual bool onSetCursor(Editor* editor) OVERRIDE;
|
||||
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE;
|
||||
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE;
|
||||
virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE;
|
||||
|
||||
private:
|
||||
gfx::Point m_oldPos;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif // APP_UI_EDITOR_ZOOMING_STATE_H_INCLUDED
|
@ -135,7 +135,8 @@ static const char* cursor_names[kCursorTypes] = {
|
||||
"rotate_bl", // kRotateBLCursor
|
||||
"rotate_b", // kRotateBCursor
|
||||
"rotate_br", // kRotateBRCursor
|
||||
"eyedropper" // kEyedropperCursor
|
||||
"eyedropper", // kEyedropperCursor
|
||||
"magnifier" // kMagnifierCursor
|
||||
};
|
||||
|
||||
SkinTheme::SkinTheme()
|
||||
|
@ -36,7 +36,8 @@ namespace ui {
|
||||
kRotateBCursor,
|
||||
kRotateBRCursor,
|
||||
kEyedropperCursor,
|
||||
kLastCursorType = kEyedropperCursor,
|
||||
kMagnifierCursor,
|
||||
kLastCursorType = kMagnifierCursor,
|
||||
kCursorTypes
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user