Skip to content

Commit

Permalink
fix: Layout of large font labels in IEEE 745 floating point tool (#1337)
Browse files Browse the repository at this point in the history
### Problem description
The issue seems to only affect the web version of ImHex but it is not
clear why. The labels of the checkboxes that represent bits in the IEEE
745 floating point tool were lay out incorrectly.

### Implementation description
The new code ensures that the bit labels are centered and located in the
middle of the checkbox regardless of the font size and the dear imgui
sized checkboxes.
  • Loading branch information
paxcut authored Oct 4, 2023
1 parent 1c88c3a commit 081c581
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/builtin/source/content/tools_entries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,13 +1397,12 @@ namespace hex::plugin::builtin {

const static auto IndentBoxOrLabel = [](
u32 startBit, u32 bitIndex, u32 count, bool isLabel) {
int columnWidth = ImGui::GetColumnWidth();
int checkBoxWidth;
std::string labelString = "xx";
checkBoxWidth = ImGui::CalcTextSize(labelString.c_str()).x + 1;
std::string labelString = "#";
checkBoxWidth = ImGui::CalcTextSize(labelString.c_str()).x + ImGui::GetStyle().FramePadding.x * 2.0f;
float result = checkBoxWidth * (startBit - bitIndex) + 1;
if (count < 4) {
result += (columnWidth - count * checkBoxWidth + 1) / 2.0f;
result += (ImGui::GetStyle().FramePadding.x + 0.5f);
}
if (isLabel) {
labelString = fmt::format("{}", startBit);
Expand Down

0 comments on commit 081c581

Please sign in to comment.