fix an issue that Parameter Panel stole a focus of timeline right before moving/resizing items
This commit is contained in:
@@ -338,19 +338,23 @@ void Timeline::UpdateXGrid() noexcept {
|
||||
}
|
||||
}
|
||||
void Timeline::HandleGrip(Item item, float off, Action ac, Action acdone, ImGuiMouseCursor cur) noexcept {
|
||||
auto ctx = ImGui::GetCurrentContext();
|
||||
auto ctx = ImGui::GetCurrentContext();
|
||||
auto& io = ImGui::GetIO();
|
||||
|
||||
if (ImGui::IsItemActive()) {
|
||||
if (ImGui::IsItemActivated()) {
|
||||
action_ = kSelect;
|
||||
action_grip_moved_ = false;
|
||||
} else {
|
||||
action_ = ac;
|
||||
if (io.MouseDelta.x != 0 || io.MouseDelta.y != 0) {
|
||||
action_grip_moved_ = true;
|
||||
}
|
||||
}
|
||||
action_target_ = item;
|
||||
ImGui::SetMouseCursor(cur);
|
||||
|
||||
off -= 1;
|
||||
off += ImGui::GetCurrentContext()->ActiveIdClickOffset.x;
|
||||
off += ctx->ActiveIdClickOffset.x;
|
||||
|
||||
const auto pos = ImGui::GetMousePos() - ImVec2{off, 0};
|
||||
action_time_ = GetTimeFromScreenX(pos.x);
|
||||
@@ -360,7 +364,7 @@ void Timeline::HandleGrip(Item item, float off, Action ac, Action acdone, ImGuiM
|
||||
|
||||
} else {
|
||||
if (ImGui::IsItemDeactivated()) {
|
||||
action_ = acdone;
|
||||
action_ = action_grip_moved_? acdone: kSelect;
|
||||
action_target_ = item;
|
||||
}
|
||||
if (ctx->LastItemData.ID == ctx->HoveredIdPreviousFrame) {
|
||||
|
@@ -193,6 +193,7 @@ struct Timeline {
|
||||
Action action_;
|
||||
Item action_target_;
|
||||
uint64_t action_time_;
|
||||
bool action_grip_moved_;
|
||||
|
||||
uint64_t action_last_set_time_ = UINT64_MAX; // for kSetTime
|
||||
|
||||
|
@@ -1427,12 +1427,14 @@ void TL::HandleTimelineAction() noexcept {
|
||||
|
||||
case tl_.kResizeBegin:
|
||||
assert(item);
|
||||
item->Select(false);
|
||||
ResizeDisplayTimingOfSelected(
|
||||
action_time_i - static_cast<int64_t>(item->displayTiming().begin()),
|
||||
0);
|
||||
break;
|
||||
case tl_.kResizeEnd:
|
||||
assert(item);
|
||||
item->Select(false);
|
||||
ResizeDisplayTimingOfSelected(
|
||||
0,
|
||||
action_time_i +
|
||||
@@ -1447,6 +1449,7 @@ void TL::HandleTimelineAction() noexcept {
|
||||
|
||||
case tl_.kMove:
|
||||
assert(item);
|
||||
item->Select(false);
|
||||
MoveDisplayTimingOfSelected(
|
||||
action_time_i - static_cast<int64_t>(item->displayTiming().begin()));
|
||||
if (auto layer = reinterpret_cast<TL::Layer*>(tl_.mouseLayer())) {
|
||||
|
Reference in New Issue
Block a user