| 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()) { |
| 747 | ResourceData newResource; |
| 748 | newResource.data = std::make_shared<std::string>(fileBuffer); |
| 749 | newResource.name = fileName; |
| 750 | NetworkingObjects::NetObjID imageID = world.rMan.add_resource(newResource).get_net_id(); |
| 751 | ResourceDisplay* display = world.rMan.get_display_data(imageID); |
| 752 | Vector2f imTrueDim = display->get_dimensions(); |
| 753 | CanvasComponentContainer* newContainer = new CanvasComponentContainer(world.netObjMan, CanvasComponentType::IMAGE); |
| 754 | ImageCanvasComponent& img = static_cast<ImageCanvasComponent&>(newContainer->get_comp()); |
| 755 | newContainer->coords = world.drawData.cam.c; |
| 756 | float imWidth = imTrueDim.x() / (imTrueDim.x() + imTrueDim.y()); |
| 757 | float imHeight = imTrueDim.y() / (imTrueDim.x() + imTrueDim.y()); |
| 758 | Vector2f imDim = Vector2f{world.main.window.size.x() * imWidth, world.main.window.size.x() * imHeight} * display->get_dimension_scale(); |
| 759 | img.d.p1 = dropPos - imDim; |
| 760 | img.d.p2 = dropPos + imDim; |
| 761 | img.d.imageID = imageID; |
| 762 | CanvasComponentContainer::ObjInfo* newObjInfo = layerMan.add_component_to_layer_being_edited(newContainer); |
| 763 | layerMan.add_undo_place_component(newObjInfo); |
| 764 | return newObjInfo; |
| 765 | } |
| 766 | return nullptr; |
| 767 | } |
| 768 | |
| 769 | float DrawingProgram::drag_point_radius() { |
| 770 | return (world.main.g.gui.io.isTouchDevice ? 10.0f : 8.0f) * world.main.g.final_gui_scale(); |
no test coverage detected