1
0
mirror of https://github.com/aseprite/aseprite.git synced 2025-02-19 15:40:31 +00:00

Fix problems changing HSV/HSL color sliders with mouse wheel

When we change HSV/HSL sliders, the RGB color is calculated and all
sliders are re-updated from that color. As HSV/HSL are floating point
values, there might be a small adjustment in the 0-100 conversion for
the sliders, so we have to lock the changed slider to keep its
original value set from the mouse wheel.

Fix: https://community.aseprite.org/t/1411
This commit is contained in:
David Capello 2018-07-04 16:28:34 -03:00
parent 7c19744798
commit 3704bb4093
2 changed files with 10 additions and 0 deletions

@ -230,6 +230,7 @@ ColorSliders::ColorSliders()
, m_items(int(Channel::Channels))
, m_grid(3, false)
, m_mode(Mode::Absolute)
, m_lockSlider(-1)
, m_lockEntry(-1)
, m_color(app::Color::fromMask())
{
@ -389,12 +390,18 @@ void ColorSliders::addSlider(const Channel channel,
void ColorSliders::setAbsSliderValue(const Channel i, int value)
{
if (m_lockSlider == i)
return;
m_items[i].absSlider->setValue(value);
updateEntryText(i);
}
void ColorSliders::setRelSliderValue(const Channel i, int value)
{
if (m_lockSlider == i)
return;
m_items[i].relSlider->setValue(value);
updateEntryText(i);
}
@ -427,6 +434,8 @@ void ColorSliders::syncRelHsvHslSliders()
void ColorSliders::onSliderChange(const Channel i)
{
base::ScopedValue<int> lock(m_lockSlider, i, m_lockSlider);
updateEntryText(i);
onControlChange(i);
}

@ -85,6 +85,7 @@ namespace app {
std::vector<Item> m_items;
ui::Grid m_grid;
Mode m_mode;
int m_lockSlider;
int m_lockEntry;
app::Color m_color;
};