Share the icon card of sounds and libraries, and merge repeated checks in frame dragging
This commit is contained in:
1 parent
67b2296fc0
commit
c891e1a873
4 files changed
+23
-23
No files matched your search
@@ -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};
|
||||
|
||||
@@ -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
@@ -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) {
|
||||
|
||||
+14
-19
@@ -470,28 +470,23 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
|
||||
|
||||
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))
|
||||
{
|
||||
isDraggedFrameActive = true;
|
||||
draggedFrameReference = frameReference;
|
||||
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;
|
||||
}
|
||||
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});
|
||||
}
|
||||
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
|
||||
draggedFrameWidth = frameSize.x;
|
||||
}
|
||||
|
||||
if (type != TRIGGER)
|
||||
|
||||
Reference in new issue
Block a user