| 719 | } |
| 720 | |
| 721 | void DrawingProgram::add_file_to_canvas_by_path(const std::filesystem::path& filePath, Vector2f dropPos) { |
| 722 | if(layerMan.is_a_layer_being_edited()) { |
| 723 | NetworkingObjects::NetObjTemporaryPtr<ResourceData> imageTempPtr = world.rMan.add_resource_file(filePath); |
| 724 | if(imageTempPtr) { |
| 725 | NetworkingObjects::NetObjID imageID = imageTempPtr.get_net_id(); |
| 726 | ResourceDisplay* display = world.rMan.get_display_data(imageID); |
| 727 | Vector2f imTrueDim = display->get_dimensions(); |
| 728 | CanvasComponentContainer* newContainer = new CanvasComponentContainer(world.netObjMan, CanvasComponentType::IMAGE); |
| 729 | ImageCanvasComponent& img = static_cast<ImageCanvasComponent&>(newContainer->get_comp()); |
| 730 | newContainer->coords = world.drawData.cam.c; |
| 731 | if(world.main.g.gui.io.isTouchDevice) |
| 732 | newContainer->coords.scale_about_double(world.drawData.cam.c.from_space(dropPos), 1.0 / world.main.get_scale_and_density_factor_gui()); |
| 733 | float imWidth = imTrueDim.x() / (imTrueDim.x() + imTrueDim.y()); |
| 734 | float imHeight = imTrueDim.y() / (imTrueDim.x() + imTrueDim.y()); |
| 735 | Vector2f imDim = Vector2f{world.main.window.size.x() * imWidth, world.main.window.size.x() * imHeight} * display->get_dimension_scale(); |
| 736 | img.d.p1 = dropPos - imDim; |
| 737 | img.d.p2 = dropPos + imDim; |
| 738 | img.d.imageID = imageID; |
| 739 | auto newObjInfo = layerMan.add_component_to_layer_being_edited(newContainer); |
| 740 | layerMan.add_undo_place_component(newObjInfo); |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | CanvasComponentContainer::ObjInfo* DrawingProgram::add_file_to_canvas_by_data(const std::string& fileName, std::string_view fileBuffer, Vector2f dropPos) { |
| 746 | if(layerMan.is_a_layer_being_edited()) { |
nothing calls this directly
no test coverage detected