mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-04 00:13:51 +00:00
Prevent spellbook window from moving during spell drag and escaping screen bounds
This commit is contained in:
parent
738b161e95
commit
258ab06d44
1 changed files with 15 additions and 1 deletions
|
|
@ -194,9 +194,23 @@ void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetMana
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(bookX, bookY), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(bookX, bookY), ImGuiCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(ImVec2(bookW, bookH), ImGuiCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(bookW, bookH), ImGuiCond_FirstUseEver);
|
||||||
|
ImGui::SetNextWindowSizeConstraints(ImVec2(280, 200), ImVec2(screenW, screenH));
|
||||||
|
|
||||||
|
ImGuiWindowFlags spellbookFlags = 0;
|
||||||
|
if (draggingSpell_) {
|
||||||
|
spellbookFlags |= ImGuiWindowFlags_NoMove;
|
||||||
|
}
|
||||||
|
|
||||||
bool windowOpen = open;
|
bool windowOpen = open;
|
||||||
if (ImGui::Begin("Spellbook", &windowOpen)) {
|
if (ImGui::Begin("Spellbook", &windowOpen, spellbookFlags)) {
|
||||||
|
// Clamp window position to stay on screen
|
||||||
|
ImVec2 winPos = ImGui::GetWindowPos();
|
||||||
|
ImVec2 winSize = ImGui::GetWindowSize();
|
||||||
|
float clampedX = std::max(0.0f, std::min(winPos.x, screenW - winSize.x));
|
||||||
|
float clampedY = std::max(0.0f, std::min(winPos.y, screenH - winSize.y));
|
||||||
|
if (clampedX != winPos.x || clampedY != winPos.y) {
|
||||||
|
ImGui::SetWindowPos(ImVec2(clampedX, clampedY));
|
||||||
|
}
|
||||||
|
|
||||||
// Tab bar
|
// Tab bar
|
||||||
if (ImGui::BeginTabBar("SpellbookTabs")) {
|
if (ImGui::BeginTabBar("SpellbookTabs")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue