void ChangeColorCommand::onExecute(Context* context) { ColorBar* colorbar = ColorBar::instance(); app::Color color = m_background ? colorbar->getBgColor(): colorbar->getFgColor(); switch (m_change) { case None: // do nothing break; case IncrementIndex: if (color.getType() == app::Color::IndexType) { int index = color.getIndex(); if (index < get_current_palette()->size()-1) color = app::Color::fromIndex(index+1); } else color = app::Color::fromIndex(0); break; case DecrementIndex: if (color.getType() == app::Color::IndexType) { int index = color.getIndex(); if (index > 0) color = app::Color::fromIndex(index-1); } else color = app::Color::fromIndex(0); break; } if (m_background) colorbar->setBgColor(color); else colorbar->setFgColor(color); }
void ChangeColorCommand::onExecute(Context* context) { ColorBar* colorbar = app_get_colorbar(); Color color = m_background ? colorbar->getBgColor(): colorbar->getFgColor(); switch (m_change) { case None: // do nothing break; case IncrementIndex: if (color.getType() == Color::IndexType) { int index = color.getIndex(); if (index < 255) // TODO use sprite palette limit color = Color::fromIndex(index+1); } else color = Color::fromIndex(0); break; case DecrementIndex: if (color.getType() == Color::IndexType) { int index = color.getIndex(); if (index > 0) color = Color::fromIndex(index-1); } else color = Color::fromIndex(0); break; } if (m_background) colorbar->setBgColor(color); else colorbar->setFgColor(color); }
void SwitchColorsCommand::onExecute(Context* context) { ColorBar* colorbar = ColorBar::instance(); app::Color fg = colorbar->getFgColor(); app::Color bg = colorbar->getBgColor(); colorbar->setFgColor(bg); colorbar->setBgColor(fg); }
void SwitchColorsCommand::onExecute(Context* context) { ASSERT(current_editor); if (!current_editor) return; tools::Tool* tool = current_editor->getCurrentEditorTool(); if (tool) { const auto& toolPref(Preferences::instance().tool(tool)); if (toolPref.ink() == tools::InkType::SHADING) { App::instance()->contextBar()->reverseShadeColors(); } } ColorBar* colorbar = ColorBar::instance(); app::Color fg = colorbar->getFgColor(); app::Color bg = colorbar->getBgColor(); // Change the background and then the foreground color so the color // spectrum and color wheel shows the foreground color as the // selected one. colorbar->setBgColor(fg); colorbar->setFgColor(bg); }