fix(layout): pack collapsed sidebar sections
This commit is contained in:
@@ -543,12 +543,6 @@ void draw_sidebar(float width) {
|
||||
section_heights[2], maximum_heights[2]);
|
||||
}
|
||||
|
||||
const float submodules_body_height = section_open[3] && section_heights[3] >= ui(1.0f)
|
||||
? section_heights[3] + ui(5.0f)
|
||||
: 1.0f;
|
||||
const float submodules_block_height = ui(22.0f) + submodules_body_height;
|
||||
ImGui::SetCursorPosY(std::max(ImGui::GetCursorPosY(),
|
||||
ImGui::GetContentRegionMax().y - submodules_block_height));
|
||||
if (g_sidebar_workspace_view) {
|
||||
section(ICON_FA_CUBES " SUBMODULES", repo().submodules, ICON_FA_CUBES,
|
||||
"Add submodule", "Add submodule", SidebarItemKind::submodule, 3,
|
||||
@@ -913,32 +907,50 @@ void draw_working_details() {
|
||||
const float files_height = std::max(ui(140.0f), ImGui::GetContentRegionAvail().y - composer_height);
|
||||
ImGui::BeginChild("working_files", {-1, files_height}, ImGuiChildFlags_None,
|
||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
const float unstaged_height = files_height * 0.52f;
|
||||
static bool unstaged_open = true;
|
||||
static bool staged_open = true;
|
||||
const float collapsed_height = ui(27.0f);
|
||||
float unstaged_height = files_height * 0.52f;
|
||||
float staged_height = files_height - unstaged_height;
|
||||
if (!unstaged_open) {
|
||||
unstaged_height = collapsed_height;
|
||||
staged_height = staged_open ? files_height - collapsed_height : collapsed_height;
|
||||
} else if (!staged_open) {
|
||||
staged_height = collapsed_height;
|
||||
unstaged_height = files_height - collapsed_height;
|
||||
}
|
||||
|
||||
ImGui::BeginChild("unstaged_files", {-1, unstaged_height}, ImGuiChildFlags_None);
|
||||
const bool unstaged_open = ImGui::TreeNodeEx(
|
||||
(std::string("Unstaged Files (") + std::to_string(unstaged) + ")").c_str(),
|
||||
ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_SpanAvailWidth);
|
||||
ImGui::SameLine(std::max(ui(145.0f), ImGui::GetWindowWidth() - ui(119.0f)));
|
||||
const ImVec2 unstaged_header = ImGui::GetCursorScreenPos();
|
||||
ImGui::InvisibleButton("##unstaged_toggle", {-1, ui(24.0f)});
|
||||
if (ImGui::IsItemClicked()) unstaged_open = !unstaged_open;
|
||||
ImGui::GetWindowDrawList()->AddText(
|
||||
{unstaged_header.x + ui(4.0f), unstaged_header.y + ui(4.0f)},
|
||||
ImGui::GetColorU32(ImGuiCol_Text),
|
||||
(std::string(unstaged_open ? ICON_FA_CHEVRON_DOWN " " : ICON_FA_CHEVRON_RIGHT " ") +
|
||||
"Unstaged Files (" + std::to_string(unstaged) + ")").c_str());
|
||||
ImGui::SetCursorScreenPos({ImGui::GetWindowPos().x + ImGui::GetWindowWidth() - ui(119.0f),
|
||||
unstaged_header.y + ui(2.0f)});
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.12f, 0.27f, 0.18f, 1.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.24f, 0.72f, 0.35f, 1.0f));
|
||||
if (ImGui::SmallButton("Stage All Changes")) g_git_manager->stageAll(repo(), g_notice);
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::SetCursorScreenPos({unstaged_header.x, unstaged_header.y + ui(24.0f)});
|
||||
ImGui::Separator();
|
||||
if (unstaged_open) {
|
||||
draw_files(repo().working_files, false, true);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (unstaged_open) draw_files(repo().working_files, false, true);
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::BeginChild("staged_files", {-1, -1}, ImGuiChildFlags_None);
|
||||
const bool staged_open = ImGui::TreeNodeEx(
|
||||
(std::string("Staged Files (") + std::to_string(staged) + ")").c_str(),
|
||||
ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_SpanAvailWidth);
|
||||
ImGui::BeginChild("staged_files", {-1, staged_height}, ImGuiChildFlags_None);
|
||||
const ImVec2 staged_header = ImGui::GetCursorScreenPos();
|
||||
ImGui::InvisibleButton("##staged_toggle", {-1, ui(24.0f)});
|
||||
if (ImGui::IsItemClicked()) staged_open = !staged_open;
|
||||
ImGui::GetWindowDrawList()->AddText(
|
||||
{staged_header.x + ui(4.0f), staged_header.y + ui(4.0f)},
|
||||
ImGui::GetColorU32(ImGuiCol_Text),
|
||||
(std::string(staged_open ? ICON_FA_CHEVRON_DOWN " " : ICON_FA_CHEVRON_RIGHT " ") +
|
||||
"Staged Files (" + std::to_string(staged) + ")").c_str());
|
||||
ImGui::Separator();
|
||||
if (staged_open) {
|
||||
draw_files(repo().working_files, true, true);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (staged_open) draw_files(repo().working_files, true, true);
|
||||
ImGui::EndChild();
|
||||
ImGui::EndChild();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user