Save last used dithering algorithm converting RGB -> Indexed

This commit is contained in:
David Capello 2019-04-03 11:05:54 -03:00
parent b6d07d995f
commit 495058e8ff
2 changed files with 21 additions and 0 deletions

View File

@ -236,6 +236,7 @@
</section>
<section id="quantization">
<option id="with_alpha" type="bool" default="true" />
<option id="dithering_algorithm" type="std::string" />
</section>
<section id="eyedropper" text="Editor">
<option id="channel" type="EyedropperChannel" default="EyedropperChannel::COLOR_ALPHA" />

View File

@ -196,6 +196,15 @@ public:
m_ditheringSelector = new DitheringSelector(DitheringSelector::SelectBoth);
m_ditheringSelector->setExpansive(true);
// Select default dithering method
{
int index = m_ditheringSelector->findItemIndex(
Preferences::instance().quantization.ditheringAlgorithm());
if (index >= 0)
m_ditheringSelector->setSelectedItemIndex(index);
}
m_ditheringSelector->Change.connect(
base::Bind<void>(&ColorModeWindow::onDithering, this));
ditheringPlaceholder()->addChild(m_ditheringSelector);
@ -239,6 +248,15 @@ public:
return flatten()->isSelected();
}
// Save the dithering method used for the future
void saveDitheringAlgorithm() {
if (m_ditheringSelector) {
if (auto item = m_ditheringSelector->getSelectedItem()) {
Preferences::instance().quantization.ditheringAlgorithm(item->text());
}
}
}
private:
void stop() {
@ -466,6 +484,8 @@ void ChangePixelFormatCommand::onExecute(Context* context)
m_ditheringAlgorithm = window.ditheringAlgorithm();
m_ditheringMatrix = window.ditheringMatrix();
flatten = window.flattenEnabled();
window.saveDitheringAlgorithm();
}
#endif // ENABLE_UI