mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
Add WheelAction to change InkType (related to #3195)
Mockup contributed here: https://community.aseprite.org/t/2468/10
This commit is contained in:
parent
ffc7af2ee8
commit
70a42c4c77
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -20,6 +21,9 @@ namespace tools {
|
||||
COPY_COLOR = 2,
|
||||
LOCK_ALPHA = 3,
|
||||
SHADING = 4,
|
||||
|
||||
FIRST = DEFAULT,
|
||||
LAST = SHADING,
|
||||
};
|
||||
|
||||
inline bool inkHasOpacity(InkType inkType) {
|
||||
|
@ -35,6 +35,7 @@ DraggingValueState::DraggingValueState(Editor* editor, const Keys& keys)
|
||||
, m_initialScroll(StateWithWheelBehavior::initialScroll(editor))
|
||||
, m_initialZoom(StateWithWheelBehavior::initialZoom(editor))
|
||||
, m_initialFrame(StateWithWheelBehavior::initialFrame(editor))
|
||||
, m_initialInkType(StateWithWheelBehavior::initialInkType(editor))
|
||||
, m_initialInkOpacity(StateWithWheelBehavior::initialInkOpacity(editor))
|
||||
, m_initialCelOpacity(StateWithWheelBehavior::initialCelOpacity(editor))
|
||||
, m_initialLayerOpacity(StateWithWheelBehavior::initialLayerOpacity(editor))
|
||||
@ -96,6 +97,9 @@ bool DraggingValueState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
// TODO we should change the direction of the wheel
|
||||
// information from the laf layer
|
||||
}
|
||||
else if (key->wheelAction() == WheelAction::InkType) {
|
||||
preciseWheel = false;
|
||||
}
|
||||
|
||||
processWheelAction(editor,
|
||||
key->wheelAction(),
|
||||
|
@ -41,6 +41,7 @@ namespace app {
|
||||
render::Zoom initialZoom(Editor* editor) const override { return m_initialZoom; }
|
||||
doc::frame_t initialFrame(Editor* editor) const override { return m_initialFrame; }
|
||||
doc::layer_t initialLayer(Editor* editor) const override { return m_initialLayer; }
|
||||
tools::InkType initialInkType(Editor* editor) const override { return m_initialInkType; }
|
||||
int initialInkOpacity(Editor* editor) const override { return m_initialInkOpacity; }
|
||||
int initialCelOpacity(Editor* editor) const override { return m_initialCelOpacity; }
|
||||
int initialLayerOpacity(Editor* editor) const override { return m_initialLayerOpacity; }
|
||||
@ -60,6 +61,7 @@ namespace app {
|
||||
render::Zoom m_initialZoom;
|
||||
doc::frame_t m_initialFrame;
|
||||
doc::layer_t m_initialLayer;
|
||||
tools::InkType m_initialInkType;
|
||||
int m_initialInkOpacity;
|
||||
int m_initialCelOpacity;
|
||||
int m_initialLayerOpacity;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "app/tools/active_tool.h"
|
||||
#include "app/tools/tool_box.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/context_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/keyboard_shortcuts.h"
|
||||
#include "app/ui/toolbar.h"
|
||||
@ -375,6 +376,24 @@ void StateWithWheelBehavior::processWheelAction(
|
||||
break;
|
||||
}
|
||||
|
||||
case WheelAction::InkType: {
|
||||
int ink = int(initialInkType(editor));
|
||||
int deltaInk = int(dz);
|
||||
if (preciseWheel) {
|
||||
if (dz < 0.0)
|
||||
deltaInk = +1;
|
||||
else if (dz > 0.0)
|
||||
deltaInk = -1;
|
||||
}
|
||||
ink += deltaInk;
|
||||
ink = base::clamp(ink,
|
||||
int(tools::InkType::FIRST),
|
||||
int(tools::InkType::LAST));
|
||||
|
||||
App::instance()->contextBar()->setInkType(tools::InkType(ink));
|
||||
break;
|
||||
}
|
||||
|
||||
case WheelAction::InkOpacity: {
|
||||
int opacity = initialInkOpacity(editor);
|
||||
adjust_value(preciseWheel, dz, opacity, 0, 255);
|
||||
@ -619,6 +638,13 @@ doc::layer_t StateWithWheelBehavior::initialLayer(Editor* editor) const
|
||||
return doc::find_layer_index(browsableLayers(editor), editor->layer());
|
||||
}
|
||||
|
||||
tools::InkType StateWithWheelBehavior::initialInkType(Editor* editor) const
|
||||
{
|
||||
tools::Tool* tool = getActiveTool();
|
||||
auto& toolPref = Preferences::instance().tool(tool);
|
||||
return toolPref.ink();
|
||||
}
|
||||
|
||||
int StateWithWheelBehavior::initialInkOpacity(Editor* editor) const
|
||||
{
|
||||
tools::Tool* tool = getActiveTool();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "app/tools/ink_type.h"
|
||||
#include "app/ui/editor/editor_state.h"
|
||||
#include "app/ui/key.h"
|
||||
#include "doc/frame.h"
|
||||
@ -54,6 +55,7 @@ namespace app {
|
||||
virtual render::Zoom initialZoom(Editor* editor) const;
|
||||
virtual doc::frame_t initialFrame(Editor* editor) const;
|
||||
virtual doc::layer_t initialLayer(Editor* editor) const;
|
||||
virtual tools::InkType initialInkType(Editor* editor) const;
|
||||
virtual int initialInkOpacity(Editor* editor) const;
|
||||
virtual int initialCelOpacity(Editor* editor) const;
|
||||
virtual int initialLayerOpacity(Editor* editor) const;
|
||||
|
@ -83,6 +83,7 @@ namespace app {
|
||||
ToolSameGroup,
|
||||
ToolOtherGroup,
|
||||
Layer,
|
||||
InkType,
|
||||
InkOpacity,
|
||||
LayerOpacity,
|
||||
CelOpacity,
|
||||
|
@ -104,6 +104,7 @@ namespace {
|
||||
{ "ToolSameGroup" , "Change Tool (same group)" , Vec(8.0, 0.0) },
|
||||
{ "ToolOtherGroup" , "Change Tool" , Vec(0.0, -8.0) },
|
||||
{ "Layer" , "Change Layer" , Vec(0.0, 8.0) },
|
||||
{ "InkType" , "Change Ink Type" , Vec(0.0, -16.0) },
|
||||
{ "InkOpacity" , "Change Ink Opacity" , Vec(0.0, 1.0) },
|
||||
{ "LayerOpacity" , "Change Layer Opacity" , Vec(0.0, 1.0) },
|
||||
{ "CelOpacity" , "Change Cel Opacity" , Vec(0.0, 1.0) },
|
||||
|
Loading…
x
Reference in New Issue
Block a user