Fixed Add file to canvas in web version
This commit is contained in:
parent
f43e89161c
commit
c479ccb9e2
3 changed files with 9 additions and 3 deletions
|
|
@ -87,7 +87,7 @@ namespace CustomEvents {
|
|||
std::string name;
|
||||
std::string buffer;
|
||||
std::filesystem::path filePath;
|
||||
Vector2f pos;
|
||||
Vector2f pos = {0.0f, 0.0f};
|
||||
};
|
||||
|
||||
struct RefreshTextBoxInputEvent {
|
||||
|
|
|
|||
|
|
@ -712,7 +712,11 @@ void DrawingProgram::update_downloading_dropped_files() {
|
|||
}
|
||||
|
||||
void DrawingProgram::input_add_file_to_canvas_callback(const CustomEvents::AddFileToCanvasEvent& addFile) {
|
||||
add_file_to_canvas_by_path(addFile.filePath, addFile.pos);
|
||||
if(addFile.type == CustomEvents::AddFileToCanvasEvent::Type::PATH)
|
||||
add_file_to_canvas_by_path(addFile.filePath, addFile.pos);
|
||||
else
|
||||
add_file_to_canvas_by_data(addFile.name, addFile.buffer, addFile.pos);
|
||||
|
||||
}
|
||||
|
||||
void DrawingProgram::add_file_to_canvas_by_path(const std::filesystem::path& filePath, Vector2f dropPos) {
|
||||
|
|
|
|||
|
|
@ -537,10 +537,12 @@ void Toolbar::top_toolbar() {
|
|||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_browser_file::upload("*", [](std::string const& fileName, std::string const& mimeType, std::string_view buffer, void* callbackData) {
|
||||
if(!buffer.empty()) {
|
||||
MainProgram* m = static_cast<MainProgram*>(callbackData);
|
||||
CustomEvents::emit_event<CustomEvents::AddFileToCanvasEvent>({
|
||||
.type = CustomEvents::AddFileToCanvasEvent::Type::BUFFER,
|
||||
.name = fileName,
|
||||
.buffer = std::string(buffer)
|
||||
.buffer = std::string(buffer),
|
||||
.pos = m->window.size.cast<float>() / 2.0f
|
||||
});
|
||||
}
|
||||
}, &main);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue