From 6345979d2eae19550dff441d52c8aea771c47229 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 2 May 2024 20:21:50 +0900 Subject: [PATCH] =?utf8?q?=E3=83=9E=E3=82=A6=E3=82=B9=E3=81=A7=E3=81=AE?= =?utf8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.c b/main.c index 300f39c..3d08ff2 100644 --- a/main.c +++ b/main.c @@ -18,6 +18,9 @@ int screenHeight; int init = 0; SDL_Rect renderQuad; +// マウス +int mouseX, mouseY, drag = 0; + const char* sofname = "mivfx"; const char* version = "0.5.0"; @@ -73,6 +76,29 @@ void windowevent(SDL_Event e) { } else if (e.key.keysym.sym == SDLK_a) { // GIFアニメーションの停止・続き、0.6.0から追加する予定 } + } else if (e.type == SDL_MOUSEBUTTONDOWN) { + if (e.button.button == SDL_BUTTON_LEFT) { + drag = 1; + SDL_GetMouseState(&mouseX, &mouseY); + } + } else if (e.type == SDL_MOUSEBUTTONUP) { + if (e.button.button == SDL_BUTTON_LEFT) { + drag = 0; + } + } else if (e.type == SDL_MOUSEMOTION) { + if (drag) { + // TODO: 画像サイズを変わらないと、画面が黒くになる + int newMouseX, newMouseY; + SDL_GetMouseState(&newMouseX, &newMouseY); + SDL_RenderClear(renderer); + + renderQuad.x = newMouseX - (renderQuad.w / 2); + renderQuad.y = newMouseY - (renderQuad.h / 2); + + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, texture, NULL, &renderQuad); + SDL_RenderPresent(renderer); + } } else if (e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED) { // ウィンドウのサイズが変わった場合 int newWidth = e.window.data1; -- 2.43.0