mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
overlay: options tab(s) clean up (#598)
## Description of change Merge option name and command line parameter columns. Expand the size of widget column. In Search tab, add a new column to display the category. Add a highlight effect to rows when hovered over - apply this to all tables in the configurator UI.
This commit is contained in:
@@ -163,4 +163,17 @@ namespace ImGui {
|
|||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
return clicked;
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InvisibleTableRowSelectable() {
|
||||||
|
ImGui::TableSetColumnIndex(0);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Header, 0);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_HeaderHovered, 0);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_HeaderActive, 0);
|
||||||
|
ImGui::Selectable("##row", false,
|
||||||
|
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap);
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
if (ImGui::IsItemHovered()) {
|
||||||
|
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, IM_COL32(200, 200, 200, 24));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ namespace ImGui {
|
|||||||
void TextTruncated(const std::string& p_text, float p_truncated_width);
|
void TextTruncated(const std::string& p_text, float p_truncated_width);
|
||||||
bool DeleteButton(const std::string& tooltip);
|
bool DeleteButton(const std::string& tooltip);
|
||||||
bool ClearButton(const std::string& tooltip);
|
bool ClearButton(const std::string& tooltip);
|
||||||
|
void InvisibleTableRowSelectable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ void overlay::SpiceOverlay::init() {
|
|||||||
|
|
||||||
// Text
|
// Text
|
||||||
colors[ImGuiCol_Text] = ImVec4(1.00f, 0.90f, 0.90f, 1.00f); // Slight pinkish tint to off-white
|
colors[ImGuiCol_Text] = ImVec4(1.00f, 0.90f, 0.90f, 1.00f); // Slight pinkish tint to off-white
|
||||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.40f, 0.40f, 1.00f);
|
colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.26f, 0.26f, 1.00f);
|
||||||
|
|
||||||
// Backgrounds
|
// Backgrounds
|
||||||
colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.07f, 0.07f, 1.00f); // Deep charcoal
|
colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.07f, 0.07f, 1.00f); // Deep charcoal
|
||||||
|
|||||||
@@ -685,12 +685,18 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
// primary
|
// primary
|
||||||
build_button(name, primary_button, &primary_button, button_it, button_it_max, 0);
|
build_button(name, primary_button, &primary_button, button_it, button_it_max, 0);
|
||||||
|
ImGui::PushID(&primary_button);
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
ImGui::PopID();
|
||||||
|
|
||||||
// alternatives
|
// alternatives
|
||||||
int alt_index = 1; // 0 is primary
|
int alt_index = 1; // 0 is primary
|
||||||
for (auto &alt : primary_button.getAlternatives()) {
|
for (auto &alt : primary_button.getAlternatives()) {
|
||||||
if (alt.isValid()) {
|
if (alt.isValid()) {
|
||||||
build_button(name, primary_button, &alt, button_it, button_it_max, alt_index);
|
build_button(name, primary_button, &alt, button_it, button_it_max, alt_index);
|
||||||
|
ImGui::PushID(&alt);
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
alt_index++;
|
alt_index++;
|
||||||
}
|
}
|
||||||
@@ -2170,6 +2176,9 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
edit_analog_popup(analog);
|
edit_analog_popup(analog);
|
||||||
|
|
||||||
|
// row hover detection (invisible selectable that spans entire row)
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
@@ -2790,13 +2799,21 @@ namespace overlay::windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build_light(light, &light, i, 0);
|
build_light(light, &light, i, 0);
|
||||||
|
ImGui::PushID(&light);
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
ImGui::PopID();
|
||||||
int alt_index = 1;
|
int alt_index = 1;
|
||||||
for (auto &alt : light.getAlternatives()) {
|
for (auto &alt : light.getAlternatives()) {
|
||||||
if (alt.isValid()) {
|
if (alt.isValid()) {
|
||||||
build_light(light, &alt, i, alt_index);
|
build_light(light, &alt, i, alt_index);
|
||||||
|
ImGui::PushID(&alt);
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
alt_index++;
|
alt_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (table_begin) {
|
if (table_begin) {
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
@@ -4399,16 +4416,18 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
// render table
|
// render table
|
||||||
// tables must share the same ID to have synced column settings
|
// tables must share the same ID to have synced column settings
|
||||||
if (ImGui::BeginTable("OptionsTable", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg)) {
|
const int num_columns = (filter != nullptr) ? 3 : 2;
|
||||||
ImGui::TableSetupColumn("Option", ImGuiTableColumnFlags_WidthStretch);
|
if (ImGui::BeginTable("OptionsTable", num_columns, ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg)) {
|
||||||
ImGui::TableSetupColumn(
|
auto widget_col_width = 0;
|
||||||
"CMD Line Parameter",
|
if (filter != nullptr) {
|
||||||
ImGuiTableColumnFlags_WidthFixed,
|
ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, overlay::apply_scaling(160));
|
||||||
overlay::apply_scaling(216));
|
ImGui::TableSetupColumn("Option", ImGuiTableColumnFlags_WidthStretch);
|
||||||
ImGui::TableSetupColumn(
|
widget_col_width = overlay::apply_scaling(220);
|
||||||
"Setting",
|
} else {
|
||||||
ImGuiTableColumnFlags_WidthFixed,
|
ImGui::TableSetupColumn("Option", ImGuiTableColumnFlags_WidthStretch);
|
||||||
overlay::apply_scaling(240));
|
widget_col_width = overlay::apply_scaling(264);
|
||||||
|
}
|
||||||
|
ImGui::TableSetupColumn("Setting", ImGuiTableColumnFlags_WidthFixed, widget_col_width);
|
||||||
|
|
||||||
// iterate options
|
// iterate options
|
||||||
options_count = 0;
|
options_count = 0;
|
||||||
@@ -4457,10 +4476,24 @@ namespace overlay::windows {
|
|||||||
ImGui::PushID(&option);
|
ImGui::PushID(&option);
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
// category (only shown for search results)
|
||||||
|
if (filter != nullptr) {
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
|
if (definition.category.empty()) {
|
||||||
|
ImGui::TextDisabled("-");
|
||||||
|
} else {
|
||||||
|
ImGui::TextDisabled(definition.category.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// option name
|
// option name
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::Indent(INDENT);
|
if (filter == nullptr) {
|
||||||
|
// add indent to make options align under category header
|
||||||
|
ImGui::Indent(INDENT);
|
||||||
|
}
|
||||||
if (option.is_active()) {
|
if (option.is_active()) {
|
||||||
// active option
|
// active option
|
||||||
if (option.disabled || definition.disabled) {
|
if (option.disabled || definition.disabled) {
|
||||||
@@ -4476,21 +4509,22 @@ namespace overlay::windows {
|
|||||||
// normal text
|
// normal text
|
||||||
ImGui::TextUnformatted(definition.title.c_str());
|
ImGui::TextUnformatted(definition.title.c_str());
|
||||||
}
|
}
|
||||||
ImGui::Unindent(INDENT);
|
if (filter == nullptr) {
|
||||||
|
ImGui::Unindent(INDENT);
|
||||||
|
}
|
||||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||||
ImGui::HelpTooltip(definition.desc.c_str());
|
ImGui::HelpTooltip(definition.desc.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// command line parameter
|
// command line parameter
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::AlignTextToFramePadding();
|
|
||||||
std::string param = "-";
|
std::string param = "-";
|
||||||
if (definition.display_name.empty()) {
|
if (definition.display_name.empty()) {
|
||||||
param += definition.name;
|
param += definition.name;
|
||||||
} else {
|
} else {
|
||||||
param += definition.display_name;
|
param += definition.display_name;
|
||||||
}
|
}
|
||||||
ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.f), "%s", param.c_str());
|
ImGui::SameLine();
|
||||||
|
ImGui::TextColored(ImVec4(0.27f, 0.27f, 0.27f, 1.f), " %s", param.c_str());
|
||||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||||
const auto help =
|
const auto help =
|
||||||
param +
|
param +
|
||||||
@@ -4511,6 +4545,10 @@ namespace overlay::windows {
|
|||||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
||||||
}
|
}
|
||||||
|
if (definition.type != OptionType::Bool) {
|
||||||
|
// take up width of column, minus some room for clear button and Pick button
|
||||||
|
ImGui::SetNextItemWidth(widget_col_width - overlay::apply_scaling(70));
|
||||||
|
}
|
||||||
switch (definition.type) {
|
switch (definition.type) {
|
||||||
case OptionType::Bool: {
|
case OptionType::Bool: {
|
||||||
bool state = !option.value.empty();
|
bool state = !option.value.empty();
|
||||||
@@ -4727,6 +4765,9 @@ namespace overlay::windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// row hover detection (invisible selectable that spans entire row)
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
|
||||||
// next item
|
// next item
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
@@ -5239,6 +5280,7 @@ namespace overlay::windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -844,6 +844,10 @@ namespace overlay::windows {
|
|||||||
ImGui::TextUnformatted(patch_checked ? "ON" : "off");
|
ImGui::TextUnformatted(patch_checked ? "ON" : "off");
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// row hover detection (invisible selectable that spans entire row)
|
||||||
|
ImGui::InvisibleTableRowSelectable();
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user