mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 21:19:18 +00:00
Independent scroll/zoom in Preview window (part of issue #407)
This commit is contained in:
parent
5f78fbe354
commit
22f35ab249
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -171,15 +171,18 @@
|
||||
<part id="sunken_mini_focused" x="16" y="80" w1="4" w2="4" w3="4" h1="4" h2="4" h3="4" />
|
||||
<part id="window" x="0" y="0" w1="3" w2="7" w3="3" h1="15" h2="4" h3="5" />
|
||||
<part id="menu" x="0" y="96" w1="3" w2="10" w3="3" h1="3" h2="9" h3="4" />
|
||||
<part id="window_close_button_normal" x="16" y= "0" w="9" h="11" />
|
||||
<part id="window_close_button_hot" x="16" y="16" w="9" h="11" />
|
||||
<part id="window_close_button_selected" x="16" y="32" w="9" h="11" />
|
||||
<part id="window_play_button_normal" x="25" y= "0" w="9" h="11" />
|
||||
<part id="window_play_button_hot" x="25" y="16" w="9" h="11" />
|
||||
<part id="window_play_button_selected" x="25" y="32" w="9" h="11" />
|
||||
<part id="window_stop_button_normal" x="34" y= "0" w="9" h="11" />
|
||||
<part id="window_stop_button_hot" x="34" y="16" w="9" h="11" />
|
||||
<part id="window_stop_button_selected" x="34" y="32" w="9" h="11" />
|
||||
<part id="window_close_button_normal" x="16" y="0" w="9" h="11" />
|
||||
<part id="window_close_button_hot" x="25" y="0" w="9" h="11" />
|
||||
<part id="window_close_button_selected" x="34" y="0" w="9" h="11" />
|
||||
<part id="window_play_button_normal" x="16" y="11" w="9" h="11" />
|
||||
<part id="window_play_button_hot" x="25" y="11" w="9" h="11" />
|
||||
<part id="window_play_button_selected" x="34" y="11" w="9" h="11" />
|
||||
<part id="window_stop_button_normal" x="16" y="22" w="9" h="11" />
|
||||
<part id="window_stop_button_hot" x="25" y="22" w="9" h="11" />
|
||||
<part id="window_stop_button_selected" x="34" y="22" w="9" h="11" />
|
||||
<part id="window_center_button_normal" x="16" y="33" w="9" h="11" />
|
||||
<part id="window_center_button_hot" x="25" y="33" w="9" h="11" />
|
||||
<part id="window_center_button_selected" x="34" y="33" w="9" h="11" />
|
||||
<part id="slider_full" x="0" y="144" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="slider_empty" x="16" y="144" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="slider_full_focused" x="0" y="160" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
|
@ -280,10 +280,12 @@ add_library(app-lib
|
||||
ui/editor/editor_view.cpp
|
||||
ui/editor/moving_cel_state.cpp
|
||||
ui/editor/moving_pixels_state.cpp
|
||||
ui/editor/navigate_state.cpp
|
||||
ui/editor/pixels_movement.cpp
|
||||
ui/editor/scrolling_state.cpp
|
||||
ui/editor/select_box_state.cpp
|
||||
ui/editor/standby_state.cpp
|
||||
ui/editor/state_with_wheel_behavior.cpp
|
||||
ui/editor/tool_loop_impl.cpp
|
||||
ui/editor/transform_handles.cpp
|
||||
ui/editor/zooming_state.cpp
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -47,8 +47,7 @@ using namespace ui;
|
||||
|
||||
class AppEditor : public Editor,
|
||||
public EditorObserver,
|
||||
public EditorCustomizationDelegate
|
||||
{
|
||||
public EditorCustomizationDelegate {
|
||||
public:
|
||||
AppEditor(Document* document) : Editor(document) {
|
||||
addObserver(this);
|
||||
@ -150,14 +149,36 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class PreviewEditor : public Editor,
|
||||
public EditorObserver {
|
||||
public:
|
||||
PreviewEditor(Document* document)
|
||||
: Editor(document, Editor::kShowOutside) // Don't show grid/mask in preview preview
|
||||
{
|
||||
addObserver(this);
|
||||
}
|
||||
|
||||
~PreviewEditor() {
|
||||
removeObserver(this);
|
||||
}
|
||||
|
||||
private:
|
||||
void onScrollChanged(Editor* editor) override {
|
||||
if (hasCapture()) {
|
||||
// TODO create a signal
|
||||
App::instance()->getMainWindow()->getPreviewEditor()->uncheckCenterButton();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DocumentView::DocumentView(Document* document, Type type)
|
||||
: Box(JI_VERTICAL)
|
||||
, m_document(document)
|
||||
, m_view(new EditorView(type == Normal ? EditorView::CurrentEditorMode:
|
||||
EditorView::AlwaysSelected))
|
||||
, m_editor(type == Normal ?
|
||||
new AppEditor(document):
|
||||
new Editor(document, Editor::kShowOutside)) // Don't show grid/mask in preview preview
|
||||
, m_editor((type == Normal ?
|
||||
(Editor*)new AppEditor(document):
|
||||
(Editor*)new PreviewEditor(document)))
|
||||
{
|
||||
addChild(m_view);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -41,7 +41,7 @@ namespace app {
|
||||
public:
|
||||
enum Type {
|
||||
Normal,
|
||||
Mini
|
||||
Preview
|
||||
};
|
||||
|
||||
DocumentView(Document* document, Type type);
|
||||
|
75
src/app/ui/editor/navigate_state.cpp
Normal file
75
src/app/ui/editor/navigate_state.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2015 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/navigate_state.h"
|
||||
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/scrolling_state.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
NavigateState::NavigateState()
|
||||
{
|
||||
}
|
||||
|
||||
bool NavigateState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
if (editor->hasCapture())
|
||||
return true;
|
||||
|
||||
// UIContext* context = UIContext::instance();
|
||||
// // When an editor is clicked the current view is changed.
|
||||
// context->setActiveView(editor->getDocumentView());
|
||||
|
||||
// Start scroll loop
|
||||
EditorStatePtr newState(new ScrollingState());
|
||||
editor->setState(newState);
|
||||
newState->onMouseDown(editor, msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NavigateState::onMouseUp(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
editor->releaseMouse();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NavigateState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
editor->moveDrawingCursor();
|
||||
editor->updateStatusBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NavigateState::onKeyDown(Editor* editor, KeyMessage* msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NavigateState::onKeyUp(Editor* editor, KeyMessage* msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace app
|
39
src/app/ui/editor/navigate_state.h
Normal file
39
src/app/ui/editor/navigate_state.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2015 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_NAVIGATE_STATE_H_INCLUDED
|
||||
#define APP_UI_EDITOR_NAVIGATE_STATE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/editor/state_with_wheel_behavior.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class NavigateState : public StateWithWheelBehavior {
|
||||
public:
|
||||
NavigateState();
|
||||
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 onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
|
||||
virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -32,7 +32,6 @@
|
||||
#include "app/tools/ink.h"
|
||||
#include "app/tools/pick_ink.h"
|
||||
#include "app/tools/tool.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/drawing_state.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/editor_customization_delegate.h"
|
||||
@ -61,14 +60,6 @@ namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
enum WHEEL_ACTION { WHEEL_NONE,
|
||||
WHEEL_ZOOM,
|
||||
WHEEL_VSCROLL,
|
||||
WHEEL_HSCROLL,
|
||||
WHEEL_FG,
|
||||
WHEEL_BG,
|
||||
WHEEL_FRAME };
|
||||
|
||||
static CursorType rotated_size_cursors[] = {
|
||||
kSizeECursor,
|
||||
kSizeNECursor,
|
||||
@ -302,129 +293,6 @@ bool StandbyState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
int dz = msg->wheelDelta().x + msg->wheelDelta().y;
|
||||
WHEEL_ACTION wheelAction = WHEEL_NONE;
|
||||
bool scrollBigSteps = false;
|
||||
|
||||
// Alt+mouse wheel changes the fg/bg colors
|
||||
if (msg->altPressed()) {
|
||||
if (msg->shiftPressed())
|
||||
wheelAction = WHEEL_BG;
|
||||
else
|
||||
wheelAction = WHEEL_FG;
|
||||
}
|
||||
// Normal behavior: mouse wheel zooms
|
||||
else if (UIContext::instance()->settings()->getZoomWithScrollWheel()) {
|
||||
if (msg->ctrlPressed())
|
||||
wheelAction = WHEEL_FRAME;
|
||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
||||
wheelAction = WHEEL_HSCROLL;
|
||||
else
|
||||
wheelAction = WHEEL_ZOOM;
|
||||
}
|
||||
// For laptops, it's convenient to that Ctrl+wheel zoom (because
|
||||
// it's the "pinch" gesture).
|
||||
else {
|
||||
if (msg->ctrlPressed())
|
||||
wheelAction = WHEEL_ZOOM;
|
||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
||||
wheelAction = WHEEL_HSCROLL;
|
||||
else
|
||||
wheelAction = WHEEL_VSCROLL;
|
||||
}
|
||||
|
||||
switch (wheelAction) {
|
||||
|
||||
case WHEEL_NONE:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
case WHEEL_FG:
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getFgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getFgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setFgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_BG:
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getBgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getBgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setBgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_FRAME:
|
||||
{
|
||||
Command* command = CommandsModule::instance()->getCommandByName
|
||||
((dz < 0) ? CommandId::GotoNextFrame:
|
||||
CommandId::GotoPreviousFrame);
|
||||
if (command)
|
||||
UIContext::instance()->executeCommand(command, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_ZOOM: {
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
render::Zoom zoom = editor->zoom();
|
||||
if (dz < 0) {
|
||||
while (dz++ < 0)
|
||||
zoom.in();
|
||||
}
|
||||
else {
|
||||
while (dz-- > 0)
|
||||
zoom.out();
|
||||
}
|
||||
|
||||
if (editor->zoom() != zoom) {
|
||||
editor->setZoomAndCenterInMouse(zoom,
|
||||
mouseMsg->position(), Editor::kDontCenterOnZoom);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WHEEL_HSCROLL:
|
||||
case WHEEL_VSCROLL: {
|
||||
View* view = View::getView(editor);
|
||||
gfx::Rect vp = view->getViewportBounds();
|
||||
gfx::Point delta(0, 0);
|
||||
|
||||
if (wheelAction == WHEEL_HSCROLL) {
|
||||
delta.x = dz * vp.w;
|
||||
}
|
||||
else {
|
||||
delta.y = dz * vp.h;
|
||||
}
|
||||
|
||||
if (scrollBigSteps) {
|
||||
delta /= 2;
|
||||
}
|
||||
else {
|
||||
delta /= 10;
|
||||
}
|
||||
|
||||
gfx::Point scroll = view->getViewScroll();
|
||||
|
||||
editor->hideDrawingCursor();
|
||||
editor->setEditorScroll(scroll+delta, true);
|
||||
editor->showDrawingCursor();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StandbyState::onSetCursor(Editor* editor)
|
||||
{
|
||||
tools::Ink* ink = editor->getCurrentEditorInk();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -21,14 +21,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/editor/editor_decorator.h"
|
||||
#include "app/ui/editor/editor_state.h"
|
||||
#include "app/ui/editor/handle_type.h"
|
||||
#include "app/ui/editor/state_with_wheel_behavior.h"
|
||||
#include "gfx/transformation.h"
|
||||
|
||||
namespace app {
|
||||
class TransformHandles;
|
||||
|
||||
class StandbyState : public EditorState {
|
||||
class StandbyState : public StateWithWheelBehavior {
|
||||
public:
|
||||
StandbyState();
|
||||
virtual ~StandbyState();
|
||||
@ -38,7 +38,6 @@ namespace app {
|
||||
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;
|
||||
|
167
src/app/ui/editor/state_with_wheel_behavior.cpp
Normal file
167
src/app/ui/editor/state_with_wheel_behavior.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2015 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/state_with_wheel_behavior.h"
|
||||
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/settings/settings.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "ui/message.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
enum WHEEL_ACTION { WHEEL_NONE,
|
||||
WHEEL_ZOOM,
|
||||
WHEEL_VSCROLL,
|
||||
WHEEL_HSCROLL,
|
||||
WHEEL_FG,
|
||||
WHEEL_BG,
|
||||
WHEEL_FRAME };
|
||||
|
||||
bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
int dz = msg->wheelDelta().x + msg->wheelDelta().y;
|
||||
WHEEL_ACTION wheelAction = WHEEL_NONE;
|
||||
bool scrollBigSteps = false;
|
||||
|
||||
// Alt+mouse wheel changes the fg/bg colors
|
||||
if (msg->altPressed()) {
|
||||
if (msg->shiftPressed())
|
||||
wheelAction = WHEEL_BG;
|
||||
else
|
||||
wheelAction = WHEEL_FG;
|
||||
}
|
||||
// Normal behavior: mouse wheel zooms
|
||||
else if (UIContext::instance()->settings()->getZoomWithScrollWheel()) {
|
||||
if (msg->ctrlPressed())
|
||||
wheelAction = WHEEL_FRAME;
|
||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
||||
wheelAction = WHEEL_HSCROLL;
|
||||
else
|
||||
wheelAction = WHEEL_ZOOM;
|
||||
}
|
||||
// For laptops, it's convenient to that Ctrl+wheel zoom (because
|
||||
// it's the "pinch" gesture).
|
||||
else {
|
||||
if (msg->ctrlPressed())
|
||||
wheelAction = WHEEL_ZOOM;
|
||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
||||
wheelAction = WHEEL_HSCROLL;
|
||||
else
|
||||
wheelAction = WHEEL_VSCROLL;
|
||||
}
|
||||
|
||||
switch (wheelAction) {
|
||||
|
||||
case WHEEL_NONE:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
case WHEEL_FG:
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getFgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getFgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setFgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_BG:
|
||||
{
|
||||
int newIndex = 0;
|
||||
if (ColorBar::instance()->getBgColor().getType() == app::Color::IndexType) {
|
||||
newIndex = ColorBar::instance()->getBgColor().getIndex() + dz;
|
||||
newIndex = MID(0, newIndex, 255);
|
||||
}
|
||||
ColorBar::instance()->setBgColor(app::Color::fromIndex(newIndex));
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_FRAME:
|
||||
{
|
||||
Command* command = CommandsModule::instance()->getCommandByName
|
||||
((dz < 0) ? CommandId::GotoNextFrame:
|
||||
CommandId::GotoPreviousFrame);
|
||||
if (command)
|
||||
UIContext::instance()->executeCommand(command, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case WHEEL_ZOOM: {
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
render::Zoom zoom = editor->zoom();
|
||||
if (dz < 0) {
|
||||
while (dz++ < 0)
|
||||
zoom.in();
|
||||
}
|
||||
else {
|
||||
while (dz-- > 0)
|
||||
zoom.out();
|
||||
}
|
||||
|
||||
if (editor->zoom() != zoom) {
|
||||
editor->setZoomAndCenterInMouse(zoom,
|
||||
mouseMsg->position(), Editor::kDontCenterOnZoom);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WHEEL_HSCROLL:
|
||||
case WHEEL_VSCROLL: {
|
||||
View* view = View::getView(editor);
|
||||
gfx::Rect vp = view->getViewportBounds();
|
||||
gfx::Point delta(0, 0);
|
||||
|
||||
if (wheelAction == WHEEL_HSCROLL) {
|
||||
delta.x = dz * vp.w;
|
||||
}
|
||||
else {
|
||||
delta.y = dz * vp.h;
|
||||
}
|
||||
|
||||
if (scrollBigSteps) {
|
||||
delta /= 2;
|
||||
}
|
||||
else {
|
||||
delta /= 10;
|
||||
}
|
||||
|
||||
gfx::Point scroll = view->getViewScroll();
|
||||
|
||||
editor->hideDrawingCursor();
|
||||
editor->setEditorScroll(scroll+delta, true);
|
||||
editor->showDrawingCursor();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace app
|
34
src/app/ui/editor/state_with_wheel_behavior.h
Normal file
34
src/app/ui/editor/state_with_wheel_behavior.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2015 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_STATE_WITH_WHEEL_BEHAVIOR_H_INCLUDED
|
||||
#define APP_UI_STATE_WITH_WHEEL_BEHAVIOR_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/editor/editor_state.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class StateWithWheelBehavior : public EditorState {
|
||||
public:
|
||||
virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -31,14 +31,15 @@
|
||||
#include "app/settings/settings.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/editor_view.h"
|
||||
#include "app/ui/editor/navigate_state.h"
|
||||
#include "app/ui/skin/skin_button.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui/toolbar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "ui/base.h"
|
||||
#include "ui/button.h"
|
||||
#include "ui/close_event.h"
|
||||
@ -50,6 +51,52 @@ namespace app {
|
||||
using namespace app::skin;
|
||||
using namespace ui;
|
||||
|
||||
class MiniCenterButton : public SkinButton<CheckBox> {
|
||||
public:
|
||||
MiniCenterButton()
|
||||
: SkinButton<CheckBox>(
|
||||
PART_WINDOW_CENTER_BUTTON_NORMAL,
|
||||
PART_WINDOW_CENTER_BUTTON_HOT,
|
||||
PART_WINDOW_CENTER_BUTTON_SELECTED)
|
||||
{
|
||||
setup_bevels(this, 0, 0, 0, 0);
|
||||
setDecorative(true);
|
||||
setSelected(true);
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetDecorativeWidgetBounds() override
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
Widget* window = getParent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
gfx::Size iconSize = theme->get_part_size(PART_WINDOW_PLAY_BUTTON_NORMAL);
|
||||
gfx::Size closeSize = theme->get_part_size(PART_WINDOW_CLOSE_BUTTON_NORMAL);
|
||||
|
||||
rect.w = iconSize.w;
|
||||
rect.h = iconSize.h;
|
||||
|
||||
rect.offset(window->getBounds().x2() - 3*guiscale()
|
||||
- iconSize.w - 1*guiscale()
|
||||
- iconSize.w - 1*guiscale() - closeSize.w,
|
||||
window->getBounds().y + 3*guiscale());
|
||||
|
||||
setBounds(rect);
|
||||
}
|
||||
|
||||
bool onProcessMessage(Message* msg) override
|
||||
{
|
||||
switch (msg->type()) {
|
||||
|
||||
case kSetCursorMessage:
|
||||
ui::set_mouse_cursor(kArrowCursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
return SkinButton<CheckBox>::onProcessMessage(msg);
|
||||
}
|
||||
};
|
||||
|
||||
class MiniPlayButton : public SkinButton<Button> {
|
||||
public:
|
||||
MiniPlayButton()
|
||||
@ -92,8 +139,8 @@ protected:
|
||||
rect.h = playSize.h;
|
||||
|
||||
rect.offset(window->getBounds().x2() - 3*guiscale()
|
||||
- playSize.w - 1*guiscale() - closeSize.w,
|
||||
window->getBounds().y + 3*guiscale());
|
||||
- playSize.w - 1*guiscale() - closeSize.w,
|
||||
window->getBounds().y + 3*guiscale());
|
||||
|
||||
setBounds(rect);
|
||||
}
|
||||
@ -117,6 +164,7 @@ private:
|
||||
PreviewEditorWindow::PreviewEditorWindow()
|
||||
: Window(WithTitleBar, "Preview")
|
||||
, m_docView(NULL)
|
||||
, m_centerButton(new MiniCenterButton())
|
||||
, m_playButton(new MiniPlayButton())
|
||||
, m_playTimer(10)
|
||||
, m_pingPongForward(true)
|
||||
@ -127,7 +175,10 @@ PreviewEditorWindow::PreviewEditorWindow()
|
||||
|
||||
m_isEnabled = get_config_bool("MiniEditor", "Enabled", true);
|
||||
|
||||
m_centerButton->Click.connect(Bind<void>(&PreviewEditorWindow::onCenterClicked, this));
|
||||
m_playButton->Click.connect(Bind<void>(&PreviewEditorWindow::onPlayClicked, this));
|
||||
|
||||
addChild(m_centerButton);
|
||||
addChild(m_playButton);
|
||||
|
||||
m_playTimer.Tick.connect(&PreviewEditorWindow::onPlaybackTick, this);
|
||||
@ -203,6 +254,15 @@ void PreviewEditorWindow::onWindowResize()
|
||||
updateUsingEditor(view->getEditor());
|
||||
}
|
||||
|
||||
void PreviewEditorWindow::onCenterClicked()
|
||||
{
|
||||
if (m_centerButton->isSelected()) {
|
||||
DocumentView* view = UIContext::instance()->activeView();
|
||||
if (view)
|
||||
updateUsingEditor(view->getEditor());
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewEditorWindow::onPlayClicked()
|
||||
{
|
||||
if (m_playButton->isPlaying()) {
|
||||
@ -236,25 +296,35 @@ void PreviewEditorWindow::updateUsingEditor(Editor* editor)
|
||||
openWindow();
|
||||
|
||||
gfx::Rect visibleBounds = editor->getVisibleSpriteBounds();
|
||||
gfx::Point pt = visibleBounds.getCenter();
|
||||
gfx::Point centerPoint = visibleBounds.getCenter();
|
||||
bool center = (m_centerButton->isSelected());
|
||||
|
||||
// Set the same location as in the given editor.
|
||||
if (!miniEditor || miniEditor->document() != document) {
|
||||
delete m_docView;
|
||||
m_docView = new DocumentView(document, DocumentView::Mini); // MiniEditorDocumentView(document, this);
|
||||
m_docView = new DocumentView(document, DocumentView::Preview);
|
||||
addChild(m_docView);
|
||||
|
||||
miniEditor = m_docView->getEditor();
|
||||
miniEditor->setZoom(render::Zoom(1, 1));
|
||||
miniEditor->setState(EditorStatePtr(new EditorState));
|
||||
miniEditor->setState(EditorStatePtr(new NavigateState));
|
||||
layout();
|
||||
center = true;
|
||||
}
|
||||
|
||||
miniEditor->centerInSpritePoint(pt);
|
||||
if (center)
|
||||
miniEditor->centerInSpritePoint(centerPoint);
|
||||
|
||||
miniEditor->setLayer(editor->layer());
|
||||
miniEditor->setFrame(editor->frame());
|
||||
}
|
||||
|
||||
void PreviewEditorWindow::uncheckCenterButton()
|
||||
{
|
||||
if (m_centerButton->isSelected())
|
||||
m_centerButton->setSelected(false);
|
||||
}
|
||||
|
||||
void PreviewEditorWindow::hideWindow()
|
||||
{
|
||||
delete m_docView;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "ui/window.h"
|
||||
|
||||
namespace app {
|
||||
class MiniCenterButton;
|
||||
class MiniPlayButton;
|
||||
|
||||
class PreviewEditorWindow : public ui::Window {
|
||||
@ -36,6 +37,7 @@ namespace app {
|
||||
void setPreviewEnabled(bool state);
|
||||
|
||||
void updateUsingEditor(Editor* editor);
|
||||
void uncheckCenterButton();
|
||||
|
||||
protected:
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
@ -43,12 +45,14 @@ namespace app {
|
||||
void onWindowResize() override;
|
||||
|
||||
private:
|
||||
void onCenterClicked();
|
||||
void onPlayClicked();
|
||||
void onPlaybackTick();
|
||||
void hideWindow();
|
||||
|
||||
bool m_isEnabled;
|
||||
DocumentView* m_docView;
|
||||
MiniCenterButton* m_centerButton;
|
||||
MiniPlayButton* m_playButton;
|
||||
ui::Timer m_playTimer;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -71,6 +71,10 @@ namespace app {
|
||||
PART_WINDOW_STOP_BUTTON_HOT,
|
||||
PART_WINDOW_STOP_BUTTON_SELECTED,
|
||||
|
||||
PART_WINDOW_CENTER_BUTTON_NORMAL,
|
||||
PART_WINDOW_CENTER_BUTTON_HOT,
|
||||
PART_WINDOW_CENTER_BUTTON_SELECTED,
|
||||
|
||||
SKIN_PART_NESW(PART_SLIDER_FULL),
|
||||
SKIN_PART_NESW(PART_SLIDER_EMPTY),
|
||||
SKIN_PART_NESW(PART_SLIDER_FULL_FOCUSED),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2014 David Capello
|
||||
* Copyright (C) 2001-2015 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
|
||||
@ -188,6 +188,9 @@ SkinTheme::SkinTheme()
|
||||
sheet_mapping["window_stop_button_normal"] = PART_WINDOW_STOP_BUTTON_NORMAL;
|
||||
sheet_mapping["window_stop_button_hot"] = PART_WINDOW_STOP_BUTTON_HOT;
|
||||
sheet_mapping["window_stop_button_selected"] = PART_WINDOW_STOP_BUTTON_SELECTED;
|
||||
sheet_mapping["window_center_button_normal"] = PART_WINDOW_CENTER_BUTTON_NORMAL;
|
||||
sheet_mapping["window_center_button_hot"] = PART_WINDOW_CENTER_BUTTON_HOT;
|
||||
sheet_mapping["window_center_button_selected"] = PART_WINDOW_CENTER_BUTTON_SELECTED;
|
||||
sheet_mapping["slider_full"] = PART_SLIDER_FULL_NW;
|
||||
sheet_mapping["slider_empty"] = PART_SLIDER_EMPTY_NW;
|
||||
sheet_mapping["slider_full_focused"] = PART_SLIDER_FULL_FOCUSED_NW;
|
||||
|
Loading…
Reference in New Issue
Block a user