Layers work with brush tool

This commit is contained in:
Yousef Khadadeh 2025-12-26 10:10:19 +03:00
parent 067abc8553
commit 702df53794
13 changed files with 151 additions and 57 deletions

View file

@ -7,8 +7,11 @@ DrawingProgramLayerManager::DrawingProgramLayerManager(DrawingProgram& drawProg)
{}
void DrawingProgramLayerManager::init() {
if(drawP.world.netObjMan.is_server())
if(drawP.world.netObjMan.is_server()) {
layerTreeRoot = drawP.world.netObjMan.make_obj_from_ptr<DrawingProgramLayerListItem>(new DrawingProgramLayerListItem(drawP.world.netObjMan, "ROOT", true));
layerTreeRoot->get_folder().set_component_list_callbacks(*this); // Only need to call set_component_list_callbacks on root, and the rest will get the callbacks set as well
editingLayer = layerTreeRoot->get_folder().folderList->emplace_back_direct(layerTreeRoot->get_folder().folderList, drawP.world.netObjMan, "First Layer", false)->obj;
}
}
void DrawingProgramLayerManager::write_components_server(cereal::PortableBinaryOutputArchive& a) {
@ -17,4 +20,15 @@ void DrawingProgramLayerManager::write_components_server(cereal::PortableBinaryO
void DrawingProgramLayerManager::read_components_client(cereal::PortableBinaryInputArchive& a) {
layerTreeRoot = drawP.world.netObjMan.read_create_message<DrawingProgramLayerListItem>(a, nullptr);
layerTreeRoot->commit_update_dont_invalidate_cache(*this);
layerTreeRoot->set_component_list_callbacks(*this);
}
bool DrawingProgramLayerManager::is_a_layer_being_edited() {
return !editingLayer.expired();
}
void DrawingProgramLayerManager::draw(SkCanvas* canvas, const DrawData& drawData) {
if(layerTreeRoot)
layerTreeRoot->draw(canvas, drawData);
}