impr: Make pattern tooltips more appropriately sized

This commit is contained in:
WerWolv 2024-07-26 19:38:21 +02:00
parent 1b26db40f7
commit d097f6ada0
2 changed files with 5 additions and 4 deletions

View file

@ -685,7 +685,7 @@ namespace hex {
return string;
// If the string is longer than the max length, find the last space before the max length
auto it = string.begin() + maxLength / 2;
auto it = string.begin() + maxLength;
while (it != string.begin() && !std::isspace(*it)) --it;
// If there's no space before the max length, just cut the string

View file

@ -1456,6 +1456,7 @@ namespace hex::plugin::builtin {
void ViewPatternEditor::drawPatternTooltip(pl::ptrn::Pattern *pattern) {
ImGui::PushID(pattern);
{
const bool shiftHeld = ImGui::GetIO().KeyShift;
ImGui::ColorButton(pattern->getVariableName().c_str(), ImColor(pattern->getColor()));
ImGui::SameLine(0, 10);
ImGuiExt::TextFormattedColored(TextEditor::GetPalette()[u32(TextEditor::PaletteIndex::KnownIdentifier)], "{} ", pattern->getFormattedName());
@ -1464,9 +1465,9 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
ImGuiExt::TextFormatted("{} ", hex::limitStringLength(pattern->getFormattedValue(), 64));
ImGuiExt::TextFormatted("{: <{}} ", hex::limitStringLength(pattern->getFormattedValue(), 64), shiftHeld ? 40 : 0);
if (ImGui::GetIO().KeyShift) {
if (shiftHeld) {
ImGui::Indent();
if (ImGui::BeginTable("##extra_info", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoClip)) {
ImGui::TableNextRow();
@ -1498,7 +1499,7 @@ namespace hex::plugin::builtin {
}
ImGui::Indent();
ImGui::PushTextWrapPos(300_scaled);
ImGui::PushTextWrapPos(500_scaled);
ImGuiExt::TextFormattedWrapped("{}", path);
ImGui::PopTextWrapPos();
ImGui::Unindent();