update colors on HEX clipboard paste

This commit is contained in:
2019-07-28 15:19:13 +02:00
parent 170fee273e
commit 087894451b

View File

@@ -93,7 +93,7 @@ void NodeColorPicker::init_controls()
m_btn_paste->on_click = [this](Node*)
{
std::string s = App::I->clipboard_get_text();
std::regex r("#([\\dabcdefABCDEF]{6})");
std::regex r("#?([\\dabcdefABCDEF]{6})");
std::smatch m;
if (std::regex_search(s, m, r))
{
@@ -103,6 +103,8 @@ void NodeColorPicker::init_controls()
uint8_t r = (ul >> 16) & 0xFF;
auto rgb = glm::vec3(r, g, b) / 255.f;
set_color(rgb);
if (on_color_change)
on_color_change(this, rgb);
}
};