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
+15
-15
No files matched your search
@@ -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};
|
||||||
|
|||||||
@@ -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
@@ -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) {
|
||||||
|
|||||||
@@ -470,29 +470,24 @@ 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))
|
|
||||||
{
|
|
||||||
if (type == TRIGGER || ImGui::IsKeyDown(ImGuiMod_Ctrl))
|
|
||||||
{
|
{
|
||||||
isDraggedFrameActive = true;
|
isDraggedFrameActive = true;
|
||||||
draggedFrameReference = frameReference;
|
draggedFrameReference = frameReference;
|
||||||
draggedFrameType = type;
|
draggedFrameType = type;
|
||||||
draggedFrameStart = hoveredTime;
|
draggedFrameStart = hoveredTime;
|
||||||
if (type != TRIGGER)
|
|
||||||
draggedFrameStartDuration = frame.duration;
|
|
||||||
draggedFrameStartDurations.clear();
|
draggedFrameStartDurations.clear();
|
||||||
if (type != TRIGGER)
|
if (type != TRIGGER)
|
||||||
|
{
|
||||||
|
draggedFrameStartDuration = frame.duration;
|
||||||
for (auto selectedReference : drag_frame_references_get(frameReference))
|
for (auto selectedReference : drag_frame_references_get(frameReference))
|
||||||
if (auto selectedFrame = document.model.frame_get(selectedReference))
|
if (auto selectedFrame = document.model.frame_get(selectedReference))
|
||||||
draggedFrameStartDurations.push_back(
|
draggedFrameStartDurations.push_back({selectedReference, selectedFrame->duration});
|
||||||
{selectedReference, selectedFrame->duration});
|
}
|
||||||
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
|
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
|
||||||
draggedFrameWidth = frameSize.x;
|
draggedFrameWidth = frameSize.x;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type != TRIGGER)
|
if (type != TRIGGER)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user