Fix issue 347: Eyedropper tool changes in gui.xml (pick_fg ink) not working

This commit is contained in:
David Capello 2014-02-24 08:08:34 -03:00
parent f2bdf38cc6
commit 43b2be4f0d
5 changed files with 101 additions and 26 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

48
src/app/tools/pick_ink.h Normal file
View File

@ -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

View File

@ -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<tools::PickInk*>(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, &params);
return true;