Use the real current tool preferences to draw and in the brush preview

The "real" current tool is the one in the editor returned by
getCurrentEditorTool() (which depends on quicktool modifiers
and right-click configuration).
This commit is contained in:
David Capello 2016-04-21 01:20:59 -03:00
parent 4198003446
commit c5f7e9618b
4 changed files with 12 additions and 9 deletions

View File

@ -1724,7 +1724,8 @@ void ContextBar::setActiveBrush(const doc::BrushRef& brush)
doc::BrushRef ContextBar::activeBrush(tools::Tool* tool) const
{
if (!tool ||
if ((!tool) ||
(tool == App::instance()->activeTool()) ||
(tool->getInk(0)->isPaint() &&
m_activeBrush->type() == kImageBrushType)) {
m_activeBrush->setPattern(Preferences::instance().brush.pattern());

View File

@ -53,10 +53,12 @@ BrushPreview::~BrushPreview()
{
}
// static
Brush* BrushPreview::getCurrentBrush()
BrushRef BrushPreview::getCurrentBrush()
{
return App::instance()->getMainWindow()->getContextBar()->activeBrush().get();
return App::instance()
->getMainWindow()
->getContextBar()
->activeBrush(m_editor->getCurrentEditorTool());
}
// static
@ -114,7 +116,7 @@ void BrushPreview::show(const gfx::Point& screenPos)
// Setup the cursor type depending on several factors (current tool,
// foreground color, layer transparency, brush size, etc.).
Brush* brush = getCurrentBrush();
BrushRef brush = getCurrentBrush();
color_t brush_color = getBrushColor(sprite, layer);
color_t mask_index = sprite->transparentColor();
@ -297,7 +299,7 @@ void BrushPreview::invalidateRegion(const gfx::Region& region)
void BrushPreview::generateBoundaries()
{
Brush* brush = getCurrentBrush();
BrushRef brush = getCurrentBrush();
if (m_brushBoundaries &&
m_brushGen == brush->gen())

View File

@ -11,6 +11,7 @@
#include "app/extra_cel.h"
#include "base/shared_ptr.h"
#include "doc/brush.h"
#include "doc/color.h"
#include "doc/frame.h"
#include "doc/mask_boundaries.h"
@ -22,7 +23,6 @@
#include <vector>
namespace doc {
class Brush;
class Layer;
class Sprite;
}
@ -58,7 +58,7 @@ namespace app {
private:
typedef void (BrushPreview::*PixelDelegate)(ui::Graphics*, const gfx::Point&, gfx::Color);
static doc::Brush* getCurrentBrush();
doc::BrushRef getCurrentBrush();
static doc::color_t getBrushColor(doc::Sprite* sprite, doc::Layer* layer);
void generateBoundaries();

View File

@ -97,7 +97,7 @@ public:
const app::Color& bgColor)
: m_editor(editor)
, m_tool(tool)
, m_brush(App::instance()->getMainWindow()->getContextBar()->activeBrush())
, m_brush(App::instance()->getMainWindow()->getContextBar()->activeBrush(m_tool))
, m_document(document)
, m_sprite(editor->sprite())
, m_layer(editor->layer())