mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 21:33:12 +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 -->
|
||||
<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>
|
||||
|
||||
<!-- Keyboard shortcuts to select tools -->
|
||||
|
@ -243,6 +243,7 @@ add_library(app-lib
|
||||
commands/cmd_save_palette.cpp
|
||||
commands/cmd_scroll.cpp
|
||||
commands/cmd_set_color_selector.cpp
|
||||
commands/cmd_set_ink_type.cpp
|
||||
commands/cmd_set_loop_section.cpp
|
||||
commands/cmd_set_palette.cpp
|
||||
commands/cmd_set_palette_entry_size.cpp
|
||||
@ -315,6 +316,7 @@ add_library(app-lib
|
||||
shell.cpp
|
||||
snap_to_grid.cpp
|
||||
thumbnail_generator.cpp
|
||||
tools/ink_type.cpp
|
||||
tools/intertwine.cpp
|
||||
tools/pick_ink.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(SelectionAsGrid)
|
||||
FOR_EACH_COMMAND(SetColorSelector)
|
||||
FOR_EACH_COMMAND(SetInkType)
|
||||
FOR_EACH_COMMAND(SetLoopSection)
|
||||
FOR_EACH_COMMAND(SetPalette)
|
||||
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
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace app {
|
||||
namespace tools {
|
||||
|
||||
@ -26,6 +28,8 @@ namespace tools {
|
||||
inkType == InkType::LOCK_ALPHA);
|
||||
}
|
||||
|
||||
std::string ink_type_to_string(InkType inkType);
|
||||
|
||||
} // namespace tools
|
||||
} // namespace app
|
||||
|
||||
|
@ -341,6 +341,21 @@ public:
|
||||
}
|
||||
|
||||
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();
|
||||
SkinPartPtr part = theme->parts.inkSimple();
|
||||
|
||||
@ -363,11 +378,11 @@ protected:
|
||||
|
||||
Menu menu;
|
||||
MenuItem
|
||||
simple("Simple Ink"),
|
||||
alphacompo("Alpha Compositing"),
|
||||
copycolor("Copy Color+Alpha"),
|
||||
lockalpha("Lock Alpha"),
|
||||
shading("Shading"),
|
||||
simple(tools::ink_type_to_string(tools::InkType::SIMPLE)),
|
||||
alphacompo(tools::ink_type_to_string(tools::InkType::ALPHA_COMPOSITING)),
|
||||
copycolor(tools::ink_type_to_string(tools::InkType::COPY_COLOR)),
|
||||
lockalpha(tools::ink_type_to_string(tools::InkType::LOCK_ALPHA)),
|
||||
shading(tools::ink_type_to_string(tools::InkType::SHADING)),
|
||||
alltools("Same in all Tools");
|
||||
menu.addChild(&simple);
|
||||
menu.addChild(&alphacompo);
|
||||
@ -387,11 +402,11 @@ protected:
|
||||
}
|
||||
alltools.setSelected(Preferences::instance().shared.shareInk());
|
||||
|
||||
simple.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::SIMPLE));
|
||||
alphacompo.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::ALPHA_COMPOSITING));
|
||||
copycolor.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::COPY_COLOR));
|
||||
lockalpha.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::LOCK_ALPHA));
|
||||
shading.Click.connect(Bind<void>(&InkTypeField::selectInk, this, InkType::SHADING));
|
||||
simple.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::SIMPLE));
|
||||
alphacompo.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::ALPHA_COMPOSITING));
|
||||
copycolor.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::COPY_COLOR));
|
||||
lockalpha.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::LOCK_ALPHA));
|
||||
shading.Click.connect(Bind<void>(&InkTypeField::setInkType, this, InkType::SHADING));
|
||||
alltools.Click.connect(Bind<void>(&InkTypeField::onSameInAllTools, this));
|
||||
|
||||
menu.showPopup(gfx::Point(bounds.x, bounds.y+bounds.h));
|
||||
@ -399,21 +414,6 @@ protected:
|
||||
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() {
|
||||
Preferences& pref = Preferences::instance();
|
||||
bool newState = !pref.shared.shareInk();
|
||||
@ -1535,7 +1535,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
||||
m_stopAtGrid->setSelected(
|
||||
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());
|
||||
|
||||
hasInkWithOpacity =
|
||||
@ -1806,4 +1806,9 @@ void ContextBar::reverseShadeColors()
|
||||
m_inkShades->reverseShadeColors();
|
||||
}
|
||||
|
||||
void ContextBar::setInkType(tools::InkType type)
|
||||
{
|
||||
m_inkType->setInkType(type);
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/tools/ink_type.h"
|
||||
#include "app/tools/selection_mode.h"
|
||||
#include "app/ui/context_bar_observer.h"
|
||||
#include "base/connection.h"
|
||||
@ -73,6 +74,8 @@ namespace app {
|
||||
doc::Remap* createShadeRemap(bool left);
|
||||
void reverseShadeColors();
|
||||
|
||||
void setInkType(tools::InkType type);
|
||||
|
||||
// Signals
|
||||
Signal0<void> BrushChange;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user