Add friendly names for ChangePixelFormat command

This commit is contained in:
David Capello 2017-05-19 10:23:26 -03:00
parent 03276e0264
commit e3701940fb
2 changed files with 46 additions and 0 deletions

View File

@ -428,6 +428,20 @@
<key command="SelectTile">
<param name="mode" value="subtract" />
</key>
<key command="ChangePixelFormat">
<param name="format" value="rgb" />
</key>
<key command="ChangePixelFormat">
<param name="format" value="grayscale" />
</key>
<key command="ChangePixelFormat">
<param name="format" value="indexed" />
<param name="dithering" value="ordered" />
</key>
<key command="ChangePixelFormat">
<param name="format" value="indexed" />
<param name="dithering" value="old-ordered" />
</key>
</commands>
<!-- Keyboard shortcuts to select tools -->

View File

@ -316,6 +316,7 @@ protected:
bool onEnabled(Context* context) override;
bool onChecked(Context* context) override;
void onExecute(Context* context) override;
std::string onGetFriendlyName() const override;
private:
bool m_useUI;
@ -430,6 +431,37 @@ void ChangePixelFormatCommand::onExecute(Context* context)
app_refresh_screen();
}
std::string ChangePixelFormatCommand::onGetFriendlyName() const
{
std::string text = "Change Color Mode";
if (!m_useUI) {
switch (m_format) {
case IMAGE_RGB:
text += " to RGB";
break;
case IMAGE_INDEXED:
text += " to Indexed";
switch (m_dithering) {
case render::DitheringAlgorithm::None:
break;
case render::DitheringAlgorithm::OldOrdered:
text += " with Old Ordered Dithering";
break;
case render::DitheringAlgorithm::Ordered:
text += " with Ordered Dithering";
break;
}
break;
case IMAGE_GRAYSCALE:
text += " to Grayscale";
break;
}
}
return text;
}
Command* CommandFactory::createChangePixelFormatCommand()
{
return new ChangePixelFormatCommand;