Share the icon card of sounds and libraries, and merge repeated checks in frame dragging

This commit is contained in:
shweet committed 2026-11-22 19:15:12 -05:00
1 parent 67b2296fc0
commit c891e1a873
4 files changed
+23 -23

No files matched your search

+1 -2
View File
@@ -92,8 +92,7 @@ void libraries_update(Panel& panel)
[&](int id) { [&](int id) {
auto loaded = loaded_get(id); auto loaded = loaded_get(id);
auto isValid = loaded && loaded->model.isValid; auto isValid = loaded && loaded->model.isValid;
auto& texture = resources.icons[isValid ? ICON_ANIMATION : ICON_NONE]; return icon_card_get(resources, ICON_ANIMATION, isValid);
return CardImage{.texture = &texture, .size = Vec2(texture.size), .isValid = isValid};
}, },
.activate = open, .activate = open,
.cardLines = LIBRARY_CARD_LINES}; .cardLines = LIBRARY_CARD_LINES};
+7
View File
@@ -108,6 +108,13 @@ bool tooltip_begin(const PanelState&, bool = true);
void tooltip_end(); void tooltip_end();
void tooltip_name_draw(Resources&, const std::string&); void tooltip_name_draw(Resources&, const std::string&);
void tooltip_image_draw(const CardImage&, const std::function<void()>&); void tooltip_image_draw(const CardImage&, const std::function<void()>&);
// A card showing `icon` for a valid item, and the none icon for one that isn't.
inline CardImage icon_card_get(Resources& resources, Icon icon, bool isValid)
{
auto& texture = resources.icons[isValid ? icon : ICON_NONE];
return {.texture = &texture, .size = Vec2(texture.size), .isValid = isValid};
}
void directory_open(Dialog&, Document&, const std::filesystem::path&); void directory_open(Dialog&, Document&, const std::filesystem::path&);
std::filesystem::path asset_path_get(Document&, const std::filesystem::path&); std::filesystem::path asset_path_get(Document&, const std::filesystem::path&);
// The confirm and cancel buttons that end a popup, side by side, on the confirm and cancel shortcuts. // The confirm and cancel buttons that end a popup, side by side, on the confirm and cancel shortcuts.
+1 -2
View File
@@ -97,8 +97,7 @@ void sounds_update(Panel& panel)
[&](int id) { [&](int id) {
auto audio = document.sound_get(id); auto audio = document.sound_get(id);
auto isValid = audio && audio->is_valid(); auto isValid = audio && audio->is_valid();
auto& texture = resources.icons[isValid ? ICON_SOUND : ICON_NONE]; return icon_card_get(resources, ICON_SOUND, isValid);
return CardImage{.texture = &texture, .size = Vec2(texture.size), .isValid = isValid};
}, },
.select = .select =
[&](int id) { [&](int id) {
+14 -19
View File
@@ -470,28 +470,23 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
ImGui::PopStyleColor(4); ImGui::PopStyleColor(4);
if (!isDraggedFrameActive && ImGui::IsItemHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Left)) if (!isDraggedFrameActive && ImGui::IsItemHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Left) &&
(type == TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl)))
{ {
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) isDraggedFrameActive = true;
draggedFrameReference = frameReference;
draggedFrameType = type;
draggedFrameStart = hoveredTime;
draggedFrameStartDurations.clear();
if (type != TRIGGER)
{ {
if (type == TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl)) draggedFrameStartDuration = frame.duration;
{ for (auto selectedReference : drag_frame_references_get(frameReference))
isDraggedFrameActive = true; if (auto selectedFrame = document.model.frame_get(selectedReference))
draggedFrameReference = frameReference; draggedFrameStartDurations.push_back({selectedReference, selectedFrame->duration});
draggedFrameType = type;
draggedFrameStart = hoveredTime;
if (type != TRIGGER)
draggedFrameStartDuration = frame.duration;
draggedFrameStartDurations.clear();
if (type != TRIGGER)
for (auto selectedReference : drag_frame_references_get(frameReference))
if (auto selectedFrame = document.model.frame_get(selectedReference))
draggedFrameStartDurations.push_back(
{selectedReference, selectedFrame->duration});
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
draggedFrameWidth = frameSize.x;
}
} }
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
draggedFrameWidth = frameSize.x;
} }
if (type != TRIGGER) if (type != TRIGGER)