mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-03 05:29:13 +00:00
Add commands to change ink type (#787)
By default there are no shortcuts to change the ink type.
This commit is contained in:
parent
c33e63bed7
commit
aaf49be654
@ -368,6 +368,11 @@
|
|||||||
|
|
||||||
<!-- Commands not associated to menu items and without shortcuts by default -->
|
<!-- Commands not associated to menu items and without shortcuts by default -->
|
||||||
<key command="PixelPerfectMode" />
|
<key command="PixelPerfectMode" />
|
||||||
|
<key command="SetInkType"><param name="type" value="simple" /></key>
|
||||||
|
<key command="SetInkType"><param name="type" value="alpha-compositing" /></key>
|
||||||
|
<key command="SetInkType"><param name="type" value="copy-color" /></key>
|
||||||
|
<key command="SetInkType"><param name="type" value="lock-alpha" /></key>
|
||||||
|
<key command="SetInkType"><param name="type" value="shading" /></key>
|
||||||
</commands>
|
</commands>
|
||||||
|
|
||||||
<!-- Keyboard shortcuts to select tools -->
|
<!-- Keyboard shortcuts to select tools -->
|
||||||
|
@ -243,6 +243,7 @@ add_library(app-lib
|
|||||||
commands/cmd_save_palette.cpp
|
commands/cmd_save_palette.cpp
|
||||||
commands/cmd_scroll.cpp
|
commands/cmd_scroll.cpp
|
||||||
commands/cmd_set_color_selector.cpp
|
commands/cmd_set_color_selector.cpp
|
||||||
|
commands/cmd_set_ink_type.cpp
|
||||||
commands/cmd_set_loop_section.cpp
|
commands/cmd_set_loop_section.cpp
|
||||||
commands/cmd_set_palette.cpp
|
commands/cmd_set_palette.cpp
|
||||||
commands/cmd_set_palette_entry_size.cpp
|
commands/cmd_set_palette_entry_size.cpp
|
||||||
@ -315,6 +316,7 @@ add_library(app-lib
|
|||||||
shell.cpp
|
shell.cpp
|
||||||
snap_to_grid.cpp
|
snap_to_grid.cpp
|
||||||
thumbnail_generator.cpp
|
thumbnail_generator.cpp
|
||||||
|
tools/ink_type.cpp
|
||||||
tools/intertwine.cpp
|
tools/intertwine.cpp
|
||||||
tools/pick_ink.cpp
|
tools/pick_ink.cpp
|
||||||
tools/point_shape.cpp
|
tools/point_shape.cpp
|
||||||
|
79
src/app/commands/cmd_set_ink_type.cpp
Normal file
79
src/app/commands/cmd_set_ink_type.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// 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 version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
|
#include "app/commands/command.h"
|
||||||
|
#include "app/commands/commands.h"
|
||||||
|
#include "app/commands/params.h"
|
||||||
|
#include "app/tools/ink_type.h"
|
||||||
|
#include "app/ui/context_bar.h"
|
||||||
|
#include "app/ui/main_window.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
class SetInkTypeCommand : public Command {
|
||||||
|
public:
|
||||||
|
SetInkTypeCommand();
|
||||||
|
Command* clone() const override { return new SetInkTypeCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onLoadParams(const Params& params) override;
|
||||||
|
void onExecute(Context* context) override;
|
||||||
|
std::string onGetFriendlyName() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
tools::InkType m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
SetInkTypeCommand::SetInkTypeCommand()
|
||||||
|
: Command("SetInkType",
|
||||||
|
"Set Ink Type",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
, m_type(tools::InkType::DEFAULT)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetInkTypeCommand::onLoadParams(const Params& params)
|
||||||
|
{
|
||||||
|
std::string typeStr = params.get("type");
|
||||||
|
if (typeStr == "simple")
|
||||||
|
m_type = tools::InkType::SIMPLE;
|
||||||
|
else if (typeStr == "alpha-compositing")
|
||||||
|
m_type = tools::InkType::ALPHA_COMPOSITING;
|
||||||
|
else if (typeStr == "copy-color")
|
||||||
|
m_type = tools::InkType::COPY_COLOR;
|
||||||
|
else if (typeStr == "lock-alpha")
|
||||||
|
m_type = tools::InkType::LOCK_ALPHA;
|
||||||
|
else if (typeStr == "shading")
|
||||||
|
m_type = tools::InkType::SHADING;
|
||||||
|
else
|
||||||
|
m_type = tools::InkType::DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetInkTypeCommand::onExecute(Context* context)
|
||||||
|
{
|
||||||
|
App::instance()
|
||||||
|
->getMainWindow()
|
||||||
|
->getContextBar()
|
||||||
|
->setInkType(m_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SetInkTypeCommand::onGetFriendlyName() const
|
||||||
|
{
|
||||||
|
return "Set Ink Type: " + tools::ink_type_to_string(m_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::createSetInkTypeCommand()
|
||||||
|
{
|
||||||
|
return new SetInkTypeCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace app
|
@ -105,6 +105,7 @@ FOR_EACH_COMMAND(SavePalette)
|
|||||||
FOR_EACH_COMMAND(Scroll)
|
FOR_EACH_COMMAND(Scroll)
|
||||||
FOR_EACH_COMMAND(SelectionAsGrid)
|
FOR_EACH_COMMAND(SelectionAsGrid)
|
||||||
FOR_EACH_COMMAND(SetColorSelector)
|
FOR_EACH_COMMAND(SetColorSelector)
|
||||||
|
FOR_EACH_COMMAND(SetInkType)
|
||||||
FOR_EACH_COMMAND(SetLoopSection)
|
FOR_EACH_COMMAND(SetLoopSection)
|
||||||
FOR_EACH_COMMAND(SetPalette)
|
FOR_EACH_COMMAND(SetPalette)
|
||||||
FOR_EACH_COMMAND(SetPaletteEntrySize)
|
FOR_EACH_COMMAND(SetPaletteEntrySize)
|
||||||
|
30
src/app/tools/ink_type.cpp
Normal file
30
src/app/tools/ink_type.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// 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 version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "app/tools/ink_type.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
namespace tools {
|
||||||
|
|
||||||
|
std::string ink_type_to_string(InkType inkType)
|
||||||
|
{
|
||||||
|
switch (inkType) {
|
||||||
|
case tools::InkType::SIMPLE: return "Simple Ink";
|
||||||
|
case tools::InkType::ALPHA_COMPOSITING: return "Alpha Compositing";
|
||||||
|
case tools::InkType::COPY_COLOR: return "Copy Color+Alpha";
|
||||||
|
case tools::InkType::LOCK_ALPHA: return "Lock Alpha";
|
||||||
|
case tools::InkType::SHADING: return "Shading";
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace tools
|
||||||
|
} // namespace app
|
@ -9,6 +9,8 @@
|
|||||||
#define APP_TOOLS_INK_TYPE_H_INCLUDED
|
#define APP_TOOLS_INK_TYPE_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace tools {
|
namespace tools {
|
||||||
|
|
||||||
@ -26,6 +28,8 @@ namespace tools {
|
|||||||
inkType == InkType::LOCK_ALPHA);
|
inkType == InkType::LOCK_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ink_type_to_string(InkType inkType);
|
||||||
|
|
||||||
} // namespace tools
|
} // namespace tools
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
|
@ -341,6 +341,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setInkType(InkType inkType) {
|
void setInkType(InkType inkType) {
|
||||||
|
Preferences& pref = Preferences::instance();
|
||||||
|
|
||||||
|
if (pref.shared.shareInk()) {
|
||||||
|
for (Tool* tool : *App::instance()->getToolBox())
|
||||||
|
pref.tool(tool).ink(inkType);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Tool* tool = App::instance()->activeTool();
|
||||||
|
pref.tool(tool).ink(inkType);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_owner->updateForCurrentTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInkTypeIcon(InkType inkType) {
|
||||||
SkinTheme* theme = SkinTheme::instance();
|
SkinTheme* theme = SkinTheme::instance();
|
||||||
SkinPartPtr part = theme->parts.inkSimple();
|
SkinPartPtr part = theme->parts.inkSimple();
|
||||||
|
|
||||||
@ -363,11 +378,11 @@ protected:
|
|||||||
|
|
||||||
Menu menu;
|
Menu menu;
|
||||||
MenuItem
|
MenuItem
|
||||||
simple("Simple Ink"),
|
simple(tools::ink_type_to_string(tools::InkType::SIMPLE)),
|
||||||
alphacompo("Alpha Compositing"),
|
alphacompo(tools::ink_type_to_string(tools::InkType::ALPHA_COMPOSITING)),
|
||||||
copycolor("Copy Color+Alpha"),
|
copycolor(tools::ink_type_to_string(tools::InkType::COPY_COLOR)),
|
||||||
lockalpha("Lock Alpha"),
|
lockalpha(tools::ink_type_to_string(tools::InkType::LOCK_ALPHA)),
|
||||||
shading("Shading"),
|
shading(tools::ink_type_to_string(tools::InkType::SHADING)),
|
||||||
alltools("Same in all Tools");
|
alltools("Same in all Tools");
|
||||||
menu.addChild(&simple);
|
menu.addChild(&simple);
|
||||||
menu.addChild(&alphacompo);
|
menu.addChild(&alphacompo);
|
||||||
@ -387,11 +402,11 @@ protected:
|
|||||||
}
|
}
|
||||||
alltools.setSelected(Preferences::instance().shared.shareInk());
|
alltools.setSelected(Preferences::instance().shared.shareInk());
|
||||||
|
|
||||||
simple.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::SIMPLE));
|
simple.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::SIMPLE));
|
||||||
alphacompo.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::ALPHA_COMPOSITING));
|
alphacompo.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::ALPHA_COMPOSITING));
|
||||||
copycolor.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::COPY_COLOR));
|
copycolor.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::COPY_COLOR));
|
||||||
lockalpha.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::LOCK_ALPHA));
|
lockalpha.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::LOCK_ALPHA));
|
||||||
shading.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::SHADING));
|
shading.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::SHADING));
|
||||||
alltools.Click.connect(Bind<void>(&InkTypeField::onSameInAllTools, this));
|
alltools.Click.connect(Bind<void>(&InkTypeField::onSameInAllTools, this));
|
||||||
|
|
||||||
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
|
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
|
||||||
@ -399,21 +414,6 @@ protected:
|
|||||||
deselectItems();
|
deselectItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectInk(InkType inkType) {
|
|
||||||
Preferences& pref = Preferences::instance();
|
|
||||||
|
|
||||||
if (pref.shared.shareInk()) {
|
|
||||||
for (Tool* tool : *App::instance()->getToolBox())
|
|
||||||
pref.tool(tool).ink(inkType);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Tool* tool = App::instance()->activeTool();
|
|
||||||
pref.tool(tool).ink(inkType);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_owner->updateForCurrentTool();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onSameInAllTools() {
|
void onSameInAllTools() {
|
||||||
Preferences& pref = Preferences::instance();
|
Preferences& pref = Preferences::instance();
|
||||||
bool newState = !pref.shared.shareInk();
|
bool newState = !pref.shared.shareInk();
|
||||||
@ -1535,7 +1535,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
|||||||
m_stopAtGrid->setSelected(
|
m_stopAtGrid->setSelected(
|
||||||
toolPref->floodfill.stopAtGrid() == app::gen::StopAtGrid::IF_VISIBLE ? true: false);
|
toolPref->floodfill.stopAtGrid() == app::gen::StopAtGrid::IF_VISIBLE ? true: false);
|
||||||
|
|
||||||
m_inkType->setInkType(toolPref->ink());
|
m_inkType->setInkTypeIcon(toolPref->ink());
|
||||||
m_inkOpacity->setTextf("%d", toolPref->opacity());
|
m_inkOpacity->setTextf("%d", toolPref->opacity());
|
||||||
|
|
||||||
hasInkWithOpacity =
|
hasInkWithOpacity =
|
||||||
@ -1806,4 +1806,9 @@ void ContextBar::reverseShadeColors()
|
|||||||
m_inkShades->reverseShadeColors();
|
m_inkShades->reverseShadeColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextBar::setInkType(tools::InkType type)
|
||||||
|
{
|
||||||
|
m_inkType->setInkType(type);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
|
#include "app/tools/ink_type.h"
|
||||||
#include "app/tools/selection_mode.h"
|
#include "app/tools/selection_mode.h"
|
||||||
#include "app/ui/context_bar_observer.h"
|
#include "app/ui/context_bar_observer.h"
|
||||||
#include "base/connection.h"
|
#include "base/connection.h"
|
||||||
@ -73,6 +74,8 @@ namespace app {
|
|||||||
doc::Remap* createShadeRemap(bool left);
|
doc::Remap* createShadeRemap(bool left);
|
||||||
void reverseShadeColors();
|
void reverseShadeColors();
|
||||||
|
|
||||||
|
void setInkType(tools::InkType type);
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
Signal0<void> BrushChange;
|
Signal0<void> BrushChange;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user