fix update tips after importing brushes
This commit is contained in:
@@ -183,43 +183,7 @@ void NodePanelBrush::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_container->m_children.empty() && !m_dir_name.empty())
|
if (m_container->m_children.empty() && !m_dir_name.empty())
|
||||||
{
|
scan();
|
||||||
auto icons = Asset::list_files("data/" + m_dir_name, ".*\\.png$");
|
|
||||||
for (auto& i : icons)
|
|
||||||
{
|
|
||||||
std::string path = "data/" + m_dir_name + "/thumbs/" + i;
|
|
||||||
std::string path_hi = "data/" + m_dir_name + "/" + i;
|
|
||||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
|
||||||
m_container->add_child(brush);
|
|
||||||
brush->init();
|
|
||||||
brush->create();
|
|
||||||
brush->loaded();
|
|
||||||
brush->set_icon(path.c_str());
|
|
||||||
brush->thumb_path = path;
|
|
||||||
brush->high_path = path_hi;
|
|
||||||
brush->brush_name = i;
|
|
||||||
brush->m_user_brush = false; // system brush, cannot be deleted from file
|
|
||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto custom_icons = Asset::list_files(App::I->data_path + "/" + m_dir_name, ".*\\.png$");
|
|
||||||
for (auto& i : custom_icons)
|
|
||||||
{
|
|
||||||
std::string path_thumb = App::I->data_path + "/" + m_dir_name + "/thumbs/" + i;
|
|
||||||
std::string path_high = App::I->data_path + "/" + m_dir_name + "/" + i;
|
|
||||||
NodeButtonBrush* brush = new NodeButtonBrush;
|
|
||||||
m_container->add_child(brush);
|
|
||||||
brush->init();
|
|
||||||
brush->create();
|
|
||||||
brush->loaded();
|
|
||||||
brush->set_icon(path_thumb.c_str());
|
|
||||||
brush->thumb_path = path_thumb;
|
|
||||||
brush->high_path = path_high;
|
|
||||||
brush->brush_name = i;
|
|
||||||
brush->m_user_brush = true;
|
|
||||||
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +327,52 @@ void NodePanelBrush::clear()
|
|||||||
m_container->remove_all_children();
|
m_container->remove_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodePanelBrush::scan()
|
||||||
|
{
|
||||||
|
auto icons = Asset::list_files("data/" + m_dir_name, ".*\\.png$");
|
||||||
|
for (auto& i : icons)
|
||||||
|
{
|
||||||
|
std::string path = "data/" + m_dir_name + "/thumbs/" + i;
|
||||||
|
std::string path_hi = "data/" + m_dir_name + "/" + i;
|
||||||
|
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||||
|
m_container->add_child(brush);
|
||||||
|
brush->init();
|
||||||
|
brush->create();
|
||||||
|
brush->loaded();
|
||||||
|
brush->set_icon(path.c_str());
|
||||||
|
brush->thumb_path = path;
|
||||||
|
brush->high_path = path_hi;
|
||||||
|
brush->brush_name = i;
|
||||||
|
brush->m_user_brush = false; // system brush, cannot be deleted from file
|
||||||
|
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto custom_icons = Asset::list_files(App::I->data_path + "/" + m_dir_name, ".*\\.png$");
|
||||||
|
for (auto& i : custom_icons)
|
||||||
|
{
|
||||||
|
std::string path_thumb = App::I->data_path + "/" + m_dir_name + "/thumbs/" + i;
|
||||||
|
std::string path_high = App::I->data_path + "/" + m_dir_name + "/" + i;
|
||||||
|
NodeButtonBrush* brush = new NodeButtonBrush;
|
||||||
|
m_container->add_child(brush);
|
||||||
|
brush->init();
|
||||||
|
brush->create();
|
||||||
|
brush->loaded();
|
||||||
|
brush->set_icon(path_thumb.c_str());
|
||||||
|
brush->thumb_path = path_thumb;
|
||||||
|
brush->high_path = path_high;
|
||||||
|
brush->brush_name = i;
|
||||||
|
brush->m_user_brush = true;
|
||||||
|
brush->on_click = std::bind(&NodePanelBrush::handle_click, this, std::placeholders::_1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodePanelBrush::reload()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
scan();
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
void NodePanelBrush::added(Node* parent)
|
void NodePanelBrush::added(Node* parent)
|
||||||
{
|
{
|
||||||
m_interacted = false;
|
m_interacted = false;
|
||||||
@@ -482,7 +492,7 @@ void NodePanelBrushPreset::init()
|
|||||||
};
|
};
|
||||||
m_btn_menu = find<NodeButtonCustom>("btn-menu");
|
m_btn_menu = find<NodeButtonCustom>("btn-menu");
|
||||||
m_btn_menu->on_click = [this](Node* b) {
|
m_btn_menu->on_click = [this](Node* b) {
|
||||||
auto popup = m_manager->instantiate<NodePopupMenu>("tpl-brush-popup");
|
auto popup = add_child_file<NodePopupMenu>("data/dialogs/panel-brushes.xml", "tpl-brush-popup");
|
||||||
popup->SetPosition(b->m_pos.x + b->m_size.x, b->m_pos.y);
|
popup->SetPosition(b->m_pos.x + b->m_size.x, b->m_pos.y);
|
||||||
root()->add_child(popup);
|
root()->add_child(popup);
|
||||||
root()->update();
|
root()->update();
|
||||||
@@ -938,6 +948,8 @@ bool NodePanelBrushPreset::import_ppbr(const std::string& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
App::I->stroke->m_brush_popup->reload();
|
||||||
|
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1015,6 +1027,7 @@ bool NodePanelBrushPreset::import_abr(const std::string& path)
|
|||||||
});
|
});
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
App::I->stroke->m_brush_popup->reload();
|
||||||
pb->destroy();
|
pb->destroy();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ public:
|
|||||||
bool save();
|
bool save();
|
||||||
bool restore();
|
bool restore();
|
||||||
void clear();
|
void clear();
|
||||||
|
void scan();
|
||||||
|
void reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user