1
0
mirror of synced 2024-11-28 09:30:51 +01:00

impr: Better look and feel of the welcome screen close button

This commit is contained in:
WerWolv 2023-05-11 12:00:45 +02:00
parent 4f17a96707
commit 8f07f0f8ae
3 changed files with 43 additions and 4 deletions

View File

@ -75,6 +75,8 @@ namespace ImGui {
bool BulletHyperlink(const char *label, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
bool DescriptionButton(const char *label, const char *description, const ImVec2 &size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
void HelpHover(const char *text);
void UnderlinedText(const char *label, ImColor color = ImGui::GetStyleColorVec4(ImGuiCol_Text), const ImVec2 &size_arg = ImVec2(0, 0));
void TextSpinner(const char *label);
@ -152,5 +154,6 @@ namespace ImGui {
bool BitCheckbox(const char* label, bool* v);
bool DimmedButton(const char* label);
bool DimmedIconButton(const char *symbol, ImVec4 color, ImVec2 size_arg = ImVec2(0, 0));
}

View File

@ -14,6 +14,8 @@
#include <hex/api/imhex_api.hpp>
#include <fonts/codicons_font.h>
namespace ImGui {
Texture::Texture(const ImU8 *buffer, int size, int width, int height) {
@ -263,6 +265,25 @@ namespace ImGui {
return pressed;
}
void HelpHover(const char *text) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarBlue));
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(0, 0));
ImGui::Button(ICON_VS_INFO);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(ImGui::GetTextLineHeight() * 75, FLT_MAX));
ImGui::BeginTooltip();
ImGui::TextFormattedWrapped("{}", text);
ImGui::EndTooltip();
}
ImGui::PopStyleVar();
ImGui::PopStyleColor(4);
}
void UnderlinedText(const char *label, ImColor color, const ImVec2 &size_arg) {
ImGuiWindow *window = GetCurrentWindow();
@ -500,7 +521,7 @@ namespace ImGui {
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered
: ImGuiCol_Button);
RenderNavHighlight(bb, id);
RenderFrame(bb.Min, bb.Max, col, false, style.FrameRounding);
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, symbol, nullptr, &label_size, style.ButtonTextAlign, &bb);
PopStyleColor();
@ -709,7 +730,22 @@ namespace ImGui {
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(1);
return res;
}
bool DimmedIconButton(const char *symbol, ImVec4 color, ImVec2 size_arg){
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 = IconButton(symbol, color, size_arg);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(1);
return res;
}

View File

@ -382,8 +382,8 @@ namespace hex::plugin::builtin {
ImGui::EndTable();
}
ImGui::SetCursorPos(ImVec2(ImGui::GetContentRegionAvail().x, 0));
if (ImGui::Hyperlink("X")) {
ImGui::SetCursorPos(ImVec2(ImGui::GetContentRegionAvail().x + ImGui::GetStyle().FramePadding.x, ImGui::GetStyle().FramePadding.y * 2 - 1));
if (ImGui::DimmedIconButton(ICON_VS_CLOSE, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed))) {
auto provider = ImHexApi::Provider::createProvider("hex.builtin.provider.null");
if (provider != nullptr)
if (provider->open())