diff --git a/data/pref.xml b/data/pref.xml
index 9ceab9652..f86c74d60 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -31,6 +31,11 @@
+
+
+
+
+
@@ -111,6 +116,9 @@
+
diff --git a/src/app/tools/point_shapes.h b/src/app/tools/point_shapes.h
index 232d1ef93..b292a940b 100644
--- a/src/app/tools/point_shapes.h
+++ b/src/app/tools/point_shapes.h
@@ -104,7 +104,7 @@ private:
bounds = bounds.createIntersection(loop->getSrcImage()->bounds());
// Limit the flood-fill to the current tile if the grid is visible.
- if (loop->getGridVisible()) {
+ if (loop->getStopAtGrid()) {
gfx::Rect grid = loop->getGridBounds();
div_t d, dx, dy;
diff --git a/src/app/tools/tool_loop.h b/src/app/tools/tool_loop.h
index 7d2a4b11a..bbe2f3c48 100644
--- a/src/app/tools/tool_loop.h
+++ b/src/app/tools/tool_loop.h
@@ -170,6 +170,7 @@ namespace app {
virtual bool getGridVisible() = 0;
virtual bool getSnapToGrid() = 0;
+ virtual bool getStopAtGrid() = 0; // For floodfill-like tools
virtual gfx::Rect getGridBounds() = 0;
// Returns true if the figure must be filled when we release the
diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp
index da39d2de7..9feca72a8 100644
--- a/src/app/ui/context_bar.cpp
+++ b/src/app/ui/context_bar.cpp
@@ -284,7 +284,25 @@ public:
setup_mini_font(this);
}
- void setContiguous(bool state) {
+protected:
+ void onClick(Event& ev) override {
+ CheckBox::onClick(ev);
+
+ Tool* tool = App::instance()->activeTool();
+ Preferences::instance().tool(tool).contiguous(isSelected());
+
+ releaseFocus();
+ }
+};
+
+class ContextBar::StopAtGridField : public CheckBox
+{
+public:
+ StopAtGridField() : CheckBox("Stop at Grid") {
+ setup_mini_font(this);
+ }
+
+ void setStopAtGrid(bool state) {
setSelected(state);
}
@@ -293,7 +311,9 @@ protected:
CheckBox::onClick(ev);
Tool* tool = App::instance()->activeTool();
- Preferences::instance().tool(tool).contiguous(isSelected());
+ Preferences::instance().tool(tool).floodfill.stopAtGrid(
+ (isSelected() ? app::gen::StopAtGrid::IF_VISIBLE:
+ app::gen::StopAtGrid::NEVER));
releaseFocus();
}
@@ -778,6 +798,7 @@ ContextBar::ContextBar()
addChild(m_toleranceLabel = new Label("Tolerance:"));
addChild(m_tolerance = new ToleranceField());
addChild(m_contiguous = new ContiguousField());
+ addChild(m_stopAtGrid = new StopAtGridField());
addChild(m_inkType = new InkTypeField());
@@ -919,6 +940,8 @@ void ContextBar::updateForTool(tools::Tool* tool)
if (toolPref) {
m_tolerance->setTextf("%d", toolPref->tolerance());
m_contiguous->setSelected(toolPref->contiguous());
+ m_stopAtGrid->setSelected(
+ toolPref->floodfill.stopAtGrid() == app::gen::StopAtGrid::IF_VISIBLE ? true: false);
m_inkType->setInkType(toolPref->ink());
m_inkOpacity->setTextf("%d", toolPref->opacity());
@@ -956,6 +979,11 @@ void ContextBar::updateForTool(tools::Tool* tool)
// tool.
bool hasInk = hasOpacity;
+ // True if the current tool is floodfill
+ bool isFloodfill = tool &&
+ (tool->getPointShape(0)->isFloodFill() ||
+ tool->getPointShape(1)->isFloodFill());
+
// True if the current tool needs tolerance options
bool hasTolerance = tool &&
(tool->getPointShape(0)->isFloodFill() ||
@@ -975,9 +1003,9 @@ void ContextBar::updateForTool(tools::Tool* tool)
tool->getController(1)->isFreehand());
// Show/Hide fields
- m_brushType->setVisible(hasOpacity);
- m_brushSize->setVisible(hasOpacity && !hasImageBrush);
- m_brushAngle->setVisible(hasOpacity && !hasImageBrush);
+ m_brushType->setVisible(hasOpacity && (!isFloodfill || (isFloodfill && hasImageBrush)));
+ m_brushSize->setVisible(hasOpacity && !isFloodfill && !hasImageBrush);
+ m_brushAngle->setVisible(hasOpacity && !isFloodfill && !hasImageBrush);
m_brushPatternField->setVisible(hasOpacity && hasImageBrush);
m_opacityLabel->setVisible(hasOpacity);
m_inkType->setVisible(hasInk && !hasImageBrush);
@@ -988,6 +1016,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
m_toleranceLabel->setVisible(hasTolerance);
m_tolerance->setVisible(hasTolerance);
m_contiguous->setVisible(hasTolerance);
+ m_stopAtGrid->setVisible(hasTolerance);
m_sprayBox->setVisible(hasSprayOptions);
m_selectionOptionsBox->setVisible(hasSelectOptions);
m_selectionMode->setVisible(true);
diff --git a/src/app/ui/context_bar.h b/src/app/ui/context_bar.h
index 42e75e6c3..de172e3ed 100644
--- a/src/app/ui/context_bar.h
+++ b/src/app/ui/context_bar.h
@@ -96,6 +96,7 @@ namespace app {
class BrushSizeField;
class ToleranceField;
class ContiguousField;
+ class StopAtGridField;
class InkTypeField;
class InkOpacityField;
class SprayWidthField;
@@ -115,6 +116,7 @@ namespace app {
ui::Label* m_toleranceLabel;
ToleranceField* m_tolerance;
ContiguousField* m_contiguous;
+ StopAtGridField* m_stopAtGrid;
InkTypeField* m_inkType;
ui::Label* m_opacityLabel;
InkOpacityField* m_inkOpacity;
diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp
index 0459135d3..5610faa55 100644
--- a/src/app/ui/editor/tool_loop_impl.cpp
+++ b/src/app/ui/editor/tool_loop_impl.cpp
@@ -159,6 +159,17 @@ public:
filters::TiledMode getTiledMode() override { return m_docPref.tiled.mode(); }
bool getGridVisible() override { return m_docPref.grid.visible(); }
bool getSnapToGrid() override { return m_docPref.grid.snap(); }
+ bool getStopAtGrid() override {
+ switch (m_toolPref.floodfill.stopAtGrid()) {
+ case app::gen::StopAtGrid::NEVER:
+ return false;
+ case app::gen::StopAtGrid::IF_VISIBLE:
+ return m_docPref.grid.visible();
+ case app::gen::StopAtGrid::ALWAYS:
+ return true;
+ }
+ return false;
+ }
gfx::Rect getGridBounds() override { return m_docPref.grid.bounds(); }
gfx::Point getOffset() override { return m_offset; }
void setSpeed(const gfx::Point& speed) override { m_speed = speed; }