mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Use dynamics for brush preview only for freehand tools (fix #4178)
This fixes a problem where the smaller brush size of the dynamics was used for tools like line/rectangle/etc. where the dynamics option aren't used. We've added some comments for a possible future #4186 too, implementing dynamics for the contour tool (which is freehand, but the result is filled).
This commit is contained in:
parent
5ae2e444f2
commit
10738b32c3
@ -379,6 +379,7 @@ Stroke::Pt ToolLoopManager::getSpriteStrokePt(const Pointer& pointer)
|
||||
bool ToolLoopManager::useDynamics() const
|
||||
{
|
||||
return (m_dynamics.isDynamic() &&
|
||||
// TODO add support for dynamics to contour tool
|
||||
!m_toolLoop->getFilled() &&
|
||||
m_toolLoop->getController()->isFreehand());
|
||||
}
|
||||
|
@ -1203,7 +1203,6 @@ public:
|
||||
}
|
||||
|
||||
void setOptionsGridVisibility(bool state) {
|
||||
m_optionsGridVisibility = state;
|
||||
if (m_popup)
|
||||
m_popup->setOptionsGridVisibility(state);
|
||||
}
|
||||
@ -1299,7 +1298,6 @@ private:
|
||||
std::unique_ptr<DynamicsPopup> m_popup;
|
||||
ContextBar* m_ctxBar;
|
||||
mutable tools::DynamicsOptions m_dynamics;
|
||||
bool m_optionsGridVisibility = true;
|
||||
bool m_sameInAllTools = false;
|
||||
};
|
||||
|
||||
@ -2170,6 +2168,10 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
||||
(tool->getController(0)->isFreehand() ||
|
||||
tool->getController(1)->isFreehand());
|
||||
|
||||
const bool isFilled = tool &&
|
||||
(tool->getFill(0) == tools::FillAlways ||
|
||||
tool->getFill(1) == tools::FillAlways);
|
||||
|
||||
const bool showOpacity =
|
||||
(supportOpacity) &&
|
||||
((isPaint && (hasInkWithOpacity || hasImageBrush)) ||
|
||||
@ -2179,9 +2181,11 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
||||
(tool->getInk(0)->withDitheringOptions() ||
|
||||
tool->getInk(1)->withDitheringOptions());
|
||||
|
||||
// True if the brush supports dynamics
|
||||
// TODO add support for dynamics in custom brushes in the future
|
||||
const bool supportDynamics = (!hasImageBrush);
|
||||
// True if the tool & brush support dynamics
|
||||
const bool supportDynamics =
|
||||
(isFreehand &&
|
||||
!isFilled && // TODO add support for dynamics to contour tool
|
||||
!hasImageBrush); // TODO add support for dynamics in custom brushes
|
||||
|
||||
// Show/Hide fields
|
||||
m_zoomButtons->setVisible(needZoomButtons(tool));
|
||||
@ -2196,7 +2200,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
||||
m_inkShades->setVisible(hasInkShades);
|
||||
m_eyedropperField->setVisible(isEyedropper);
|
||||
m_autoSelectLayer->setVisible(isMove);
|
||||
m_dynamics->setVisible(isFreehand && supportDynamics);
|
||||
m_dynamics->setVisible(supportDynamics);
|
||||
m_dynamics->setOptionsGridVisibility(isFreehand && !hasSelectOptions);
|
||||
m_freehandBox->setVisible(isFreehand && (supportOpacity || hasSelectOptions));
|
||||
m_toleranceLabel->setVisible(hasTolerance);
|
||||
|
@ -163,7 +163,8 @@ void BrushPreview::show(const gfx::Point& screenPos)
|
||||
|
||||
BrushRef brush = getCurrentBrush();
|
||||
|
||||
const bool isFloodfill = m_editor->getCurrentEditorTool()->getPointShape(0)->isFloodFill();
|
||||
tools::Tool* tool = m_editor->getCurrentEditorTool();
|
||||
const bool isFloodfill = tool->getPointShape(0)->isFloodFill();
|
||||
// TODO add support for "tile-brushes"
|
||||
gfx::Rect origBrushBounds =
|
||||
((isFloodfill && brush->type() != BrushType::kImageBrushType) ||
|
||||
@ -190,21 +191,26 @@ void BrushPreview::show(const gfx::Point& screenPos)
|
||||
// Get current tilemap mode
|
||||
TilemapMode tilemapMode = ColorBar::instance()->tilemapMode();
|
||||
|
||||
const auto& dynamics = App::instance()->contextBar()->getDynamics();
|
||||
|
||||
// Setup the cursor type depending on several factors (current tool,
|
||||
// foreground color, layer transparency, brush size, etc.).
|
||||
color_t brush_color = getBrushColor(sprite, layer);
|
||||
color_t mask_index = sprite->transparentColor();
|
||||
|
||||
if (brush->type() != doc::kImageBrushType &&
|
||||
(dynamics.size != tools::DynamicSensor::Static ||
|
||||
dynamics.angle != tools::DynamicSensor::Static)) {
|
||||
brush.reset(
|
||||
new Brush(
|
||||
brush->type(),
|
||||
(dynamics.size != tools::DynamicSensor::Static ? dynamics.minSize: brush->size()),
|
||||
(dynamics.angle != tools::DynamicSensor::Static ? dynamics.minAngle: brush->angle())));
|
||||
// Check dynamics option for freehand tools
|
||||
if (tool &&
|
||||
tool->getController(0)->isFreehand() &&
|
||||
// TODO add support for dynamics to contour tool
|
||||
tool->getFill(0) == tools::FillNone) {
|
||||
const auto& dynamics = App::instance()->contextBar()->getDynamics();
|
||||
if (brush->type() != doc::kImageBrushType &&
|
||||
(dynamics.size != tools::DynamicSensor::Static ||
|
||||
dynamics.angle != tools::DynamicSensor::Static)) {
|
||||
brush.reset(
|
||||
new Brush(
|
||||
brush->type(),
|
||||
(dynamics.size != tools::DynamicSensor::Static ? dynamics.minSize: brush->size()),
|
||||
(dynamics.angle != tools::DynamicSensor::Static ? dynamics.minAngle: brush->angle())));
|
||||
}
|
||||
}
|
||||
|
||||
if (ink->isSelection() || ink->isSlice()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user