Fix card lists: zero window padding for the list child, tooltips keep the window style

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 18:00:15 -04:00
1 parent dc32483c45
commit c6c8e3598b
7 files changed
+49 -26

No files matched your search

+1 -1
View File
@@ -783,7 +783,7 @@ namespace anm2ed::imgui
list_select_end(panel, selection, focus, rows, arrowKey);
animations_selection_set(document, selection, groupSelection);
},
&footerActions);
false, &footerActions);
}
ImGui::End();
+28 -11
View File
@@ -42,14 +42,27 @@ namespace anm2ed::imgui
if (state.scrollId == key) state.scrollId = -1;
}
void row_tooltip_update(const ListRows& rows, int key)
// Tooltips keep the window's padding and spacing, which card lists zero out for themselves.
bool tooltip_begin(const PanelState& state, bool isItem)
{
if (!rows.tooltip_draw) return;
if (ImGui::BeginItemTooltip())
{
rows.tooltip_draw(key);
ImGui::EndTooltip();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, state.tooltipPadding);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, state.tooltipSpacing);
if (isItem ? ImGui::BeginItemTooltip() : ImGui::BeginTooltip()) return true;
ImGui::PopStyleVar(2);
return false;
}
void tooltip_end()
{
ImGui::EndTooltip();
ImGui::PopStyleVar(2);
}
void row_tooltip_update(const PanelState& state, const ListRows& rows, int key)
{
if (!rows.tooltip_draw || !tooltip_begin(state)) return;
rows.tooltip_draw(key);
tooltip_end();
}
// Arrow keys move a single selection through the keys.
@@ -152,7 +165,7 @@ namespace anm2ed::imgui
rows.activate(key);
auto isBreak = rows.drag_drop_update && rows.drag_drop_update(key, index);
row_tooltip_update(rows, key);
row_tooltip_update(panel.state, rows, key);
ImGui::PopID();
return isBreak;
}
@@ -194,11 +207,11 @@ namespace anm2ed::imgui
if (rows.tooltip_draw && ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip) &&
!ImGui::IsMouseDragging(ImGuiMouseButton_Left))
{
ImGui::SetNextWindowSize(ImVec2(ImGui::CalcTextSize(label.c_str()).x + style.ItemSpacing.x +
style.WindowPadding.x * TOOLTIP_PADDING_MULTIPLIER,
ImGui::SetNextWindowSize(ImVec2(ImGui::CalcTextSize(label.c_str()).x + panel.state.tooltipSpacing.x +
panel.state.tooltipPadding.x * TOOLTIP_PADDING_MULTIPLIER,
0),
ImGuiCond_Appearing);
row_tooltip_update(rows, key);
row_tooltip_update(panel.state, rows, key);
}
isBreak = rows.drag_drop_update && rows.drag_drop_update(key, index);
@@ -258,15 +271,19 @@ namespace anm2ed::imgui
// The list in a bordered child with its context menu and shortcuts, then the footer buttons.
void list_panel_draw(Panel& panel, Actions& actions, const Footer& footer, const std::function<void()>& list,
Actions* footerActions)
bool isCards, Actions* footerActions)
{
auto& [manager, settings, resources, dialog, clipboard, document, state] = panel;
state.tooltipPadding = ImGui::GetStyle().WindowPadding;
state.tooltipSpacing = ImGui::GetStyle().ItemSpacing;
if (isCards) ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
if (ImGui::BeginChild("##List Child", size_without_footer_get((int)footer.size()), ImGuiChildFlags_Borders))
{
list();
actions_shortcuts_update(actions, manager);
}
ImGui::EndChild();
if (isCards) ImGui::PopStyleVar();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlappedByWindow) &&
ImGui::IsMouseReleased(ImGuiMouseButton_Right))
+5 -1
View File
@@ -47,6 +47,8 @@ namespace anm2ed::imgui
std::vector<int> keys{};
std::vector<int> dragIds{};
MultiSelectStorage selection{};
ImVec2 tooltipPadding{};
ImVec2 tooltipSpacing{};
};
// Everything a panel draws with, for one frame. Commands get the document again when they run.
@@ -91,7 +93,9 @@ namespace anm2ed::imgui
void content_list_draw(Panel&, SelectionKind, const std::vector<int>&, const ListRows&);
int list_select_begin(Panel&, std::set<int>&, int&, const ListRows&, const std::vector<int>&);
void list_select_end(Panel&, std::set<int>&, int&, const ListRows&, int);
void list_panel_draw(Panel&, Actions&, const Footer&, const std::function<void()>&, Actions* = nullptr);
void list_panel_draw(Panel&, Actions&, const Footer&, const std::function<void()>&, bool = false, Actions* = nullptr);
bool tooltip_begin(const PanelState&, bool = true);
void tooltip_end();
void tooltip_name_draw(Resources&, const std::string&);
void tooltip_image_draw(const CardImage&, const std::function<void()>&);
void directory_open(Dialog&, Document&, const std::filesystem::path&);
+6 -6
View File
@@ -252,12 +252,10 @@ namespace anm2ed::imgui
auto mousePos = ImGui::GetIO().MousePos;
ImGui::SetNextWindowPos(ImVec2(mousePos.x + DRAG_TOOLTIP_OFFSET.x, mousePos.y + DRAG_TOOLTIP_OFFSET.y));
if (ImGui::BeginTooltip())
{
if (!tooltip_begin(state, false)) return;
for (auto regionId : state.dragIds)
if (auto region = model::item_get(spritesheet->regions, regionId)) ImGui::TextUnformatted(region->name.c_str());
ImGui::EndTooltip();
}
tooltip_end();
}
void region_properties_open(RegionsPanel& regions, Document& document, int id)
@@ -536,12 +534,14 @@ namespace anm2ed::imgui
.activate = [&](int id) { region_properties_open(regions, document, id); },
.drag_drop_update = [&](int id, int index) { return region_drag_drop_update(panel, id, index); },
.cardLines = REGION_CARD_LINES};
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_EXPORT, ACTION_REMOVE_UNUSED}},
list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_EXPORT, ACTION_REMOVE_UNUSED}},
[&]()
{
content_list_draw(panel, SelectionKind::REGIONS, item_ids_get(spritesheet->regions), rows);
region_drag_tooltip_update(panel);
});
},
true);
}
}
ImGui::End();
+3 -2
View File
@@ -378,8 +378,9 @@ namespace anm2ed::imgui
.image_get = image_get,
.activate = properties_open,
.cardLines = SHADER_CARD_LINES};
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD}},
[&]() { content_list_draw(panel, SelectionKind::SHADERS, item_ids_get(items), rows); });
list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD}},
[&]() { content_list_draw(panel, SelectionKind::SHADERS, item_ids_get(items), rows); }, true);
propertiesPopup.trigger();
if (ImGui::BeginPopupModal(propertiesPopup.label(), &propertiesPopup.isOpen, ImGuiWindowFlags_NoResize))
+3 -2
View File
@@ -131,8 +131,9 @@ namespace anm2ed::imgui
},
.activate = open,
.cardLines = SOUND_CARD_LINES};
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_REPLACE}},
[&]() { content_list_draw(panel, SelectionKind::SOUNDS, item_ids_get(sounds), rows); });
list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED, ACTION_RELOAD, ACTION_REPLACE}},
[&]() { content_list_draw(panel, SelectionKind::SOUNDS, item_ids_get(sounds), rows); }, true);
}
ImGui::End();
}
+3 -3
View File
@@ -363,9 +363,9 @@ namespace anm2ed::imgui
},
.activate = open,
.cardLines = SPRITESHEET_CARD_LINES};
list_panel_draw(panel, actions,
{{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE_UNUSED, ACTION_SAVE}},
[&]() { content_list_draw(panel, SelectionKind::SPRITESHEETS, item_ids_get(items), rows); });
list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE_UNUSED, ACTION_SAVE}},
[&]() { content_list_draw(panel, SelectionKind::SPRITESHEETS, item_ids_get(items), rows); }, true);
}
ImGui::End();