This is an automated email from the git hooks/post-receive script. thansen pushed a commit to branch master in repository aseprite.
commit e683b8fb1a8f66cf60b9bf5bcb80fa20483e1b32 Author: David Capello <[email protected]> Date: Fri Nov 20 18:44:08 2015 -0300 Switch shading colors with X key Related to #85 and #854 --- src/app/commands/cmd_switch_colors.cpp | 26 ++++++++++++++++++++++++-- src/app/ui/context_bar.cpp | 10 ++++++++++ src/app/ui/context_bar.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/app/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp index c0a04cb..8922998 100644 --- a/src/app/commands/cmd_switch_colors.cpp +++ b/src/app/commands/cmd_switch_colors.cpp @@ -11,7 +11,11 @@ #include "app/app.h" #include "app/commands/command.h" +#include "app/modules/editors.h" #include "app/ui/color_bar.h" +#include "app/ui/context_bar.h" +#include "app/ui/editor/editor.h" +#include "app/ui/main_window.h" #include "ui/base.h" namespace app { @@ -21,7 +25,8 @@ public: SwitchColorsCommand(); protected: - void onExecute(Context* context); + bool onEnabled(Context* context) override; + void onExecute(Context* context) override; }; SwitchColorsCommand::SwitchColorsCommand() @@ -31,12 +36,29 @@ SwitchColorsCommand::SwitchColorsCommand() { } +bool SwitchColorsCommand::onEnabled(Context* context) +{ + return (current_editor ? true: false); +} + void SwitchColorsCommand::onExecute(Context* context) { + ASSERT(current_editor); + if (!current_editor) + return; + + tools::Tool* tool = current_editor->getCurrentEditorTool(); + if (tool) { + const auto& toolPref(Preferences::instance().tool(tool)); + if (toolPref.ink() == tools::InkType::SHADING) { + App::instance()->getMainWindow()-> + getContextBar()->reverseShadesColors(); + } + } + ColorBar* colorbar = ColorBar::instance(); app::Color fg = colorbar->getFgColor(); app::Color bg = colorbar->getBgColor(); - colorbar->setFgColor(bg); colorbar->setBgColor(fg); } diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index ef1de84..9226de1 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -437,6 +437,11 @@ public: setText("Select colors in the palette"); } + void reverseColors() { + std::reverse(m_colors.begin(), m_colors.end()); + invalidate(); + } + doc::Remap* createShadesRemap(bool left) { base::UniquePtr<doc::Remap> remap; Colors colors = getColors(); @@ -1503,4 +1508,9 @@ doc::Remap* ContextBar::createShadesRemap(bool left) return m_inkShades->createShadesRemap(left); } +void ContextBar::reverseShadesColors() +{ + m_inkShades->reverseColors(); +} + } // namespace app diff --git a/src/app/ui/context_bar.h b/src/app/ui/context_bar.h index 52ca071..0d0bda8 100644 --- a/src/app/ui/context_bar.h +++ b/src/app/ui/context_bar.h @@ -71,6 +71,7 @@ namespace app { ToolPreferences::Brush* brushPref = nullptr); doc::Remap* createShadesRemap(bool left); + void reverseShadesColors(); // Signals Signal0<void> BrushChange; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

