void ColorPopup::onSimpleColorClick() { m_colorType.deselectItems(); if (!g_simplePal) return; app::Color color = getColor(); // Find bestfit palette entry int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); int a = color.getAlpha(); // Search for the closest color to the RGB values int i = g_simplePal->findBestfit(r, g, b, a, 0); if (i >= 0) { color_t c = g_simplePal->getEntry(i); color = app::Color::fromRgb(doc::rgba_getr(c), doc::rgba_getg(c), doc::rgba_getb(c), doc::rgba_geta(c)); } setColorWithSignal(color, ChangeType); }
SimpleColors(ColorPopup* colorPopup, TooltipManager* tooltips) { for (int i=0; i<g_simplePal->size(); ++i) { doc::color_t c = g_simplePal->getEntry(i); app::Color color = app::Color::fromRgb(doc::rgba_getr(c), doc::rgba_getg(c), doc::rgba_getb(c), doc::rgba_geta(c)); Item* item = new Item(colorPopup, color); item->InitTheme.connect( [item]{ item->setSizeHint(gfx::Size(16, 16)*ui::guiscale()); item->setStyle(skin::SkinTheme::instance()->styles.simpleColor()); }); item->initTheme(); addChild(item); tooltips->addTooltipFor( item, g_simplePal->getEntryName(i), BOTTOM); } }