Grid modify tool and drag drop work with events
This commit is contained in:
parent
e39c94ff19
commit
a7030059a4
11 changed files with 166 additions and 114 deletions
|
|
@ -52,6 +52,31 @@ void DrawingProgram::on_tab_out() {
|
||||||
controls.middleClickHeld = false;
|
controls.middleClickHeld = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawingProgram::input_drop_file_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(world.main.toolbar.check_if_position_isnt_obstructed(drop.pos) && std::filesystem::is_regular_file(drop.data)) {
|
||||||
|
#ifdef __EMSCRIPTEN_
|
||||||
|
add_file_to_canvas_by_path(drop.data, world.main.input.mouse.pos, true);
|
||||||
|
#else
|
||||||
|
add_file_to_canvas_by_path(drop.data, drop.pos, true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawingProgram::input_drop_text_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(world.main.toolbar.check_if_position_isnt_obstructed(drop.pos) && is_valid_http_url(drop.data)) {
|
||||||
|
CanvasComponentContainer* newContainer = new CanvasComponentContainer(world.netObjMan, CanvasComponentType::IMAGE);
|
||||||
|
ImageCanvasComponent& img = static_cast<ImageCanvasComponent&>(newContainer->get_comp());
|
||||||
|
newContainer->coords = world.drawData.cam.c;
|
||||||
|
Vector2f imDim = Vector2f{100.0f, 100.0f};
|
||||||
|
img.d.p1 = drop.pos - imDim;
|
||||||
|
img.d.p2 = drop.pos + imDim;
|
||||||
|
img.d.imageID = {0, 0};
|
||||||
|
auto newObjInfo = layerMan.add_component_to_layer_being_edited(newContainer);
|
||||||
|
layerMan.add_undo_place_component(newObjInfo);
|
||||||
|
droppedDownloadingFiles.emplace_back(newObjInfo, world.main.window.size.cast<float>(), FileDownloader::download_data_from_url(drop.data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||||
auto buttonCallbacks = [&](const InputManager::MouseButtonCallbackArgs& b) {
|
auto buttonCallbacks = [&](const InputManager::MouseButtonCallbackArgs& b) {
|
||||||
drawTool->input_mouse_button_on_canvas_callback(b);
|
drawTool->input_mouse_button_on_canvas_callback(b);
|
||||||
|
|
@ -433,8 +458,6 @@ void DrawingProgram::update() {
|
||||||
addFileInNextFrame = false;
|
addFileInNextFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
drag_drop_update();
|
|
||||||
|
|
||||||
selection.update();
|
selection.update();
|
||||||
drawTool->tool_update();
|
drawTool->tool_update();
|
||||||
|
|
||||||
|
|
@ -527,32 +550,6 @@ void DrawingProgram::rebuild_cache() {
|
||||||
drawCache.build({});
|
drawCache.build({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawingProgram::drag_drop_update() {
|
|
||||||
if(controls.cursorHoveringOverCanvas && layerMan.is_a_layer_being_edited()) {
|
|
||||||
for(auto& droppedItem : world.main.input.droppedItems) {
|
|
||||||
if(droppedItem.dataPath.has_value() && std::filesystem::is_regular_file(droppedItem.dataPath.value())) {
|
|
||||||
#ifdef __EMSCRIPTEN_
|
|
||||||
add_file_to_canvas_by_path(droppedItem.dataPath.value(), world.main.input.mouse.pos, true);
|
|
||||||
#else
|
|
||||||
add_file_to_canvas_by_path(droppedItem.dataPath.value(), droppedItem.pos, true);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if(droppedItem.dataText.has_value() && is_valid_http_url(droppedItem.dataText.value())) {
|
|
||||||
CanvasComponentContainer* newContainer = new CanvasComponentContainer(world.netObjMan, CanvasComponentType::IMAGE);
|
|
||||||
ImageCanvasComponent& img = static_cast<ImageCanvasComponent&>(newContainer->get_comp());
|
|
||||||
newContainer->coords = world.drawData.cam.c;
|
|
||||||
Vector2f imDim = Vector2f{100.0f, 100.0f};
|
|
||||||
img.d.p1 = droppedItem.pos - imDim;
|
|
||||||
img.d.p2 = droppedItem.pos + imDim;
|
|
||||||
img.d.imageID = {0, 0};
|
|
||||||
auto newObjInfo = layerMan.add_component_to_layer_being_edited(newContainer);
|
|
||||||
layerMan.add_undo_place_component(newObjInfo);
|
|
||||||
droppedDownloadingFiles.emplace_back(newObjInfo, world.main.window.size.cast<float>(), FileDownloader::download_data_from_url(droppedItem.dataText.value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawingProgram::update_downloading_dropped_files() {
|
void DrawingProgram::update_downloading_dropped_files() {
|
||||||
std::erase_if(droppedDownloadingFiles, [&](auto& downFile) {
|
std::erase_if(droppedDownloadingFiles, [&](auto& downFile) {
|
||||||
switch(downFile.downData->status) {
|
switch(downFile.downData->status) {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ class DrawingProgram {
|
||||||
void send_transforms_for(const std::vector<CanvasComponentContainer::ObjInfo*>& objsToSendTransformsFor);
|
void send_transforms_for(const std::vector<CanvasComponentContainer::ObjInfo*>& objsToSendTransformsFor);
|
||||||
|
|
||||||
void on_tab_out();
|
void on_tab_out();
|
||||||
|
void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
|
void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||||
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
||||||
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,76 @@ DrawingProgramToolType GridModifyTool::get_type() {
|
||||||
void GridModifyTool::erase_component(CanvasComponentContainer::ObjInfo* erasedComp) {
|
void GridModifyTool::erase_component(CanvasComponentContainer::ObjInfo* erasedComp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GridModifyTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||||
|
if(button.button == InputManager::MouseButton::LEFT) {
|
||||||
|
switch(selectionMode) {
|
||||||
|
case 0:
|
||||||
|
if(button.down) {
|
||||||
|
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
||||||
|
if(gLock) {
|
||||||
|
WorldGrid& g = *gLock;
|
||||||
|
Vector2f gOffsetScreenPos = drawP.world.drawData.cam.c.to_space(g.offset);
|
||||||
|
Vector2f gSizeScreenPos = drawP.world.drawData.cam.c.to_space(g.offset + WorldVec{g.size, 0});
|
||||||
|
if(SCollision::collide(SCollision::Circle(gOffsetScreenPos, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
||||||
|
selectionMode = 1;
|
||||||
|
else if(SCollision::collide(SCollision::Circle(gSizeScreenPos, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
||||||
|
selectionMode = 2;
|
||||||
|
else if(g.bounds.has_value()) {
|
||||||
|
const auto& b = g.bounds.value();
|
||||||
|
Vector2f bMin = drawP.world.drawData.cam.c.to_space(b.min);
|
||||||
|
Vector2f bMax = drawP.world.drawData.cam.c.to_space(b.max);
|
||||||
|
if(SCollision::collide(SCollision::Circle(bMin, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
||||||
|
selectionMode = 3;
|
||||||
|
else if(SCollision::collide(SCollision::Circle(bMax, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
||||||
|
selectionMode = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
if(!button.down)
|
||||||
|
selectionMode = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridModifyTool::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) {
|
||||||
|
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
||||||
|
if(gLock) {
|
||||||
|
WorldGrid& g = *gLock;
|
||||||
|
switch(selectionMode) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
g.offset = drawP.world.get_mouse_world_pos();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
g.size = std::max(FixedPoint::abs(drawP.world.get_mouse_world_pos().x() - g.offset.x()), WorldScalar(1));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if(g.bounds.has_value()) {
|
||||||
|
auto& b = g.bounds.value();
|
||||||
|
b.min = cwise_vec_min(drawP.world.get_mouse_world_pos(), b.max);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
selectionMode = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if(g.bounds.has_value()) {
|
||||||
|
auto& b = g.bounds.value();
|
||||||
|
b.max = cwise_vec_max(drawP.world.get_mouse_world_pos(), b.min);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
selectionMode = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GridModifyTool::gui_toolbox() {
|
void GridModifyTool::gui_toolbox() {
|
||||||
Toolbar& t = drawP.world.main.toolbar;
|
Toolbar& t = drawP.world.main.toolbar;
|
||||||
t.gui.push_id("Grid modify tool");
|
t.gui.push_id("Grid modify tool");
|
||||||
|
|
@ -93,60 +163,7 @@ bool GridModifyTool::right_click_popup_gui(Vector2f popupPos) {
|
||||||
|
|
||||||
void GridModifyTool::tool_update() {
|
void GridModifyTool::tool_update() {
|
||||||
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
||||||
if(gLock) {
|
if(!gLock)
|
||||||
WorldGrid& g = *gLock;
|
|
||||||
switch(selectionMode) {
|
|
||||||
case 0:
|
|
||||||
if(drawP.controls.leftClick) {
|
|
||||||
Vector2f gOffsetScreenPos = drawP.world.drawData.cam.c.to_space(g.offset);
|
|
||||||
Vector2f gSizeScreenPos = drawP.world.drawData.cam.c.to_space(g.offset + WorldVec{g.size, 0});
|
|
||||||
if(SCollision::collide(SCollision::Circle(gOffsetScreenPos, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
|
||||||
selectionMode = 1;
|
|
||||||
else if(SCollision::collide(SCollision::Circle(gSizeScreenPos, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
|
||||||
selectionMode = 2;
|
|
||||||
else if(g.bounds.has_value()) {
|
|
||||||
const auto& b = g.bounds.value();
|
|
||||||
Vector2f bMin = drawP.world.drawData.cam.c.to_space(b.min);
|
|
||||||
Vector2f bMax = drawP.world.drawData.cam.c.to_space(b.max);
|
|
||||||
if(SCollision::collide(SCollision::Circle(bMin, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
|
||||||
selectionMode = 3;
|
|
||||||
else if(SCollision::collide(SCollision::Circle(bMax, drawP.drag_point_radius()), drawP.world.main.input.mouse.pos))
|
|
||||||
selectionMode = 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if(drawP.controls.leftClickHeld)
|
|
||||||
g.offset = drawP.world.get_mouse_world_pos();
|
|
||||||
else
|
|
||||||
selectionMode = 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if(drawP.controls.leftClickHeld)
|
|
||||||
g.size = std::max(FixedPoint::abs(drawP.world.get_mouse_world_pos().x() - g.offset.x()), WorldScalar(1));
|
|
||||||
else
|
|
||||||
selectionMode = 0;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if(drawP.controls.leftClickHeld && g.bounds.has_value()) {
|
|
||||||
auto& b = g.bounds.value();
|
|
||||||
b.min = cwise_vec_min(drawP.world.get_mouse_world_pos(), b.max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
selectionMode = 0;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if(drawP.controls.leftClickHeld && g.bounds.has_value()) {
|
|
||||||
auto& b = g.bounds.value();
|
|
||||||
b.max = cwise_vec_max(drawP.world.get_mouse_world_pos(), b.min);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
selectionMode = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
drawP.world.delayedUpdateObjectManager.send_update_to_all<WorldGrid>(gLock, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
selectionMode = 0;
|
selectionMode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ class GridModifyTool : public DrawingProgramToolBase {
|
||||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||||
virtual bool prevent_undo_or_redo() override;
|
virtual bool prevent_undo_or_redo() override;
|
||||||
virtual void switch_tool(DrawingProgramToolType newTool) override;
|
virtual void switch_tool(DrawingProgramToolType newTool) override;
|
||||||
|
virtual void input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) override;
|
||||||
|
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) override;
|
||||||
private:
|
private:
|
||||||
WorldGrid oldGrid;
|
WorldGrid oldGrid;
|
||||||
NetworkingObjects::NetObjWeakPtr<WorldGrid> grid;
|
NetworkingObjects::NetObjWeakPtr<WorldGrid> grid;
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,28 @@ uint32_t InputManager::make_generic_key_mod(SDL_Keymod m) {
|
||||||
return toRet;
|
return toRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputManager::backend_drop_file_event(const SDL_DropEvent& e) {
|
||||||
|
Vector2f mousePos = {e.x * main.window.density, e.y * main.window.density};
|
||||||
|
mouse.set_pos(mousePos);
|
||||||
|
|
||||||
|
main.input_drop_file_callback({
|
||||||
|
.pos = mousePos,
|
||||||
|
.source = e.source,
|
||||||
|
.data = e.data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputManager::backend_drop_text_event(const SDL_DropEvent& e) {
|
||||||
|
Vector2f mousePos = {e.x * main.window.density, e.y * main.window.density};
|
||||||
|
mouse.set_pos(mousePos);
|
||||||
|
|
||||||
|
main.input_drop_text_callback({
|
||||||
|
.pos = mousePos,
|
||||||
|
.source = e.source,
|
||||||
|
.data = e.data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void InputManager::backend_mouse_button_up_update(const SDL_MouseButtonEvent& e) {
|
void InputManager::backend_mouse_button_up_update(const SDL_MouseButtonEvent& e) {
|
||||||
Vector2f mousePos = {e.x * main.window.density, e.y * main.window.density};
|
Vector2f mousePos = {e.x * main.window.density, e.y * main.window.density};
|
||||||
mouse.set_pos(mousePos);
|
mouse.set_pos(mousePos);
|
||||||
|
|
@ -902,8 +924,6 @@ void InputManager::frame_reset(const Vector2i& windowSize) {
|
||||||
mouse.rightClicks = 0;
|
mouse.rightClicks = 0;
|
||||||
mouse.middleClicks = 0;
|
mouse.middleClicks = 0;
|
||||||
|
|
||||||
droppedItems.clear();
|
|
||||||
|
|
||||||
cursorIcon = SystemCursorType::DEFAULT;
|
cursorIcon = SystemCursorType::DEFAULT;
|
||||||
|
|
||||||
for(auto& p : keys) {
|
for(auto& p : keys) {
|
||||||
|
|
|
||||||
|
|
@ -122,12 +122,6 @@ struct InputManager {
|
||||||
friend struct InputManager;
|
friend struct InputManager;
|
||||||
} text;
|
} text;
|
||||||
|
|
||||||
struct DroppedItem {
|
|
||||||
Vector2f pos;
|
|
||||||
std::optional<std::string> dataText;
|
|
||||||
std::optional<std::filesystem::path> dataPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
SDL_Keymod CTRL_MOD = SDL_KMOD_GUI;
|
SDL_Keymod CTRL_MOD = SDL_KMOD_GUI;
|
||||||
#else
|
#else
|
||||||
|
|
@ -137,8 +131,6 @@ struct InputManager {
|
||||||
int stopKeyInput = 0;
|
int stopKeyInput = 0;
|
||||||
std::optional<Vector2ui32> lastPressedKeybind;
|
std::optional<Vector2ui32> lastPressedKeybind;
|
||||||
|
|
||||||
std::vector<DroppedItem> droppedItems;
|
|
||||||
|
|
||||||
void text_input_silence_everything();
|
void text_input_silence_everything();
|
||||||
|
|
||||||
enum KeyCodeEnum : unsigned {
|
enum KeyCodeEnum : unsigned {
|
||||||
|
|
@ -213,6 +205,8 @@ struct InputManager {
|
||||||
void set_key_up(const SDL_KeyboardEvent& e, KeyCode kCode);
|
void set_key_up(const SDL_KeyboardEvent& e, KeyCode kCode);
|
||||||
void set_key_down(const SDL_KeyboardEvent& e, KeyCode kCode);
|
void set_key_down(const SDL_KeyboardEvent& e, KeyCode kCode);
|
||||||
|
|
||||||
|
void backend_drop_file_event(const SDL_DropEvent& e);
|
||||||
|
void backend_drop_text_event(const SDL_DropEvent& e);
|
||||||
void backend_mouse_button_up_update(const SDL_MouseButtonEvent& e);
|
void backend_mouse_button_up_update(const SDL_MouseButtonEvent& e);
|
||||||
void backend_mouse_button_down_update(const SDL_MouseButtonEvent& e);
|
void backend_mouse_button_down_update(const SDL_MouseButtonEvent& e);
|
||||||
void backend_mouse_motion_update(const SDL_MouseMotionEvent& e);
|
void backend_mouse_motion_update(const SDL_MouseMotionEvent& e);
|
||||||
|
|
@ -297,6 +291,12 @@ struct InputManager {
|
||||||
float value;
|
float value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DropCallbackArgs {
|
||||||
|
Vector2f pos;
|
||||||
|
const char* source;
|
||||||
|
const char* data;
|
||||||
|
};
|
||||||
|
|
||||||
MainProgram& main;
|
MainProgram& main;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,20 +68,6 @@ void MainProgram::update() {
|
||||||
while(std::chrono::duration_cast<std::chrono::duration<float>>(std::chrono::steady_clock::now() - lastFrameTime).count() < 1.0 / fpsLimit);
|
while(std::chrono::duration_cast<std::chrono::duration<float>>(std::chrono::steady_clock::now() - lastFrameTime).count() < 1.0 / fpsLimit);
|
||||||
lastFrameTime = std::chrono::steady_clock::now();
|
lastFrameTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
std::erase_if(input.droppedItems, [&](auto& droppedItem) {
|
|
||||||
if(droppedItem.dataPath.has_value() && std::filesystem::is_regular_file(droppedItem.dataPath.value())) {
|
|
||||||
const std::filesystem::path& droppedFilePath = droppedItem.dataPath.value();
|
|
||||||
if(droppedFilePath.has_extension() && droppedFilePath.extension().string() == std::string("." + World::FILE_EXTENSION)) {
|
|
||||||
new_tab({
|
|
||||||
.isClient = false,
|
|
||||||
.filePathSource = droppedFilePath
|
|
||||||
}, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
for(auto& s : setTabsToClose)
|
for(auto& s : setTabsToClose)
|
||||||
std::erase(worlds, s.lock());
|
std::erase(worlds, s.lock());
|
||||||
|
|
||||||
|
|
@ -310,6 +296,26 @@ sk_sp<SkSurface> MainProgram::create_native_surface(Vector2i resolution, bool is
|
||||||
return surfaceToRet;
|
return surfaceToRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainProgram::input_drop_file_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(std::filesystem::is_regular_file(drop.data)) {
|
||||||
|
std::filesystem::path droppedFilePath(drop.data);
|
||||||
|
if(droppedFilePath.has_extension() && droppedFilePath.extension().string() == std::string("." + World::FILE_EXTENSION)) {
|
||||||
|
new_tab({
|
||||||
|
.isClient = false,
|
||||||
|
.filePathSource = droppedFilePath
|
||||||
|
}, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(world)
|
||||||
|
world->input_drop_file_callback(drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainProgram::input_drop_text_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(world)
|
||||||
|
world->input_drop_text_callback(drop);
|
||||||
|
}
|
||||||
|
|
||||||
void MainProgram::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
void MainProgram::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||||
switch(key.key) {
|
switch(key.key) {
|
||||||
case InputManager::KEY_NOGUI: {
|
case InputManager::KEY_NOGUI: {
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,8 @@ class MainProgram {
|
||||||
|
|
||||||
std::string displayName;
|
std::string displayName;
|
||||||
|
|
||||||
|
void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
|
void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||||
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
||||||
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,16 @@ void World::on_tab_out() {
|
||||||
rMan.clear_display_cache();
|
rMan.clear_display_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::input_drop_file_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(!clientStillConnecting)
|
||||||
|
drawProg.input_drop_file_callback(drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::input_drop_text_callback(const InputManager::DropCallbackArgs& drop) {
|
||||||
|
if(!clientStillConnecting)
|
||||||
|
drawProg.input_drop_text_callback(drop);
|
||||||
|
}
|
||||||
|
|
||||||
void World::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
void World::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||||
if(!clientStillConnecting) {
|
if(!clientStillConnecting) {
|
||||||
switch(key.key) {
|
switch(key.key) {
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,8 @@ class World {
|
||||||
std::shared_ptr<NetServer> netServer;
|
std::shared_ptr<NetServer> netServer;
|
||||||
std::shared_ptr<NetClient> netClient;
|
std::shared_ptr<NetClient> netClient;
|
||||||
|
|
||||||
|
void input_drop_file_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
|
void input_drop_text_callback(const InputManager::DropCallbackArgs& drop);
|
||||||
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||||
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button);
|
||||||
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion);
|
||||||
|
|
|
||||||
10
src/main.cpp
10
src/main.cpp
|
|
@ -762,17 +762,11 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_DROP_FILE:
|
case SDL_EVENT_DROP_FILE:
|
||||||
mS.m->update_scale_and_density();
|
mS.m->update_scale_and_density();
|
||||||
mS.m->input.droppedItems.emplace_back(InputManager::DroppedItem{
|
mS.m->input.backend_drop_file_event(event->drop);
|
||||||
.pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.density,
|
|
||||||
.dataPath = std::u8string_view(reinterpret_cast<const char8_t*>(event->drop.data))
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_DROP_TEXT:
|
case SDL_EVENT_DROP_TEXT:
|
||||||
mS.m->update_scale_and_density();
|
mS.m->update_scale_and_density();
|
||||||
mS.m->input.droppedItems.emplace_back(InputManager::DroppedItem{
|
mS.m->input.backend_drop_text_event(event->drop);
|
||||||
.pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.density,
|
|
||||||
.dataText = event->drop.data
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_PEN_PROXIMITY_IN: {
|
case SDL_EVENT_PEN_PROXIMITY_IN: {
|
||||||
mS.m->input.pen.inProximity = true;
|
mS.m->input.pen.inProximity = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue