diff --git a/data/gui.xml b/data/gui.xml index c19364f8f..1ab622030 100644 --- a/data/gui.xml +++ b/data/gui.xml @@ -113,17 +113,17 @@ - - + + - + - + - + @@ -546,7 +546,7 @@ text="Pencil Tool" ink="paint" controller="freehand" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="accumulative" /> @@ -565,10 +565,10 @@ ink_left="eraser" ink_right="replace_fg_with_bg" controller="freehand" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="accumulative" - default_pen_size="8"> + default_brush_size="8"> * Left-button: Erase with the background color in `Background' layer or transparent color in any other layer. * @@ -617,7 +617,7 @@ text="Line Tool" ink="paint" controller="two_points" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="last" /> @@ -625,7 +625,7 @@ text="Curve Tool" ink="paint" controller="four_points" - pointshape="pen" + pointshape="brush" intertwine="as_bezier" tracepolicy="last" /> @@ -637,7 +637,7 @@ fill="optional" ink="paint" controller="two_points" - pointshape="pen" + pointshape="brush" intertwine="as_rectangles" tracepolicy="last" /> @@ -646,7 +646,7 @@ fill="always" ink="paint" controller="two_points" - pointshape="pen" + pointshape="brush" intertwine="as_rectangles" tracepolicy="last" /> @@ -655,7 +655,7 @@ fill="optional" ink="paint" controller="two_points" - pointshape="pen" + pointshape="brush" intertwine="as_ellipses" tracepolicy="last" /> @@ -664,7 +664,7 @@ fill="always" ink="paint" controller="two_points" - pointshape="pen" + pointshape="brush" intertwine="as_ellipses" tracepolicy="last" /> @@ -676,7 +676,7 @@ fill="always" ink="paint" controller="freehand" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="accumulative" /> @@ -685,7 +685,7 @@ fill="always" ink="paint" controller="point_by_point" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="last" /> @@ -696,19 +696,19 @@ text="Blur Tool" ink="blur" controller="freehand" - pointshape="pen" + pointshape="brush" intertwine="as_lines" tracepolicy="overlap" - default_pen_size="16" + default_brush_size="16" /> diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 787d9c4fe..33aa0a89b 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -17,8 +17,8 @@ add_library(app-lib commands/cmd_cancel.cpp commands/cmd_canvas_size.cpp commands/cmd_cel_properties.cpp + commands/cmd_change_brush.cpp commands/cmd_change_color.cpp - commands/cmd_change_pen.cpp commands/cmd_change_pixel_format.cpp commands/cmd_clear.cpp commands/cmd_close_file.cpp diff --git a/src/app/app.h b/src/app/app.h index af93b56a0..42a9afe69 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -76,10 +76,10 @@ namespace app { // App Signals Signal0 Exit; Signal0 PaletteChange; - Signal0 PenSizeBeforeChange; - Signal0 PenSizeAfterChange; - Signal0 PenAngleBeforeChange; - Signal0 PenAngleAfterChange; + Signal0 BrushSizeBeforeChange; + Signal0 BrushSizeAfterChange; + Signal0 BrushAngleBeforeChange; + Signal0 BrushAngleAfterChange; Signal0 CurrentToolChange; private: diff --git a/src/app/commands/cmd_change_pen.cpp b/src/app/commands/cmd_change_brush.cpp similarity index 73% rename from src/app/commands/cmd_change_pen.cpp rename to src/app/commands/cmd_change_brush.cpp index 9fb7ce6b0..2ee899690 100644 --- a/src/app/commands/cmd_change_pen.cpp +++ b/src/app/commands/cmd_change_brush.cpp @@ -31,7 +31,7 @@ namespace app { -class ChangePenCommand : public Command { +class ChangeBrushCommand : public Command { enum Change { None, IncrementSize, @@ -43,22 +43,22 @@ class ChangePenCommand : public Command { Change m_change; public: - ChangePenCommand(); + ChangeBrushCommand(); protected: void onLoadParams(Params* params); void onExecute(Context* context); }; -ChangePenCommand::ChangePenCommand() - : Command("ChangePen", - "Change Pen", +ChangeBrushCommand::ChangeBrushCommand() + : Command("ChangeBrush", + "Change Brush", CmdUIOnlyFlag) { m_change = None; } -void ChangePenCommand::onLoadParams(Params* params) +void ChangeBrushCommand::onLoadParams(Params* params) { std::string change = params->get("change"); if (change == "increment-size") m_change = IncrementSize; @@ -67,38 +67,38 @@ void ChangePenCommand::onLoadParams(Params* params) else if (change == "decrement-angle") m_change = DecrementAngle; } -void ChangePenCommand::onExecute(Context* context) +void ChangeBrushCommand::onExecute(Context* context) { tools::Tool* current_tool = context->getSettings()->getCurrentTool(); IToolSettings* tool_settings = context->getSettings()->getToolSettings(current_tool); - IPenSettings* pen = tool_settings->getPen(); + IBrushSettings* brush = tool_settings->getBrush(); switch (m_change) { case None: // Do nothing break; case IncrementSize: - if (pen->getSize() < 32) - pen->setSize(pen->getSize()+1); + if (brush->getSize() < 32) + brush->setSize(brush->getSize()+1); break; case DecrementSize: - if (pen->getSize() > 1) - pen->setSize(pen->getSize()-1); + if (brush->getSize() > 1) + brush->setSize(brush->getSize()-1); break; case IncrementAngle: - if (pen->getAngle() < 180) - pen->setAngle(pen->getAngle()+1); + if (brush->getAngle() < 180) + brush->setAngle(brush->getAngle()+1); break; case DecrementAngle: - if (pen->getAngle() > 0) - pen->setAngle(pen->getAngle()-1); + if (brush->getAngle() > 0) + brush->setAngle(brush->getAngle()-1); break; } } -Command* CommandFactory::createChangePenCommand() +Command* CommandFactory::createChangeBrushCommand() { - return new ChangePenCommand; + return new ChangeBrushCommand; } } // namespace app diff --git a/src/app/commands/commands_list.h b/src/app/commands/commands_list.h index e5b5904a6..b01a62dac 100644 --- a/src/app/commands/commands_list.h +++ b/src/app/commands/commands_list.h @@ -23,8 +23,8 @@ FOR_EACH_COMMAND(BackgroundFromLayer) FOR_EACH_COMMAND(Cancel) FOR_EACH_COMMAND(CanvasSize) FOR_EACH_COMMAND(CelProperties) +FOR_EACH_COMMAND(ChangeBrush) FOR_EACH_COMMAND(ChangeColor) -FOR_EACH_COMMAND(ChangePen) FOR_EACH_COMMAND(ChangePixelFormat) FOR_EACH_COMMAND(Clear) FOR_EACH_COMMAND(CloseAllFiles) diff --git a/src/app/settings/settings.h b/src/app/settings/settings.h index d2e0e8180..ede6e94ad 100644 --- a/src/app/settings/settings.h +++ b/src/app/settings/settings.h @@ -27,7 +27,7 @@ #include "app/settings/selection_mode.h" #include "gfx/point.h" #include "gfx/rect.h" -#include "raster/pen_type.h" +#include "raster/brush_type.h" namespace app { @@ -35,8 +35,8 @@ namespace app { class Document; class IColorSwatchesStore; class IDocumentSettings; - class IPenSettings; - class PenSettingsObserver; + class IBrushSettings; + class BrushSettingsObserver; class IToolSettings; class ToolSettingsObserver; class ISelectionSettings; @@ -88,7 +88,7 @@ namespace app { public: virtual ~IToolSettings() { } - virtual IPenSettings* getPen() = 0; + virtual IBrushSettings* getBrush() = 0; virtual int getOpacity() = 0; virtual int getTolerance() = 0; @@ -112,21 +112,21 @@ namespace app { virtual void removeObserver(ToolSettingsObserver* observer) = 0; }; - // Settings for a tool's pen - class IPenSettings { + // Settings for a tool's brush + class IBrushSettings { public: - virtual ~IPenSettings() { } + virtual ~IBrushSettings() { } - virtual raster::PenType getType() = 0; + virtual raster::BrushType getType() = 0; virtual int getSize() = 0; virtual int getAngle() = 0; - virtual void setType(PenType type) = 0; + virtual void setType(BrushType type) = 0; virtual void setSize(int size) = 0; virtual void setAngle(int angle) = 0; - virtual void addObserver(PenSettingsObserver* observer) = 0; - virtual void removeObserver(PenSettingsObserver* observer) = 0; + virtual void addObserver(BrushSettingsObserver* observer) = 0; + virtual void removeObserver(BrushSettingsObserver* observer) = 0; }; class ISelectionSettings { diff --git a/src/app/settings/settings_observers.h b/src/app/settings/settings_observers.h index e0f75ac8d..c8c3f2ab0 100644 --- a/src/app/settings/settings_observers.h +++ b/src/app/settings/settings_observers.h @@ -27,7 +27,7 @@ #include "app/settings/selection_mode.h" #include "filters/tiled_mode.h" #include "gfx/fwd.h" -#include "raster/pen_type.h" +#include "raster/brush_type.h" namespace app { class Color; @@ -37,13 +37,13 @@ namespace app { } class ColorSwatches; - class PenSettingsObserver { + class BrushSettingsObserver { public: - virtual ~PenSettingsObserver() {} + virtual ~BrushSettingsObserver() {} - virtual void onSetPenSize(int newSize) {} - virtual void onSetPenType(raster::PenType newType) {} - virtual void onSetPenAngle(int newAngle) {} + virtual void onSetBrushSize(int newSize) {} + virtual void onSetBrushType(raster::BrushType newType) {} + virtual void onSetBrushAngle(int newAngle) {} }; class ToolSettingsObserver { diff --git a/src/app/settings/ui_settings_impl.cpp b/src/app/settings/ui_settings_impl.cpp index bb17a3f2e..02f8adf05 100644 --- a/src/app/settings/ui_settings_impl.cpp +++ b/src/app/settings/ui_settings_impl.cpp @@ -304,16 +304,16 @@ void UISettingsImpl::setBgColor(const app::Color& color) void UISettingsImpl::setCurrentTool(tools::Tool* tool) { if (m_currentTool != tool) { - // Fire signals (maybe the new selected tool has a different pen size) - App::instance()->PenSizeBeforeChange(); - App::instance()->PenAngleBeforeChange(); + // Fire signals (maybe the new selected tool has a different brush size) + App::instance()->BrushSizeBeforeChange(); + App::instance()->BrushAngleBeforeChange(); // Change the tool m_currentTool = tool; App::instance()->CurrentToolChange(); // Fire CurrentToolChange signal - App::instance()->PenSizeAfterChange(); // Fire PenSizeAfterChange signal - App::instance()->PenAngleAfterChange(); // Fire PenAngleAfterChange signal + App::instance()->BrushSizeAfterChange(); // Fire BrushSizeAfterChange signal + App::instance()->BrushAngleAfterChange(); // Fire BrushAngleAfterChange signal } } @@ -579,66 +579,66 @@ void UIDocumentSettingsImpl::removeObserver(DocumentSettingsObserver* observer) } ////////////////////////////////////////////////////////////////////// -// Tools & pen settings +// Tools & brush settings -class UIPenSettingsImpl - : public IPenSettings - , public base::Observable { +class UIBrushSettingsImpl + : public IBrushSettings + , public base::Observable { private: - PenType m_type; + BrushType m_type; int m_size; int m_angle; bool m_fireSignals; public: - UIPenSettingsImpl() + UIBrushSettingsImpl() { - m_type = PEN_TYPE_FIRST; + m_type = kFirstBrushType; m_size = 1; m_angle = 0; m_fireSignals = true; } - ~UIPenSettingsImpl() + ~UIBrushSettingsImpl() { } - PenType getType() { return m_type; } + BrushType getType() { return m_type; } int getSize() { return m_size; } int getAngle() { return m_angle; } - void setType(PenType type) + void setType(BrushType type) { - m_type = MID(PEN_TYPE_FIRST, type, PEN_TYPE_LAST); - notifyObservers(&PenSettingsObserver::onSetPenType, m_type); + m_type = MID(kFirstBrushType, type, kLastBrushType); + notifyObservers(&BrushSettingsObserver::onSetBrushType, m_type); } void setSize(int size) { - // Trigger PenSizeBeforeChange signal + // Trigger BrushSizeBeforeChange signal if (m_fireSignals) - App::instance()->PenSizeBeforeChange(); + App::instance()->BrushSizeBeforeChange(); - // Change the size of the pencil + // Change the size of the brushcil m_size = MID(1, size, 32); - // Trigger PenSizeAfterChange signal + // Trigger BrushSizeAfterChange signal if (m_fireSignals) - App::instance()->PenSizeAfterChange(); - notifyObservers(&PenSettingsObserver::onSetPenSize, m_size); + App::instance()->BrushSizeAfterChange(); + notifyObservers(&BrushSettingsObserver::onSetBrushSize, m_size); } void setAngle(int angle) { - // Trigger PenAngleBeforeChange signal + // Trigger BrushAngleBeforeChange signal if (m_fireSignals) - App::instance()->PenAngleBeforeChange(); + App::instance()->BrushAngleBeforeChange(); m_angle = MID(0, angle, 360); - // Trigger PenAngleAfterChange signal + // Trigger BrushAngleAfterChange signal if (m_fireSignals) - App::instance()->PenAngleAfterChange(); + App::instance()->BrushAngleAfterChange(); } void enableSignals(bool state) @@ -646,12 +646,12 @@ public: m_fireSignals = state; } - void addObserver(PenSettingsObserver* observer) OVERRIDE{ - base::Observable::addObserver(observer); + void addObserver(BrushSettingsObserver* observer) OVERRIDE{ + base::Observable::addObserver(observer); } - void removeObserver(PenSettingsObserver* observer) OVERRIDE{ - base::Observable::removeObserver(observer); + void removeObserver(BrushSettingsObserver* observer) OVERRIDE{ + base::Observable::removeObserver(observer); } }; @@ -659,7 +659,7 @@ class UIToolSettingsImpl : public IToolSettings , base::Observable { tools::Tool* m_tool; - UIPenSettingsImpl m_pen; + UIBrushSettingsImpl m_brush; int m_opacity; int m_tolerance; bool m_filled; @@ -693,11 +693,11 @@ public: m_inkType != kLockAlphaInk) m_inkType = kDefaultInk; - m_pen.enableSignals(false); - m_pen.setType((PenType)get_config_int(cfg_section.c_str(), "PenType", (int)PEN_TYPE_CIRCLE)); - m_pen.setSize(get_config_int(cfg_section.c_str(), "PenSize", m_tool->getDefaultPenSize())); - m_pen.setAngle(get_config_int(cfg_section.c_str(), "PenAngle", 0)); - m_pen.enableSignals(true); + m_brush.enableSignals(false); + m_brush.setType((BrushType)get_config_int(cfg_section.c_str(), "BrushType", (int)kCircleBrushType)); + m_brush.setSize(get_config_int(cfg_section.c_str(), "BrushSize", m_tool->getDefaultBrushSize())); + m_brush.setAngle(get_config_int(cfg_section.c_str(), "BrushAngle", 0)); + m_brush.enableSignals(true); if (m_tool->getPointShape(0)->isSpray() || m_tool->getPointShape(1)->isSpray()) { @@ -718,10 +718,10 @@ public: set_config_int(cfg_section.c_str(), "Opacity", m_opacity); set_config_int(cfg_section.c_str(), "Tolerance", m_tolerance); - set_config_int(cfg_section.c_str(), "PenType", m_pen.getType()); - set_config_int(cfg_section.c_str(), "PenSize", m_pen.getSize()); - set_config_int(cfg_section.c_str(), "PenAngle", m_pen.getAngle()); - set_config_int(cfg_section.c_str(), "PenAngle", m_pen.getAngle()); + set_config_int(cfg_section.c_str(), "BrushType", m_brush.getType()); + set_config_int(cfg_section.c_str(), "BrushSize", m_brush.getSize()); + set_config_int(cfg_section.c_str(), "BrushAngle", m_brush.getAngle()); + set_config_int(cfg_section.c_str(), "BrushAngle", m_brush.getAngle()); set_config_int(cfg_section.c_str(), "InkType", m_inkType); set_config_bool(cfg_section.c_str(), "PreviewFilled", m_previewFilled); @@ -737,7 +737,7 @@ public: } } - IPenSettings* getPen() { return &m_pen; } + IBrushSettings* getBrush() { return &m_brush; } int getOpacity() OVERRIDE { return m_opacity; } int getTolerance() OVERRIDE { return m_tolerance; } diff --git a/src/app/tools/point_shapes.h b/src/app/tools/point_shapes.h index 91174a246..3a5762147 100644 --- a/src/app/tools/point_shapes.h +++ b/src/app/tools/point_shapes.h @@ -43,16 +43,16 @@ public: } }; -class PenPointShape : public PointShape { +class BrushPointShape : public PointShape { public: void transformPoint(ToolLoop* loop, int x, int y) { - Pen* pen = loop->getPen(); - std::vector::const_iterator scanline = pen->get_scanline().begin(); - register int v, h = pen->getBounds().h; + Brush* brush = loop->getBrush(); + std::vector::const_iterator scanline = brush->get_scanline().begin(); + register int v, h = brush->getBounds().h; - x += pen->getBounds().x; - y += pen->getBounds().y; + x += brush->getBounds().x; + y += brush->getBounds().y; for (v=0; vstate) @@ -62,8 +62,8 @@ public: } void getModifiedArea(ToolLoop* loop, int x, int y, Rect& area) { - Pen* pen = loop->getPen(); - area = pen->getBounds(); + Brush* brush = loop->getBrush(); + area = brush->getBounds(); area.x += x; area.y += y; } @@ -84,7 +84,7 @@ public: }; class SprayPointShape : public PointShape { - PenPointShape m_subPointShape; + BrushPointShape m_subPointShape; public: diff --git a/src/app/tools/tool.h b/src/app/tools/tool.h index b8b006645..34a1c4006 100644 --- a/src/app/tools/tool.h +++ b/src/app/tools/tool.h @@ -42,12 +42,12 @@ namespace app { const std::string& id, const std::string& text, const std::string& tips, - int default_pen_size) + int default_brush_size) : m_group(group) , m_id(id) , m_text(text) , m_tips(tips) - , m_default_pen_size(default_pen_size) + , m_default_brush_size(default_brush_size) { } virtual ~Tool() @@ -57,7 +57,7 @@ namespace app { const std::string& getId() const { return m_id; } const std::string& getText() const { return m_text; } const std::string& getTips() const { return m_tips; } - int getDefaultPenSize() const { return m_default_pen_size; } + int getDefaultBrushSize() const { return m_default_brush_size; } Fill getFill(int button) { return m_button[button].m_fill; } Ink* getInk(int button) { return m_button[button].m_ink; } @@ -78,7 +78,7 @@ namespace app { std::string m_id; std::string m_text; std::string m_tips; - int m_default_pen_size; + int m_default_brush_size; struct { Fill m_fill; diff --git a/src/app/tools/tool_box.cpp b/src/app/tools/tool_box.cpp index b9424650d..92be6334f 100644 --- a/src/app/tools/tool_box.cpp +++ b/src/app/tools/tool_box.cpp @@ -31,9 +31,9 @@ #include "app/tools/tool_loop.h" #include "base/exception.h" #include "raster/algo.h" +#include "raster/brush.h" #include "raster/image.h" #include "raster/mask.h" -#include "raster/pen.h" #include #include @@ -109,7 +109,7 @@ ToolBox::ToolBox() m_pointshapers["none"] = new NonePointShape(); m_pointshapers["pixel"] = new PixelPointShape(); - m_pointshapers["pen"] = new PenPointShape(); + m_pointshapers["brush"] = new BrushPointShape(); m_pointshapers["floodfill"] = new FloodFillPointShape(); m_pointshapers["spray"] = new SprayPointShape(); @@ -196,10 +196,10 @@ void ToolBox::loadTools() const char* tool_id = xmlTool->Attribute("id"); const char* tool_text = xmlTool->Attribute("text"); const char* tool_tips = xmlTool->FirstChild("tooltip") ? ((TiXmlElement*)xmlTool->FirstChild("tooltip"))->GetText(): ""; - const char* default_pen_size = xmlTool->Attribute("default_pen_size"); + const char* default_brush_size = xmlTool->Attribute("default_brush_size"); Tool* tool = new Tool(tool_group, tool_id, tool_text, tool_tips, - default_pen_size ? strtol(default_pen_size, NULL, 10): 1); + default_brush_size ? strtol(default_brush_size, NULL, 10): 1); PRINTF(" - New tool '%s' in group '%s' found\n", tool_id, group_id); diff --git a/src/app/tools/tool_loop.h b/src/app/tools/tool_loop.h index 5e66ca980..e14dacdfa 100644 --- a/src/app/tools/tool_loop.h +++ b/src/app/tools/tool_loop.h @@ -33,7 +33,7 @@ namespace raster { class Image; class Layer; class Mask; - class Pen; + class Brush; class RgbMap; class Sprite; } @@ -70,8 +70,8 @@ namespace app { // Returns the tool to use to draw or use virtual Tool* getTool() = 0; - // Returns the pen which will be used with the tool - virtual Pen* getPen() = 0; + // Returns the brush which will be used with the tool + virtual Brush* getBrush() = 0; // Returns the document to which belongs the sprite. virtual Document* getDocument() = 0; diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index d80431fc8..82f41ab7e 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -39,10 +39,10 @@ #include "app/ui_context.h" #include "base/bind.h" #include "base/unique_ptr.h" +#include "raster/brush.h" #include "raster/conversion_alleg.h" #include "raster/image.h" #include "raster/palette.h" -#include "raster/pen.h" #include "ui/button.h" #include "ui/combobox.h" #include "ui/int_entry.h" @@ -69,7 +69,7 @@ public: BrushTypeField() : Button("") , m_popupWindow(NULL) - , m_brushType(NULL) { + , m_brushTypeButton(NULL) { setup_mini_look(this); setIconInterface(this); @@ -83,15 +83,18 @@ public: destroy_bitmap(m_bitmap); } - void setPenSettings(IPenSettings* penSettings) { + void setBrushSettings(IBrushSettings* brushSettings) { base::UniquePtr palette(new Palette(FrameNumber(0), 2)); palette->setEntry(0, raster::rgba(0, 0, 0, 0)); palette->setEntry(1, raster::rgba(0, 0, 0, 255)); - base::UniquePtr pen(new Pen(m_penType = penSettings->getType(), - std::min(10, penSettings->getSize()), - penSettings->getAngle())); - Image* image = pen->get_image(); + base::UniquePtr brush( + new Brush( + m_brushType = brushSettings->getType(), + std::min(10, brushSettings->getSize()), + brushSettings->getAngle())); + + Image* image = brush->get_image(); if (m_bitmap) destroy_bitmap(m_bitmap); @@ -161,15 +164,15 @@ private: Region rgn(m_popupWindow->getBounds().createUnion(getBounds())); m_popupWindow->setHotRegion(rgn); - m_brushType = new ButtonSet(3, 1, m_penType, + m_brushTypeButton = new ButtonSet(3, 1, m_brushType, PART_BRUSH_CIRCLE, PART_BRUSH_SQUARE, PART_BRUSH_LINE); - m_brushType->ItemChange.connect(&BrushTypeField::onBrushTypeChange, this); - m_brushType->setTransparent(true); - m_brushType->setBgColor(ui::ColorNone); + m_brushTypeButton->ItemChange.connect(&BrushTypeField::onBrushTypeChange, this); + m_brushTypeButton->setTransparent(true); + m_brushTypeButton->setBgColor(ui::ColorNone); - m_popupWindow->addChild(m_brushType); + m_popupWindow->addChild(m_brushTypeButton); m_popupWindow->openWindow(); } @@ -178,25 +181,25 @@ private: m_popupWindow->closeWindow(NULL); delete m_popupWindow; m_popupWindow = NULL; - m_brushType = NULL; + m_brushTypeButton = NULL; } } void onBrushTypeChange() { - m_penType = (PenType)m_brushType->getSelectedItem(); + m_brushType = (BrushType)m_brushTypeButton->getSelectedItem(); ISettings* settings = UIContext::instance()->getSettings(); Tool* currentTool = settings->getCurrentTool(); - IPenSettings* penSettings = settings->getToolSettings(currentTool)->getPen(); - penSettings->setType(m_penType); + IBrushSettings* brushSettings = settings->getToolSettings(currentTool)->getBrush(); + brushSettings->setType(m_brushType); - setPenSettings(penSettings); + setBrushSettings(brushSettings); } BITMAP* m_bitmap; - PenType m_penType; + BrushType m_brushType; PopupWindow* m_popupWindow; - ButtonSet* m_brushType; + ButtonSet* m_brushTypeButton; }; class ContextBar::BrushSizeField : public IntEntry @@ -213,7 +216,7 @@ private: ISettings* settings = UIContext::instance()->getSettings(); Tool* currentTool = settings->getCurrentTool(); settings->getToolSettings(currentTool) - ->getPen() + ->getBrush() ->setSize(getValue()); } }; @@ -234,12 +237,12 @@ protected: ISettings* settings = UIContext::instance()->getSettings(); Tool* currentTool = settings->getCurrentTool(); settings->getToolSettings(currentTool) - ->getPen() + ->getBrush() ->setAngle(getValue()); IToolSettings* toolSettings = settings->getToolSettings(currentTool); - IPenSettings* penSettings = toolSettings->getPen(); - m_brushType->setPenSettings(penSettings); + IBrushSettings* brushSettings = toolSettings->getBrush(); + m_brushType->setBrushSettings(brushSettings); } private: @@ -595,8 +598,8 @@ ContextBar::ContextBar() m_selectionMode->setupTooltips(tooltipManager); m_dropPixels->setupTooltips(tooltipManager); - App::instance()->PenSizeAfterChange.connect(&ContextBar::onPenSizeChange, this); - App::instance()->PenAngleAfterChange.connect(&ContextBar::onPenAngleChange, this); + App::instance()->BrushSizeAfterChange.connect(&ContextBar::onBrushSizeChange, this); + App::instance()->BrushAngleAfterChange.connect(&ContextBar::onBrushAngleChange, this); App::instance()->CurrentToolChange.connect(&ContextBar::onCurrentToolChange, this); m_dropPixels->DropPixels.connect(&ContextBar::onDropPixels, this); @@ -624,26 +627,26 @@ void ContextBar::onSetOpacity(int newOpacity) m_inkOpacity->setTextf("%d", newOpacity); } -void ContextBar::onPenSizeChange() +void ContextBar::onBrushSizeChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* currentTool = settings->getCurrentTool(); IToolSettings* toolSettings = settings->getToolSettings(currentTool); - IPenSettings* penSettings = toolSettings->getPen(); + IBrushSettings* brushSettings = toolSettings->getBrush(); - m_brushType->setPenSettings(penSettings); - m_brushSize->setTextf("%d", penSettings->getSize()); + m_brushType->setBrushSettings(brushSettings); + m_brushSize->setTextf("%d", brushSettings->getSize()); } -void ContextBar::onPenAngleChange() +void ContextBar::onBrushAngleChange() { ISettings* settings = UIContext::instance()->getSettings(); Tool* currentTool = settings->getCurrentTool(); IToolSettings* toolSettings = settings->getToolSettings(currentTool); - IPenSettings* penSettings = toolSettings->getPen(); + IBrushSettings* brushSettings = toolSettings->getBrush(); - m_brushType->setPenSettings(penSettings); - m_brushAngle->setTextf("%d", penSettings->getAngle()); + m_brushType->setBrushSettings(brushSettings); + m_brushAngle->setTextf("%d", brushSettings->getAngle()); } void ContextBar::onCurrentToolChange() @@ -661,16 +664,16 @@ void ContextBar::updateFromTool(tools::Tool* tool) { ISettings* settings = UIContext::instance()->getSettings(); IToolSettings* toolSettings = settings->getToolSettings(tool); - IPenSettings* penSettings = toolSettings->getPen(); + IBrushSettings* brushSettings = toolSettings->getBrush(); if (m_toolSettings) m_toolSettings->removeObserver(this); m_toolSettings = toolSettings; m_toolSettings->addObserver(this); - m_brushType->setPenSettings(penSettings); - m_brushSize->setTextf("%d", penSettings->getSize()); - m_brushAngle->setTextf("%d", penSettings->getAngle()); + m_brushType->setBrushSettings(brushSettings); + m_brushSize->setTextf("%d", brushSettings->getSize()); + m_brushAngle->setTextf("%d", brushSettings->getAngle()); m_tolerance->setTextf("%d", toolSettings->getTolerance()); diff --git a/src/app/ui/context_bar.h b/src/app/ui/context_bar.h index aea1b19e3..8bfc58cec 100644 --- a/src/app/ui/context_bar.h +++ b/src/app/ui/context_bar.h @@ -57,8 +57,8 @@ namespace app { void onSetOpacity(int newOpacity) OVERRIDE; private: - void onPenSizeChange(); - void onPenAngleChange(); + void onBrushSizeChange(); + void onBrushAngleChange(); void onCurrentToolChange(); void onDropPixels(ContextBarObserver::DropAction action); diff --git a/src/app/ui/editor/cursor.cpp b/src/app/ui/editor/cursor.cpp index 9e1bc1a2b..1d4f96d14 100644 --- a/src/app/ui/editor/cursor.cpp +++ b/src/app/ui/editor/cursor.cpp @@ -32,9 +32,9 @@ #include "app/ui_context.h" #include "app/util/boundary.h" #include "base/memory.h" +#include "raster/brush.h" #include "raster/image.h" #include "raster/layer.h" -#include "raster/pen.h" #include "raster/primitives.h" #include "raster/sprite.h" #include "ui/base.h" @@ -68,20 +68,20 @@ using namespace ui; #define MAX_SAVED 4096 static struct { - int pen_type; - int pen_size; - int pen_angle; + int brush_type; + int brush_size; + int brush_angle; int nseg; BoundSeg *seg; } cursor_bound = { 0, 0, 0, 0, NULL }; enum { - CURSOR_PENCIL = 1, // New cursor style (with preview) + CURSOR_BRUSH = 1, // New cursor style (with preview) CURSOR_CROSS_ONE = 2, // Old cursor style (deprecated) CURSOR_BOUNDS = 4 // Old cursor boundaries (deprecated) }; -static int cursor_type = CURSOR_PENCIL; +static int cursor_type = CURSOR_BRUSH; static int cursor_negative; static int saved_pixel[MAX_SAVED]; @@ -94,7 +94,7 @@ static gfx::Region old_clipping_region; static void generate_cursor_boundaries(); -static void editor_cursor_pencil(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color)); +static void editor_cursor_brush(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color)); static void editor_cursor_cross(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color)); static void editor_cursor_bounds(Editor *editor, int x, int y, int color, void (*pixel)(BITMAP *bmp, int x, int y, int color)); @@ -102,7 +102,7 @@ static void savepixel(BITMAP *bmp, int x, int y, int color); static void drawpixel(BITMAP *bmp, int x, int y, int color); static void cleanpixel(BITMAP *bmp, int x, int y, int color); -static color_t get_pen_color(Sprite* sprite, Layer* layer); +static color_t get_brush_color(Sprite* sprite, Layer* layer); ////////////////////////////////////////////////////////////////////// // CURSOR COLOR @@ -147,57 +147,58 @@ void Editor::set_cursor_color(const app::Color& color) // Slots for App signals ////////////////////////////////////////////////////////////////////// -static int pen_size_thick = 0; -static Pen* current_pen = NULL; +static int brush_size_thick = 0; +static Brush* current_brush = NULL; static void on_palette_change_update_cursor_color() { update_cursor_color(); } -static void on_pen_before_change() +static void on_brush_before_change() { if (current_editor != NULL) { - pen_size_thick = current_editor->getCursorThick(); - if (pen_size_thick) + brush_size_thick = current_editor->getCursorThick(); + if (brush_size_thick) current_editor->hideDrawingCursor(); } } -static void on_pen_after_change() +static void on_brush_after_change() { if (current_editor != NULL) { // Show drawing cursor - if (current_editor->getSprite() && pen_size_thick > 0) + if (current_editor->getSprite() && brush_size_thick > 0) current_editor->showDrawingCursor(); } } -static Pen* editor_get_current_pen() +static Brush* editor_get_current_brush() { - // Create the current pen from settings + // Create the current brush from settings tools::Tool* current_tool = UIContext::instance() ->getSettings() ->getCurrentTool(); - IPenSettings* pen_settings = UIContext::instance() + IBrushSettings* brush_settings = UIContext::instance() ->getSettings() ->getToolSettings(current_tool) - ->getPen(); + ->getBrush(); - ASSERT(pen_settings != NULL); + ASSERT(brush_settings != NULL); - if (!current_pen || - current_pen->get_type() != pen_settings->getType() || - current_pen->get_size() != pen_settings->getSize() || - current_pen->get_angle() != pen_settings->getAngle()) { - delete current_pen; - current_pen = new Pen(pen_settings->getType(), - pen_settings->getSize(), - pen_settings->getAngle()); + if (!current_brush || + current_brush->get_type() != brush_settings->getType() || + current_brush->get_size() != brush_settings->getSize() || + current_brush->get_angle() != brush_settings->getAngle()) { + delete current_brush; + current_brush = new Brush( + brush_settings->getType(), + brush_settings->getSize(), + brush_settings->getAngle()); } - return current_pen; + return current_brush; } ////////////////////////////////////////////////////////////////////// @@ -210,10 +211,10 @@ void Editor::editor_cursor_init() set_cursor_color(get_config_color("Tools", "CursorColor", app::Color::fromMask())); App::instance()->PaletteChange.connect(&on_palette_change_update_cursor_color); - App::instance()->PenSizeBeforeChange.connect(&on_pen_before_change); - App::instance()->PenSizeAfterChange.connect(&on_pen_after_change); - App::instance()->PenAngleBeforeChange.connect(&on_pen_before_change); - App::instance()->PenAngleAfterChange.connect(&on_pen_after_change); + App::instance()->BrushSizeBeforeChange.connect(&on_brush_before_change); + App::instance()->BrushSizeAfterChange.connect(&on_brush_after_change); + App::instance()->BrushAngleBeforeChange.connect(&on_brush_before_change); + App::instance()->BrushAngleAfterChange.connect(&on_brush_after_change); } void Editor::editor_cursor_exit() @@ -223,12 +224,12 @@ void Editor::editor_cursor_exit() if (cursor_bound.seg != NULL) base_free(cursor_bound.seg); - delete current_pen; - current_pen = NULL; + delete current_brush; + current_brush = NULL; } /** - * Draws the pen cursor inside the specified editor. + * Draws the brush cursor inside the specified editor. * * @warning You should clean the cursor before to use * this routine with other editor. @@ -263,9 +264,9 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh) ->getSettings() ->getCurrentTool(); - // Setup the cursor type depending of several factors (current tool, + // Setup the cursor type debrushding of several factors (current tool, // foreground color, and layer transparency). - color_t pen_color = get_pen_color(m_sprite, m_layer); + color_t brush_color = get_brush_color(m_sprite, m_layer); color_t mask_color = m_sprite->getTransparentColor(); if (current_tool->getInk(0)->isSelection()) { @@ -274,49 +275,49 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh) else if ( // Use cursor bounds for inks that are effects (eraser, blur, etc.) (current_tool->getInk(0)->isEffect()) || - // or when the pen color is transparent and we are not in the background layer + // or when the brush color is transparent and we are not in the background layer (m_layer && !m_layer->isBackground() && - pen_color == mask_color)) { + brush_color == mask_color)) { cursor_type = CURSOR_BOUNDS; } else { - cursor_type = CURSOR_PENCIL; + cursor_type = CURSOR_BRUSH; } // For cursor type 'bounds' we have to generate cursor boundaries if (cursor_type & CURSOR_BOUNDS) generate_cursor_boundaries(); - // draw pixel/pen preview - if (cursor_type & CURSOR_PENCIL && m_state->requirePenPreview()) { + // draw pixel/brush preview + if (cursor_type & CURSOR_BRUSH && m_state->requireBrushPreview()) { IToolSettings* tool_settings = UIContext::instance() ->getSettings() ->getToolSettings(current_tool); - Pen* pen = editor_get_current_pen(); - gfx::Rect penBounds = pen->getBounds(); + Brush* brush = editor_get_current_brush(); + gfx::Rect brushBounds = brush->getBounds(); - // Create the extra cel to show the pen preview - m_document->prepareExtraCel(x+penBounds.x, y+penBounds.y, - penBounds.w, penBounds.h, + // Create the extra cel to show the brush preview + m_document->prepareExtraCel(x+brushBounds.x, y+brushBounds.y, + brushBounds.w, brushBounds.h, tool_settings->getOpacity()); // In 'indexed' images, if the current color is 0, we have to use // a different mask color (different from 0) to draw the extra layer - if (pen_color == mask_color) + if (brush_color == mask_color) mask_color = (mask_color == 0 ? 1: 0); Image* extraImage = m_document->getExtraCelImage(); extraImage->setMaskColor(mask_color); - put_pen(extraImage, pen, -penBounds.x, -penBounds.y, - pen_color, extraImage->getMaskColor()); + draw_brush(extraImage, brush, -brushBounds.x, -brushBounds.y, + brush_color, extraImage->getMaskColor()); if (refresh) { m_document->notifySpritePixelsModified (m_sprite, - gfx::Region(gfx::Rect(x+penBounds.x, - y+penBounds.y, - penBounds.w, penBounds.h))); + gfx::Region(gfx::Rect(x+brushBounds.x, + y+brushBounds.y, + brushBounds.w, brushBounds.h))); } } @@ -324,8 +325,8 @@ void Editor::editor_draw_cursor(int x, int y, bool refresh) if (refresh) { acquire_bitmap(ji_screen); ji_screen->clip = false; - for_each_pixel_of_pen(m_cursor_screen_x, m_cursor_screen_y, x, y, color, savepixel); - for_each_pixel_of_pen(m_cursor_screen_x, m_cursor_screen_y, x, y, color, drawpixel); + forEachBrushPixel(m_cursor_screen_x, m_cursor_screen_y, x, y, color, savepixel); + forEachBrushPixel(m_cursor_screen_x, m_cursor_screen_y, x, y, color, drawpixel); ji_screen->clip = true; release_bitmap(ji_screen); } @@ -360,15 +361,15 @@ void Editor::editor_move_cursor(int x, int y, bool refresh) /* restore points */ acquire_bitmap(ji_screen); ji_screen->clip = FALSE; - for_each_pixel_of_pen(old_screen_x, old_screen_y, old_x, old_y, 0, cleanpixel); + forEachBrushPixel(old_screen_x, old_screen_y, old_x, old_y, 0, cleanpixel); ji_screen->clip = TRUE; release_bitmap(ji_screen); - if (cursor_type & CURSOR_PENCIL && m_state->requirePenPreview()) { - Pen* pen = editor_get_current_pen(); - gfx::Rect penBounds = pen->getBounds(); - gfx::Rect rc1(old_x+penBounds.x, old_y+penBounds.y, penBounds.w, penBounds.h); - gfx::Rect rc2(new_x+penBounds.x, new_y+penBounds.y, penBounds.w, penBounds.h); + if (cursor_type & CURSOR_BRUSH && m_state->requireBrushPreview()) { + Brush* brush = editor_get_current_brush(); + gfx::Rect brushBounds = brush->getBounds(); + gfx::Rect rc1(old_x+brushBounds.x, old_y+brushBounds.y, brushBounds.w, brushBounds.h); + gfx::Rect rc2(new_x+brushBounds.x, new_y+brushBounds.y, brushBounds.w, brushBounds.h); m_document->notifySpritePixelsModified (m_sprite, gfx::Region(rc1.createUnion(rc2))); } @@ -377,15 +378,15 @@ void Editor::editor_move_cursor(int x, int y, bool refresh) int color = get_raw_cursor_color(); acquire_bitmap(ji_screen); ji_screen->clip = false; - for_each_pixel_of_pen(m_cursor_screen_x, m_cursor_screen_y, new_x, new_y, color, savepixel); - for_each_pixel_of_pen(m_cursor_screen_x, m_cursor_screen_y, new_x, new_y, color, drawpixel); + forEachBrushPixel(m_cursor_screen_x, m_cursor_screen_y, new_x, new_y, color, savepixel); + forEachBrushPixel(m_cursor_screen_x, m_cursor_screen_y, new_x, new_y, color, drawpixel); ji_screen->clip = true; release_bitmap(ji_screen); } } /** - * Cleans the pen cursor from the specified editor. + * Cleans the brush cursor from the specified editor. * * The mouse position is got from the last * call to @c editor_draw_cursor. So you must @@ -413,26 +414,26 @@ void Editor::editor_clean_cursor(bool refresh) /* restore points */ acquire_bitmap(ji_screen); ji_screen->clip = FALSE; - for_each_pixel_of_pen(m_cursor_screen_x, m_cursor_screen_y, x, y, 0, cleanpixel); + forEachBrushPixel(m_cursor_screen_x, m_cursor_screen_y, x, y, 0, cleanpixel); ji_screen->clip = TRUE; release_bitmap(ji_screen); } - // clean pixel/pen preview - if (cursor_type & CURSOR_PENCIL && m_state->requirePenPreview()) { - Pen* pen = editor_get_current_pen(); - gfx::Rect penBounds = pen->getBounds(); + // clean pixel/brush preview + if (cursor_type & CURSOR_BRUSH && m_state->requireBrushPreview()) { + Brush* brush = editor_get_current_brush(); + gfx::Rect brushBounds = brush->getBounds(); - m_document->prepareExtraCel(x+penBounds.x, y+penBounds.y, - penBounds.w, penBounds.h, + m_document->prepareExtraCel(x+brushBounds.x, y+brushBounds.y, + brushBounds.w, brushBounds.h, 0); // Opacity = 0 if (refresh) { m_document->notifySpritePixelsModified (m_sprite, - gfx::Region(gfx::Rect(x+penBounds.x, - y+penBounds.y, - penBounds.w, penBounds.h))); + gfx::Region(gfx::Rect(x+brushBounds.x, + y+brushBounds.y, + brushBounds.w, brushBounds.h))); } } @@ -460,49 +461,50 @@ static void generate_cursor_boundaries() ->getSettings() ->getCurrentTool(); - IPenSettings* pen_settings = NULL; + IBrushSettings* brush_settings = NULL; if (current_tool) - pen_settings = UIContext::instance() + brush_settings = UIContext::instance() ->getSettings() ->getToolSettings(current_tool) - ->getPen(); + ->getBrush(); if (cursor_bound.seg == NULL || - cursor_bound.pen_type != pen_settings->getType() || - cursor_bound.pen_size != pen_settings->getSize() || - cursor_bound.pen_angle != pen_settings->getAngle()) { - cursor_bound.pen_type = pen_settings->getType(); - cursor_bound.pen_size = pen_settings->getSize(); - cursor_bound.pen_angle = pen_settings->getAngle(); + cursor_bound.brush_type != brush_settings->getType() || + cursor_bound.brush_size != brush_settings->getSize() || + cursor_bound.brush_angle != brush_settings->getAngle()) { + cursor_bound.brush_type = brush_settings->getType(); + cursor_bound.brush_size = brush_settings->getSize(); + cursor_bound.brush_angle = brush_settings->getAngle(); if (cursor_bound.seg != NULL) base_free(cursor_bound.seg); - Pen* pen; + Brush* brush; - if (pen_settings) { - pen = new Pen(pen_settings->getType(), - pen_settings->getSize(), - pen_settings->getAngle()); + if (brush_settings) { + brush = new Brush(brush_settings->getType(), + brush_settings->getSize(), + brush_settings->getAngle()); } else - pen = new Pen(); + brush = new Brush(); - cursor_bound.seg = find_mask_boundary(pen->get_image(), + cursor_bound.seg = find_mask_boundary(brush->get_image(), &cursor_bound.nseg, IgnoreBounds, 0, 0, 0, 0); - delete pen; + delete brush; } } -void Editor::for_each_pixel_of_pen(int screen_x, int screen_y, - int sprite_x, int sprite_y, int color, - void (*pixel)(BITMAP *bmp, int x, int y, int color)) +void Editor::forEachBrushPixel( + int screen_x, int screen_y, + int sprite_x, int sprite_y, int color, + void (*pixel)(BITMAP *bmp, int x, int y, int color)) { saved_pixel_n = 0; - if (cursor_type & CURSOR_PENCIL) { - editor_cursor_pencil(this, screen_x, screen_y, color, 1, pixel); + if (cursor_type & CURSOR_BRUSH) { + editor_cursor_brush(this, screen_x, screen_y, color, 1, pixel); } if (cursor_type & CURSOR_CROSS_ONE) { @@ -521,7 +523,7 @@ void Editor::for_each_pixel_of_pen(int screen_x, int screen_y, ////////////////////////////////////////////////////////////////////// // New cross -static void editor_cursor_pencil(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color)) +static void editor_cursor_brush(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color)) { static int cursor_cross[7*7] = { 0, 0, 0, 1, 0, 0, 0, @@ -592,10 +594,10 @@ static void editor_cursor_bounds(Editor *editor, int x, int y, int color, void ( for (c=0; cx1 - cursor_bound.pen_size/2; - y1 = seg->y1 - cursor_bound.pen_size/2; - x2 = seg->x2 - cursor_bound.pen_size/2; - y2 = seg->y2 - cursor_bound.pen_size/2; + x1 = seg->x1 - cursor_bound.brush_size/2; + y1 = seg->y1 - cursor_bound.brush_size/2; + x2 = seg->x2 - cursor_bound.brush_size/2; + y2 = seg->y2 - cursor_bound.brush_size/2; editor->editorToScreen(x+x1, y+y1, &x1, &y1); editor->editorToScreen(x+x2, y+y2, &x2, &y2); @@ -663,7 +665,7 @@ static void cleanpixel(BITMAP *bmp, int x, int y, int color) } } -static color_t get_pen_color(Sprite* sprite, Layer* layer) +static color_t get_brush_color(Sprite* sprite, Layer* layer) { app::Color c = UIContext::instance()->getSettings()->getFgColor(); ASSERT(sprite != NULL); diff --git a/src/app/ui/editor/drawing_state.h b/src/app/ui/editor/drawing_state.h index ad3d37ad7..7d2502941 100644 --- a/src/app/ui/editor/drawing_state.h +++ b/src/app/ui/editor/drawing_state.h @@ -41,9 +41,9 @@ namespace app { virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; - // Drawing state doesn't require the pen-preview because we are + // Drawing state doesn't require the brush-preview because we are // already drawing (viewing the real trace). - virtual bool requirePenPreview() OVERRIDE { return false; } + virtual bool requireBrushPreview() OVERRIDE { return false; } private: void destroyLoop(); diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h index 3ec896b31..e8d444f0d 100644 --- a/src/app/ui/editor/editor.h +++ b/src/app/ui/editor/editor.h @@ -210,9 +210,10 @@ namespace app { void editor_setcursor(); - void for_each_pixel_of_pen(int screen_x, int screen_y, - int sprite_x, int sprite_y, int color, - void (*pixel)(BITMAP *bmp, int x, int y, int color)); + void forEachBrushPixel( + int screen_x, int screen_y, + int sprite_x, int sprite_y, int color, + void (*pixel)(BITMAP *bmp, int x, int y, int color)); // Draws the specified portion of sprite in the editor. Warning: // You should setup the clip of the screen before calling this diff --git a/src/app/ui/editor/editor_state.h b/src/app/ui/editor/editor_state.h index 13203919c..551d22ae9 100644 --- a/src/app/ui/editor/editor_state.h +++ b/src/app/ui/editor/editor_state.h @@ -99,9 +99,9 @@ namespace app { // Called when a key is released. virtual bool onUpdateStatusBar(Editor* editor) { return false; } - // Returns true if the this state requires the pen-preview as + // Returns true if the this state requires the brush-preview as // drawing cursor. - virtual bool requirePenPreview() { return false; } + virtual bool requireBrushPreview() { return false; } private: DISABLE_COPYING(EditorState); diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h index 7ed39c9d1..1cad976cf 100644 --- a/src/app/ui/editor/select_box_state.h +++ b/src/app/ui/editor/select_box_state.h @@ -63,7 +63,7 @@ namespace app { // Returns false as it overrides default standby state behavior & // look. This state uses normal arrow cursors. - virtual bool requirePenPreview() OVERRIDE { return false; } + virtual bool requireBrushPreview() OVERRIDE { return false; } // EditorDecorator overrides virtual void preRenderDecorator(EditorPreRender* render) OVERRIDE; diff --git a/src/app/ui/editor/standby_state.h b/src/app/ui/editor/standby_state.h index b003f5805..127879ef5 100644 --- a/src/app/ui/editor/standby_state.h +++ b/src/app/ui/editor/standby_state.h @@ -45,9 +45,9 @@ namespace app { virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; - // Returns true as the standby state is the only one which shows the - // pen-preview. - virtual bool requirePenPreview() OVERRIDE { return true; } + // Returns true as the standby state is the only one which shows + // the brush-preview. + virtual bool requireBrushPreview() OVERRIDE { return true; } virtual gfx::Transformation getTransformation(Editor* editor); diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index 9bfd0ea77..3460b8eb7 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -40,10 +40,10 @@ #include "app/ui/status_bar.h" #include "app/undo_transaction.h" #include "app/util/expand_cel_canvas.h" +#include "raster/brush.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/mask.h" -#include "raster/pen.h" #include "raster/sprite.h" #include "ui/ui.h" @@ -58,7 +58,7 @@ class ToolLoopImpl : public tools::ToolLoop, Editor* m_editor; Context* m_context; tools::Tool* m_tool; - Pen* m_pen; + Brush* m_brush; Document* m_document; Sprite* m_sprite; Layer* m_layer; @@ -146,13 +146,14 @@ public: m_sprayWidth = m_toolSettings->getSprayWidth(); m_spraySpeed = m_toolSettings->getSpraySpeed(); - // Create the pen - IPenSettings* pen_settings = m_toolSettings->getPen(); - ASSERT(pen_settings != NULL); + // Create the brush + IBrushSettings* brush_settings = m_toolSettings->getBrush(); + ASSERT(brush_settings != NULL); - m_pen = new Pen(pen_settings->getType(), - pen_settings->getSize(), - pen_settings->getAngle()); + m_brush = new Brush( + brush_settings->getType(), + brush_settings->getSize(), + brush_settings->getAngle()); m_useMask = m_document->isMaskVisible(); @@ -201,13 +202,13 @@ public: m_expandCelCanvas.rollback(); } - delete m_pen; + delete m_brush; delete m_shadeTable; } // IToolLoop interface tools::Tool* getTool() OVERRIDE { return m_tool; } - Pen* getPen() OVERRIDE { return m_pen; } + Brush* getBrush() OVERRIDE { return m_brush; } Document* getDocument() OVERRIDE { return m_document; } Sprite* getSprite() OVERRIDE { return m_sprite; } Layer* getLayer() OVERRIDE { return m_layer; } diff --git a/src/raster/CMakeLists.txt b/src/raster/CMakeLists.txt index 8f1c1fbd3..cb07fa1af 100644 --- a/src/raster/CMakeLists.txt +++ b/src/raster/CMakeLists.txt @@ -1,5 +1,5 @@ # Aseprite -# Copyright (C) 2001-2013 David Capello +# Copyright (C) 2001-2014 David Capello add_library(raster-lib algo.cpp @@ -9,6 +9,7 @@ add_library(raster-lib algorithm/resize_image.cpp algorithm/shrink_bounds.cpp blend.cpp + brush.cpp cel.cpp cel_io.cpp color_scales.cpp @@ -27,7 +28,6 @@ add_library(raster-lib object.cpp palette.cpp palette_io.cpp - pen.cpp primitives.cpp quantization.cpp rgbmap.cpp diff --git a/src/raster/pen.cpp b/src/raster/brush.cpp similarity index 78% rename from src/raster/pen.cpp rename to src/raster/brush.cpp index b271e8e96..fb2dcc046 100644 --- a/src/raster/pen.cpp +++ b/src/raster/brush.cpp @@ -20,7 +20,7 @@ #include "config.h" #endif -#include "raster/pen.h" +#include "raster/brush.h" #include "raster/algo.h" #include "raster/image.h" @@ -30,60 +30,60 @@ namespace raster { -Pen::Pen() +Brush::Brush() { - m_type = PEN_TYPE_CIRCLE; + m_type = kCircleBrushType; m_size = 1; m_angle = 0; m_image = NULL; - regenerate_pen(); + regenerate(); } -Pen::Pen(PenType type, int size, int angle) +Brush::Brush(BrushType type, int size, int angle) { m_type = type; m_size = size; m_angle = angle; m_image = NULL; - regenerate_pen(); + regenerate(); } -Pen::Pen(const Pen& pen) +Brush::Brush(const Brush& brush) { - m_type = pen.m_type; - m_size = pen.m_size; - m_angle = pen.m_angle; + m_type = brush.m_type; + m_size = brush.m_size; + m_angle = brush.m_angle; - regenerate_pen(); + regenerate(); } -Pen::~Pen() +Brush::~Brush() { - clean_pen(); + clean(); } -void Pen::set_type(PenType type) +void Brush::set_type(BrushType type) { m_type = type; - regenerate_pen(); + regenerate(); } -void Pen::set_size(int size) +void Brush::set_size(int size) { m_size = size; - regenerate_pen(); + regenerate(); } -void Pen::set_angle(int angle) +void Brush::set_angle(int angle) { m_angle = angle; - regenerate_pen(); + regenerate(); } -// Cleans the pen's data (image and region). -void Pen::clean_pen() +// Cleans the brush's data (image and region). +void Brush::clean() { if (m_image) { delete m_image; @@ -98,15 +98,15 @@ static void algo_hline(int x1, int y, int x2, void *data) draw_hline(reinterpret_cast(data), x1, y, x2, BitmapTraits::max_value); } -// Regenerates the pen bitmap and its rectangle's region. -void Pen::regenerate_pen() +// Regenerates the brush bitmap and its rectangle's region. +void Brush::regenerate() { - clean_pen(); + clean(); ASSERT(m_size > 0); int size = m_size; - if (m_type == PEN_TYPE_SQUARE && m_angle != 0 && m_size > 2) + if (m_type == kSquareBrushType && m_angle != 0 && m_size > 2) size = std::sqrt((double)2*m_size*m_size)+2; m_image = Image::create(IMAGE_BITMAP, size, size); @@ -119,11 +119,11 @@ void Pen::regenerate_pen() switch (m_type) { - case PEN_TYPE_CIRCLE: + case kCircleBrushType: fill_ellipse(m_image, 0, 0, size-1, size-1, BitmapTraits::max_value); break; - case PEN_TYPE_SQUARE: + case kSquareBrushType: if (m_angle == 0 || size <= 2) { clear_image(m_image, BitmapTraits::max_value); } @@ -146,7 +146,7 @@ void Pen::regenerate_pen() } break; - case PEN_TYPE_LINE: { + case kLineBrushType: { double a = PI * m_angle / 180; float r = m_size/2; float d = m_size; @@ -180,8 +180,9 @@ void Pen::regenerate_pen() } } - m_bounds = gfx::Rect(-m_image->getWidth()/2, -m_image->getHeight()/2, - m_image->getWidth(), m_image->getHeight()); + m_bounds = gfx::Rect( + -m_image->getWidth()/2, -m_image->getHeight()/2, + m_image->getWidth(), m_image->getHeight()); } } // namespace raster diff --git a/src/raster/pen.h b/src/raster/brush.h similarity index 69% rename from src/raster/pen.h rename to src/raster/brush.h index 26802bd26..0cae1e025 100644 --- a/src/raster/pen.h +++ b/src/raster/brush.h @@ -16,51 +16,51 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RASTER_PEN_H_INCLUDED -#define RASTER_PEN_H_INCLUDED +#ifndef RASTER_BRUSH_H_INCLUDED +#define RASTER_BRUSH_H_INCLUDED #pragma once #include "gfx/point.h" #include "gfx/rect.h" -#include "raster/pen_type.h" +#include "raster/brush_type.h" #include namespace raster { class Image; - struct PenScanline { + struct BrushScanline { int state, x1, x2; }; - class Pen { + class Brush { public: - Pen(); - Pen(PenType type, int size, int angle); - Pen(const Pen& pen); - ~Pen(); + Brush(); + Brush(BrushType type, int size, int angle); + Brush(const Brush& brush); + ~Brush(); - PenType get_type() const { return m_type; } + BrushType get_type() const { return m_type; } int get_size() const { return m_size; } int get_angle() const { return m_angle; } Image* get_image() { return m_image; } - const std::vector& get_scanline() const { return m_scanline; } + const std::vector& get_scanline() const { return m_scanline; } const gfx::Rect& getBounds() const { return m_bounds; } - void set_type(PenType type); + void set_type(BrushType type); void set_size(int size); void set_angle(int angle); private: - void clean_pen(); - void regenerate_pen(); + void clean(); + void regenerate(); - PenType m_type; // Type of pen + BrushType m_type; // Type of brush int m_size; // Size (diameter) int m_angle; // Angle in degrees 0-360 - Image* m_image; // Image of the pen - std::vector m_scanline; + Image* m_image; // Image of the brush + std::vector m_scanline; gfx::Rect m_bounds; }; diff --git a/src/raster/pen_type.h b/src/raster/brush_type.h similarity index 77% rename from src/raster/pen_type.h rename to src/raster/brush_type.h index 030fef372..f8a4b91d5 100644 --- a/src/raster/pen_type.h +++ b/src/raster/brush_type.h @@ -16,19 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RASTER_PEN_TYPE_H_INCLUDED -#define RASTER_PEN_TYPE_H_INCLUDED +#ifndef RASTER_BRUSH_TYPE_H_INCLUDED +#define RASTER_BRUSH_TYPE_H_INCLUDED #pragma once namespace raster { - enum PenType { - PEN_TYPE_CIRCLE = 0, - PEN_TYPE_SQUARE = 1, - PEN_TYPE_LINE = 2, + enum BrushType { + kCircleBrushType = 0, + kSquareBrushType = 1, + kLineBrushType = 2, - PEN_TYPE_FIRST = PEN_TYPE_CIRCLE, - PEN_TYPE_LAST = PEN_TYPE_LINE, + kFirstBrushType = kCircleBrushType, + kLastBrushType = kLineBrushType, }; } // namespace raster diff --git a/src/raster/image.cpp b/src/raster/image.cpp index 77564a8d6..7dd2082da 100644 --- a/src/raster/image.cpp +++ b/src/raster/image.cpp @@ -24,9 +24,9 @@ #include "raster/algo.h" #include "raster/blend.h" +#include "raster/brush.h" #include "raster/image_impl.h" #include "raster/palette.h" -#include "raster/pen.h" #include "raster/primitives.h" #include "raster/rgbmap.h" diff --git a/src/raster/primitives.cpp b/src/raster/primitives.cpp index 7d5da4d6b..b8f0349f8 100644 --- a/src/raster/primitives.cpp +++ b/src/raster/primitives.cpp @@ -24,10 +24,10 @@ #include "raster/algo.h" #include "raster/blend.h" +#include "raster/brush.h" #include "raster/image.h" #include "raster/image_impl.h" #include "raster/palette.h" -#include "raster/pen.h" #include "raster/rgbmap.h" #include @@ -48,22 +48,22 @@ void put_pixel(Image* image, int x, int y, color_t color) image->putPixel(x, y, color); } -void put_pen(Image* image, Pen* pen, int x, int y, color_t fg, color_t bg) +void draw_brush(Image* image, Brush* brush, int x, int y, color_t fg, color_t bg) { - Image* pen_image = pen->get_image(); - const gfx::Rect& penBounds = pen->getBounds(); + Image* brush_image = brush->get_image(); + const gfx::Rect& brushBounds = brush->getBounds(); - x += penBounds.x; - y += penBounds.y; + x += brushBounds.x; + y += brushBounds.y; if (fg == bg) { - fill_rect(image, x, y, x+penBounds.w-1, y+penBounds.h-1, bg); + fill_rect(image, x, y, x+brushBounds.w-1, y+brushBounds.h-1, bg); } else { int u, v; - for (v=0; v