From d9755a31fee2c8d003e32c46f9e4fc793884527b Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Wed, 29 Nov 2023 13:51:36 +0100 Subject: [PATCH] Application: update layout in the frame editor. That table for the joint sliders was ugly as fuck. I'm glad to be rid of it. --- .../Application_MassViewer_Frame.cpp | 147 +++++++----------- 1 file changed, 55 insertions(+), 92 deletions(-) diff --git a/src/Application/Application_MassViewer_Frame.cpp b/src/Application/Application_MassViewer_Frame.cpp index d9a6c22..35e3f8b 100644 --- a/src/Application/Application_MassViewer_Frame.cpp +++ b/src/Application/Application_MassViewer_Frame.cpp @@ -41,6 +41,8 @@ Application::drawFrameInfo() { { if(ImGui::BeginMenuBar()) { ImGui::TextUnformatted("Joint sliders"); + drawHelpMarker("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.", + static_cast(windowSize().x()) / 4.0f); ImGui::EndMenuBar(); } @@ -67,7 +69,7 @@ Application::drawFrameInfo() { ImGui::SameLine(); - if(ImGui::BeginChild("##EyeFlare", {0.0f, 0.0f}, true, ImGuiWindowFlags_MenuBar)) { + if(ImGui::BeginChild("##EyeFlare", {}, ImGuiChildFlags_Border, ImGuiWindowFlags_MenuBar)) { if(ImGui::BeginMenuBar()) { ImGui::TextUnformatted("Eye flare colour"); drawHelpMarker("Right-click the picker for more options.", 250.0f); @@ -88,98 +90,53 @@ Application::drawJointSliders() { return; } - ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game."); + ImGui::BeginGroup(); + drawAlignedText("Neck:"); + drawAlignedText("Body:"); + drawAlignedText("Shoulders:"); + drawAlignedText("Hips:"); + drawAlignedText("Arms:"); + drawAlignedText("Legs:"); + ImGui::EndGroup(); - if(ImGui::BeginTable("##JointSliderTable", 2, ImGuiTableFlags_Borders)) { - ImGui::TableSetupColumn("##SliderLabel", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("##Sliders", ImGuiTableColumnFlags_WidthStretch); + ImGui::SameLine(); - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Neck"); - ImGui::TableSetColumnIndex(1); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##NeckSlider", &_currentMass->jointSliders().neck, 0.0f, 1.0f)) { - _jointsDirty = true; - } - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Body"); - ImGui::TableSetColumnIndex(1); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##BodySlider", &_currentMass->jointSliders().body, 0.0f, 1.0f)) { - _jointsDirty = true; - } - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Shoulders"); - ImGui::TableSetColumnIndex(1); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##ShouldersSlider", &_currentMass->jointSliders().shoulders, 0.0f, 1.0f)) { - _jointsDirty = true; - } - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Hips"); - ImGui::TableSetColumnIndex(1); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##HipsSlider", &_currentMass->jointSliders().hips, 0.0f, 1.0f)) { - _jointsDirty = true; - } - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Arms"); - ImGui::TableSetColumnIndex(1); - ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{2.0f, 1.0f}); - if(ImGui::BeginTable("##UpperLowerArmsLayoutTable", 2)) { - ImGui::TableSetupColumn("##UpperArms", ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("##LowerArms", ImGuiTableColumnFlags_WidthStretch); - - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##UpperArmsSlider", &_currentMass->jointSliders().upperArms, 0.0f, 1.0f, "Upper: %.3f")) { - _jointsDirty = true; - } - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##LowerArmsSlider", &_currentMass->jointSliders().lowerArms, 0.0f, 1.0f, "Lower: %.3f")) { - _jointsDirty = true; - } - - ImGui::EndTable(); - } - ImGui::PopStyleVar(); - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - drawAlignedText("Legs"); - ImGui::TableSetColumnIndex(1); - ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{2.0f, 1.0f}); - if(ImGui::BeginTable("##UpperLowerLegsLayoutTable", 2)) { - ImGui::TableSetupColumn("##UpperLegs", ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("##LowerLegs", ImGuiTableColumnFlags_WidthStretch); - - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##UpperLegsSlider", &_currentMass->jointSliders().upperLegs, 0.0f, 1.0f, "Upper: %.3f")) { - _jointsDirty = true; - } - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1.0f); - if(ImGui::SliderFloat("##LowerLegsSlider", &_currentMass->jointSliders().lowerLegs, 0.0f, 1.0f, "Lower: %.3f")) { - _jointsDirty = true; - } - - ImGui::EndTable(); - } - ImGui::PopStyleVar(); - - ImGui::EndTable(); + ImGui::BeginGroup(); + ImGui::PushItemWidth(-1.0f); + if(ImGui::SliderFloat("##NeckSlider", &_currentMass->jointSliders().neck, 0.0f, 1.0f)) { + _jointsDirty = true; } + if(ImGui::SliderFloat("##BodySlider", &_currentMass->jointSliders().body, 0.0f, 1.0f)) { + _jointsDirty = true; + } + if(ImGui::SliderFloat("##ShouldersSlider", &_currentMass->jointSliders().shoulders, 0.0f, 1.0f)) { + _jointsDirty = true; + } + if(ImGui::SliderFloat("##HipsSlider", &_currentMass->jointSliders().hips, 0.0f, 1.0f)) { + _jointsDirty = true; + } + ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth()); + if(ImGui::SliderFloat("##UpperArmsSlider", &_currentMass->jointSliders().upperArms, 0.0f, 1.0f, "Upper: %.3f")) { + _jointsDirty = true; + } + ImGui::PopItemWidth(); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + if(ImGui::SliderFloat("##LowerArmsSlider", &_currentMass->jointSliders().lowerArms, 0.0f, 1.0f, "Lower: %.3f")) { + _jointsDirty = true; + } + ImGui::PopItemWidth(); + ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth()); + if(ImGui::SliderFloat("##UpperLegsSlider", &_currentMass->jointSliders().upperLegs, 0.0f, 1.0f, "Upper: %.3f")) { + _jointsDirty = true; + } + ImGui::PopItemWidth(); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + if(ImGui::SliderFloat("##LowerLegsSlider", &_currentMass->jointSliders().lowerLegs, 0.0f, 1.0f, "Lower: %.3f")) { + _jointsDirty = true; + } + ImGui::PopItemWidth(); + ImGui::PopItemWidth(); + ImGui::EndGroup(); if(!_jointsDirty) { ImGui::BeginDisabled(); @@ -218,9 +175,14 @@ Application::drawFrameStyles() { ImGui::PushID(i); - if(ImGui::BeginCombo("##Style", getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) { + ImGui::PushItemWidth(-1.0f); + if(ImGui::BeginCombo("##Style", + getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) + { for(const auto& style : GameData::style_names) { - if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), _currentMass->frameStyles()[i] == style.first)) { + if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), + _currentMass->frameStyles()[i] == style.first)) + { _currentMass->frameStyles()[i] = style.first; _stylesDirty = true; } @@ -228,6 +190,7 @@ Application::drawFrameStyles() { ImGui::EndCombo(); } + ImGui::PopItemWidth(); ImGui::PopID(); }