2013-08-09 08:01:20 +08:00
|
|
|
/* Aseprite
|
2013-01-27 23:13:13 +08:00
|
|
|
* Copyright (C) 2001-2013 David Capello
|
2012-01-06 06:45:03 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/editor/tool_loop_impl.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "app/color.h"
|
|
|
|
#include "app/color_utils.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/context.h"
|
|
|
|
#include "app/context_access.h"
|
|
|
|
#include "app/settings/document_settings.h"
|
|
|
|
#include "app/settings/settings.h"
|
|
|
|
#include "app/tools/ink.h"
|
|
|
|
#include "app/tools/shade_table.h"
|
|
|
|
#include "app/tools/shading_options.h"
|
|
|
|
#include "app/tools/tool.h"
|
|
|
|
#include "app/tools/tool_box.h"
|
|
|
|
#include "app/tools/tool_loop.h"
|
|
|
|
#include "app/ui/color_bar.h"
|
|
|
|
#include "app/ui/editor/editor.h"
|
|
|
|
#include "app/ui/status_bar.h"
|
|
|
|
#include "app/undo_transaction.h"
|
|
|
|
#include "app/util/expand_cel_canvas.h"
|
2014-06-15 02:09:43 +08:00
|
|
|
#include "raster/brush.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "raster/cel.h"
|
|
|
|
#include "raster/layer.h"
|
|
|
|
#include "raster/mask.h"
|
|
|
|
#include "raster/sprite.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
using namespace ui;
|
|
|
|
|
2013-04-03 08:02:18 +08:00
|
|
|
class ToolLoopImpl : public tools::ToolLoop,
|
2013-08-06 08:20:19 +08:00
|
|
|
public tools::ShadingOptions {
|
2012-01-06 06:45:03 +08:00
|
|
|
Editor* m_editor;
|
|
|
|
Context* m_context;
|
|
|
|
tools::Tool* m_tool;
|
2014-06-15 02:09:43 +08:00
|
|
|
Brush* m_brush;
|
2012-01-06 06:45:03 +08:00
|
|
|
Document* m_document;
|
|
|
|
Sprite* m_sprite;
|
|
|
|
Layer* m_layer;
|
2013-03-12 07:29:45 +08:00
|
|
|
FrameNumber m_frame;
|
2012-01-06 06:45:03 +08:00
|
|
|
Cel* m_cel;
|
|
|
|
bool m_filled;
|
|
|
|
bool m_previewFilled;
|
|
|
|
int m_sprayWidth;
|
|
|
|
int m_spraySpeed;
|
2012-11-18 21:21:06 +08:00
|
|
|
ISettings* m_settings;
|
|
|
|
IDocumentSettings* m_docSettings;
|
2013-04-02 07:44:59 +08:00
|
|
|
IToolSettings* m_toolSettings;
|
2012-01-06 06:45:03 +08:00
|
|
|
bool m_useMask;
|
|
|
|
Mask* m_mask;
|
|
|
|
gfx::Point m_maskOrigin;
|
|
|
|
int m_opacity;
|
|
|
|
int m_tolerance;
|
|
|
|
gfx::Point m_offset;
|
|
|
|
gfx::Point m_speed;
|
|
|
|
bool m_canceled;
|
|
|
|
tools::ToolLoop::Button m_button;
|
2013-04-02 07:44:59 +08:00
|
|
|
tools::Ink* m_ink;
|
2012-01-06 06:45:03 +08:00
|
|
|
int m_primary_color;
|
|
|
|
int m_secondary_color;
|
2014-01-26 04:58:29 +08:00
|
|
|
SelectionMode m_selectionMode;
|
2012-07-08 12:25:26 +08:00
|
|
|
UndoTransaction m_undoTransaction;
|
2012-01-06 06:45:03 +08:00
|
|
|
ExpandCelCanvas m_expandCelCanvas;
|
2013-01-21 05:40:37 +08:00
|
|
|
gfx::Region m_dirtyArea;
|
2013-11-11 02:54:36 +08:00
|
|
|
gfx::Rect m_dirtyBounds;
|
2013-04-03 08:02:18 +08:00
|
|
|
tools::ShadeTable8* m_shadeTable;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
ToolLoopImpl(Editor* editor,
|
|
|
|
Context* context,
|
|
|
|
tools::Tool* tool,
|
|
|
|
Document* document,
|
|
|
|
tools::ToolLoop::Button button,
|
2013-01-07 01:45:43 +08:00
|
|
|
const app::Color& primary_color,
|
|
|
|
const app::Color& secondary_color)
|
2012-01-06 06:45:03 +08:00
|
|
|
: m_editor(editor)
|
|
|
|
, m_context(context)
|
|
|
|
, m_tool(tool)
|
|
|
|
, m_document(document)
|
2013-03-12 07:29:45 +08:00
|
|
|
, m_sprite(editor->getSprite())
|
|
|
|
, m_layer(editor->getLayer())
|
|
|
|
, m_frame(editor->getFrame())
|
2012-01-06 06:45:03 +08:00
|
|
|
, m_canceled(false)
|
2012-11-18 21:21:06 +08:00
|
|
|
, m_settings(m_context->getSettings())
|
|
|
|
, m_docSettings(m_settings->getDocumentSettings(m_document))
|
2013-04-02 07:44:59 +08:00
|
|
|
, m_toolSettings(m_settings->getToolSettings(m_tool))
|
2012-01-06 06:45:03 +08:00
|
|
|
, m_button(button)
|
2013-04-02 07:44:59 +08:00
|
|
|
, m_ink(getInkFromType())
|
2013-03-12 07:29:45 +08:00
|
|
|
, m_primary_color(color_utils::color_for_layer(primary_color, m_layer))
|
|
|
|
, m_secondary_color(color_utils::color_for_layer(secondary_color, m_layer))
|
2014-01-26 04:58:29 +08:00
|
|
|
, m_selectionMode(m_settings->selection()->getSelectionMode())
|
2013-03-12 07:29:45 +08:00
|
|
|
, m_undoTransaction(m_context,
|
2012-07-08 12:25:26 +08:00
|
|
|
m_tool->getText().c_str(),
|
|
|
|
((getInk()->isSelection() ||
|
|
|
|
getInk()->isEyedropper() ||
|
2014-04-20 07:08:21 +08:00
|
|
|
getInk()->isScrollMovement() ||
|
|
|
|
getInk()->isZoom()) ? undo::DoesntModifyDocument:
|
|
|
|
undo::ModifyDocument))
|
2013-03-12 07:29:45 +08:00
|
|
|
, m_expandCelCanvas(m_context, m_docSettings->getTiledMode(), m_undoTransaction)
|
2013-04-03 08:02:18 +08:00
|
|
|
, m_shadeTable(NULL)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2012-11-18 21:21:06 +08:00
|
|
|
// Settings
|
2012-01-06 06:45:03 +08:00
|
|
|
switch (tool->getFill(m_button)) {
|
|
|
|
case tools::FillNone:
|
|
|
|
m_filled = false;
|
|
|
|
break;
|
|
|
|
case tools::FillAlways:
|
|
|
|
m_filled = true;
|
|
|
|
break;
|
|
|
|
case tools::FillOptional:
|
2013-04-02 07:44:59 +08:00
|
|
|
m_filled = m_toolSettings->getFilled();
|
2012-01-06 06:45:03 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-01-26 04:58:29 +08:00
|
|
|
|
|
|
|
// Right-click subtract selection always.
|
|
|
|
if (m_button == 1)
|
|
|
|
m_selectionMode = kSubtractSelectionMode;
|
|
|
|
|
2013-04-02 07:44:59 +08:00
|
|
|
m_previewFilled = m_toolSettings->getPreviewFilled();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-04-02 07:44:59 +08:00
|
|
|
m_sprayWidth = m_toolSettings->getSprayWidth();
|
|
|
|
m_spraySpeed = m_toolSettings->getSpraySpeed();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-15 02:09:43 +08:00
|
|
|
// Create the brush
|
|
|
|
IBrushSettings* brush_settings = m_toolSettings->getBrush();
|
|
|
|
ASSERT(brush_settings != NULL);
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-15 02:09:43 +08:00
|
|
|
m_brush = new Brush(
|
|
|
|
brush_settings->getType(),
|
|
|
|
brush_settings->getSize(),
|
|
|
|
brush_settings->getAngle());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
m_useMask = m_document->isMaskVisible();
|
|
|
|
|
|
|
|
// Selection ink
|
2014-01-26 04:58:29 +08:00
|
|
|
if (getInk()->isSelection() &&
|
|
|
|
(!m_document->isMaskVisible() ||
|
|
|
|
m_selectionMode == kDefaultSelectionMode)) {
|
2012-01-06 06:45:03 +08:00
|
|
|
Mask emptyMask;
|
|
|
|
m_document->setMask(&emptyMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
int x1 = m_expandCelCanvas.getCel()->getX();
|
|
|
|
int y1 = m_expandCelCanvas.getCel()->getY();
|
|
|
|
|
|
|
|
m_mask = m_document->getMask();
|
2012-01-09 09:34:36 +08:00
|
|
|
m_maskOrigin = (!m_mask->isEmpty() ? gfx::Point(m_mask->getBounds().x-x1,
|
|
|
|
m_mask->getBounds().y-y1):
|
|
|
|
gfx::Point(0, 0));
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-04-02 07:44:59 +08:00
|
|
|
m_opacity = m_toolSettings->getOpacity();
|
|
|
|
m_tolerance = m_toolSettings->getTolerance();
|
2012-01-06 06:45:03 +08:00
|
|
|
m_speed.x = 0;
|
|
|
|
m_speed.y = 0;
|
|
|
|
|
|
|
|
m_offset.x = -x1;
|
|
|
|
m_offset.y = -y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
~ToolLoopImpl()
|
|
|
|
{
|
|
|
|
if (!m_canceled) {
|
|
|
|
// Paint ink
|
|
|
|
if (getInk()->isPaint()) {
|
2013-11-11 02:54:36 +08:00
|
|
|
m_expandCelCanvas.commit(m_dirtyBounds);
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
// Selection ink
|
|
|
|
else if (getInk()->isSelection()) {
|
|
|
|
m_document->generateMaskBoundaries();
|
|
|
|
}
|
2012-07-08 12:25:26 +08:00
|
|
|
|
|
|
|
m_undoTransaction.commit();
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the trace was not canceled or it is not a 'paint' ink...
|
|
|
|
if (m_canceled || !getInk()->isPaint()) {
|
|
|
|
m_expandCelCanvas.rollback();
|
|
|
|
}
|
|
|
|
|
2014-06-15 02:09:43 +08:00
|
|
|
delete m_brush;
|
2013-04-03 08:02:18 +08:00
|
|
|
delete m_shadeTable;
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// IToolLoop interface
|
2012-11-18 21:21:06 +08:00
|
|
|
tools::Tool* getTool() OVERRIDE { return m_tool; }
|
2014-06-15 02:09:43 +08:00
|
|
|
Brush* getBrush() OVERRIDE { return m_brush; }
|
2012-11-18 21:21:06 +08:00
|
|
|
Document* getDocument() OVERRIDE { return m_document; }
|
|
|
|
Sprite* getSprite() OVERRIDE { return m_sprite; }
|
|
|
|
Layer* getLayer() OVERRIDE { return m_layer; }
|
|
|
|
Image* getSrcImage() OVERRIDE { return m_expandCelCanvas.getSourceCanvas(); }
|
|
|
|
Image* getDstImage() OVERRIDE { return m_expandCelCanvas.getDestCanvas(); }
|
2013-03-12 07:29:45 +08:00
|
|
|
RgbMap* getRgbMap() OVERRIDE { return m_sprite->getRgbMap(m_frame); }
|
2012-11-18 21:21:06 +08:00
|
|
|
bool useMask() OVERRIDE { return m_useMask; }
|
|
|
|
Mask* getMask() OVERRIDE { return m_mask; }
|
|
|
|
gfx::Point getMaskOrigin() OVERRIDE { return m_maskOrigin; }
|
|
|
|
ToolLoop::Button getMouseButton() OVERRIDE { return m_button; }
|
|
|
|
int getPrimaryColor() OVERRIDE { return m_primary_color; }
|
|
|
|
void setPrimaryColor(int color) OVERRIDE { m_primary_color = color; }
|
|
|
|
int getSecondaryColor() OVERRIDE { return m_secondary_color; }
|
|
|
|
void setSecondaryColor(int color) OVERRIDE { m_secondary_color = color; }
|
|
|
|
int getOpacity() OVERRIDE { return m_opacity; }
|
|
|
|
int getTolerance() OVERRIDE { return m_tolerance; }
|
2014-01-26 04:58:29 +08:00
|
|
|
SelectionMode getSelectionMode() OVERRIDE { return m_selectionMode; }
|
2012-11-18 21:21:06 +08:00
|
|
|
ISettings* getSettings() OVERRIDE { return m_settings; }
|
|
|
|
IDocumentSettings* getDocumentSettings() OVERRIDE { return m_docSettings; }
|
|
|
|
bool getFilled() OVERRIDE { return m_filled; }
|
|
|
|
bool getPreviewFilled() OVERRIDE { return m_previewFilled; }
|
|
|
|
int getSprayWidth() OVERRIDE { return m_sprayWidth; }
|
|
|
|
int getSpraySpeed() OVERRIDE { return m_spraySpeed; }
|
|
|
|
gfx::Point getOffset() OVERRIDE { return m_offset; }
|
|
|
|
void setSpeed(const gfx::Point& speed) OVERRIDE { m_speed = speed; }
|
|
|
|
gfx::Point getSpeed() OVERRIDE { return m_speed; }
|
2013-04-02 07:44:59 +08:00
|
|
|
tools::Ink* getInk() OVERRIDE { return m_ink; }
|
2012-11-18 21:21:06 +08:00
|
|
|
tools::Controller* getController() OVERRIDE { return m_tool->getController(m_button); }
|
|
|
|
tools::PointShape* getPointShape() OVERRIDE { return m_tool->getPointShape(m_button); }
|
|
|
|
tools::Intertwine* getIntertwine() OVERRIDE { return m_tool->getIntertwine(m_button); }
|
|
|
|
tools::TracePolicy getTracePolicy() OVERRIDE { return m_tool->getTracePolicy(m_button); }
|
2013-04-03 08:02:18 +08:00
|
|
|
tools::ShadingOptions* getShadingOptions() OVERRIDE { return this; }
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2012-11-18 21:21:06 +08:00
|
|
|
void cancel() OVERRIDE { m_canceled = true; }
|
|
|
|
bool isCanceled() OVERRIDE { return m_canceled; }
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2012-11-18 21:21:06 +08:00
|
|
|
gfx::Point screenToSprite(const gfx::Point& screenPoint) OVERRIDE
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
|
|
|
gfx::Point spritePoint;
|
|
|
|
m_editor->screenToEditor(screenPoint.x, screenPoint.y,
|
|
|
|
&spritePoint.x, &spritePoint.y);
|
|
|
|
return spritePoint;
|
|
|
|
}
|
|
|
|
|
2013-01-21 05:40:37 +08:00
|
|
|
gfx::Region& getDirtyArea() OVERRIDE
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2013-01-21 05:40:37 +08:00
|
|
|
return m_dirtyArea;
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-01-21 05:40:37 +08:00
|
|
|
void updateDirtyArea() OVERRIDE
|
|
|
|
{
|
2013-11-11 02:54:36 +08:00
|
|
|
m_dirtyBounds = m_dirtyBounds.createUnion(m_dirtyArea.getBounds());
|
2013-01-21 05:40:37 +08:00
|
|
|
m_document->notifySpritePixelsModified(m_sprite, m_dirtyArea);
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
2012-11-18 21:21:06 +08:00
|
|
|
void updateStatusBar(const char* text) OVERRIDE
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2012-07-10 00:20:58 +08:00
|
|
|
StatusBar::instance()->setStatusText(0, text);
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
2013-04-02 07:44:59 +08:00
|
|
|
|
2013-04-03 08:02:18 +08:00
|
|
|
// ShadingOptions implementation
|
|
|
|
tools::ShadeTable8* getShadeTable() OVERRIDE
|
|
|
|
{
|
|
|
|
if (m_shadeTable == NULL) {
|
|
|
|
app::ColorSwatches* colorSwatches = m_settings->getColorSwatches();
|
|
|
|
ASSERT(colorSwatches != NULL);
|
|
|
|
m_shadeTable = new tools::ShadeTable8(*colorSwatches,
|
|
|
|
tools::kRotateShadingMode);
|
|
|
|
}
|
|
|
|
return m_shadeTable;
|
|
|
|
}
|
|
|
|
|
2013-04-02 07:44:59 +08:00
|
|
|
private:
|
|
|
|
tools::Ink* getInkFromType()
|
|
|
|
{
|
|
|
|
using namespace tools;
|
|
|
|
|
|
|
|
InkType inkType = m_toolSettings->getInkType();
|
|
|
|
if (inkType == kDefaultInk)
|
|
|
|
return m_tool->getInk(m_button);
|
|
|
|
|
|
|
|
const char* id = WellKnownInks::Paint;
|
|
|
|
switch (inkType) {
|
|
|
|
case kOpaqueInk:
|
2013-05-23 11:48:24 +08:00
|
|
|
id = WellKnownInks::PaintOpaque;
|
|
|
|
break;
|
2014-05-05 09:20:33 +08:00
|
|
|
case kSetAlphaInk:
|
|
|
|
id = WellKnownInks::PaintSetAlpha;
|
2013-04-02 07:44:59 +08:00
|
|
|
break;
|
2014-05-05 09:16:30 +08:00
|
|
|
case kLockAlphaInk:
|
|
|
|
id = WellKnownInks::PaintLockAlpha;
|
|
|
|
break;
|
2013-04-02 07:44:59 +08:00
|
|
|
case kMergeInk:
|
|
|
|
id = WellKnownInks::Paint;
|
|
|
|
break;
|
|
|
|
case kShadingInk:
|
2013-04-03 08:02:18 +08:00
|
|
|
id = WellKnownInks::Shading;
|
2013-04-02 07:44:59 +08:00
|
|
|
break;
|
|
|
|
case kReplaceInk:
|
|
|
|
if (m_button == ToolLoop::Left)
|
|
|
|
id = WellKnownInks::ReplaceBgWithFg;
|
|
|
|
else
|
|
|
|
id = WellKnownInks::ReplaceFgWithBg;
|
|
|
|
break;
|
2013-04-02 07:55:29 +08:00
|
|
|
case kEraseInk:
|
|
|
|
id = WellKnownInks::Eraser;
|
|
|
|
break;
|
2013-04-02 07:44:59 +08:00
|
|
|
case kSelectionInk:
|
|
|
|
id = WellKnownInks::Selection;
|
|
|
|
break;
|
|
|
|
case kBlurInk:
|
|
|
|
id = WellKnownInks::Blur;
|
|
|
|
break;
|
|
|
|
case kJumbleInk:
|
|
|
|
id = WellKnownInks::Jumble;
|
|
|
|
break;
|
|
|
|
}
|
2013-05-23 11:48:24 +08:00
|
|
|
|
2013-04-02 07:44:59 +08:00
|
|
|
return App::instance()->getToolBox()->getInkById(id);
|
|
|
|
}
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
};
|
|
|
|
|
2013-07-29 08:17:07 +08:00
|
|
|
tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, MouseMessage* msg)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
|
|
|
tools::Tool* current_tool = context->getSettings()->getCurrentTool();
|
|
|
|
if (!current_tool)
|
|
|
|
return NULL;
|
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
Layer* layer = editor->getLayer();
|
2012-01-06 06:45:03 +08:00
|
|
|
if (!layer) {
|
|
|
|
Alert::show(PACKAGE "<<The current sprite does not have any layer.||&Close");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the active layer is not visible.
|
2013-01-11 23:43:25 +08:00
|
|
|
if (!layer->isReadable()) {
|
2012-01-06 06:45:03 +08:00
|
|
|
Alert::show(PACKAGE
|
|
|
|
"<<The current layer is hidden,"
|
|
|
|
"<<make it visible and try again"
|
|
|
|
"||&Close");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// If the active layer is read-only.
|
2013-01-11 23:43:25 +08:00
|
|
|
else if (!layer->isWritable()) {
|
2012-01-06 06:45:03 +08:00
|
|
|
Alert::show(PACKAGE
|
|
|
|
"<<The current layer is locked,"
|
|
|
|
"<<unlock it and try again"
|
|
|
|
"||&Close");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get fg/bg colors
|
2012-07-10 00:20:58 +08:00
|
|
|
ColorBar* colorbar = ColorBar::instance();
|
2013-01-07 01:45:43 +08:00
|
|
|
app::Color fg = colorbar->getFgColor();
|
|
|
|
app::Color bg = colorbar->getBgColor();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
if (!fg.isValid() || !bg.isValid()) {
|
|
|
|
Alert::show(PACKAGE
|
|
|
|
"<<The current selected foreground and/or background color"
|
|
|
|
"<<is out of range. Select valid colors in the color-bar."
|
|
|
|
"||&Close");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the new tool loop
|
2013-11-11 03:20:20 +08:00
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ToolLoopImpl(editor,
|
|
|
|
context,
|
|
|
|
current_tool,
|
|
|
|
editor->getDocument(),
|
|
|
|
msg->left() ? tools::ToolLoop::Left:
|
|
|
|
tools::ToolLoop::Right,
|
|
|
|
msg->left() ? fg: bg,
|
|
|
|
msg->left() ? bg: fg);
|
|
|
|
}
|
|
|
|
catch (const std::exception& ex)
|
|
|
|
{
|
|
|
|
Alert::show(PACKAGE
|
|
|
|
"<<Error drawing ink:"
|
|
|
|
"<<%s"
|
|
|
|
"||&Close",
|
|
|
|
ex.what());
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|