housekeeping

This commit is contained in:
scawful
2024-07-20 09:02:04 -04:00
parent 94690f9175
commit 5fcd2a8f7e
7 changed files with 43 additions and 18 deletions

View File

@@ -503,7 +503,7 @@ struct GfxSheetAssetBrowser {
ImGui::GetColorU32(ImVec4(1, 1, 1, 1)));
draw_list->AddText(
ImVec2(box_min.x, box_max.y - ImGui::GetFontSize()),
label_col, "ID");
label_col, absl::StrFormat("%X", item_data->ID).c_str());
}
}

View File

@@ -47,9 +47,9 @@ bool InputScalarLeft(const char* label, ImGuiDataType data_type, void* p_data,
// value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
// } else {
const float button_size = GetFrameHeight();
ImGui::AlignTextToFramePadding();
ImGui::Text("%s", label);
ImGui::SameLine();
AlignTextToFramePadding();
Text("%s", label);
SameLine();
BeginGroup(); // The only purpose of the group here is to allow the caller
// to query item data e.g. IsItemActive()
PushID(label);
@@ -57,12 +57,12 @@ bool InputScalarLeft(const char* label, ImGuiDataType data_type, void* p_data,
1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
// Place the label on the left of the input field
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,
ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2{style.FramePadding.x, style.FramePadding.y});
PushStyleVar(ImGuiStyleVar_ItemSpacing,
ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2{style.FramePadding.x, style.FramePadding.y});
ImGui::SetNextItemWidth(input_width);
SetNextItemWidth(input_width);
if (InputText("", buf, IM_ARRAYSIZE(buf),
flags)) // PushId(label) + "" gives us the expected ID
// from outside point of view
@@ -173,6 +173,19 @@ bool InputHexByte(const char* label, uint8_t* data, float input_width,
ImGuiInputTextFlags_CharsHexadecimal, no_step);
}
bool InputHexByte(const char* label, uint8_t* data, uint8_t max_value,
float input_width, bool no_step) {
if (ImGui::InputScalarLeft(label, ImGuiDataType_U8, data, &kStepOneHex,
&kStepFastHex, "%02X", input_width,
ImGuiInputTextFlags_CharsHexadecimal, no_step)) {
if (*data > max_value) {
*data = max_value;
}
return true;
}
return false;
}
void ItemLabel(absl::string_view title, ItemLabelFlags flags) {
ImGuiWindow* window = ImGui::GetCurrentWindow();
const ImVec2 lineStart = ImGui::GetCursorScreenPos();

View File

@@ -31,6 +31,9 @@ IMGUI_API bool InputHexWord(const char* label, int16_t* data,
IMGUI_API bool InputHexByte(const char* label, uint8_t* data,
float input_width = 50.f, bool no_step = false);
IMGUI_API bool InputHexByte(const char* label, uint8_t* data, uint8_t max_value,
float input_width = 50.f, bool no_step = false);
IMGUI_API bool ListBox(const char* label, int* current_item,
const std::vector<std::string>& items,
int height_in_items = -1);