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
+15 -15

No files matched your search

+1 -2
View File
@@ -92,8 +92,7 @@ void libraries_update(Panel& panel)
[&](int id) {
auto loaded = loaded_get(id);
auto isValid = loaded && loaded->model.isValid;
auto& texture = resources.icons[isValid ? ICON_ANIMATION : ICON_NONE];
return CardImage{.texture = &texture, .size = Vec2(texture.size), .isValid = isValid};
return icon_card_get(resources, ICON_ANIMATION, isValid);
},
.activate = open,
.cardLines = LIBRARY_CARD_LINES};
+7
View File
@@ -108,6 +108,13 @@ 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()>&);
// 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&);
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.
+1 -2
View File
@@ -97,8 +97,7 @@ void sounds_update(Panel& panel)
[&](int id) {
auto audio = document.sound_get(id);
auto isValid = audio && audio->is_valid();
auto& texture = resources.icons[isValid ? ICON_SOUND : ICON_NONE];
return CardImage{.texture = &texture, .size = Vec2(texture.size), .isValid = isValid};
return icon_card_get(resources, ICON_SOUND, isValid);
},
.select =
[&](int id) {
+6 -11
View File
@@ -470,29 +470,24 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
ImGui::PopStyleColor(4);
if (!isDraggedFrameActive && ImGui::IsItemHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Left))
{
if (ImGui::IsMouseDown(ImGuiMouseButton_Left))
{
if (type == TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl))
if (!isDraggedFrameActive && ImGui::IsItemHovered() && ImGui::IsMouseDown(ImGuiMouseButton_Left) &&
(type == TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl)))
{
isDraggedFrameActive = true;
draggedFrameReference = frameReference;
draggedFrameType = type;
draggedFrameStart = hoveredTime;
if (type != TRIGGER)
draggedFrameStartDuration = frame.duration;
draggedFrameStartDurations.clear();
if (type != TRIGGER)
{
draggedFrameStartDuration = frame.duration;
for (auto selectedReference : drag_frame_references_get(frameReference))
if (auto selectedFrame = document.model.frame_get(selectedReference))
draggedFrameStartDurations.push_back(
{selectedReference, selectedFrame->duration});
draggedFrameStartDurations.push_back({selectedReference, selectedFrame->duration});
}
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
draggedFrameWidth = frameSize.x;
}
}
}
if (type != TRIGGER)
{