mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-27 06:35:16 +00:00
Add option to ignore grid limits in paint bucket or magic wand tools (fix 564)
This commit is contained in:
parent
3c60136631
commit
90f988d928
@ -31,6 +31,11 @@
|
||||
<value id="VERTICAL_STRIP" value="2" />
|
||||
<value id="MATRIX" value="3" />
|
||||
</enum>
|
||||
<enum id="StopAtGrid">
|
||||
<value id="NEVER" value="0" />
|
||||
<value id="IF_VISIBLE" value="1" />
|
||||
<value id="ALWAYS" value="2" />
|
||||
</enum>
|
||||
</types>
|
||||
|
||||
<global>
|
||||
@ -111,6 +116,9 @@
|
||||
<option id="width" type="int" default="16" />
|
||||
<option id="speed" type="int" default="32" />
|
||||
</section>
|
||||
<section id="floodfill">
|
||||
<option id="stop_at_grid" type="StopAtGrid" default="StopAtGrid::IF_VISIBLE" />
|
||||
</section>
|
||||
</tool>
|
||||
|
||||
<document>
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user