From 43b2be4f0d89c95035293198b2734bfb7c9b4226 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 24 Feb 2014 08:08:34 -0300 Subject: [PATCH] Fix issue 347: Eyedropper tool changes in gui.xml (pick_fg ink) not working --- src/app/CMakeLists.txt | 1 + src/app/tools/inks.h | 26 +--------------- src/app/tools/pick_ink.cpp | 48 +++++++++++++++++++++++++++++ src/app/tools/pick_ink.h | 48 +++++++++++++++++++++++++++++ src/app/ui/editor/standby_state.cpp | 4 ++- 5 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 src/app/tools/pick_ink.cpp create mode 100644 src/app/tools/pick_ink.h diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 17531244d..4d618d4c0 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -141,6 +141,7 @@ add_library(app-library shell.cpp thumbnail_generator.cpp tools/intertwine.cpp + tools/pick_ink.cpp tools/point_shape.cpp tools/shade_table.cpp tools/tool_box.cpp diff --git a/src/app/tools/inks.h b/src/app/tools/inks.h index 7065a6274..c0242fe07 100644 --- a/src/app/tools/inks.h +++ b/src/app/tools/inks.h @@ -24,6 +24,7 @@ #include "app/document.h" #include "app/document_undo.h" #include "app/settings/settings.h" +#include "app/tools/pick_ink.h" #include "app/undoers/set_mask.h" #include "raster/mask.h" @@ -111,31 +112,6 @@ public: }; -class PickInk : public Ink { -public: - enum Target { Fg, Bg }; - -private: - Target m_target; - -public: - PickInk(Target target) : m_target(target) { } - - bool isEyedropper() const { return true; } - - void prepareInk(ToolLoop* loop) - { - // Do nothing - } - - void inkHline(int x1, int y, int x2, ToolLoop* loop) - { - // Do nothing - } - -}; - - class ScrollInk : public Ink { public: diff --git a/src/app/tools/pick_ink.cpp b/src/app/tools/pick_ink.cpp new file mode 100644 index 000000000..b663265cc --- /dev/null +++ b/src/app/tools/pick_ink.cpp @@ -0,0 +1,48 @@ +/* Aseprite + * Copyright (C) 2001-2014 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "app/tools/pick_ink.h" + +namespace app { +namespace tools { + +PickInk::PickInk(Target target) : m_target(target) +{ +} + +bool PickInk::isEyedropper() const +{ + return true; +} + +void PickInk::prepareInk(ToolLoop* loop) +{ + // Do nothing +} + +void PickInk::inkHline(int x1, int y, int x2, ToolLoop* loop) +{ + // Do nothing +} + +} // namespace tools +} // namespace app diff --git a/src/app/tools/pick_ink.h b/src/app/tools/pick_ink.h new file mode 100644 index 000000000..6d18b8f5b --- /dev/null +++ b/src/app/tools/pick_ink.h @@ -0,0 +1,48 @@ +/* Aseprite + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_PICK_INK_H_INCLUDED +#define APP_TOOLS_PICK_INK_H_INCLUDED + +#include "app/tools/ink.h" +#include "base/compiler_specific.h" + +namespace app { + namespace tools { + + class PickInk : public Ink { + public: + enum Target { Fg, Bg }; + + public: + PickInk(Target target); + + Target target() const { return m_target; } + + bool isEyedropper() const OVERRIDE; + void prepareInk(ToolLoop* loop) OVERRIDE; + void inkHline(int x1, int y, int x2, ToolLoop* loop) OVERRIDE; + + private: + Target m_target; + }; + + } // namespace tools +} // namespace app + +#endif // APP_TOOLS_PICK_INK_H_INCLUDED diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp index a21b3e33d..b47025e8f 100644 --- a/src/app/ui/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -30,6 +30,7 @@ #include "app/ini_file.h" #include "app/settings/settings.h" #include "app/tools/ink.h" +#include "app/tools/pick_ink.h" #include "app/tools/tool.h" #include "app/ui/color_bar.h" #include "app/ui/editor/drawing_state.h" @@ -226,9 +227,10 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg) if (clickedInk->isEyedropper()) { Command* eyedropper_cmd = CommandsModule::instance()->getCommandByName(CommandId::Eyedropper); + bool fg = (static_cast(clickedInk)->target() == tools::PickInk::Target::Fg); Params params; - params.set("target", msg->right() ? "background": "foreground"); + params.set("target", fg ? "foreground": "background"); UIContext::instance()->executeCommand(eyedropper_cmd, ¶ms); return true;