mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Add ContiguousFillCommand to switch Contiguous option with a shortcut
This commit is contained in:
parent
d9ae6812d5
commit
8691345f03
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Aseprite -->
|
<!-- Aseprite -->
|
||||||
<!-- Copyright (C) 2001-2016 by David Capello -->
|
<!-- Copyright (C) 2001-2017 by David Capello -->
|
||||||
<gui version="1.1.12-dev">
|
<gui version="1.1.12-dev">
|
||||||
<!-- Keyboard shortcuts -->
|
<!-- Keyboard shortcuts -->
|
||||||
<keyboard version="1">
|
<keyboard version="1">
|
||||||
@ -388,6 +388,7 @@
|
|||||||
|
|
||||||
<!-- 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="ContiguousFill" />
|
||||||
<key command="SetInkType"><param name="type" value="simple" /></key>
|
<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="alpha-compositing" /></key>
|
||||||
<key command="SetInkType"><param name="type" value="copy-color" /></key>
|
<key command="SetInkType"><param name="type" value="copy-color" /></key>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Aseprite
|
# Aseprite
|
||||||
# Copyright (C) 2001-2016 David Capello
|
# Copyright (C) 2001-2017 David Capello
|
||||||
|
|
||||||
# Generate a ui::Widget for each widget in a XML file
|
# Generate a ui::Widget for each widget in a XML file
|
||||||
file(GLOB widget_files ${CMAKE_SOURCE_DIR}/data/widgets/*.xml)
|
file(GLOB widget_files ${CMAKE_SOURCE_DIR}/data/widgets/*.xml)
|
||||||
@ -200,6 +200,7 @@ add_library(app-lib
|
|||||||
commands/cmd_clear_cel.cpp
|
commands/cmd_clear_cel.cpp
|
||||||
commands/cmd_close_file.cpp
|
commands/cmd_close_file.cpp
|
||||||
commands/cmd_color_quantization.cpp
|
commands/cmd_color_quantization.cpp
|
||||||
|
commands/cmd_contiguous_fill.cpp
|
||||||
commands/cmd_copy.cpp
|
commands/cmd_copy.cpp
|
||||||
commands/cmd_copy_cel.cpp
|
commands/cmd_copy_cel.cpp
|
||||||
commands/cmd_copy_merged.cpp
|
commands/cmd_copy_merged.cpp
|
||||||
|
60
src/app/commands/cmd_contiguous_fill.cpp
Normal file
60
src/app/commands/cmd_contiguous_fill.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Aseprite
|
||||||
|
// Copyright (C) 2017 David Capello
|
||||||
|
//
|
||||||
|
// This program is distributed under the terms of
|
||||||
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
|
#include "app/commands/command.h"
|
||||||
|
#include "app/pref/preferences.h"
|
||||||
|
#include "app/tools/tool.h"
|
||||||
|
|
||||||
|
namespace app {
|
||||||
|
|
||||||
|
class ContiguousFillCommand : public Command {
|
||||||
|
public:
|
||||||
|
ContiguousFillCommand();
|
||||||
|
Command* clone() const override { return new ContiguousFillCommand(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onChecked(Context* context) override;
|
||||||
|
void onExecute(Context* context) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
ContiguousFillCommand::ContiguousFillCommand()
|
||||||
|
: Command("ContiguousFill",
|
||||||
|
"Switch Contiguous Fill",
|
||||||
|
CmdUIOnlyFlag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ContiguousFillCommand::onChecked(Context* ctx)
|
||||||
|
{
|
||||||
|
tools::Tool* tool = App::instance()->activeTool();
|
||||||
|
if (!tool)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto& toolPref = Preferences::instance().tool(tool);
|
||||||
|
return toolPref.contiguous();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContiguousFillCommand::onExecute(Context* ctx)
|
||||||
|
{
|
||||||
|
tools::Tool* tool = App::instance()->activeTool();
|
||||||
|
if (!tool)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto& toolPref = Preferences::instance().tool(tool);
|
||||||
|
toolPref.contiguous(!toolPref.contiguous());
|
||||||
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::createContiguousFillCommand()
|
||||||
|
{
|
||||||
|
return new ContiguousFillCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace app
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -21,6 +21,7 @@ FOR_EACH_COMMAND(CloseAllFiles)
|
|||||||
FOR_EACH_COMMAND(CloseFile)
|
FOR_EACH_COMMAND(CloseFile)
|
||||||
FOR_EACH_COMMAND(ColorCurve)
|
FOR_EACH_COMMAND(ColorCurve)
|
||||||
FOR_EACH_COMMAND(ColorQuantization)
|
FOR_EACH_COMMAND(ColorQuantization)
|
||||||
|
FOR_EACH_COMMAND(ContiguousFill)
|
||||||
FOR_EACH_COMMAND(ConvolutionMatrix)
|
FOR_EACH_COMMAND(ConvolutionMatrix)
|
||||||
FOR_EACH_COMMAND(Copy)
|
FOR_EACH_COMMAND(Copy)
|
||||||
FOR_EACH_COMMAND(CopyCel)
|
FOR_EACH_COMMAND(CopyCel)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -1480,6 +1480,15 @@ void ContextBar::onToolSetFreehandAlgorithm()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextBar::onToolSetContiguous()
|
||||||
|
{
|
||||||
|
Tool* tool = App::instance()->activeTool();
|
||||||
|
if (tool) {
|
||||||
|
m_contiguous->setSelected(
|
||||||
|
Preferences::instance().tool(tool).contiguous());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ContextBar::onBrushSizeChange()
|
void ContextBar::onBrushSizeChange()
|
||||||
{
|
{
|
||||||
if (m_activeBrush->type() != kImageBrushType)
|
if (m_activeBrush->type() != kImageBrushType)
|
||||||
@ -1564,6 +1573,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
|||||||
m_angleConn = brushPref->angle.AfterChange.connect(base::Bind<void>(&ContextBar::onBrushAngleChange, this));
|
m_angleConn = brushPref->angle.AfterChange.connect(base::Bind<void>(&ContextBar::onBrushAngleChange, this));
|
||||||
m_opacityConn = toolPref->opacity.AfterChange.connect(&ContextBar::onToolSetOpacity, this);
|
m_opacityConn = toolPref->opacity.AfterChange.connect(&ContextBar::onToolSetOpacity, this);
|
||||||
m_freehandAlgoConn = toolPref->freehandAlgorithm.AfterChange.connect(base::Bind<void>(&ContextBar::onToolSetFreehandAlgorithm, this));
|
m_freehandAlgoConn = toolPref->freehandAlgorithm.AfterChange.connect(base::Bind<void>(&ContextBar::onToolSetFreehandAlgorithm, this));
|
||||||
|
m_contiguousConn = toolPref->contiguous.AfterChange.connect(base::Bind<void>(&ContextBar::onToolSetContiguous, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tool)
|
if (tool)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -77,6 +77,7 @@ namespace app {
|
|||||||
void onSizeHint(ui::SizeHintEvent& ev) override;
|
void onSizeHint(ui::SizeHintEvent& ev) override;
|
||||||
void onToolSetOpacity(const int& newOpacity);
|
void onToolSetOpacity(const int& newOpacity);
|
||||||
void onToolSetFreehandAlgorithm();
|
void onToolSetFreehandAlgorithm();
|
||||||
|
void onToolSetContiguous();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onBrushSizeChange();
|
void onBrushSizeChange();
|
||||||
@ -145,6 +146,7 @@ namespace app {
|
|||||||
obs::scoped_connection m_angleConn;
|
obs::scoped_connection m_angleConn;
|
||||||
obs::scoped_connection m_opacityConn;
|
obs::scoped_connection m_opacityConn;
|
||||||
obs::scoped_connection m_freehandAlgoConn;
|
obs::scoped_connection m_freehandAlgoConn;
|
||||||
|
obs::scoped_connection m_contiguousConn;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
Loading…
x
Reference in New Issue
Block a user