mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Disable tool changes when we're previewing a filter
In this way the user cannot use Ctrl key to try to move a cel and get an error that the sprite is locked so we cannot move the cel. Actually we shouldn't be able to move the cel when we're using the Editor for preview purposes (FilterWindow / WindowWithHand). This issue was reported in #4465, and created for the new Dialog:show{hand=true} API mainly.
This commit is contained in:
parent
21565a9349
commit
9eadd740b8
@ -47,6 +47,7 @@ private:
|
|||||||
ActiveToolManager::ActiveToolManager(ToolBox* toolbox)
|
ActiveToolManager::ActiveToolManager(ToolBox* toolbox)
|
||||||
: m_toolbox(toolbox)
|
: m_toolbox(toolbox)
|
||||||
, m_quickTool(nullptr)
|
, m_quickTool(nullptr)
|
||||||
|
, m_allowQuickToolChanges(true)
|
||||||
, m_rightClick(false)
|
, m_rightClick(false)
|
||||||
, m_rightClickTool(nullptr)
|
, m_rightClickTool(nullptr)
|
||||||
, m_rightClickInk(nullptr)
|
, m_rightClickInk(nullptr)
|
||||||
@ -57,14 +58,16 @@ ActiveToolManager::ActiveToolManager(ToolBox* toolbox)
|
|||||||
|
|
||||||
Tool* ActiveToolManager::activeTool() const
|
Tool* ActiveToolManager::activeTool() const
|
||||||
{
|
{
|
||||||
if (m_quickTool)
|
if (m_allowQuickToolChanges) {
|
||||||
return m_quickTool;
|
if (m_quickTool)
|
||||||
|
return m_quickTool;
|
||||||
|
|
||||||
if (m_rightClickTool)
|
if (m_rightClickTool)
|
||||||
return m_rightClickTool;
|
return m_rightClickTool;
|
||||||
|
|
||||||
if (m_proximityTool)
|
if (m_proximityTool)
|
||||||
return m_proximityTool;
|
return m_proximityTool;
|
||||||
|
}
|
||||||
|
|
||||||
// Active tool should never returns null
|
// Active tool should never returns null
|
||||||
ASSERT(m_selectedTool);
|
ASSERT(m_selectedTool);
|
||||||
@ -234,6 +237,11 @@ void ActiveToolManager::setSelectedTool(Tool* tool)
|
|||||||
notify_observers(&ActiveToolObserver::onSelectedToolChange, tool);
|
notify_observers(&ActiveToolObserver::onSelectedToolChange, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActiveToolManager::setAllowQuickToolChanges(const bool state)
|
||||||
|
{
|
||||||
|
m_allowQuickToolChanges = state;
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool ActiveToolManager::isToolAffectedByRightClickMode(Tool* tool)
|
bool ActiveToolManager::isToolAffectedByRightClickMode(Tool* tool)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,8 @@ public:
|
|||||||
const InkType inkType,
|
const InkType inkType,
|
||||||
const app::Color& color) const;
|
const app::Color& color) const;
|
||||||
|
|
||||||
|
void setAllowQuickToolChanges(bool state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool isToolAffectedByRightClickMode(Tool* tool);
|
static bool isToolAffectedByRightClickMode(Tool* tool);
|
||||||
|
|
||||||
@ -63,6 +65,11 @@ private:
|
|||||||
// shortuts).
|
// shortuts).
|
||||||
Tool* m_quickTool;
|
Tool* m_quickTool;
|
||||||
|
|
||||||
|
// This can be disable temporarily in case we want to use an Editor
|
||||||
|
// in "preview only mode" (e.g. when we're previewing a filter we
|
||||||
|
// want to disable the Ctrl key to change to the Move tool).
|
||||||
|
bool m_allowQuickToolChanges;
|
||||||
|
|
||||||
// Special tool by stylus proximity.
|
// Special tool by stylus proximity.
|
||||||
bool m_rightClick;
|
bool m_rightClick;
|
||||||
Tool* m_rightClickTool;
|
Tool* m_rightClickTool;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "app/ui/window_with_hand.h"
|
#include "app/ui/window_with_hand.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/tools/active_tool.h"
|
||||||
#include "app/tools/tool_box.h"
|
#include "app/tools/tool_box.h"
|
||||||
#include "app/ui/context_bar.h"
|
#include "app/ui/context_bar.h"
|
||||||
#include "app/ui/editor/editor.h"
|
#include "app/ui/editor/editor.h"
|
||||||
@ -30,11 +31,14 @@ WindowWithHand::~WindowWithHand()
|
|||||||
|
|
||||||
void WindowWithHand::enableHandTool(const bool state)
|
void WindowWithHand::enableHandTool(const bool state)
|
||||||
{
|
{
|
||||||
|
auto* atm = App::instance()->activeToolManager();
|
||||||
|
|
||||||
if (m_editor) {
|
if (m_editor) {
|
||||||
m_editor->remove_observer(this);
|
m_editor->remove_observer(this);
|
||||||
m_editor = nullptr;
|
m_editor = nullptr;
|
||||||
}
|
}
|
||||||
if (m_oldTool) {
|
if (m_oldTool) {
|
||||||
|
atm->setAllowQuickToolChanges(true);
|
||||||
ToolBar::instance()->selectTool(m_oldTool);
|
ToolBar::instance()->selectTool(m_oldTool);
|
||||||
m_oldTool = nullptr;
|
m_oldTool = nullptr;
|
||||||
}
|
}
|
||||||
@ -43,7 +47,13 @@ void WindowWithHand::enableHandTool(const bool state)
|
|||||||
if (state && editor) {
|
if (state && editor) {
|
||||||
m_editor = editor;
|
m_editor = editor;
|
||||||
m_editor->add_observer(this);
|
m_editor->add_observer(this);
|
||||||
|
|
||||||
|
// Disable quick tools like Ctrl to select the Move tool and move
|
||||||
|
// cels, or Alt for eyedropper. We just want the Hand tool
|
||||||
|
// (selected tool) for preview purposes.
|
||||||
|
atm->setAllowQuickToolChanges(false);
|
||||||
m_oldTool = m_editor->getCurrentEditorTool();
|
m_oldTool = m_editor->getCurrentEditorTool();
|
||||||
|
|
||||||
tools::Tool* hand = App::instance()->toolBox()->getToolById(tools::WellKnownTools::Hand);
|
tools::Tool* hand = App::instance()->toolBox()->getToolById(tools::WellKnownTools::Hand);
|
||||||
ToolBar::instance()->selectTool(hand);
|
ToolBar::instance()->selectTool(hand);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user