From bedd6906eabdd513042d6a178d4dc56a3a41d1d3 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Fri, 16 Dec 2022 20:16:43 -0500 Subject: v3, file/build organization --- imgui_helper_widgets.cpp | 108 ----------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100644 imgui_helper_widgets.cpp (limited to 'imgui_helper_widgets.cpp') diff --git a/imgui_helper_widgets.cpp b/imgui_helper_widgets.cpp deleted file mode 100644 index 231b4b9..0000000 --- a/imgui_helper_widgets.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// Widgets not directly related to drawing UI. - -// Returns a normalized UV position of the composition -static v2 -ImGui_ScreenPointToCompUV(ImVec2 ViewportMin, ImVec2 CompPos, ImVec2 CompZoom, ImVec2 MousePos) -{ - ImVec2 LocalMousePos = MousePos - ViewportMin; - ImVec2 LocalCompPos = CompPos - ViewportMin; - ImVec2 MouseScreenUV = LocalMousePos - LocalCompPos; - ImVec2 Result = MouseScreenUV / CompZoom; - return V2(Result); -} - -// NOTE(fox): We have to do a bit of hackery here to tell how many times the -// mouse has been warped during a drag, since it doesn't seem like we can rely -// on SDL_WarpMouseGlobal to update on the first frame of a WantSetPos request. - -static void -ImGui_WarpMouse(project_state *State, ImVec2 MousePos, ImVec2 Min, ImVec2 Max, int Direction = 3) -{ - if (Direction & 1) { - if (MousePos.x < Min.x) { - State->Warp_WantSetPos = true; - State->Warp_PositionToSet = ImVec2(Max.x - 5, MousePos.y); - State->Warp_PositionInitial = MousePos.x; - State->Warp_Direction = 0; - } - if (MousePos.x > Max.x) { - State->Warp_WantSetPos = true; - State->Warp_PositionToSet = ImVec2(Min.x + 5, MousePos.y); - State->Warp_PositionInitial = MousePos.x; - State->Warp_Direction = 1; - } - } - if (Direction & 2) { - if (MousePos.y < Min.y) { - State->Warp_WantSetPos = true; - State->Warp_PositionToSet = ImVec2(MousePos.x, Max.y - 5); - State->Warp_PositionInitial = MousePos.y; - State->Warp_Direction = 2; - } - if (MousePos.y > Max.y) { - State->Warp_WantSetPos = true; - State->Warp_PositionToSet = ImVec2(MousePos.x, Min.y + 5); - State->Warp_PositionInitial = MousePos.y; - State->Warp_Direction = 3; - } - } -} - -// We record the initial position and the direction of the wrap, and only -// increment the wrap amount when MousePos actually is measured to be what we expect. - -static void -ImGui_WarpMouseFinish(project_state *State, ImVec2 MousePos) -{ - if (State->Warp_Direction == 0) { - if (MousePos.x < State->Warp_PositionInitial) State->Warp_X--; - } else if (State->Warp_Direction == 1) { - if (MousePos.x > State->Warp_PositionInitial) State->Warp_X++; - } else if (State->Warp_Direction == 2) { - if (MousePos.y < State->Warp_PositionInitial) State->Warp_Y--; - } else if (State->Warp_Direction == 3) { - if (MousePos.y > State->Warp_PositionInitial) State->Warp_Y++; - } else { - Assert(0); - } -} - -static ImVec2 -ImGui_Brush_CalcMousePos(project_state *State, ImGuiIO &io, ImVec2 MouseDelta, int32 i, real32 DeltaDistance, real32 DeltaSlope) -{ - ImVec2 MousePos; - if (State->Brush.Type == brush_normal) { - MousePos = io.MousePos - (MouseDelta * (i / DeltaDistance)); - } else if (State->Brush.Type == brush_wacky1) { - MousePos = io.MousePos + (io.MousePos * (i / MouseDelta)); - } else if (State->Brush.Type == brush_wacky2) { - MousePos = io.MousePos - (MouseDelta / (i / DeltaDistance)); - } else if (State->Brush.Type == brush_wacky3) { - MousePos = io.MousePos - (MouseDelta * (i / ImVec2(MouseDelta.y, MouseDelta.x))); - } else { - Assert(0); - } - return MousePos; -} - -static bool32 -ImGui_TestBoxSelection_Point(ImVec2 Pos, ImGuiIO &io, bool32 *Test) -{ - bool32 Result = 0; - real32 Y_Top = (io.MouseClickedPos[0].y < io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; - real32 Y_Bottom = (io.MouseClickedPos[0].y > io.MousePos.y) ? io.MouseClickedPos[0].y : io.MousePos.y; - real32 X_Left = (io.MouseClickedPos[0].x < io.MousePos.x) ? io.MouseClickedPos[0].x : io.MousePos.x; - real32 X_Right = (io.MouseClickedPos[0].x > io.MousePos.x) ? io.MouseClickedPos[0].x : io.MousePos.x; - - if (Pos.y >= Y_Top && Pos.y <= Y_Bottom && - Pos.x >= X_Left && Pos.x <= X_Right) - { - if (!(*Test)) { - *Test = 1; - Result = 1; - } - } else if (!io.KeyShift) { - *Test = 0; - } - return Result; -} -- cgit v1.2.3