mirror of https://github.com/aseprite/aseprite.git
Add corner radius field in context bar
This commit is contained in:
parent
26cf154198
commit
5d8a50d009
|
@ -601,6 +601,7 @@ discard_brush = Discard Brush (Esc)
|
|||
brush_type = Brush Type
|
||||
brush_size = Brush Size (in pixels)
|
||||
brush_angle = Brush Angle (in degrees)
|
||||
corner_radius = Corner Radius (in pixels)
|
||||
ink = Ink
|
||||
opacity = Opacity (paint intensity)
|
||||
shades = Shades
|
||||
|
|
|
@ -223,6 +223,7 @@ public:
|
|||
if (loop->getIntertwine()->cornerRadiusSupport() &&
|
||||
(int(loop->getModifiers()) & int(ToolLoopModifiers::kCornerRadius))) {
|
||||
m_cornerRadius.modifyRadius(stroke, pt);
|
||||
m_cornerRadius.save();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "app/tools/controller.h"
|
||||
#include "app/tools/ink.h"
|
||||
#include "app/tools/ink_type.h"
|
||||
#include "app/tools/intertwine.h"
|
||||
#include "app/tools/point_shape.h"
|
||||
#include "app/tools/tool.h"
|
||||
#include "app/tools/tool_box.h"
|
||||
|
@ -349,6 +350,24 @@ protected:
|
|||
bool m_lock;
|
||||
};
|
||||
|
||||
class ContextBar::CornerRadiusField : public IntEntry {
|
||||
public:
|
||||
CornerRadiusField() : IntEntry(0, 999) { setSuffix("px"); }
|
||||
|
||||
private:
|
||||
void onValueChange() override
|
||||
{
|
||||
if (g_updatingFromCode)
|
||||
return;
|
||||
|
||||
IntEntry::onValueChange();
|
||||
base::ScopedValue lockFlag(g_updatingFromCode, true);
|
||||
|
||||
Tool* tool = App::instance()->activeTool();
|
||||
Preferences::instance().tool(tool).cornerRadius.setValue(getValue());
|
||||
}
|
||||
};
|
||||
|
||||
class ContextBar::ToleranceField : public IntEntry {
|
||||
public:
|
||||
ToleranceField() : IntEntry(0, 255) {}
|
||||
|
@ -1919,6 +1938,8 @@ ContextBar::ContextBar(TooltipManager* tooltipManager, ColorBar* colorBar)
|
|||
addChild(m_brushBack = new BrushBackField);
|
||||
addChild(m_brushType = new BrushTypeField(this));
|
||||
addChild(m_brushSize = new BrushSizeField());
|
||||
addChild(m_cornerRadius = new CornerRadiusField());
|
||||
m_cornerRadius->useSlider(false);
|
||||
addChild(m_brushAngle = new BrushAngleField(m_brushType));
|
||||
addChild(m_brushPatternField = new BrushPatternField());
|
||||
|
||||
|
@ -2074,6 +2095,11 @@ void ContextBar::onBrushSizeChange()
|
|||
updateForActiveTool();
|
||||
}
|
||||
|
||||
void ContextBar::onCornerRadiusChange(int value)
|
||||
{
|
||||
m_cornerRadius->setValue(value);
|
||||
}
|
||||
|
||||
void ContextBar::onBrushAngleChange()
|
||||
{
|
||||
if (m_activeBrush->type() != kImageBrushType)
|
||||
|
@ -2164,6 +2190,9 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
|||
m_freehandAlgoConn = toolPref->freehandAlgorithm.AfterChange.connect(
|
||||
[this] { onToolSetFreehandAlgorithm(); });
|
||||
m_contiguousConn = toolPref->contiguous.AfterChange.connect([this] { onToolSetContiguous(); });
|
||||
m_cornerRadius->setValue(toolPref->cornerRadius());
|
||||
m_cornerRadiusConn = toolPref->cornerRadius.AfterChange.connect(
|
||||
[this](const int value) { onCornerRadiusChange(value); });
|
||||
}
|
||||
|
||||
if (tool)
|
||||
|
@ -2241,6 +2270,9 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
|||
const bool isFloodfill = tool && (tool->getPointShape(0)->isFloodFill() ||
|
||||
tool->getPointShape(1)->isFloodFill());
|
||||
|
||||
const bool hasCornerRadius = tool && (tool->getIntertwine(0)->cornerRadiusSupport() ||
|
||||
tool->getIntertwine(1)->cornerRadiusSupport());
|
||||
|
||||
// True if the current tool needs tolerance options
|
||||
const bool hasTolerance = tool && (tool->getPointShape(0)->isFloodFill() ||
|
||||
tool->getPointShape(1)->isFloodFill());
|
||||
|
@ -2276,6 +2308,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
|
|||
m_brushSize->setVisible(supportOpacity && !isFloodfill && !hasImageBrush);
|
||||
m_brushAngle->setVisible(supportOpacity && !isFloodfill && !hasImageBrush && hasBrushWithAngle);
|
||||
m_brushPatternField->setVisible(supportOpacity && hasImageBrush && !withDithering);
|
||||
m_cornerRadius->setVisible(hasCornerRadius);
|
||||
m_inkType->setVisible(hasInk);
|
||||
m_inkOpacityLabel->setVisible(showOpacity);
|
||||
m_inkOpacity->setVisible(showOpacity);
|
||||
|
@ -2637,6 +2670,7 @@ void ContextBar::setupTooltips(TooltipManager* tooltipManager)
|
|||
tooltipManager->addTooltipFor(m_brushType->at(0), Strings::context_bar_brush_type(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_brushSize, Strings::context_bar_brush_size(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_brushAngle, Strings::context_bar_brush_angle(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_cornerRadius, Strings::context_bar_corner_radius(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_inkType->at(0), Strings::context_bar_ink(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_inkOpacity, Strings::context_bar_opacity(), BOTTOM);
|
||||
tooltipManager->addTooltipFor(m_inkShades->at(0), Strings::context_bar_shades(), BOTTOM);
|
||||
|
|
|
@ -131,6 +131,7 @@ protected:
|
|||
private:
|
||||
void onBrushSizeChange();
|
||||
void onBrushAngleChange();
|
||||
void onCornerRadiusChange(int value);
|
||||
void onSymmetryModeChange();
|
||||
void onFgOrBgColorChange(doc::Brush::ImageColor imageColor);
|
||||
void onOpacityRangeChange();
|
||||
|
@ -168,6 +169,7 @@ private:
|
|||
class DynamicsField;
|
||||
class FreehandAlgorithmField;
|
||||
class BrushPatternField;
|
||||
class CornerRadiusField;
|
||||
class EyedropperField;
|
||||
class DropPixelsField;
|
||||
class AutoSelectLayerField;
|
||||
|
@ -181,6 +183,7 @@ private:
|
|||
BrushTypeField* m_brushType;
|
||||
BrushAngleField* m_brushAngle;
|
||||
BrushSizeField* m_brushSize;
|
||||
CornerRadiusField* m_cornerRadius;
|
||||
ui::Label* m_toleranceLabel;
|
||||
ToleranceField* m_tolerance;
|
||||
ContiguousField* m_contiguous;
|
||||
|
@ -224,6 +227,7 @@ private:
|
|||
obs::scoped_connection m_opacityConn;
|
||||
obs::scoped_connection m_freehandAlgoConn;
|
||||
obs::scoped_connection m_contiguousConn;
|
||||
obs::scoped_connection m_cornerRadiusConn;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
|
Loading…
Reference in New Issue