1
0
mirror of synced 2024-11-12 02:00:52 +01:00

feat: Added a button to restore default layout when there are no views open (#1053)

Co-authored-by: Nik <werwolv98@gmail.com>
This commit is contained in:
iTrooz 2023-05-05 22:00:17 +02:00 committed by GitHub
parent 980e4cad06
commit 34e12e2515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View File

@ -151,4 +151,6 @@ namespace ImGui {
bool BitCheckbox(const char* label, bool* v);
bool DimmedButton(const char* label);
}

View File

@ -698,4 +698,19 @@ namespace ImGui {
return pressed;
}
bool DimmedButton(const char* label){
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetCustomColorU32(ImGuiCustomCol_DescButtonHovered));
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetCustomColorU32(ImGuiCustomCol_DescButton));
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(ImGuiCol_ButtonActive));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetCustomColorU32(ImGuiCustomCol_DescButtonActive));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1);
bool res = ImGui::Button(label);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(1);
return res;
}
}

View File

@ -132,6 +132,7 @@
"hex.builtin.inspector.utf8": "UTF-8 code point",
"hex.builtin.inspector.wide": "Wide Character",
"hex.builtin.layouts.default": "Default",
"hex.builtin.layouts.none.restore_default": "Restore default layout",
"hex.builtin.menu.edit": "Edit",
"hex.builtin.menu.edit.bookmark.create": "Create bookmark",
"hex.builtin.menu.edit.redo": "Redo",

View File

@ -418,10 +418,23 @@ namespace hex::plugin::builtin {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10_scaled, 10_scaled));
if (ImGui::BeginChild("NoViewsBackground", ImVec2(0, 0), false, ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoScrollWithMouse)) {
auto imageSize = scaled(ImVec2(350, 350));
auto pos = (ImGui::GetContentRegionAvail() - imageSize) / 2;
auto imagePos = (ImGui::GetContentRegionAvail() - imageSize) / 2;
ImGui::SetCursorPos(pos);
ImGui::SetCursorPos(imagePos);
ImGui::Image(s_backdropTexture, imageSize);
auto loadDefaultText = "hex.builtin.layouts.none.restore_default"_lang;
auto textSize = ImGui::CalcTextSize(loadDefaultText);
auto textPos = scaled(ImVec2(
(ImGui::GetContentRegionAvail().x - textSize.x) / 2,
imagePos.y + imageSize.y
));
ImGui::SetCursorPos(textPos);
if (ImGui::DimmedButton(loadDefaultText)){
loadDefaultLayout();
}
}
ImGui::EndChild();
ImGui::PopStyleVar();