mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-03 13:39:02 +00:00
Add option to switch dynamic gradient between BG>FG and FG>BG
This commit is contained in:
parent
4087bd5782
commit
4123e98d16
@ -41,7 +41,7 @@
|
||||
|
||||
<label id="gradient_label" text="@.gradient" style="mini_label" />
|
||||
<hbox id="gradient_placeholder" cell_vspan="2" />
|
||||
<boxfiller />
|
||||
<link id="gradient_from_to" style="mini_label" />
|
||||
|
||||
<separator id="separator2" text="@.sensors_tweaks" horizontal="true" cell_hspan="2" />
|
||||
|
||||
|
@ -19,6 +19,11 @@ namespace tools {
|
||||
Velocity,
|
||||
};
|
||||
|
||||
enum class ColorFromTo {
|
||||
BgToFg,
|
||||
FgToBg,
|
||||
};
|
||||
|
||||
struct DynamicsOptions {
|
||||
DynamicSensor size = DynamicSensor::Static;
|
||||
DynamicSensor angle = DynamicSensor::Static;
|
||||
@ -26,6 +31,7 @@ namespace tools {
|
||||
int minSize = 0;
|
||||
int minAngle = 0;
|
||||
render::DitheringMatrix ditheringMatrix;
|
||||
ColorFromTo colorFromTo = ColorFromTo::BgToFg;
|
||||
float minPressureThreshold = 0.0f, maxPressureThreshold = 1.0f;
|
||||
float minVelocityThreshold = 0.0f, maxVelocityThreshold = 1.0f;
|
||||
|
||||
|
@ -65,8 +65,15 @@ public:
|
||||
|
||||
// For dynamic gradient
|
||||
m_hasDynamicGradient = (m_dynamics.gradient != DynamicSensor::Static);
|
||||
m_primaryColor = loop->getPrimaryColor();
|
||||
m_secondaryColor = loop->getSecondaryColor();
|
||||
if (m_hasDynamicGradient &&
|
||||
m_dynamics.colorFromTo == ColorFromTo::FgToBg) {
|
||||
m_primaryColor = loop->getSecondaryColor();
|
||||
m_secondaryColor = loop->getPrimaryColor();
|
||||
}
|
||||
else {
|
||||
m_primaryColor = loop->getPrimaryColor();
|
||||
m_secondaryColor = loop->getSecondaryColor();
|
||||
}
|
||||
m_lastGradientValue = -1;
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,7 @@ DynamicsPopup::DynamicsPopup(Delegate* delegate)
|
||||
, m_delegate(delegate)
|
||||
, m_dynamics(new gen::Dynamics)
|
||||
, m_ditheringSel(new DitheringSelector(DitheringSelector::SelectMatrix))
|
||||
, m_fromTo(tools::ColorFromTo::BgToFg)
|
||||
{
|
||||
m_dynamics->values()->ItemChange.connect(
|
||||
[this](ButtonSet::Item* item){
|
||||
@ -226,6 +227,14 @@ DynamicsPopup::DynamicsPopup(Delegate* delegate)
|
||||
[this]{
|
||||
m_delegate->setMaxAngle(m_dynamics->maxAngle()->getValue());
|
||||
});
|
||||
m_dynamics->gradientFromTo()->Click.connect(
|
||||
[this]{
|
||||
if (m_fromTo == tools::ColorFromTo::BgToFg)
|
||||
m_fromTo = tools::ColorFromTo::FgToBg;
|
||||
else
|
||||
m_fromTo = tools::ColorFromTo::BgToFg;
|
||||
updateFromToText();
|
||||
});
|
||||
|
||||
m_dynamics->gradientPlaceholder()->addChild(m_ditheringSel);
|
||||
m_dynamics->pressurePlaceholder()->addChild(m_pressureThreshold = new ThresholdSlider);
|
||||
@ -253,6 +262,7 @@ tools::DynamicsOptions DynamicsPopup::getDynamics() const
|
||||
opts.minSize = m_dynamics->minSize()->getValue();
|
||||
opts.minAngle = m_dynamics->minAngle()->getValue();
|
||||
opts.ditheringMatrix = m_ditheringSel->ditheringMatrix();
|
||||
opts.colorFromTo = m_fromTo;
|
||||
|
||||
opts.minPressureThreshold = m_pressureThreshold->minThreshold();
|
||||
opts.maxPressureThreshold = m_pressureThreshold->maxThreshold();
|
||||
@ -349,6 +359,8 @@ void DynamicsPopup::onValuesChange(ButtonSet::Item* item)
|
||||
|
||||
m_dynamics->gradientLabel()->setVisible(needsGradient);
|
||||
m_dynamics->gradientPlaceholder()->setVisible(needsGradient);
|
||||
m_dynamics->gradientFromTo()->setVisible(needsGradient);
|
||||
updateFromToText();
|
||||
|
||||
m_dynamics->separator()->setVisible(any);
|
||||
m_dynamics->options()->setVisible(any);
|
||||
@ -369,6 +381,13 @@ void DynamicsPopup::onValuesChange(ButtonSet::Item* item)
|
||||
manager()->invalidateRect(oldBounds);
|
||||
}
|
||||
|
||||
void DynamicsPopup::updateFromToText()
|
||||
{
|
||||
m_dynamics->gradientFromTo()->setText(
|
||||
m_fromTo == tools::ColorFromTo::BgToFg ? "BG > FG":
|
||||
m_fromTo == tools::ColorFromTo::FgToBg ? "FG > BG": "-");
|
||||
}
|
||||
|
||||
bool DynamicsPopup::onProcessMessage(Message* msg)
|
||||
{
|
||||
switch (msg->type()) {
|
||||
|
@ -43,6 +43,7 @@ namespace app {
|
||||
bool isCheck(int i) const;
|
||||
void onValuesChange(ButtonSet::Item* item);
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
void updateFromToText();
|
||||
|
||||
Delegate* m_delegate;
|
||||
gen::Dynamics* m_dynamics;
|
||||
@ -51,6 +52,7 @@ namespace app {
|
||||
ThresholdSlider* m_pressureThreshold;
|
||||
ThresholdSlider* m_velocityThreshold;
|
||||
tools::VelocitySensor m_velocity;
|
||||
tools::ColorFromTo m_fromTo;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
Loading…
Reference in New Issue
Block a user