diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-02-22 15:34:20 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-02-28 13:47:13 +0000 |
commit | 6741e0b808aef4992c81df1128b8db0f8113f49f (patch) | |
tree | e6d96b203c2a2f67ac84d7e038b4c25ed67772dc /src/Authoring/Studio/Palettes/Timeline | |
parent | 26a16b56b39f3904c382c392d7ed958fab73108b (diff) |
Implement graphics view based timeline basics
Add rows, reorder rows, keyframes
Task-number: QT3DS-927
Change-Id: Iaff7354fd5d5b8feaa86364d1b545a48cc3c0376
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Timeline')
73 files changed, 4 insertions, 11613 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.cpp b/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.cpp deleted file mode 100644 index 48fe8993..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "AreaBoundingRect.h" -#include "Renderer.h" -#include "CColor.h" - -//============================================================================= -/** - * Draws the rectangle. - */ -void CAreaBoundingRect::Draw(CRenderer *inRenderer) -{ - CPt theSize = GetSize(); - inRenderer->PushPen(CColor(89, 120, 223)); - - // Removed because alpha doesn't work on Mac - // CColor theOverlayColor( 184, 198, 246 ); - // inRenderer->FillSolidRect( CPt( theSize.x - 1, theSize.y - 1 ) ), theOverlayColor ); - - // Draw the rectangle outline - if (theSize.y > 1 && theSize.x > 1) { - inRenderer->MoveTo(CPt(0, 0)); - inRenderer->LineTo(CPt(0, theSize.y - 1)); - inRenderer->LineTo(CPt(theSize.x - 1, theSize.y - 1)); - inRenderer->LineTo(CPt(theSize.x - 1, 0)); - inRenderer->LineTo(CPt(0, 0)); - } - inRenderer->PopPen(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.h b/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.h deleted file mode 100644 index 1ec98c55..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/AreaBoundingRect.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_AREA_BOUNDING_RECT -#define INCLUDED_AREA_BOUNDING_RECT 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "OverlayControl.h" - -//============================================================================== -// Forwards -//============================================================================== -class CRenderer; - -class CAreaBoundingRect : public COverlayControl -{ -public: - virtual ~CAreaBoundingRect(){} - void Draw(CRenderer *inRenderer) override; - -protected: -}; -#endif // INCLUDED_AREA_BOUNDING_RECT diff --git a/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.cpp b/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.cpp deleted file mode 100644 index 911861ee..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "AssetTimelineKeyframe.h" -#include "StateTimebarlessRow.h" -#include "Renderer.h" -#include "MasterP.h" -#include "StateRow.h" -#include "StateRowUI.h" -#include "KeyframeContextMenu.h" -#include "HotKeys.h" -#include "ResourceCache.h" -#include "ITimelineControl.h" -#include "Bindings/ITimelineItemBinding.h" -#include "StudioUtils.h" -#include "TimeEditDlg.h" -#include "TimelineUIFactory.h" -#include "AbstractTimelineRowUI.h" - -CAssetTimelineKeyframe::CAssetTimelineKeyframe(CStateTimebarlessRow *inParentRow, - double inTimeRatio) - : m_Selected(false) - , m_ParentRow(inParentRow) - , m_IsMouseDown(false) - , m_IsDragging(false) - , m_TimeRatio(inTimeRatio) -{ - CResourceCache *theCache = CResourceCache::GetInstance(); - m_Icon = theCache->GetBitmap("Keyframe-Master-Normal.png"); - m_DisabledIcon = theCache->GetBitmap("Keyframe-Master-Disabled.png"); - m_SelectedIcon = theCache->GetBitmap("Keyframe-Master-Selected.png"); - m_DynamicIcon = theCache->GetBitmap("Keyframe-MasterDynamic-Normal.png"); - m_DynamicSelectedIcon = theCache->GetBitmap("Keyframe-MasterDynamic-Selected.png"); - - m_RightIcon = theCache->GetBitmap("Keyframe-MasterRight-Normal.png"); - m_RightDisabledIcon = theCache->GetBitmap("Keyframe-MasterRight-disabled.png"); - m_RightSelectedIcon = theCache->GetBitmap("Keyframe-MasterRight-Selected.png"); - m_RightDynamicIcon = theCache->GetBitmap("Keyframe-MasterRightDynamic-Normal.png"); - m_RightDynamicSelectedIcon = theCache->GetBitmap("Keyframe-MasterRightDynamic-Selected.png"); - - m_LeftIcon = theCache->GetBitmap("Keyframe-MasterLeft-Normal.png"); - m_LeftDisabledIcon = theCache->GetBitmap("Keyframe-MasterLeft-disabled.png"); - m_LeftSelectedIcon = theCache->GetBitmap("Keyframe-MasterLeft-Selected.png"); - m_LeftDynamicIcon = theCache->GetBitmap("Keyframe-MasterLeftDynamic-Normal.png"); - m_LeftDynamicSelectedIcon = theCache->GetBitmap("Keyframe-MasterLeftDynamic-Selected.png"); - - m_RectOverHandled = false; - m_PreviousSelectState = false; -} - -CAssetTimelineKeyframe::~CAssetTimelineKeyframe() -{ -} - -//============================================================================= -/** - * SetRectOverHandled: Sets if mouse rectangle has been handled - * param@ inState indicates if the rectangle over has been handled. - * return@ NONE - */ - -void CAssetTimelineKeyframe::SetRectOverHandled(bool inState) -{ - m_RectOverHandled = inState; -} - -//============================================================================= -/** - * GetRectOverHandled: GetRectOverHandled - * param@ NONE - * return@ m_RectOverHandled, which indicates if the rectangle over has been handled - */ -bool CAssetTimelineKeyframe::GetRectOverHandled() -{ - return m_RectOverHandled; -} - -//============================================================================= -/** - * SetPreviousSelectState: Sets if the current keyframe was previously selected - * param@ inState is used to set m_PreviousSelectState. - * return@ NONE - */ -void CAssetTimelineKeyframe::SetPreviousSelectState(bool inState) -{ - m_PreviousSelectState = inState; -} - -//============================================================================= -/** - * GetPreviousSelectState: Returns the keyframe's previous select state - * param@ NONE - * return@ m_PreviousSelectState that stores the select state for the keyframe - */ -bool CAssetTimelineKeyframe::GetPreviousSelectState() -{ - return m_PreviousSelectState; -} - -//============================================================================= -/** -* Updates the ToolTip and moves it to the correct place on screen. -* @param inPoint the point that the tooltip is supposed to be placed. -*/ -void CAssetTimelineKeyframe::RefreshToolTip(CPt inPoint) -{ - Q3DStudio::CString theCommentText; - CStateRowUI *theStateRow = m_ParentRow->GetStateRowUI(); - CRct theTimelineBounds(theStateRow->GetTopControl()->GetBounds()); - - // format label - theCommentText = " " + ::FormatTimeString(GetTime()); - - inPoint.y = GetPosition().y - GetSize().y; - inPoint.x = GetSize().x / 2; - ShowMoveableWindow(inPoint, theCommentText, theTimelineBounds); -} - -//============================================================================= -/** - * Gets the correct image and draws - */ -void CAssetTimelineKeyframe::Draw(CRenderer *inRenderer) -{ - inRenderer->DrawBitmap(CPt(0, 0), GetImage()); -} - -//============================================================================= -/** - * Gets the name of the current bitmap depending on the state of the button, - * postion of the mouse, etc. Returns name of the image for the up state by - * default. - * @return name of the image representing current state of the button - */ -QPixmap CAssetTimelineKeyframe::GetImage() const -{ - QPixmap theImage = m_Icon; - auto baseStateRow = static_cast<CBaseStateRow *>(m_ParentRow->GetStateRowUI()->GetTimelineRow()); - long theStartTime = baseStateRow->GetStartTime(); - long theEndTime = baseStateRow->GetEndTime(); - - if (theStartTime == m_Time) { - theImage = m_LeftIcon; - if (!IsEnabled()) - theImage = m_LeftDisabledIcon; - else if (m_IsDynamic) { - if (m_Selected) - return m_LeftDynamicSelectedIcon; - else - return m_LeftDynamicIcon; - } else if (m_Selected) - theImage = m_LeftSelectedIcon; - } else if (theEndTime == m_Time) { - theImage = m_RightIcon; - if (!IsEnabled()) - theImage = m_RightDisabledIcon; - else if (m_IsDynamic) { - if (m_Selected) - return m_RightDynamicSelectedIcon; - else - return m_RightDynamicIcon; - } else if (m_Selected) - theImage = m_RightSelectedIcon; - } else { - if (!IsEnabled()) - theImage = m_DisabledIcon; - else if (m_IsDynamic) { - if (m_Selected) - return m_DynamicSelectedIcon; - else - return m_DynamicIcon; - } else if (m_Selected) - theImage = m_SelectedIcon; - } - return theImage; -} - -//============================================================================= -/** - * @return true if the mouse is over the keyframe - * @param inPoint the point where the mouse is - */ -bool CAssetTimelineKeyframe::HitTest(const CPt &inPoint) const -{ - bool theRetVal = false; - // If not over the control then don't bother with specific checks - if (CControl::HitTest(inPoint)) { - // If the key is at the beginning or end of the timebar then calculate the test differently - auto baseStateRow = static_cast<CBaseStateRow *>(m_ParentRow->GetStateRowUI()->GetTimelineRow()); - long theStartTime = baseStateRow->GetStartTime(); - long theEndTime = baseStateRow->GetEndTime(); - CPt thePoint = inPoint - GetPosition(); - if (theStartTime == m_Time) - theRetVal = (thePoint.x > 7); - else if (theEndTime == m_Time) - theRetVal = (thePoint.x < 9); - else { - if (m_Selected) - theRetVal = (thePoint.x > 1 && thePoint.x < 15); - else - theRetVal = (thePoint.x > 3 && thePoint.x < 13); - } - } - return theRetVal; -} - -//============================================================================= -/** - * Handler for left mouse down events. - * @param inPoint the point where the mouse is - * @param inFlags indicates modifier keys that were down at time of the event - */ -bool CAssetTimelineKeyframe::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // Store the mouse down location in screen coordinates so that we can check the dragging buffer - // in OnMouseMove - m_MouseDownLoc = inPoint; - - if (!CControl::OnMouseDown(inPoint, inFlags)) { - bool theClearPreviouslySelectedKeys = false; - bool theSelectedFlag = false; - // If the control key is down then we change state, otherwise - if (!((CHotKeys::MODIFIER_CONTROL & inFlags) == CHotKeys::MODIFIER_CONTROL)) { - theClearPreviouslySelectedKeys = !m_Selected; // clear if not multi-selecting - theSelectedFlag = true; - } else { - theSelectedFlag = !m_Selected; - } - m_ParentRow->OnKeySelected(m_Time, theSelectedFlag, theClearPreviouslySelectedKeys); - m_Selected = theSelectedFlag; // set this after OnKeySelected, because the function may - // clear out all previously selected keys including this - // TODO : sk - 1-1 mapping of seemingly useless calls in - // CPropertyTimelineKeyframe::OnMouseDown, see my comments there. - // m_StudioDoc->UpdateClientScene( true ); - // m_ParentRow->GetStateRow( )->GetState( )->FireAnimatedPropertiesChanged( ); - - m_IsMouseDown = true; - auto theStateRow = static_cast<CBaseStateRow *>(m_ParentRow->GetStateRowUI()->GetTimelineRow()); - long theStartTime = theStateRow->GetStartTime(); - long theEndTime = theStateRow->GetEndTime(); - m_Snapper.SetStartEndTime(theStartTime, theEndTime); - m_Snapper.SetSource(this); - m_Snapper.SetKeyFrameClicked(true); - m_Snapper.SetSnappingSelectedKeyframes(false); - - m_ParentRow->GetStateRowUI()->GetTimebar()->GetSnappingListProvider().PopulateSnappingList(&m_Snapper); - m_Snapper.BeginDrag(inPoint.x); - - // display the time range tooltip - RefreshToolTip(inPoint); - } - return true; -} - -//============================================================================= -/** - * Handler for right mouse down events. - * @param inPoint the point where the mouse is - * @param inFlags indicates modifier keys that were down at time of the event - */ -bool CAssetTimelineKeyframe::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseRDown(inPoint, inFlags)) { - if (!m_Selected) { - m_Selected = true; - m_ParentRow->OnKeySelected(m_Time, m_Selected, true); - } - ITimelineItemProperty *iProperty = nullptr; - if (GetTimelineItemBinding()->GetPropertyCount() > 0) { - iProperty = GetTimelineItemBinding()->GetProperty(0); - } - CKeyframeContextMenu theMenu(GetTimelineItemBinding()->GetKeyframesManager(), iProperty); - theMenu.SetTime(GetTime()); - DoPopup(&theMenu, inPoint); - } - - return true; -} - -//============================================================================= -/** - * called when this key is selected - * - * @param inState the state this key is selected to - */ -void CAssetTimelineKeyframe::Select(bool inState) -{ - if (m_Selected != inState) { - m_Selected = inState; - Invalidate(); - } -} - -//============================================================================= -/** - * handler for the mouse up event - * @param inFlags the state of things when the mouse button was released - * @param inPoint the point where the mouse is - */ -void CAssetTimelineKeyframe::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); - m_IsMouseDown = false; - m_IsDragging = false; - - GetTimelineItemBinding()->CommitChangedKeyframes(); - - HideMoveableWindow(); - Invalidate(); -} - -//============================================================================= -/** - * handler for the onMouse Move event. Offsets selected keys. - * Displays the StudioToolTip for the keyframe, showing the time it is at. - * - * @param inFlags the state of things when the mouse was moved - * @param inPoint the point where the mouse is - */ -void CAssetTimelineKeyframe::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - QT3DS_PROFILE(OnMouseMove); - // If the mouse is down and this is slected, then offst the keys - if (m_IsMouseDown && m_Selected) { - // If we are not yet dragging the keyframe - if (!m_IsDragging) { - long theDiff = ::abs(inPoint.x) - m_MouseDownLoc.x; - // Figure out if the mouse has moved far enough to start the drag, and readjust the drag - // postion on the snapper - m_IsDragging = (::abs(theDiff) > DRAGBUFFER); - if (m_IsDragging && (::abs(theDiff) - DRAGBUFFER) > 2) { - m_Snapper.BeginDrag(m_MouseDownLoc.x); - } else - m_Snapper.BeginDrag(inPoint.x); - } - - // If we are now dragging, procceed as normal - if (m_IsDragging) { - long theNewTime = m_Snapper.ProcessDrag(m_Time, inPoint.x, inFlags); - long theDiffTime = theNewTime - m_Time; - - if (theDiffTime != 0) { - // theDiffTime can get updated if its invalid. - theDiffTime = GetTimelineItemBinding()->OffsetSelectedKeyframes(theDiffTime); - // Set this key's time so it won't be recalced in Refresh keyframes in the row - SetTime(m_Time + theDiffTime); - - Invalidate(); - } - } - - // display the time range tooltip - RefreshToolTip(inPoint); - } -} - -//============================================================================= -/** - * Sets the time ratio - * - * @param inTimeRatio the new ratio - */ -void CAssetTimelineKeyframe::SetTimeRatio(double inTimeRatio) -{ - m_TimeRatio = inTimeRatio; - CPt theSize = GetSize(); - SetPosition(::TimeToPos(GetTime(), m_TimeRatio) - (theSize.x / 2), 0); -} - -//============================================================================= -/** - * Pass the double click notification on to the row and have it process it. - * The row will do object-specific actions on doubleclicks. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - * @return true stating that the event was processed. - */ -bool CAssetTimelineKeyframe::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inPoint); - Q_UNUSED(inFlags); - - GetTimelineItemBinding()->OnEditKeyframeTime(m_Time, ASSETKEYFRAME); - m_IsMouseDown = false; - m_IsDragging = false; - return true; -} - -//============================================================================= -/** - * @return true if selected - */ -bool CAssetTimelineKeyframe::IsSelected() -{ - return m_Selected; -} - -void CAssetTimelineKeyframe::SetSize(CPt inSize) -{ - CControl::SetSize(inSize); -} - -//============================================================================= -/** - * - */ -ITimelineItemBinding *CAssetTimelineKeyframe::GetTimelineItemBinding() const -{ - return m_ParentRow->GetStateRowUI()->GetTimelineRow()->GetTimelineItemBinding(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.h b/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.h deleted file mode 100644 index 54a8b501..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/AssetTimelineKeyframe.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_ASSET_TIMELINE_KEYFRAME -#define INCLUDED_ASSET_TIMELINE_KEYFRAME 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "Control.h" -#include "TimelineKeyframe.h" -#include "Snapper.h" - -#include <QPixmap> - -//============================================================================== -// Forwards -//============================================================================== -class CRenderer; -class CStateTimebarlessRow; -class ITimelineItemBinding; - -class CAssetTimelineKeyframe : public CControl, public CTimelineKeyframe -{ - -public: - CAssetTimelineKeyframe(CStateTimebarlessRow *inParentRow, double inTimeRatio); - ~CAssetTimelineKeyframe(); - - void Draw(CRenderer *inRenderer) override; - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void Select(bool inState); - void SetTimeRatio(double inTimeRatio); - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool IsSelected(); - void SetSize(CPt inSize) override; - bool HitTest(const CPt &inPoint) const override; - void SetRectOverHandled(bool inState); - bool GetRectOverHandled(); - void SetPreviousSelectState(bool inState); - bool GetPreviousSelectState(); - -protected: - void RefreshToolTip(CPt inPoint); - QPixmap GetImage() const; - ITimelineItemBinding *GetTimelineItemBinding() const; - -protected: - bool m_RectOverHandled; ///< Indicates if the mouse rect over has been handled. - bool m_PreviousSelectState; ///< Stores the previous select state for the keyframe. - bool m_Selected; - CStateTimebarlessRow *m_ParentRow; - bool m_IsMouseDown; - CPt m_MouseDownLoc; ///< Location of the mouse after an OnMouseDownEvent, in client coordinates - bool m_IsDragging; ///< Indicates whether or not the keyframe is currently being dragged, - ///determined by the pixel buffer - double m_TimeRatio; - - CSnapper m_Snapper; - QPixmap m_Icon; - QPixmap m_DisabledIcon; - QPixmap m_SelectedIcon; - QPixmap m_DynamicIcon; - QPixmap m_DynamicSelectedIcon; - QPixmap m_LeftIcon; - QPixmap m_LeftDisabledIcon; - QPixmap m_LeftSelectedIcon; - QPixmap m_LeftDynamicIcon; - QPixmap m_LeftDynamicSelectedIcon; - QPixmap m_RightIcon; - QPixmap m_RightDisabledIcon; - QPixmap m_RightSelectedIcon; - QPixmap m_RightDynamicIcon; - QPixmap m_RightDynamicSelectedIcon; -}; - -#endif // INCLUDED_ASSET_TIMELINE_KEYFRAME diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseStateRow.cpp b/src/Authoring/Studio/Palettes/Timeline/BaseStateRow.cpp index 30b80ab8..a9a65b9a 100644 --- a/src/Authoring/Studio/Palettes/Timeline/BaseStateRow.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/BaseStateRow.cpp @@ -32,8 +32,6 @@ #include "BaseStateRow.h" #include "PropertyRow.h" #include "StateRowFactory.h" -#include "TimelineTimelineLayout.h" -#include "ComponentContextMenu.h" #include "ResourceCache.h" #include "StudioUtils.h" #include "Bindings/ITimelineItemBinding.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.cpp b/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.cpp deleted file mode 100644 index f33031f2..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "BaseStateRowUI.h" - -#include "BaseStateRow.h" -#include "BaseTimelineTreeControl.h" -#include "BaseTimebarlessRow.h" -#include "ColorControl.h" -#include "PropertyRow.h" -#include "StateRow.h" -#include "ToggleControl.h" -#include "TimelineRow.h" -#include "TimelineUIFactory.h" -#include "ITimelineControl.h" -#include "StudioPreferences.h" -#include "Snapper.h" -#include "PropertyRowUI.h" -#include "ComponentContextMenu.h" - -#include "Bindings/ITimelineItemBinding.h" - -const long CBaseStateRowUI::DEFAULT_TOGGLE_LENGTH = 57; - -CBaseStateRowUI::CBaseStateRowUI(CBaseStateRow *baseStateRow, - CAbstractTimelineRowUI *parentUiRow) - : CAbstractTimelineRowUI(baseStateRow, parentUiRow) - , m_TreeList(true)// true to align the children in the timeline. - , m_TreeControl(nullptr) - , m_ColorControl(nullptr) - , m_ToggleControl(nullptr) - , m_TimebarControl(nullptr) - , m_baseStateRow(baseStateRow) - , m_Highlighted(false) -{ - connectBackend(); -} - -CBaseStateRowUI::~CBaseStateRowUI() -{ - delete m_TreeControl; - delete m_ColorControl; - delete m_ToggleControl; - delete m_TimebarControl; -} - -void CBaseStateRowUI::Initialize() -{ - m_TreeControl = new CBaseTimelineTreeControl(this, m_baseStateRow->GetTimelineItem()->IsMaster()); - m_ColorControl = new CColorControl(m_baseStateRow); - m_ToggleControl = CreateToggleControl(); - m_TimebarControl = CreateTimebarRow(); - - m_timelineRow->setDirty(true); - - long theTimebarHeight = CStudioPreferences::GetRowSize(); - m_TreeControl->SetSize(CPt(500, theTimebarHeight)); - m_ColorControl->SetAbsoluteSize(CPt(theTimebarHeight, theTimebarHeight)); - m_ToggleControl->SetAbsoluteSize(CPt(DEFAULT_TOGGLE_LENGTH, theTimebarHeight)); - m_TimebarControl->SetSize(CPt(800, theTimebarHeight)); - - ::CColor theColor = m_timelineRow->GetTimebarBackgroundColor(m_timelineRow->GetObjectType()); - m_TreeControl->SetBackgroundColor(theColor); - m_ToggleControl->SetBackgroundColor(theColor); - m_TimebarControl->SetBackgroundColor(theColor); - - m_ColorList.AddChild(m_ColorControl); - m_TreeList.AddChild(m_TreeControl); - m_ToggleList.AddChild(m_ToggleControl); - m_TimebarList.AddChild(m_TimebarControl); - - m_timelineRow->setDirty(false); -} - -void CBaseStateRowUI::connectBackend() -{ - connect(m_baseStateRow, &CBaseStateRow::initialized, - this, &CBaseStateRowUI::Initialize); - connect(m_baseStateRow, &CBaseStateRow::dirtyChanged, - this, &CBaseStateRowUI::handleDirtyChange); - connect(m_baseStateRow, &CBaseStateRow::propertyRowAdded, - this, &CBaseStateRowUI::handlePropertyRowAdded); - connect(m_baseStateRow, &CBaseStateRow::rowAdded, - this, &CBaseStateRowUI::handleRowAdded); - connect(m_baseStateRow, &CBaseStateRow::childrenLoaded, - this, &CBaseStateRowUI::handleChildrenLoaded); - connect(m_baseStateRow, &CBaseStateRow::timeRatioChanged, - this, &CBaseStateRowUI::setTimeRatio); - connect(m_baseStateRow, &CBaseStateRow::expanded, - this, &CBaseStateRowUI::handleExpanded); - connect(m_baseStateRow, &CBaseStateRow::visibleChanged, - this, &CBaseStateRowUI::handleVisibleChanged); - connect(m_baseStateRow, &CBaseStateRow::hasChildrenChanged, - this, &CBaseStateRowUI::handleHasChildrenChanged); - connect(m_baseStateRow, &CBaseStateRow::rowAboutToBeRemoved, - this, &CBaseStateRowUI::handleRowAboutToBeRemoved); - connect(m_baseStateRow, &CBaseStateRow::selectAllKeys, - this, &CBaseStateRowUI::handleSelectAllKeys); - connect(m_baseStateRow, &CBaseStateRow::selectedChanged, - this, &CBaseStateRowUI::handleSelectedChanged); - connect(m_baseStateRow, &CBaseStateRow::addRowToUILists, - this, &CBaseStateRowUI::handleAddRowToUILists); - connect(m_baseStateRow, &CBaseStateRow::refreshRowMetaData, - this, &CBaseStateRowUI::handleRefreshRowMetaDataRequest); - connect(m_baseStateRow, &CBaseStateRow::setNameReadOnly, - this, [this] { SetNameReadOnly(true);}); - connect(m_baseStateRow, &CBaseStateRow::updateActionStatus, - this, &CBaseStateRowUI::UpdateActionStatus); -} - -//============================================================================= -/** - * Get the color control for this row. - * @return the color control for this row. - */ -CControl *CBaseStateRowUI::GetColorControl() -{ - return &m_ColorList; -} - -//============================================================================= -/** - * Get the tree control for this row. - * @return the tree control for this row. - */ -CControl *CBaseStateRowUI::GetTreeControl() -{ - return &m_TreeList; -} - -//============================================================================= -/** - * Get the toggle control for this row. - * @return the toggle control for this row. - */ -CControl *CBaseStateRowUI::GetToggleControl() -{ - return &m_ToggleList; -} - -//============================================================================= -/** - * Get the timebar control for this row. - * @return the timebar control for this row. - */ -CControl *CBaseStateRowUI::GetTimebarControl() -{ - return &m_TimebarList; -} - -CBaseTimebarlessRow *CBaseStateRowUI::GetTimebar() const -{ - return m_TimebarControl; -} - -//============================================================================= -/** - * Restores the focus state of this row. - */ -void CBaseStateRowUI::SetFocus() -{ - if (!initialized()) - return; - - CControl *theParent = m_TreeControl->GetParent(); - if (theParent) - theParent->GrabFocus(m_TreeControl); -} - -void CBaseStateRowUI::SetNameReadOnly(bool inReadOnly) -{ - if (!initialized()) - return; - - m_TreeControl->SetNameReadOnly(inReadOnly); -} - -//============================================================================= -/** - * Call from the child controls that the mouse is over one of the children. - * This is used to highlight the entire row on mouse over. - */ -void CBaseStateRowUI::OnMouseOver() -{ - if (!initialized()) - return; - - if (!m_Highlighted) { - try { - // TODO: Added the try/catch block to prevent crashing when the instance handle is not - // found - // this will happen sometimes when delete the object from the timeline - // need to really fix this at the root. - ::CColor theColor = m_baseStateRow->GetTimebarHighlightBackgroundColor( - m_baseStateRow->GetObjectType()); - m_TreeControl->SetBackgroundColor(theColor); - m_ToggleControl->SetBackgroundColor(theColor); - m_TimebarControl->SetBackgroundColor(theColor); - - m_Highlighted = true; - } catch (...) { - } - } -} - - -//============================================================================= -/** - * Call from the child controls that the mouse is no longer over one of the children. - * This is used to highlight the entire row on mouse over. - */ -void CBaseStateRowUI::OnMouseOut() -{ - if (!initialized()) - return; - - if (m_Highlighted) { - try { - // TODO: Added the try/catch block to prevent crashing when the instance handle is not - // found - // this will happen sometimes when delete the object from the timeline - // need to really fix this at the root. - ::CColor theColor = m_baseStateRow->GetTimebarBackgroundColor( - m_baseStateRow->GetObjectType()); - m_TreeControl->SetBackgroundColor(theColor); - m_ToggleControl->SetBackgroundColor(theColor); - m_TimebarControl->SetBackgroundColor(theColor); - - m_Highlighted = false; - } catch (...) { - } - } -} - -//============================================================================= -/** - * Called when the mouse is double clicked. - * @param inPoint location of the mouse at time of event - * @param inFlags modifier key states at time of event - */ -void CBaseStateRowUI::OnMouseDoubleClick(CPt, Qt::KeyboardModifiers inFlags) -{ - // Do nothing by default. Let subclasses define what to do. - Q_UNUSED(inFlags); -} - -//============================================================================= -/** - * Show context menu for this row - */ -void CBaseStateRowUI::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!initialized()) - return; - - Q_UNUSED(inFlags); - - m_baseStateRow->Select(Qt::NoModifier); // ensure this is selected, but doesn't affect any key - // selections, because this can be triggered from a - // key being selected - CComponentContextMenu theMenu(m_TreeControl, m_baseStateRow->GetTimelineItemBinding()); - m_TreeControl->DoPopup(&theMenu, inPoint); -} - -void CBaseStateRowUI::OnChildVisibilityChanged() -{ - if (!initialized()) - return; - - m_TreeControl->SetToggleVisible(m_timelineRow->HasVisibleChildren()); -} - -//============================================================================= -/** - * Selects keys in a given rect - * @param inRect the rect to use for selection - */void CBaseStateRowUI::SelectKeysInRect(CRct inRect, bool inModifierKeyDown, bool inGlobalCommitSelectionFlag) -{ - if (!initialized()) - return; - - CRct theOffsetRect = inRect; - theOffsetRect.Offset(-m_TimebarList.GetPosition()); - - // KDAB_TODO avoid deep copy - auto propertyRows = m_baseStateRow->GetPropertyRows(); - - // Commits the keyframe selection by setting the keyframes' previous state to its current state, - // when the user releases the mouse button. - // This will help the keyframes to retain their original states even though they are - // not in the mouse select region. - if (inGlobalCommitSelectionFlag) { - m_TimebarControl->CommitSelections(); - - // iterates through every property row and commits the selection states of properties - // keyframes - auto thePropPos = propertyRows.begin(); - for (; thePropPos != propertyRows.end(); ++thePropPos) { - CPropertyRow *thePropRow = (*thePropPos); - if (thePropRow && thePropRow->IsViewable()) { - auto uiRow = static_cast<CPropertyRowUI *>(TimelineUIFactory::instance()->uiForRow(thePropRow)); - uiRow->CommitSelections(); - } - } - } - - if (m_timelineRow->isExpanded()) { - // Iterates each property row and select the keys that are in the rectangle - auto thePropPos = propertyRows.begin(); - for (; thePropPos != propertyRows.end(); ++thePropPos) { - CPropertyRow *thePropRow = (*thePropPos); - if (thePropRow && thePropRow->IsViewable()) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(thePropRow); - uiRow->SelectKeysInRect(theOffsetRect, inModifierKeyDown, false); - } - } - - // KDAB_TODO avoid deep copy - auto stateRows = m_baseStateRow->GetStateRows(); - // Recurse the each state row (or master row) and selects the property keyframes in them - auto thePos = stateRows.begin(); - for (; thePos != stateRows.end(); ++thePos) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(*thePos); - uiRow->SelectKeysInRect(theOffsetRect, inModifierKeyDown, - inGlobalCommitSelectionFlag); - } - - } else { - // Selects all the master key frames in the rect - m_TimebarControl->SelectKeysInRect(theOffsetRect, inModifierKeyDown); - } -} - -//============================================================================= -/** - * Add snapping points to inSnappingList. - * This will add the snapping points for any visible objects to inSnappingList. - * @param inSnappingList the list to add the snapping points to. - */ -void CBaseStateRowUI::PopulateSnappingList(CSnapper *inSnappingList) -{ - if (!initialized()) - return; - - inSnappingList->PushOffset(-m_TimebarList.GetPosition().y); - m_TimebarControl->PopulateSnappingList(inSnappingList); - - if (m_timelineRow->isExpanded()) { - auto baseStateRow = static_cast<CBaseStateRow *>(m_timelineRow); - // KDAB_TODO avoid deep copy - auto stateRows = baseStateRow->GetStateRows(); - - auto thePos = stateRows.begin(); - for (; thePos != stateRows.end(); ++thePos) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(*thePos); - uiRow->PopulateSnappingList(inSnappingList); - } - } -} - -//============================================================================= -/** - * Begin dragging. - * sk - potential spot for refactoring the Drag&Drop implementation. - * Right now, each IDragable is implicitly assumed to be a asset implementation. See - * *DropSource.cpp: each IDragable is dynamically cast to its implementation. - */ -void CBaseStateRowUI::DoStartDrag(CControlWindowListener *inWndListener) -{ - m_timelineRow->GetTimelineItemBinding()->DoStartDrag(inWndListener); -} - -void CBaseStateRowUI::AcceptDropAfter(bool inAccept) -{ - if (!initialized()) - return; - m_TreeControl->AcceptDropAfter(inAccept); -} - -void CBaseStateRowUI::AcceptDropBefore(bool inAccept) -{ - if (!initialized()) - return; - m_TreeControl->AcceptDropBefore(inAccept); -} - -//============================================================================= -/** - * Pass through to the binding to set up the target aset for a drag&drop action on this - *control. - */ -void CBaseStateRowUI::SetDropTarget(CDropTarget *inDropTarget) -{ - m_timelineRow->GetTimelineItemBinding()->SetDropTarget(inDropTarget); -} - -//============================================================================= -/** - * Sets all the child control enable states - * @param inEnabled the state to set the controls to - */ -void CBaseStateRowUI::SetEnabled(bool inEnabled) -{ - if (!initialized()) - return; - m_TreeControl->SetEnabled(inEnabled); - m_ToggleControl->SetEnabled(inEnabled); - m_ColorControl->SetEnabled(inEnabled); - m_TimebarControl->SetEnabled(inEnabled); -} - -void CBaseStateRowUI::UpdateActionStatus() -{ - if (!initialized()) - return; - m_ColorControl->UpdateIconStatus(); -} - -void CBaseStateRowUI::setTimeRatio(double inTimeRatio) -{ - if (!initialized()) - return; - m_TimebarControl->SetTimeRatio(inTimeRatio); -} - -void CBaseStateRowUI::handleDirtyChange(bool dirty) -{ - if (!initialized()) - return; - - if (dirty) { - m_TimebarControl->SetDirty(true); - m_TreeControl->Refresh(m_baseStateRow->GetTimelineItemBinding()->GetTimelineItem()); - m_ToggleControl->Refresh(); - m_ColorControl->Invalidate(); - m_TimebarControl->RefreshRowMetaData(); - } -} - -void CBaseStateRowUI::handleRowAdded(CBaseStateRow *row) -{ - auto uiRow = TimelineUIFactory::instance()->uiForRow(row); - CControl *theTreeControl = uiRow->GetTreeControl(); - if (theTreeControl) - theTreeControl->EnsureVisible(); -} - -void CBaseStateRowUI::handlePropertyRowAdded(CPropertyRow *row) -{ - if (!initialized()) - return; - - // For snapping timebars/keyframes - auto uiRow = TimelineUIFactory::instance()->uiForRow(row); - uiRow->SetSnappingListProvider(GetSnappingListProvider()); - - m_TimebarControl->SetDirty(true); -} - -void CBaseStateRowUI::handleChildrenLoaded() -{ - GetTopControl()->OnLayoutChanged(); -} - -void CBaseStateRowUI::handleVisibleChanged(bool visible) -{ - m_ColorList.SetVisible(visible); - m_TreeList.SetVisible(visible); - m_ToggleList.SetVisible(visible); - m_TimebarList.SetVisible(visible); -} - -void CBaseStateRowUI::handleHasChildrenChanged(bool hasChildren) -{ - m_TreeControl->SetToggleVisible(hasChildren); -} - -void CBaseStateRowUI::handleRowAboutToBeRemoved(CTimelineRow *row) -{ - auto uiRow = TimelineUIFactory::instance()->uiForRow(row); - - m_ColorList.RemoveChild(uiRow->GetColorControl()); - m_TreeList.RemoveChild(uiRow->GetTreeControl()); - m_ToggleList.RemoveChild(uiRow->GetToggleControl()); - m_TimebarList.RemoveChild(uiRow->GetTimebarControl()); -} - -void CBaseStateRowUI::handleSelectAllKeys() -{ - if (!initialized()) - return; - - m_TimebarControl->SelectAllKeys(); -} - -void CBaseStateRowUI::handleSelectedChanged(bool selected) -{ - if (!initialized()) - return; - - if (selected) { - m_TreeControl->EnsureVisible(); - - m_TreeControl->OnSelect(); - m_ToggleControl->OnSelect(); - m_ColorControl->OnSelect(); - m_TimebarControl->OnSelect(); - } else { - m_TreeControl->OnDeselect(); - m_ToggleControl->OnDeselect(); - m_ColorControl->OnDeselect(); - m_TimebarControl->OnDeselect(); - } -} - -void CBaseStateRowUI::handleAddRowToUILists(CTimelineRow *inRow, CTimelineRow *inNextRow, CFilter &inFilter) -{ - // Default the insert locations to the end of the list. - CControl *theNextColorControl = nullptr; - CControl *theNextTreeControl = nullptr; - CControl *theNextToggleControl = nullptr; - CControl *theNextTimebarControl = nullptr; - if (inNextRow) { - auto uiNextRow = TimelineUIFactory::instance()->uiForRow(inNextRow); - - theNextColorControl = uiNextRow->GetColorControl(); - theNextTreeControl = uiNextRow->GetTreeControl(); - theNextToggleControl = uiNextRow->GetToggleControl(); - theNextTimebarControl = uiNextRow->GetTimebarControl(); - } - - auto inRowUI = TimelineUIFactory::instance()->uiForRow(inRow); - inRowUI->SetIndent(m_Indent + CTimelineRow::TREE_INDENT); - inRow->SetParent(m_timelineRow); - inRow->Filter(inFilter); - inRow->SetTimeRatio(m_timelineRow->GetTimeRatio()); - - CControl *theColorControl = inRowUI->GetColorControl(); - CControl *theTreeControl = inRowUI->GetTreeControl(); - CControl *theToggleControl = inRowUI->GetToggleControl(); - CControl *theTimebarControl = inRowUI->GetTimebarControl(); - - // If not expanded then hide the controls. - if (!m_timelineRow->isExpanded()) { - theColorControl->SetVisible(false); - theTreeControl->SetVisible(false); - theToggleControl->SetVisible(false); - theTimebarControl->SetVisible(false); - } - - // Add the controls to the lists in the prioritized order - m_ColorList.AddChild(theColorControl, theNextColorControl); - m_TreeList.AddChild(theTreeControl, theNextTreeControl); - m_ToggleList.AddChild(theToggleControl, theNextToggleControl); - m_TimebarList.AddChild(theTimebarControl, theNextTimebarControl); - - m_TreeControl->SetToggleVisible(m_timelineRow->HasVisibleChildren()); -} - -void CBaseStateRowUI::handleRefreshRowMetaDataRequest() -{ - if (initialized()) - m_TimebarControl->RefreshRowMetaData(); -} - -void CBaseStateRowUI::handleExpanded(bool expanded) -{ - if (!initialized()) - return; - - m_TreeControl->SetExpanded(expanded); - m_ColorControl->UpdateIconStatus(); -} - - -//============================================================================= -/** - * By default, we don't show shy/eye/lock toggles - */ -CBlankToggleControl *CBaseStateRowUI::CreateToggleControl() -{ - return new CBlankToggleControl(this); -} - -bool CBaseStateRowUI::initialized() const -{ - return m_TreeControl && m_ToggleControl && m_ColorControl && m_TimebarControl; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.h b/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.h deleted file mode 100644 index 2e748ab6..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseStateRowUI.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BASESTATEROWUI_H -#define BASESTATEROWUI_H - -#include "AbstractTimelineRowUI.h" -#include "ListLayout.h" - -#include <QObject> - -class CBaseTimelineTreeControl; -class CColorControl; -class CBlankToggleControl; -class CBaseTimebarlessRow; -class CBaseStateRow; -class CPropertyRow; -class CFilter; -class CSnapper; - -class CBaseStateRowUI : public CAbstractTimelineRowUI -{ - Q_OBJECT -public: - static const long DEFAULT_TOGGLE_LENGTH; - - CBaseStateRowUI(CBaseStateRow *baseStateRow, CAbstractTimelineRowUI *parentUiRow); - ~CBaseStateRowUI(); - - CControl *GetColorControl() override; - CControl *GetTreeControl() override; - CControl *GetToggleControl() override; - CControl *GetTimebarControl() override; - - CBaseTimebarlessRow *GetTimebar() const; - - void SetFocus() override; - void SetNameReadOnly(bool inReadOnly) override; - - void OnChildVisibilityChanged() override; - void SelectKeysInRect(CRct inRect, bool inModifierKeyDown, - bool inGlobalCommitSelectionFlag) override; - void PopulateSnappingList(CSnapper *inSnappingList) override; - - void DoStartDrag(CControlWindowListener *inWndListener) override; - void AcceptDropAfter(bool inAccept) override; - void AcceptDropBefore(bool inAccept) override; - void SetDropTarget(CDropTarget *inDropTarget) override; - - void SetEnabled(bool inEnabled) override; - void UpdateActionStatus() override; - - virtual void OnMouseOver(); - virtual void OnMouseOut(); - virtual void OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags); - virtual void OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags); - -private Q_SLOTS: - void Initialize() override; - void setTimeRatio(double inTimeRatio); - void handleDirtyChange(bool dirty); - void handleRowAdded(CBaseStateRow *row); - void handlePropertyRowAdded(CPropertyRow *row); - void handleChildrenLoaded(); - void handleExpanded(bool expanded); - void handleVisibleChanged(bool visible); - void handleHasChildrenChanged(bool hasChildren); - void handleRowAboutToBeRemoved(CTimelineRow *row); - void handleSelectAllKeys(); - void handleSelectedChanged(bool selected); - void handleAddRowToUILists(CTimelineRow *inRow, CTimelineRow *inNextRow, CFilter &inFilter); - void handleRefreshRowMetaDataRequest(); - -protected: - void connectBackend(); - - virtual CBlankToggleControl *CreateToggleControl(); - virtual CBaseTimebarlessRow *CreateTimebarRow() = 0; - - bool initialized() const; - - CListLayout m_ColorList; - CListLayout m_TreeList; - CListLayout m_ToggleList; - CListLayout m_TimebarList; - - CBaseTimelineTreeControl *m_TreeControl; - CColorControl *m_ColorControl; - CBlankToggleControl *m_ToggleControl; - CBaseTimebarlessRow *m_TimebarControl; - CBaseStateRow *m_baseStateRow; - - bool m_Highlighted; -}; - -#endif // BASESTATEROWUI_H diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.cpp b/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.cpp deleted file mode 100644 index 84bee54e..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "BaseTimebarlessRow.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "BaseStateRow.h" -#include "BaseStateRowUI.h" - -CBaseTimebarlessRow::CBaseTimebarlessRow() - : m_Selected(false) - , m_DirtyFlag(true) - , m_TimeRatio(0.0f) -{ -} - -CBaseTimebarlessRow::~CBaseTimebarlessRow() -{ -} - -void CBaseTimebarlessRow::Draw(CRenderer *inRenderer) -{ - CRct theRect(GetSize()); - - // Fill in the background - if (!m_Selected) - inRenderer->FillSolidRect(theRect, m_BackgroundColor); - else - inRenderer->FillSolidRect(theRect, CStudioPreferences::GetTimelineSelectColor()); - - // Draw the line at the bottom of this control and the one on the side - inRenderer->PushPen(CStudioPreferences::GetPropertyFloorColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * Set this control to being highlighted or not. - * @param inIsHighlighted true if this is to be highlighted. - */ -void CBaseTimebarlessRow::SetBackgroundColor(::CColor inBackgroundColor) -{ - if (m_BackgroundColor != inBackgroundColor) { - m_BackgroundColor = inBackgroundColor; - Invalidate(); - } -} - -void CBaseTimebarlessRow::SetTimeRatio(double inTimeRatio) -{ - m_TimeRatio = inTimeRatio; -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been selected. - */ -void CBaseTimebarlessRow::OnSelect() -{ - m_Selected = true; - - Invalidate(); -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been deselected. - */ -void CBaseTimebarlessRow::OnDeselect() -{ - m_Selected = false; - - Invalidate(); -} - -//============================================================================= -/** - * called when meta data for this row is changed... should be overridden by the - * timebar row - */ -void CBaseTimebarlessRow::RefreshRowMetaData() -{ -} - -//============================================================================= -/** - * called when a child changes and the keyframes need to be refreshed - * @param inDirtyFlag true if this object is now dirty - */ -void CBaseTimebarlessRow::SetDirty(bool inDirtyFlag) -{ - if (m_DirtyFlag == inDirtyFlag) - return; - - m_DirtyFlag = inDirtyFlag; - Invalidate(); -} - -void CBaseTimebarlessRow::UpdateTime(long inStartTime, long inEndTime) -{ - Q_UNUSED(inStartTime); - Q_UNUSED(inEndTime); -} - -//============================================================================= -/** - * OnMouseOver event, handles the highlighting of the row. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -void CBaseTimebarlessRow::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - GetBaseStateRowUI()->OnMouseOver(); -} - -//============================================================================= -/** - * OnMouseOut event, handles the de-highlighting of this row. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -void CBaseTimebarlessRow::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - GetBaseStateRowUI()->OnMouseOut(); -} - -//============================================================================= -/** - * OnMouseDown event, handles the selecting of this object. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -bool CBaseTimebarlessRow::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - return CControl::OnMouseDown(inPoint, inFlags); -#if 0 - // this addition is causing 4085: Cannot do rubber band selection from sections of timeline that don't contain timebars anymore - bool theReturn = CControl::OnMouseDown( inPoint, inFlags ); - if ( !theReturn ) - { - // Tests if the user has pressed the modifier key, where the intention is to multi-select keyframes. - if ( !(inFlags & CHotKeys::MODIFIER_CONTROL ) ) - { - // SK - I changed this to select the row when this is clicked, because I think its a nice feature. ie don't always have to click on the timebar (esp for those e.g. scene without one) - // when the modifier key is pressed. - GetBaseStateRow( )->Select( false ); - - theReturn = true; - } - } - return theReturn; -#endif -} diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.h b/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.h deleted file mode 100644 index ee26f3c2..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseTimebarlessRow.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_BASE_TIMEBARLESS_ROW_H -#define INCLUDED_BASE_TIMEBARLESS_ROW_H 1 - -#pragma once - -#include "Control.h" -#include "CColor.h" - -class CSnapper; -class CBaseStateRowUI; -class ISnappingListProvider; - -class CBaseTimebarlessRow : public CControl -{ -public: - CBaseTimebarlessRow(); - virtual ~CBaseTimebarlessRow(); - - void Draw(CRenderer *inRenderer) override; - - virtual void SetBackgroundColor(::CColor inColor); - virtual void SetTimeRatio(double inTimeRatio); - - virtual void RefreshRowMetaData(); - - virtual void OnSelect(); - virtual void OnDeselect(); - - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - virtual void SetDirty(bool inIsDirty); - virtual void UpdateTime(long inStartTime, long inEndTime); - - virtual void CommitSelections() = 0; - virtual void SelectKeysInRect(CRct inRect, bool inModifierKeyDown) = 0; - virtual void SelectAllKeys() = 0; - virtual void SelectKeysByTime(long inTime, bool inSelected) = 0; - virtual void PopulateSnappingList(CSnapper *inSnappingList) = 0; - virtual ISnappingListProvider &GetSnappingListProvider() const = 0; - -protected: - virtual CBaseStateRowUI *GetBaseStateRowUI() const = 0; - - ::CColor m_BackgroundColor; - bool m_Selected; - bool m_DirtyFlag; - double m_TimeRatio; -}; -#endif // INCLUDED_BASE_TIMEBARLESS_ROW_H diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.cpp b/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.cpp deleted file mode 100644 index 7db17c99..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.cpp +++ /dev/null @@ -1,693 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "Renderer.h" -#include "ToggleButton.h" -#include "BaseStateRow.h" -#include "BaseStateRowUI.h" -#include "StudioPreferences.h" -#include "TimelineDropTarget.h" -#include "BaseTimelineTreeControl.h" -#include "NameEdit.h" -#include "Bindings/ITimelineItem.h" -#include "StudioPreferences.h" - -//============================================================================= -/** - * Create a new tree control for the specified state row. - * This control contains the toggle button and item name controls. - * @param inStateRow the state row of which this belongs to. - */ -CBaseTimelineTreeControl::CBaseTimelineTreeControl(CBaseStateRowUI *inStateRow, bool inMaster) - : m_Selected(false) - , m_MouseDown(false) -{ - m_StateRowUI = inStateRow; - - auto timelineRow = m_StateRowUI->GetTimelineRow(); - m_BackgroundColor = timelineRow->GetTimebarBackgroundColor(timelineRow->GetObjectType()); - - // Create the expand/collapse button. - m_ExpandButton = new CToggleButton(); - m_ExpandButton->SetUpImage("arrow.png"); - m_ExpandButton->SetDownImage("arrow_down.png"); - - // Add the button and initialize all the listeners for the events on it. - AddChild(m_ExpandButton); - QObject::connect(m_ExpandButton,&CToggleButton::SigToggle, - std::bind(&CBaseStateRow::ToggleExpansion, baseStateRow(), - std::placeholders::_1, std::placeholders::_2)); - m_ExpandButton->SetVisible(false); - - m_Icon = new CSIcon(baseStateRow()->GetIcon(), baseStateRow()->GetDisabledIcon()); - AddChild(m_Icon); - - // Create and add the name label. - m_Text = nullptr; // withdrawn from constructor to delay creation of text object - - // Initialize all the component's positions to 0. - SetIndent(CStudioPreferences::GetRowSize()); - - SetMinimumSize(CPt(CBaseStateRowUI::DEFAULT_TOGGLE_LENGTH + m_Icon->GetPosition().x - + m_Icon->GetSize().x + 5, - CStudioPreferences::GetRowSize())); - - m_TrackingPoint.x = 0; - m_TrackingPoint.y = 0; - m_DrawAcceptBefore = false; - m_DrawAcceptAfter = false; - - // Set up default text colors - m_NormalTextColor = CStudioPreferences::GetNormalColor(); - m_SelectedTextColor = CStudioPreferences::GetNormalColor(); - if (inMaster) { - m_NormalTextColor = CStudioPreferences::GetMasterColor(); - m_SelectedTextColor = CStudioPreferences::GetMasterColor(); - } - m_LockedTextColor = CStudioPreferences::GetLockedTextColor(); -} - -CBaseTimelineTreeControl::~CBaseTimelineTreeControl() -{ - delete m_Icon; - delete m_ExpandButton; - delete m_Text; -} - -//============================================================================= -/** - * Create a new text object. For performance reasons we delay - * creating this object until it is needed, i.e. until the row is exposed - * by the user and the Draw method is called - */ -void CBaseTimelineTreeControl::CreateText() -{ - if (!m_Text) { - ITimelineItem *theTimelineItem = baseStateRow()->GetTimelineItem(); - - m_Text = new CNameEdit(theTimelineItem); - - m_Text->SetSize( - CPt(CStudioPreferences::GetTimelineNameSize(), - CStudioPreferences::GetRowSize() - 3)); /* m_ExpandButton->GetSize( ).y - 3*/ - // m_Text->SetBGColorNoFocus( CStudioPreferences::GetNormalColor( ) ); - // if ( theTimelineItem->IsMaster( ) ) - // m_Text->SetBGColorNoFocus( CStudioPreferences::GetMasterColor( ) ); - // m_Text->SetFillBackground( false ); - m_Text->SetBoldText(false); - - // If the object is the scene, you can't edit it's name - m_Text->SetEditable(baseStateRow()->GetObjectType() != OBJTYPE_SCENE); - AddChild(m_Text); - m_Text->SetPosition(CPt(m_Icon->GetPosition().x + m_Icon->GetSize().x + 5, 1)); - - // This was disabled before Text was created. - if (!IsEnabled()) { - m_Text->SetEnabled(false); - m_Text->SetParentEnabled(false); - m_Text->SetTextColor(m_LockedTextColor); - } else // since we do delay-creation, "sync" with the parent's selection state - UpdateTextSelection(); - - // This is so that make the timeline scrollbar scrolls correctly - // ( i.e. to the end of the asset name ) - CPt theSize(GetSize()); - theSize.x = - CBaseStateRowUI::DEFAULT_TOGGLE_LENGTH + m_Text->GetPosition().x + m_Text->GetSize().x; - SetAbsoluteSize(theSize); - } -} - -void CBaseTimelineTreeControl::UpdateTextSelection() -{ - // since we do delay-creation for the Text only when we have to draw it.. this checks if it is - // created first - if (m_Text) { - if (!IsEnabled()) - m_Text->SetTextColor(m_LockedTextColor); - else - m_Text->SetTextColor(m_Selected ? m_SelectedTextColor : m_NormalTextColor); - // m_Text->SetFillBackground( m_Selected ); - // m_Text->SetBoldText( m_Selected ); - } -} - -CBaseStateRow *CBaseTimelineTreeControl::baseStateRow() const -{ - return static_cast<CBaseStateRow* >(m_StateRowUI->GetTimelineRow()); -} - -//============================================================================= -/** - * Perform the drawing of this control. - * @param inRenderer the renderer to draw to. - */ -void CBaseTimelineTreeControl::Draw(CRenderer *inRenderer) -{ - CreateText(); // the row is now exposed and we can't delay creating the text object any longer - - CRct theRect(GetSize()); - // Fill in the background - if (!m_Selected) - inRenderer->FillSolidRect(theRect, m_BackgroundColor); - else - inRenderer->FillSolidRect(theRect, CStudioPreferences::GetTimelineSelectColor()); - - // if ( m_Text ) - // m_Text->SetBoldText( m_Selected ); - // m_Text->SetFillBackground( m_Selected ); - - // Draw the line at the bottom of this control - inRenderer->PushPen(CStudioPreferences::GetTreeFloorColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * Override for the set parent enabled function which tells children the state of the parent - */ -void CBaseTimelineTreeControl::SetEnabled(bool inIsEnabled) -{ - CControl::SetEnabled(inIsEnabled); - if (m_Text) { - m_Text->SetEnabled(inIsEnabled); - if (!inIsEnabled) - m_Text->SetTextColor(m_LockedTextColor); - else - m_Text->SetTextColor(m_Selected ? m_SelectedTextColor : m_NormalTextColor); - Invalidate(); - } -} - -//============================================================================= -/** - * Notification that something has changed on the asset that this - * represents, update it. - */ -void CBaseTimelineTreeControl::Refresh(ITimelineItem *inTimelineItem) -{ - bool theEnabled = !inTimelineItem->IsLocked(); - if (m_Text) { - // Make sure the color is correct depending on if its is a master object - if (m_NormalTextColor != CStudioPreferences::GetMasterColor() - && inTimelineItem->IsMaster()) { - m_NormalTextColor = CStudioPreferences::GetMasterColor(); - m_Text->SetBGColorNoFocus(CStudioPreferences::GetMasterColor()); - if (!m_Selected) - m_Text->SetTextColor(m_NormalTextColor); - } - - m_Text->SetData(inTimelineItem->GetName()); - } - m_Icon->SetImage((theEnabled) ? baseStateRow()->GetIcon() : baseStateRow()->GetDisabledIcon()); - SetEnabled(theEnabled); -} - -//============================================================================= -/** - * Set the indent of this control. - * The indent gives the semblance of a tree control, and causes the toggle - * name and icon to be pushed in some. - * @param inIndent the indent for this control. - */ -void CBaseTimelineTreeControl::SetIndent(long inIndent) -{ - m_Indent = inIndent; - - // Set the new position for all the children. - m_ExpandButton->SetPosition(CPt(inIndent, 0)); - - m_Icon->SetPosition(CPt(m_ExpandButton->GetPosition().x + m_ExpandButton->GetSize().x, 0)); - if (m_Text) - m_Text->SetPosition(CPt(m_Icon->GetPosition().x + m_Icon->GetSize().x + 5, 1)); -} - -//============================================================================= -/** - * Get the current indent of this control. - */ -long CBaseTimelineTreeControl::GetIndent() -{ - return m_Indent; -} - -//============================================================================= -/** - * Set whether or not to have the toggle control visible. - * The toggle is turned off by the state row when there are no visible children. - * @param inIsToggleVisible false if the toggle is not to be visible. - */ -void CBaseTimelineTreeControl::SetToggleVisible(bool inIsToggleVisible) -{ - m_ExpandButton->SetVisible(inIsToggleVisible); -} - -//============================================================================= -/** - * Set whether or not this control is expanded. - * This is used to set the state of the expand button. - */ -void CBaseTimelineTreeControl::SetExpanded(bool inIsExpanded) -{ - m_ExpandButton->SetToggleState(inIsExpanded); -} - -//============================================================================= -/** - * Set the current background color for this control. - * The background color changes when the control gets a mouse over/mouse out. - */ -void CBaseTimelineTreeControl::SetBackgroundColor(CColor inColor) -{ - if (m_BackgroundColor == inColor) - return; - - m_BackgroundColor = inColor; - - Invalidate(); -} - -//============================================================================= -/** - * Notify the row that a mouse out occurred. - * The row will in turn turn off the highlighting. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - */ -void CBaseTimelineTreeControl::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - m_DrawAcceptAfter = false; - m_DrawAcceptBefore = false; - - CControl::OnMouseOut(inPoint, inFlags); - - m_StateRowUI->OnMouseOut(); - - if (m_TimerHandler) { - - // nullptr out our handle so we can create a new one. - m_TimerHandler = std::shared_ptr<qt3dsdm::ISignalConnection>(); - } - - AcceptDropAfter(false); - AcceptDropBefore(false); -} - -//============================================================================= -/** - * Notify the row that a mouse over occurred. - * The row will in turn turn on the highlighting. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - */ -void CBaseTimelineTreeControl::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - m_StateRowUI->OnMouseOver(); -} - -//============================================================================= -/** - * Pass the double click notification on to the row and have it process it. - * The row will do object-specific actions on doubleclicks. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - * @return true stating that the event was processed. - */ -bool CBaseTimelineTreeControl::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDoubleClick(inPoint, inFlags)) { - m_StateRowUI->OnMouseDoubleClick(inPoint, inFlags); - GrabFocus(nullptr); - } - return true; -} - -//============================================================================= -/** - * Handles mouse down on the this control. Flags the button as down which results - * in some possible drawing changes. - * @param inPoint location of the mouse when event occurred - * @param inFlags state of modifier keys when event occurred - * @return true - */ -bool CBaseTimelineTreeControl::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - Qt::KeyboardModifiers theKeyState; - if ((CHotKeys::MODIFIER_SHIFT & inFlags) == CHotKeys::MODIFIER_SHIFT) - theKeyState.setFlag(Qt::ShiftModifier); - if ((CHotKeys::MODIFIER_CONTROL & inFlags) == CHotKeys::MODIFIER_CONTROL) - theKeyState.setFlag(Qt::ControlModifier); - baseStateRow()->Select(theKeyState); - - // Always track where the mouse is. - m_MouseDown = true; - - Invalidate(); - } - - return true; -} - -bool CBaseTimelineTreeControl::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseRDown(inPoint, inFlags)) - m_StateRowUI->OnMouseRDown(inPoint, inFlags); - - return true; -} - -void CBaseTimelineTreeControl::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - m_MouseDown = false; - - CControl::OnMouseUp(inPoint, inFlags); - - AcceptDropAfter(false); - AcceptDropBefore(false); -} - -//============================================================================= -/** - * This method handles the keydown event for a StateTreeControl. It calls - * CControl::OnKeyDown method to make sure that the keydown event is handled - * by its children. If the keydown event is not handled and F2 is down, it - * enables text edit mode. - * @param inChar is the char pressed - * @param inFlags state of modifier keys when event occurred - * @return if the key was handled - */ -bool CBaseTimelineTreeControl::OnKeyDown(unsigned int inChar, Qt::KeyboardModifiers inFlags) -{ - bool theKeyWasHandled = CControl::OnKeyDown(inChar, inFlags); - - if (!theKeyWasHandled && (inChar == Qt::Key_F2)) { - DoRename(); - theKeyWasHandled = true; - } - - return theKeyWasHandled; -} - -//============================================================================= -/** - * This is so the Gesture can this object to get something ready to Drag. - */ -void CBaseTimelineTreeControl::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - - if (m_MouseDown /*&& inFlags & MOUSE_LBUTTON*/) { - long theDeltaX = inPoint.x - m_TrackingPoint.x; - long theDeltaY = inPoint.y - m_TrackingPoint.y; - - if (::abs(theDeltaX) > 3 || ::abs(theDeltaY) > 3) { - m_TrackingPoint = inPoint; - - m_StateRowUI->DoStartDrag(GetWindowListener()); - } - } -} - -//============================================================================= -/** - * Notification that the state that this is displaying has been selected. - */ -void CBaseTimelineTreeControl::OnSelect() -{ - m_Selected = true; - - UpdateTextSelection(); - - Invalidate(); -} - -//============================================================================= -/** - * Notification that the state that this is displaying has been deselected. - */ -void CBaseTimelineTreeControl::OnDeselect() -{ - m_Selected = false; - - UpdateTextSelection(); - Invalidate(); -} - -void CBaseTimelineTreeControl::GrabTextFocus() -{ - GrabFocus(m_Text); -} - -//============================================================================= -/** - * To enable F2 editing. - */ -void CBaseTimelineTreeControl::OnGainFocus() -{ - CControl::OnGainFocus(); - GrabFocus(m_Text); -} - -//============================================================================= -/** - * Called when this control loses focus. Overridden because we need to set the - * text color depending on whether or not the asset for this row is still - * selected. - */ -void CBaseTimelineTreeControl::OnLoseFocus() -{ - CControl::OnLoseFocus(); - - if (m_Text) { - if (m_Selected) { - m_Text->SetTextColor(m_SelectedTextColor); - } else // If this asset is no longer selected - { - // If the row is enabled, use the normal text color - if (m_Text->IsEnabled()) { - m_Text->SetTextColor(m_NormalTextColor); - } - // Otherwise use the locked text color - else { - m_Text->SetTextColor(m_LockedTextColor); - } - } - } - - AcceptDropAfter(false); - AcceptDropBefore(false); -} - -//============================================================================= -/** - * If the name is changed, the size has to be adjusted accordingly. - */ -void CBaseTimelineTreeControl::OnChildSizeChanged(CControl *inChild) -{ - CControl::OnChildSizeChanged(inChild); - - if (inChild == m_Text) { // This is so that make the timeline scrollbar scrolls correctly - // ( i.e. to the end of the asset name ) - CPt theSize(GetSize()); - theSize.x = - CBaseStateRowUI::DEFAULT_TOGGLE_LENGTH + m_Text->GetPosition().x + m_Text->GetSize().x; - SetAbsoluteSize(theSize); - } -} - -//============================================================================= -/** - * This will do a vertical hit test on this control. - * This need to figure out if the point is toward teh top or toward the bottom, or on this - *control. - * @param inMousePoint the point where the dropp wants to occure. - * @return An enumeration representing the location of the potential drop. - */ -CBaseTimelineTreeControl::ECONTROLREGION CBaseTimelineTreeControl::FindHitRegion(CPt &inMousePoint) -{ - // Default Region is "on" - CBaseTimelineTreeControl::ECONTROLREGION theDropRegion = - CBaseTimelineTreeControl::ECONTROLREGION_ON; - - CPt theSize = GetSize(); - long theTop = 0; - long theBottom = theSize.y - 1; - long thePointY = inMousePoint.y; - - // check if we are in the upper part of the control - if ((thePointY >= theTop) && (thePointY <= (theTop + 3))) { - theDropRegion = CBaseTimelineTreeControl::ECONTROLREGION_ABOVE; - } - // check if we are in the lower part of the control - else if ((thePointY <= (theBottom)) && (thePointY >= (theBottom - 3))) { - theDropRegion = CBaseTimelineTreeControl::ECONTROLREGION_BELOW; - } - - return theDropRegion; -} - -//============================================================================= -/** - * Find an object under the point. - * If tht point is close to the top or the bottom of the control, - * then the Asset to use would be the parent of the current asset. - * @param inMousePoint the point where the Drop wants to occure. - */ -CDropTarget *CBaseTimelineTreeControl::BuildDropTarget(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inFlags); - - // This will do the hit testing to see where we are with the point. - ECONTROLREGION theRegion = FindHitRegion(inMousePoint); - - // Make a new DropTarget to return. - CTimeLineDropTarget *theTarget = new CTimeLineDropTarget(); - - EDROPDESTINATION theDropDest = EDROPDESTINATION_ON; - - switch (theRegion) { - case ECONTROLREGION_BELOW: - theDropDest = EDROPDESTINATION_BELOW; - - AcceptDropAfter(true); - AcceptDropBefore(false); - break; - - case ECONTROLREGION_ABOVE: - theDropDest = EDROPDESTINATION_ABOVE; - - AcceptDropAfter(false); - AcceptDropBefore(true); - break; - - case ECONTROLREGION_ON: - - AcceptDropAfter(false); - AcceptDropBefore(false); - break; - } - theTarget->SetDestination(theDropDest); - // For insertion markers - theTarget->SetInsertionMarkerRow(this); - theTarget->SetInsertionMarkerIndent(m_Icon->GetPosition().x); - - // connect the data portion of the drag&drop action - m_StateRowUI->SetDropTarget(theTarget); - - return theTarget; -} - -//============================================================================= -/** - * This function is overriden from the CControl class. - * It will find an Asset that can be dropped upon. Also it will - * figureout if the DropTarget should contain this Asset or the parent - * of this Asset. - * @param inMousePoint the coords [in local space] of the drop action. - * @param inFlags the Modifier flags for the keyboard state. - * @return the found DropTarget or null if not found. - */ -CDropTarget *CBaseTimelineTreeControl::FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) -{ - // Make sure the Mouse Highlighting happens. - m_StateRowUI->OnMouseOver(); - - // This will do all of the work. - CDropTarget *theReturnTarget = BuildDropTarget(inMousePoint, inFlags); - - // Expand the object [ once again ask CE for an explaination of this ] - if (!m_TimerHandler && m_ExpandButton->IsVisible() && m_ExpandButton->IsEnabled()) { - if (!m_DrawAcceptBefore && !m_DrawAcceptAfter) - m_TimerHandler = Q3DStudio::ITickTock::GetInstance().AddTimer( - 1000, false, std::bind(&CBaseTimelineTreeControl::OnTimer, this), - "CStateTreeControl::FindDropCandidate::" + GetName()); - } - - // we always return true, since we should be the only one to handle it. - return theReturnTarget; -} - -//============================================================================= -/** - * Notification that the Hover Time has expired, - */ -void CBaseTimelineTreeControl::OnTimer() -{ - // Expand the Row to show the children. - baseStateRow()->Expand(); -} - -//============================================================================= -/** - * This will set the Flag so we can Draw the Bottom Line. - * @param inAccept true to draw the line false otherwise. - */ -void CBaseTimelineTreeControl::AcceptDropAfter(bool inAccept) -{ - if (inAccept != m_DrawAcceptAfter) { - m_DrawAcceptAfter = inAccept; - } -} - -//============================================================================= -/** - * This will set the Flag so we can Draw the Top Line. - * @param inAccept true to draw the line false otherwise. - */ -void CBaseTimelineTreeControl::AcceptDropBefore(bool inAccept) -{ - if (inAccept != m_DrawAcceptBefore) { - m_DrawAcceptBefore = inAccept; - } -} - -//============================================================================= -/** - * Called by the state context menu to do the renaming portion of the menu - */ -void CBaseTimelineTreeControl::DoRename() -{ - CreateText(); - m_Text->SetEditMode(true); - GrabFocus(m_Text); - m_Text->SelectAllText(); -} - -void CBaseTimelineTreeControl::SetNameReadOnly(bool inReadOnly) -{ - CreateText(); // Create the text if it's not ready. - m_Text->SetEditable(!inReadOnly); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.h b/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.h deleted file mode 100644 index d48a9c2c..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BaseTimelineTreeControl.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_BASE_TIMELINE_TREE_CONTROL_H -#define INCLUDED_BASE_TIMELINE_TREE_CONTROL_H 1 - -#pragma once - -#include "Control.h" -#include "SIcon.h" -#include "ToggleButton.h" -#include "ITickTock.h" - -class CButtonControl; -class CBaseStateRow; -class CBaseStateRowUI; -class CDropTarget; -class CNameEdit; -class CTickTockProc; -struct STickTockHandle; -class CPt; -class CToggleButton; -class ITimelineItem; - -class CBaseTimelineTreeControl : public CControl -{ - -public: - enum ECONTROLREGION { ECONTROLREGION_ON, ECONTROLREGION_ABOVE, ECONTROLREGION_BELOW }; - - CBaseTimelineTreeControl(CBaseStateRowUI *inStateRow, bool inMaster); - virtual ~CBaseTimelineTreeControl(); - - void Draw(CRenderer *inRenderer) override; - void OnChildSizeChanged(CControl *inChild) override; - - void SetIndent(long inIndent); - long GetIndent(); - - void SetExpanded(bool inIsExpanded); - - void SetToggleVisible(bool inIsToggleVisible); - void OnSelect(); - void OnDeselect(); - void GrabTextFocus(); - void OnGainFocus() override; - void OnLoseFocus() override; - void SetBackgroundColor(::CColor inBackgroundColor); - - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnKeyDown(unsigned int inChar, Qt::KeyboardModifiers inFlags) override; - - void OnTimer(); - - void Refresh(ITimelineItem *inTimelineItem); - - void SetEnabled(bool inIsEnabled) override; - - CDropTarget *BuildDropTarget(CPt &inMousePoint, Qt::KeyboardModifiers inFlags); - CDropTarget *FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) override; - void AcceptDropAfter(bool inAccept); - void AcceptDropBefore(bool inAccept); - void DoRename(); - - void SetNameReadOnly(bool inReadOnly); - -protected: - ECONTROLREGION FindHitRegion(CPt &inMousePoint); - void CreateText(); // delay text creation until row is exposed - void UpdateTextSelection(); - - CBaseStateRow *baseStateRow() const; - - long m_Indent; - - CBaseStateRowUI *m_StateRowUI; - - CToggleButton *m_ExpandButton; - CNameEdit *m_Text; - - CSIcon *m_Icon; - bool m_Selected; - - ::CColor m_BackgroundColor; - - CPt m_TrackingPoint; - CPt m_MouseMovePoint; - bool m_MouseDown; - bool m_DrawAcceptBefore; - bool m_DrawAcceptAfter; - std::shared_ptr<qt3dsdm::ISignalConnection> m_TimerHandler; - ::CColor m_NormalTextColor; - ::CColor m_SelectedTextColor; - ::CColor m_LockedTextColor; -}; -#endif // INCLUDED_BASE_TIMELINE_TREE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp index 94aa3ba3..8b53aba0 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp @@ -39,7 +39,6 @@ #include "TimelineTranslationManager.h" #include "Qt3DSDMHandles.h" #include "BaseStateRow.h" -#include "BaseStateRowUI.h" #include "Doc.h" #include "IObjectReferenceHelper.h" #include "EmptyTimelineTimebar.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 9620155d..02ff7c58 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -41,8 +41,6 @@ #include "EmptyTimelineTimebar.h" #include "Qt3DSDMTimelineTimebar.h" #include "BaseStateRow.h" -#include "BaseTimebarlessRow.h" -#include "PropertyTimebarRow.h" #include "PropertyRow.h" #include "KeyframesManager.h" #include "StudioApp.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp index 88728fd7..eb6f4864 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp @@ -39,7 +39,6 @@ #include "PropertyRow.h" #include "TimelineTranslationManager.h" #include "ITimelineItemBinding.h" -#include "PropertyTimebarRow.h" #include "Qt3DSDMTimelineItemBinding.h" #include "Qt3DSDMTimelineKeyframe.h" #include "KeyframesManager.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp index 90ab90a0..f6a16c94 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp @@ -47,7 +47,6 @@ #include "DurationEditDlg.h" #include "IDocumentEditor.h" #include "BaseStateRow.h" -#include "BaseTimebarlessRow.h" #include "StudioFullSystem.h" #include "StudioPreferences.h" #include "ITimelineItemBinding.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp index d33f947e..1afb57fc 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp @@ -37,7 +37,6 @@ //============================================================================== #include "SlideTimelineItemBinding.h" #include "BaseStateRow.h" -#include "BaseStateRowUI.h" // Data model specific #include "Doc.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.cpp b/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.cpp deleted file mode 100644 index 9407b8c4..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "BlankToggleControl.h" -#include "Renderer.h" -#include "BaseStateRowUI.h" -#include "StudioPreferences.h" -#include "HotKeys.h" -#include "BaseStateRow.h" - -CBlankToggleControl::CBlankToggleControl(CBaseStateRowUI *inBaseStateRow) - : m_StateRowUI(inBaseStateRow) - , m_Selected(false) -{ - m_StateRow = static_cast<CBaseStateRow *>(m_StateRowUI->GetTimelineRow()); - m_BackgroundColor = m_StateRow->GetTimebarBackgroundColor(m_StateRow->GetObjectType()); -} - -CBlankToggleControl::~CBlankToggleControl() -{ -} - -//============================================================================== -/** - * Handles the drawing fo rthe toggle control - */ -void CBlankToggleControl::Draw(CRenderer *inRenderer) -{ - CRct theRect(GetSize()); - - // Fill in the background - if (!m_Selected) - inRenderer->FillSolidRect(theRect, m_BackgroundColor); - else - inRenderer->FillSolidRect(theRect, CStudioPreferences::GetTimelineSelectColor()); - - // Draw the line at the bottom of this control - inRenderer->PushPen(CStudioPreferences::GetTreeFloorColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - inRenderer->PopPen(); - - // Draw the line on the left side of this control - inRenderer->PushPen(CStudioPreferences::GetPropertyFloorColor()); - inRenderer->MoveTo(CPt(0, 0)); - inRenderer->LineTo(CPt(0, theRect.size.y - 1)); - inRenderer->PopPen(); - - // Draw the highlight - inRenderer->PushPen(CStudioPreferences::GetButtonHighlightColor()); - inRenderer->MoveTo(CPt(1, 0)); - inRenderer->LineTo(CPt(1, theRect.size.y - 1)); - inRenderer->PopPen(); - - // Draw the line on the right side of this control - inRenderer->PushPen(CStudioPreferences::GetButtonShadowColor()); - inRenderer->MoveTo(CPt(theRect.size.x - 1, 0)); - inRenderer->LineTo(CPt(theRect.size.x - 1, theRect.size.y - 1)); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been selected. - */ -void CBlankToggleControl::OnSelect() -{ - m_Selected = true; - - Invalidate(); -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been deselected. - */ -void CBlankToggleControl::OnDeselect() -{ - m_Selected = false; - - Invalidate(); -} - -//============================================================================== -/** - * Handler for the OnMouseDown event - * - * @param inPoint the point where this event takes place - * @param inFlags the state when this event takes place. - */ -bool CBlankToggleControl::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - m_StateRow->Select(Qt::NoModifier); - } - return true; -} - -//============================================================================== -/** - * Sets the background color of this toggle control - */ -void CBlankToggleControl::SetBackgroundColor(::CColor inBackgroundColor) -{ - if (m_BackgroundColor == inBackgroundColor) - return; - - m_BackgroundColor = inBackgroundColor; - - Invalidate(); -} - -//============================================================================== -/** - * Handler for the OnMouseOver event - * - * @param inPoint the point where this event takes place - * @param inFlags the state when this event takes place. - */ -void CBlankToggleControl::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - m_StateRowUI->OnMouseOver(); -} - -//============================================================================== -/** - * Handler for the OnMouseOut event - * - * @param inPoint the point where this event takes place - * @param inFlags the state when this event takes place. - */ -void CBlankToggleControl::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - m_StateRowUI->OnMouseOut(); -} - -void CBlankToggleControl::Refresh() -{ -} - -CBaseStateRow *CBlankToggleControl::baseStateRow() const -{ - return m_StateRow; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.h b/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.h deleted file mode 100644 index cafb5cee..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/BlankToggleControl.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_BLANK_TOGGLE_CONTROL_H -#define INCLUDED_BLANK_TOGGLE_CONTROL_H 1 - -#pragma once - -#include "Control.h" -#include "CColor.h" - -class CBaseStateRow; -class CBaseStateRowUI; - -class CBlankToggleControl : public CControl -{ -public: - CBlankToggleControl(CBaseStateRowUI *inStateRow); - virtual ~CBlankToggleControl(); - - void Draw(CRenderer *inRenderer) override; - - void OnSelect(); - void OnDeselect(); - - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void SetBackgroundColor(::CColor inBackgroundColor); - - virtual void Refresh(); - -protected: - CBaseStateRow *baseStateRow() const; - - CBaseStateRow *m_StateRow; - CBaseStateRowUI *m_StateRowUI; - bool m_Selected; - - ::CColor m_BackgroundColor; -}; -#endif // INCLUDED_BLANK_TOGGLE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.cpp b/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.cpp deleted file mode 100644 index a2197b19..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "ComponentContextMenu.h" -#include "TimelineControl.h" -#include "StudioUtils.h" -#include "StudioClipboard.h" -#include "Dialogs.h" -#include "BaseTimelineTreeControl.h" -#include "Bindings/ITimelineItemBinding.h" -#include "RelativePathTools.h" - -CComponentContextMenu::CComponentContextMenu(CBaseTimelineTreeControl *inTreeControl, - ITimelineItemBinding *inTimelineItemBinding, - QWidget *parent) - : QMenu(parent) - , m_TreeControl(inTreeControl) - , m_TimelineItemBinding(inTimelineItemBinding) -{ - Initialize(); -} - -void CComponentContextMenu::Initialize() -{ - m_renameAction = new QAction(tr("Rename Object"), this); - connect(m_renameAction, &QAction::triggered, this, &CComponentContextMenu::RenameObject); - addAction(m_renameAction); - - m_duplicateAction = new QAction(tr("Duplicate Object"), this); - connect(m_duplicateAction, &QAction::triggered, this, &CComponentContextMenu::DuplicateObject); - addAction(m_duplicateAction); - - m_deleteAction = new QAction(tr("Delete Object"), this); - connect(m_deleteAction, &QAction::triggered, this, &CComponentContextMenu::DeleteObject); - addAction(m_deleteAction); - - addSeparator(); - - m_copyAction = new QAction(tr("Copy"), this); - connect(m_copyAction, &QAction::triggered, this, &CComponentContextMenu::CopyObject); - addAction(m_copyAction); - - m_pasteAction = new QAction(tr("Paste"), this); - connect(m_pasteAction, &QAction::triggered, this, &CComponentContextMenu::PasteObject); - addAction(m_pasteAction); - - m_cutAction = new QAction(tr("Cut"), this); - connect(m_cutAction, &QAction::triggered, this, &CComponentContextMenu::CutObject); - addAction(m_cutAction); - addSeparator(); - - m_makeAction = new QAction(tr("Make Component"), this); - connect(m_makeAction, &QAction::triggered, this, &CComponentContextMenu::MakeComponent); - addAction(m_makeAction); - - if (CanInspectComponent()) { - m_inspectAction = new QAction(tr("Edit Component"), this); - connect(m_inspectAction, &QAction::triggered, - this, &CComponentContextMenu::InspectComponent); - addAction(m_inspectAction); - } - - if (m_TimelineItemBinding->IsExternalizeable()) { - addSeparator(); - m_externalizeAction = new QAction(tr("Externalize Buffer"), this); - connect(m_externalizeAction, &QAction::triggered, - this, &CComponentContextMenu::Externalize); - addAction(m_externalizeAction); - } else if (m_TimelineItemBinding->IsInternalizeable()) { - addSeparator(); - m_internalizeAction = new QAction(tr("Internalize Buffer"), this); - connect(m_internalizeAction, &QAction::triggered, - this, &CComponentContextMenu::Internalize); - addAction(m_internalizeAction); - } - - addSeparator(); - - m_copyPathAction = new QAction(tr("Copy Object Path"), this); - connect(m_copyPathAction, &QAction::triggered, this, &CComponentContextMenu::CopyObjectPath); - addAction(m_copyPathAction); -} - -void CComponentContextMenu::showEvent(QShowEvent *event) -{ - m_renameAction->setEnabled(CanRenameObject()); - m_duplicateAction->setEnabled(CanDuplicateObject()); - m_deleteAction->setEnabled(CanDeleteObject()); - - m_cutAction->setEnabled(CanCutObject()); - m_copyAction->setEnabled(CanCopyObject()); - m_pasteAction->setEnabled(CanPasteObject()); - - m_makeAction->setEnabled(CanMakeComponent()); - - QMenu::showEvent(event); -} - - -CComponentContextMenu::~CComponentContextMenu() -{ -} - -//============================================================================= -/** - * Checks to see if the object can be renamed. - * @return true if the object can be renamed. - */ -bool CComponentContextMenu::CanRenameObject() -{ - return m_TimelineItemBinding->IsValidTransaction(ITimelineItemBinding::EUserTransaction_Rename); -} - -//============================================================================= -/** - * Rename the object. - */ -void CComponentContextMenu::RenameObject() -{ - m_TreeControl->DoRename(); -} - -//============================================================================= -/** - * Checks to see if the object can be duplicated. - * @return true if the object can be duplicated. - */ -bool CComponentContextMenu::CanDuplicateObject() -{ - return m_TimelineItemBinding->IsValidTransaction( - ITimelineItemBinding::EUserTransaction_Duplicate); -} - -//============================================================================= -/** - * Duplicate the object. - */ -void CComponentContextMenu::DuplicateObject() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_Duplicate); -} - -//============================================================================= -/** - * Checks to see if the object can be deleted. - * @return true if the object can be deleted. - */ -bool CComponentContextMenu::CanDeleteObject() -{ - return m_TimelineItemBinding->IsValidTransaction(ITimelineItemBinding::EUserTransaction_Delete); -} - -//============================================================================= -/** - * Deletes the object from the scene graph. - */ -void CComponentContextMenu::DeleteObject() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_Delete); -} - -//============================================================================= -/** - * Checks to see if the State is a component and can be inspected. - * @return true is the state is a component and can be inspected. - */ -bool CComponentContextMenu::CanInspectComponent() -{ - return m_TimelineItemBinding->IsValidTransaction( - ITimelineItemBinding::EUserTransaction_EditComponent); -} - -//============================================================================= -/** - * Inspect the State (Component). - * This will make the component the top level item of the timelineview. - */ -void CComponentContextMenu::InspectComponent() -{ - m_TimelineItemBinding->OpenAssociatedEditor(); -} - -//============================================================================= -/** - * Checks to see if the object can be wrapped in a component. - * @return true if the object is allowed to be wrapped in a component. - */ -bool CComponentContextMenu::CanMakeComponent() -{ - return m_TimelineItemBinding->IsValidTransaction( - ITimelineItemBinding::EUserTransaction_MakeComponent); -} - -//============================================================================= -/** - * Wraps the specified asset hierarchy under a component. - */ -void CComponentContextMenu::MakeComponent() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_MakeComponent); -} - -//============================================================================= -/** - * Get the full Scripting path of the object and copy it to the clipboard. - * This will figure out the proper way to address the object via scripting - * and put that path into the clipboard. - */ -void CComponentContextMenu::CopyObjectPath() -{ - CStudioClipboard::CopyTextToClipboard(m_TimelineItemBinding->GetObjectPath().toQString()); -} - -//============================================================================= -/** - * Checks to see if the object can be copied - * @return true if the object can be copied - */ -bool CComponentContextMenu::CanCopyObject() -{ - return m_TimelineItemBinding->IsValidTransaction(ITimelineItemBinding::EUserTransaction_Copy); -} - -//============================================================================= -/** - * Copy the object. - */ -void CComponentContextMenu::CopyObject() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_Copy); -} - -bool CComponentContextMenu::CanCutObject() -{ - return m_TimelineItemBinding->IsValidTransaction(ITimelineItemBinding::EUserTransaction_Cut); -} - -void CComponentContextMenu::CutObject() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_Cut); -} - -//============================================================================= -/** - * Checks to see if the object can be pasted - * @return true if the object can be pasted - */ -bool CComponentContextMenu::CanPasteObject() -{ - return m_TimelineItemBinding->IsValidTransaction(ITimelineItemBinding::EUserTransaction_Paste); -} - -//============================================================================= -/** - * Paste the object. - */ -void CComponentContextMenu::PasteObject() -{ - m_TimelineItemBinding->PerformTransaction(ITimelineItemBinding::EUserTransaction_Paste); -} - -ITimelineItem *CComponentContextMenu::GetTimelineItem() const -{ - return m_TimelineItemBinding->GetTimelineItem(); -} - -void CComponentContextMenu::Externalize() -{ - m_TimelineItemBinding->Externalize(); -} - -void CComponentContextMenu::Internalize() -{ - m_TimelineItemBinding->Internalize(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.h b/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.h deleted file mode 100644 index dc837a2c..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ComponentContextMenu.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_COMPONENT_CONTEXT_MENU_H -#define INCLUDED_COMPONENT_CONTEXT_MENU_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include <QtWidgets/qmenu.h> - -//============================================================================== -// Forwards -//============================================================================== -class CBaseTimelineTreeControl; -class ITimelineItem; -class ITimelineItemBinding; - -class CComponentContextMenu : public QMenu -{ - Q_OBJECT -public: - CComponentContextMenu(CBaseTimelineTreeControl *inTreeControl, - ITimelineItemBinding *inTimelineItemBinding, - QWidget *parent = nullptr); - virtual ~CComponentContextMenu(); - -protected Q_SLOTS: - void RenameObject(); - void DuplicateObject(); - void DeleteObject(); - void InspectComponent(); - void MakeComponent(); - void CopyObjectPath(); - void CopyObject(); - void PasteObject(); - void CutObject(); - void Externalize(); - void Internalize(); - -protected: - void showEvent(QShowEvent *event) override; - - bool CanRenameObject(); - bool CanDuplicateObject(); - bool CanDeleteObject(); - bool CanInspectComponent(); - bool CanMakeComponent(); - bool CanCopyObject(); - bool CanPasteObject(); - bool CanCutObject(); - void Import(); - void RefreshImport(); - bool CanImport(); - bool CanRefreshImport(); - bool CanExportComponent(); - - void Initialize(); - - ITimelineItem *GetTimelineItem() const; - - CBaseTimelineTreeControl *m_TreeControl; - ITimelineItemBinding *m_TimelineItemBinding; - QAction *m_renameAction; - QAction *m_duplicateAction; - QAction *m_deleteAction; - QAction *m_inspectAction; - QAction *m_makeAction; - QAction *m_copyPathAction; - QAction *m_cutAction; - QAction *m_copyAction; - QAction *m_pasteAction; - QAction *m_externalizeAction; - QAction *m_internalizeAction; -}; -#endif // INCLDUED_STATE_CONTEXT_MENU_H diff --git a/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.cpp b/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.cpp deleted file mode 100644 index 24d9fc60..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "FilterToolbar.h" -#include "ButtonControl.h" -#include "SystemPreferences.h" -#include "Renderer.h" -#include "TimelineTreeLayout.h" -#include "StudioPreferences.h" - -//============================================================================= -/** - * Constructor - */ -CFilterToolbar::CFilterToolbar(CTimelineTreeLayout *inTreeLayout) - : CFlowLayout(nullptr, false) -{ - m_TreeLayout = inTreeLayout; - - SetFlowDirection(FLOW_HORIZONTAL); - SetAlignment(ALIGN_TOP, ALIGN_LEFT); - SetLeftMargin(1); - - // Create the buttons - m_FltrBehaviorsBtn = new CProceduralButton<CToggleButton>(); - m_FltrPropertiesBtn = new CProceduralButton<CToggleButton>(); - m_FltrMaterialsBtn = new CProceduralButton<CToggleButton>(); - m_FltrShyBtn = new CProceduralButton<CToggleButton>(); - m_FltrVisibleBtn = new CProceduralButton<CToggleButton>(); - - // Load the bitmaps - m_FltrBehaviorsBtn->SetUpImage("obsolete_placeholder.png"); - m_FltrBehaviorsBtn->SetDownImage("obsolete_placeholder.png"); - - m_FltrPropertiesBtn->SetUpImage("obsolete_placeholder.png"); - m_FltrPropertiesBtn->SetDownImage("obsolete_placeholder.png"); - - m_FltrMaterialsBtn->SetUpImage("obsolete_placeholder.png"); - m_FltrMaterialsBtn->SetDownImage("obsolete_placeholder.png"); - - m_FltrShyBtn->SetUpImage("Toggle-Shy.png"); - m_FltrShyBtn->SetDownImage("Toggle-Shy.png"); - - m_FltrVisibleBtn->SetUpImage("Toggle-HideShow.png"); - m_FltrVisibleBtn->SetDownImage("Toggle-HideShow.png"); - - // Turn off the left border of each button since they are all next to each other, otherwise, - // you'll get a double line effect - CProceduralButton<CToggleButton>::SBorderOptions theBorderOptions(false, true, true, true); - m_FltrBehaviorsBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrPropertiesBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrMaterialsBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrShyBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrVisibleBtn->SetBorderVisibilityAll(theBorderOptions); - - // Set the max sizes for the buttons - m_FltrBehaviorsBtn->SetAbsoluteSize(m_FltrBehaviorsBtn->GetSize()); - m_FltrPropertiesBtn->SetAbsoluteSize(m_FltrPropertiesBtn->GetSize()); - m_FltrMaterialsBtn->SetAbsoluteSize(m_FltrMaterialsBtn->GetSize()); - m_FltrShyBtn->SetAbsoluteSize(m_FltrShyBtn->GetSize()); - m_FltrVisibleBtn->SetAbsoluteSize(m_FltrShyBtn->GetSize()); - - // Tooltips - m_FltrBehaviorsBtn->SetTooltipText(QObject::tr("Hide behaviors")); - m_FltrPropertiesBtn->SetTooltipText(QObject::tr("Hide properties")); - m_FltrMaterialsBtn->SetTooltipText(QObject::tr("Hide materials")); - m_FltrShyBtn->SetTooltipText(QObject::tr("Hide shy objects")); - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Hide inactive objects")); - - // Callback for one of the Filter buttons being clicked on - QObject::connect(m_FltrBehaviorsBtn,&CToggleButton::SigToggle, - std::bind(&CFilterToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_FltrPropertiesBtn,&CToggleButton::SigToggle, - std::bind(&CFilterToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_FltrMaterialsBtn,&CToggleButton::SigToggle, - std::bind(&CFilterToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_FltrShyBtn,&CToggleButton::SigToggle, - std::bind(&CFilterToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_FltrVisibleBtn,&CToggleButton::SigToggle, - std::bind(&CFilterToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - // Add the buttons to this layout - AddChild(m_FltrMaterialsBtn); - AddChild(m_FltrPropertiesBtn); - AddChild(m_FltrBehaviorsBtn); - AddChild(m_FltrShyBtn); - AddChild(m_FltrVisibleBtn); - - m_FltrBehaviorsBtn->SetToggleState(false); - m_FltrPropertiesBtn->SetToggleState(false); - m_FltrMaterialsBtn->SetToggleState(false); - m_FltrShyBtn->SetToggleState(false); - m_FltrVisibleBtn->SetToggleState(false); -} - -//============================================================================= -/** - * Destructor - */ -CFilterToolbar::~CFilterToolbar() -{ - delete m_FltrBehaviorsBtn; - delete m_FltrPropertiesBtn; - delete m_FltrMaterialsBtn; - delete m_FltrShyBtn; - delete m_FltrVisibleBtn; -} - -//============================================================================= -/** - * Overriden to draw some highlighting. - */ -void CFilterToolbar::Draw(CRenderer *inRenderer) -{ - CRct theRect(GetSize()); - // Draw the highlight at the bottom - inRenderer->PushPen(CStudioPreferences::GetButtonHighlightColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - inRenderer->PopPen(); - - // Draw the line on the left side - inRenderer->PushPen(CStudioPreferences::GetButtonShadowColor()); - inRenderer->MoveTo(0, 0); - inRenderer->LineTo(0, theRect.size.y - 1); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * Turns filtering on and off for behavior objects in the timeline. - * @param inFilter true to filter behaviors out of the timeline, false to show - * behaviors in the timeline. - */ -void CFilterToolbar::FilterBehaviors(bool inFilter) -{ - if (inFilter) - m_FltrBehaviorsBtn->SetTooltipText(QObject::tr("Show behaviors")); - else - m_FltrBehaviorsBtn->SetTooltipText(QObject::tr("Hide behaviors")); - - m_TreeLayout->GetFilter()->SetBehaviors(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for properties on objects in the timeline. - * @param inFilter true to filter properties out of the timeline, false to show - * properties in the timeline. - */ -void CFilterToolbar::FilterProperties(bool inFilter) -{ - if (inFilter) - m_FltrPropertiesBtn->SetTooltipText(QObject::tr("Show properties")); - else - m_FltrPropertiesBtn->SetTooltipText(QObject::tr("Hide properties")); - - m_TreeLayout->GetFilter()->SetProperties(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for material objects. - * @param inFilter true to filter material objects out of the timeline, false to show - * material objects in the timeline. - */ -void CFilterToolbar::FilterMaterials(bool inFilter) -{ - if (inFilter) - m_FltrMaterialsBtn->SetTooltipText(QObject::tr("Show materials")); - else - m_FltrMaterialsBtn->SetTooltipText(QObject::tr("Hide materials")); - - m_TreeLayout->GetFilter()->SetMaterials(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for shy objects. - * @param inFilter true to filter shy objects out of the timeline, false to show - * shy objects in the timeline. - */ -void CFilterToolbar::FilterShy(bool inFilter) -{ - if (inFilter) - m_FltrShyBtn->SetTooltipText(QObject::tr("Show shy objects")); - else - m_FltrShyBtn->SetTooltipText(QObject::tr("Hide shy objects")); - - m_TreeLayout->GetFilter()->SetShy(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for visible objects. - * @param inFilter true to filter visible objects out of the timeline, false to show - * shy objects in the timeline. - */ -void CFilterToolbar::FilterVisible(bool inFilter) -{ - if (inFilter) - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Show inactive objects")); - else - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Hide inactive objects")); - - m_TreeLayout->GetFilter()->SetVisible(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Handles turning a filter on or off in response to a button being pressed. - * @param inButton button that generated the event - * @param inState new state of the button after being toggled - */ -void CFilterToolbar::OnButtonToggled(CToggleButton *inButton, CButtonControl::EButtonState inState) -{ - bool theFilterNeedsApplied = (inState == CButtonControl::EBUTTONSTATE_UP); - - if (inButton == m_FltrBehaviorsBtn) - FilterBehaviors(theFilterNeedsApplied); - else if (inButton == m_FltrPropertiesBtn) - FilterProperties(theFilterNeedsApplied); - else if (inButton == m_FltrMaterialsBtn) - FilterMaterials(theFilterNeedsApplied); - else if (inButton == m_FltrShyBtn) - FilterShy(theFilterNeedsApplied); - else if (inButton == m_FltrVisibleBtn) - FilterVisible(theFilterNeedsApplied); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.h b/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.h deleted file mode 100644 index 8148fff3..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/FilterToolbar.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_FILTER_TOOLBAR_H -#define INCLUDED_FILTER_TOOLBAR_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "FlowLayout.h" -#include "ProceduralButton.h" -#include "ToggleButton.h" - -//============================================================================== -// Forwards -//============================================================================== -class CButtonControl; -class CRenderer; -class CTimelineTreeLayout; - -//============================================================================= -/** - * Control at the top of the timeline containing filter buttons. - */ -class CFilterToolbar : public CFlowLayout -{ -public: - CFilterToolbar(CTimelineTreeLayout *inTreeLayout); - virtual ~CFilterToolbar(); - void Draw(CRenderer *inRenderer) override; - - void FilterBehaviors(bool inFilter); - void FilterProperties(bool inFilter); - void FilterMaterials(bool inFilter); - void FilterShy(bool inFilter); - void FilterVisible(bool inFilter); - - void OnButtonToggled(CToggleButton *inButton, CToggleButton::EButtonState inState); - -protected: - CProceduralButton<CToggleButton> *m_FltrBehaviorsBtn; - CProceduralButton<CToggleButton> *m_FltrPropertiesBtn; - CProceduralButton<CToggleButton> *m_FltrMaterialsBtn; - CProceduralButton<CToggleButton> *m_FltrShyBtn; - CProceduralButton<CToggleButton> *m_FltrVisibleBtn; - CTimelineTreeLayout *m_TreeLayout; -}; - -#endif // INCLUDED_FILTER_TOOLBAR_H diff --git a/src/Authoring/Studio/Palettes/Timeline/MultiSelectAspect.h b/src/Authoring/Studio/Palettes/Timeline/MultiSelectAspect.h index 0c19b2b2..7a686522 100644 --- a/src/Authoring/Studio/Palettes/Timeline/MultiSelectAspect.h +++ b/src/Authoring/Studio/Palettes/Timeline/MultiSelectAspect.h @@ -36,7 +36,6 @@ // Includes //============================================================================== #include "StateRow.h" -#include "TimelineTimelineLayout.h" #include "Bindings/IKeyframeSelector.h" //============================================================================== diff --git a/src/Authoring/Studio/Palettes/Timeline/Playhead.cpp b/src/Authoring/Studio/Palettes/Timeline/Playhead.cpp deleted file mode 100644 index be59530d..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/Playhead.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "Playhead.h" -#include "Renderer.h" -#include "TimelineTimelineLayout.h" -#include "IDoc.h" -#include "HotKeys.h" -#include "ResourceCache.h" -#include "TimeEditDlg.h" -#include "TimeMeasure.h" - -//============================================================================= -/** - * Create a new Playhead. - * The timeline is used for notifying of time changes and for scrolling. - * @param inTimeline the timeline that this is a part of. - */ -CPlayhead::CPlayhead(CTimelineTimelineLayout *inTimeline, IDoc *inDoc) - : m_IsMouseDown(false) - , m_MinimumPosition(0) - , m_MaximumPosition(LONG_MAX) - , m_InitialOffset(0) - , m_Doc(inDoc) -{ - m_Timeline = inTimeline; - - m_PlayheadImage = CResourceCache::GetInstance()->GetBitmap("PlaybackHead.png"); - SetName("Playhead"); - - // Set the line to the middle of this. - m_LinePos = GetSize().x / 2; - SetAlpha(128); -} - -CPlayhead::~CPlayhead() -{ -} - -//============================================================================= -/** - * Call from the OverlayControl to perform the draw. - * Wish this didn't have to be a special function but... - * @param inRenderer the renderer to draw to. - */ -void CPlayhead::Draw(CRenderer *inRenderer) -{ - // If this goes before position then clip it at 0. - if (GetPosition().x < 0) { - CRct theClipRect(GetSize()); - theClipRect.Offset(CPt(-GetPosition().x, 0)); - inRenderer->PushClippingRect(theClipRect); - } - - // Draw the playhead - inRenderer->DrawBitmap(CPt(0, 2), m_PlayheadImage); - - // Draw the line - inRenderer->PushPen(CColor(255, 0, 0)); - inRenderer->MoveTo(m_LinePos, 20); - inRenderer->LineTo(m_LinePos, GetSize().y - 1); - inRenderer->PopPen(); - - // If we added an extra clipping rect then remove it. - if (GetPosition().x < 0) { - inRenderer->PopClippingRect(); - } -} - -//============================================================================= -/** - * Handles mouse down messages. - * @param inPoint where the mouse was clicked. - * @param inFlags the state of the mouse. - */ -bool CPlayhead::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // If no one else processed it then process the command. - if (!COverlayControl::OnMouseDown(inPoint, inFlags)) { - m_Snapper.Clear(); - m_Snapper.SetSource(this); - m_Timeline->PopulateSnappingList(&m_Snapper); - - // m_Snapper.SetTimeOffset( m_Timeline->GetViewTimeOffset( ) ); - m_Snapper.SetSnappingKeyframes(true); - m_Snapper.BeginDrag(inPoint.x, GetSize().x / 2); - - m_InitialOffset = inPoint.x; - m_IsMouseDown = true; - - m_Timeline->RecalcTime((inFlags & CHotKeys::MODIFIER_CONTROL) == 0, 0); - } - - return true; -} - -//============================================================================= -/** - * Handles mouse double click messages. Pops up a time edit dialog box for - * modifying playhead time. - * @param inPoint the location of the mouse in local coordinates. - * @param inFlags the state of the mouse. - */ -bool CPlayhead::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inPoint); - Q_UNUSED(inFlags); - - CTimeEditDlg theTimeEditDlg; - theTimeEditDlg.showDialog(GetCurrentTime(), m_Doc, PLAYHEAD); - return true; -} - -//============================================================================= -/** - * Handles mouse move messages. - * @param inPoint the location of the mouse in local coordinates. - * @param inFlags the state of the mouse. - */ -void CPlayhead::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - COverlayControl::OnMouseMove(inPoint, inFlags); - - // If we are down then move the playhead - if (m_IsMouseDown) { - long theTime = m_Snapper.ProcessDrag(GetCurrentTime(), inPoint.x, inFlags); - bool theUpdateClientTimeFlag = (inFlags & CHotKeys::MODIFIER_CONTROL) == 0; - - UpdateTime(theTime, theUpdateClientTimeFlag); - } -} - -//============================================================================= -/** - * Updates the time of the active context - * @param inTime the new time - * @param inUpdateClient true if scene is to be redrawn - */ -void CPlayhead::UpdateTime(long inTime, bool /*inUpdateClient*/) -{ - // true to "check bounds" to ensure playhead is within valid range. - m_Doc->NotifyTimeChanged(inTime); -} - -//============================================================================= -/** - * Notification that the mouse was let go. - * @param inPoint the location of the mouse in local coordinates. - * @param inFlags the state of the mouse. - */ -void CPlayhead::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - COverlayControl::OnMouseUp(inPoint, inFlags); - - m_IsMouseDown = false; -} - -//============================================================================= -/** - * Set the size of this control. - * @param inSize the size to be set. - */ -void CPlayhead::SetSize(CPt inSize) -{ - COverlayControl::SetSize(inSize); - // Update the line position. - m_LinePos = inSize.x / 2; -} - -//============================================================================= -/** - * Set the minimum and maximum allowed positions of the line. - * @param inMinimumPosition the minimum allowed position. - * @param inMaximumPosition the maximum allowed position. - */ -void CPlayhead::SetMinMaxPosition(long inMinimumPosition, long inMaximumPosition) -{ - m_MinimumPosition = inMinimumPosition; - m_MaximumPosition = inMaximumPosition; -} - -long CPlayhead::GetCurrentTime() -{ - return m_Doc->GetCurrentViewTime(); -} - -//============================================================================= -/** - * Check to see if inPoint is over this control or not. - * This overrides COverlayControl::HitTest so that the playhead line can be - * exempt from mouse hits. - * @param inPoint the location of the mouse in local coordinates. - */ -bool CPlayhead::HitTest(const CPt &inPoint) const -{ - if (inPoint.y < m_PlayheadImage.height()) { - return COverlayControl::HitTest(inPoint); - } - return false; -} - -void CPlayhead::StepRightSmall() -{ - long theInterval = m_Timeline->GetTimeMeasure()->GetSmallHashInterval(); - - long theCurrentTime = GetCurrentTime(); - long theTime = theCurrentTime / theInterval * theInterval + theInterval; - UpdateTime(theTime, true); -} - -void CPlayhead::StepRightLarge() -{ - long theInterval = m_Timeline->GetTimeMeasure()->GetLargeHashInterval(); - - long theCurrentTime = GetCurrentTime(); - long theTime = theCurrentTime / theInterval * theInterval + theInterval; - UpdateTime(theTime, true); -} - -void CPlayhead::StepLeftSmall() -{ - long theInterval = m_Timeline->GetTimeMeasure()->GetSmallHashInterval(); - - long theCurrentTime = GetCurrentTime(); - long theTime = theCurrentTime / theInterval * theInterval - theInterval; - - UpdateTime(theTime, true); -} - -void CPlayhead::StepLeftLarge() -{ - long theInterval = m_Timeline->GetTimeMeasure()->GetLargeHashInterval(); - - long theCurrentTime = GetCurrentTime(); - long theTime = theCurrentTime / theInterval * theInterval - theInterval; - - UpdateTime(theTime, true); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/Playhead.h b/src/Authoring/Studio/Palettes/Timeline/Playhead.h deleted file mode 100644 index 21d21041..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/Playhead.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PLAYHEAD_H -#define INCLUDED_PLAYHEAD_H 1 - -#pragma once - -#include "OverlayControl.h" -#include "Snapper.h" - -#include <QPixmap> - -class CTimelineTimelineLayout; -class IDoc; - -class CPlayhead : public COverlayControl -{ -public: - CPlayhead(CTimelineTimelineLayout *inTimeline, IDoc *inDoc); - virtual ~CPlayhead(); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void SetSize(CPt inSize) override; - void Draw(CRenderer *inRenderer) override; - void SetMinMaxPosition(long inMinimumPosition, long inMaximumPosition); - long GetCurrentTime(); - bool HitTest(const CPt &inPoint) const override; - void StepRightSmall(); - void StepRightLarge(); - void StepLeftSmall(); - void StepLeftLarge(); - - long GetCenterOffset() const { return m_LinePos; } - bool IsMouseDown() const { return m_IsMouseDown; } - - void UpdateTime(long inTime, bool inUpdateClient); - -protected: - QPixmap m_PlayheadImage; - bool m_IsMouseDown; - long m_InitialOffset; - - long m_MinimumPosition; - long m_MaximumPosition; - long m_LinePos; - - CTimelineTimelineLayout *m_Timeline; - - CSnapper m_Snapper; - IDoc *m_Doc; -}; -#endif // INCLUDED_PLAYHEAD_H diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyRow.h b/src/Authoring/Studio/Palettes/Timeline/PropertyRow.h index 5c608d06..7b76b955 100644 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyRow.h +++ b/src/Authoring/Studio/Palettes/Timeline/PropertyRow.h @@ -48,8 +48,6 @@ class CPropertyColorControl; class CBlankControl; class CPropertyTreeControl; -class CPropertyToggleControl; -class CPropertyTimebarRow; class ITimelineItemProperty; class CPropertyRow : public CTimelineRow diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.cpp b/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.cpp deleted file mode 100644 index 2f8e3ffb..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "PropertyRowUI.h" - -#include "PropertyRow.h" -#include "PropertyTreeControl.h" -#include "TimelineControl.h" -#include "PropertyColorControl.h" -#include "PropertyToggleControl.h" -#include "PropertyTreeControl.h" -#include "PropertyTimebarRow.h" -#include "BlankControl.h" - -CPropertyRowUI::CPropertyRowUI(CPropertyRow *propertyRow, CAbstractTimelineRowUI *parentUiRow) - : CAbstractTimelineRowUI(propertyRow, parentUiRow) - , m_propertyRow(propertyRow) -{ - connect(propertyRow, &CPropertyRow::dirtyChanged, - this, &CPropertyRowUI::handleDirtyChanged); - connect(propertyRow, &CPropertyRow::visibleChanged, - this, &CPropertyRowUI::handleVisibleChanged); - connect(propertyRow, &CPropertyRow::selectAllKeys, - this, &CPropertyRowUI::handleSelectAllKeys); - connect(propertyRow, &CPropertyRow::deleteAllKeys, - this, &CPropertyRowUI::handleDeleteAllKeys); - connect(propertyRow, &CPropertyRow::refreshRequested, - this, &CPropertyRowUI::handleRefreshRequested); - connect(propertyRow, &CPropertyRow::selectKeysByTime, - this, &CPropertyRowUI::handleSelectKeysByTime); - connect(propertyRow, &CPropertyRow::timeRatioChanged, - this, &CPropertyRowUI::setTimeRatio); - - m_TreeControl = new CPropertyTreeControl(this); - m_ToggleControl = new CPropertyToggleControl(this); - m_TimebarRow = new CPropertyTimebarRow(this); - m_TimebarRow->SetTimeRatio(propertyRow->GetTimeRatio()); - - m_PropertyColorControl = new CPropertyColorControl(m_propertyRow); - long theTimebarHeight = CStudioPreferences::GetRowSize(); - - // do not set absolute size because it messes up the timeline - m_TreeControl->SetSize(CPt(500, theTimebarHeight)); - m_PropertyColorControl->SetAbsoluteSize(CPt(theTimebarHeight, theTimebarHeight)); - m_ToggleControl->SetAbsoluteSize(CPt(57, theTimebarHeight)); - m_TimebarRow->SetSize(CPt(0, theTimebarHeight)); - - // sk: setting controls names' seem to be only useful for debugging. - // Q3DStudio::CString thePropName( inProperty->GetName( ) ); - // m_TreeControl->SetName( thePropName ); - // m_TimebarRow->SetName( thePropName + "TimebarRow" ); -} - -CPropertyRowUI::~CPropertyRowUI() -{ - delete m_TreeControl; - delete m_ToggleControl; - delete m_PropertyColorControl; - delete m_TimebarRow; -} - - -//============================================================================= -/** - * Get the left hand color control for this row. - * @return the color control for this row. - */ -CControl *CPropertyRowUI::GetColorControl() -{ - return m_PropertyColorControl; -} - -//============================================================================= -/** - * Get the tree control object for this row. - * @return the tree control object for this row. - */ -CControl *CPropertyRowUI::GetTreeControl() -{ - return m_TreeControl; -} - -//============================================================================= -/** - * Get the toggle control object for this row. - * @return the toggle control object for this row. - */ -CControl *CPropertyRowUI::GetToggleControl() -{ - return m_ToggleControl; -} - -//============================================================================= -/** - * Get the timebar control for this row. - * @return the timebar control for this row. - */ -CControl *CPropertyRowUI::GetTimebarControl() -{ - return m_TimebarRow; -} - -//============================================================================= -/** - * Set the amount that this row is indented. - * This handles the tree indenting. - * @param inIndent the amount of indent for this row. - */ -void CPropertyRowUI::SetIndent(long inIndent) -{ - m_TreeControl->SetIndent(inIndent); -} - -long CPropertyRowUI::GetIndent() const -{ - return m_TreeControl->GetIndent(); -} - -void CPropertyRowUI::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - m_TimebarRow->SetSnappingListProvider(inProvider); -} - -ISnappingListProvider *CPropertyRowUI::GetSnappingListProvider() const -{ - return &m_TimebarRow->GetSnappingListProvider(); -} - -//============================================================================= -/** - * Notification from one of the child controls that the mouse just entered. - * This is used to handle the highlighting of the entire row. - */ -void CPropertyRowUI::OnMouseOver() -{ - // Only change if change is needed - if (!m_Highlighted) { - m_TreeControl->SetHighlighted(true); - m_ToggleControl->SetHighlighted(true); - m_TimebarRow->SetHighlighted(true); - - m_Highlighted = true; - } -} - -//============================================================================= -/** - * Notification from one of the child controls that the mouse just left. - * This is used to handle the highlighting of the entire row. - */ -void CPropertyRowUI::OnMouseOut() -{ - // Only change is change is needed. - if (m_Highlighted) { - m_TreeControl->SetHighlighted(false); - m_ToggleControl->SetHighlighted(false); - m_TimebarRow->SetHighlighted(false); - - m_Highlighted = false; - } -} - -//============================================================================= -/** - * Double click handler for the property row - */ -void CPropertyRowUI::OnMouseDoubleClick() -{ - SetDetailedView(!m_DetailedView); -} - -//============================================================================= -/** - * Selects all keyframes of this property that are inside inRect - * - * @param inRect theRect to check - */ -void CPropertyRowUI::SelectKeysInRect(CRct inRect, bool inModifierKeyDown, - bool inGlobalCommitSelectionFlag) -{ - Q_UNUSED(inGlobalCommitSelectionFlag); - CRct theOffsetRect = inRect; - - theOffsetRect.Offset(-m_TimebarRow->GetPosition()); - m_TimebarRow->SelectKeysInRect(theOffsetRect, inModifierKeyDown); -} - -//============================================================================= -/** - * Sets all the child control enable states - * @param inEnabled the state to set the controls to - */ -void CPropertyRowUI::SetEnabled(bool inEnabled) -{ - m_TreeControl->SetEnabled(inEnabled); - m_ToggleControl->SetEnabled(inEnabled); - m_PropertyColorControl->SetEnabled(inEnabled); - m_TimebarRow->SetEnabled(inEnabled); -} - - -//============================================================================= -/** - * CommitSelections: commits all the property keyframe selections by setting their - * previous selection state to the current selection state. - * This will prevent the keyframes in the current selection - * from - * switching states as we select other keyframes. - * - * @param NONE - * @return NONE - */ -void CPropertyRowUI::CommitSelections() -{ - m_TimebarRow->CommitSelections(); -} - -void CPropertyRowUI::handleDirtyChanged(bool dirty) -{ - m_TimebarRow->SetDirty(true); -} - -void CPropertyRowUI::setTimeRatio(double inTimeRatio) -{ - m_TimebarRow->SetTimeRatio(inTimeRatio); -} - -void CPropertyRowUI::handleVisibleChanged(bool visible) -{ - m_TreeControl->SetVisible(visible); - m_TimebarRow->SetVisible(visible); - m_ToggleControl->SetVisible(visible); - m_PropertyColorControl->SetVisible(visible); -} - -void CPropertyRowUI::handleSelectAllKeys() -{ - m_TimebarRow->SelectAllKeys(); -} - -void CPropertyRowUI::handleDeleteAllKeys() -{ - m_TimebarRow->Invalidate(); -} - -void CPropertyRowUI::handleRefreshRequested() -{ - if (m_TimebarRow->IsVisible()) - m_TimebarRow->SetDirty(true); -} - -void CPropertyRowUI::handleSelectKeysByTime(long inTime, bool inSelected) -{ - m_TimebarRow->SelectKeysByTime(inTime, inSelected); -} - -//============================================================================= -/** - * Expands the row out so a more detailed view of the animation tracks can be seen - * - * @param inIsInDetailedView true if we are switching to a detailed view - */ -void CPropertyRowUI::SetDetailedView(bool inIsDetailedView) -{ - m_DetailedView = inIsDetailedView; - - if (m_DetailedView) { - long theHeight = 100; - m_PropertyColorControl->SetAbsoluteSize( - CPt(m_PropertyColorControl->GetSize().x, theHeight)); - m_TreeControl->SetSize(CPt(m_TreeControl->GetSize().x, theHeight)); - m_ToggleControl->SetAbsoluteSize(CPt(m_ToggleControl->GetSize().x, theHeight)); - m_TimebarRow->SetAbsoluteSize(CPt(m_TimebarRow->GetSize().x, theHeight)); - - m_TimebarRow->SetDetailedView(true); - } else { - long theDefaultHeight = CStudioPreferences::GetRowSize(); - - m_PropertyColorControl->SetAbsoluteSize( - CPt(m_PropertyColorControl->GetSize().x, theDefaultHeight)); - m_TreeControl->SetSize(CPt(m_TreeControl->GetSize().x, theDefaultHeight)); - m_ToggleControl->SetAbsoluteSize(CPt(m_ToggleControl->GetSize().x, theDefaultHeight)); - m_TimebarRow->SetAbsoluteSize(CPt(m_TimebarRow->GetSize().x, theDefaultHeight)); - - m_TimebarRow->SetDetailedView(false); - } - - GetTopControl()->OnLayoutChanged(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.h b/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.h deleted file mode 100644 index d698209b..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyRowUI.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PROPERTYROWUI_H -#define PROPERTYROWUI_H - -#include "AbstractTimelineRowUI.h" - -class CPropertyRow; -class CPropertyColorControl; -class CBlankControl; -class CPropertyTreeControl; -class CPropertyToggleControl; -class CPropertyTimebarRow; -class ITimelineItemProperty; - -class CPropertyRowUI : public CAbstractTimelineRowUI -{ - Q_OBJECT -public: - CPropertyRowUI(CPropertyRow *baseStateRow, CAbstractTimelineRowUI *parentUiRow); - ~CPropertyRowUI(); - - CControl *GetColorControl() override; - CControl *GetTreeControl() override; - CControl *GetToggleControl() override; - CControl *GetTimebarControl() override; - - void SetIndent(long inIndent) override; - long GetIndent() const override; - - void SetSnappingListProvider(ISnappingListProvider *inProvider) override; - ISnappingListProvider *GetSnappingListProvider() const override; - - void OnMouseOver(); - void OnMouseOut(); - void OnMouseDoubleClick(); - - void SelectKeysInRect(CRct inRect, bool inModifierKeyDown, - bool inGlobalCommitSelectionFlag) override; - void SetEnabled(bool inEnabled) override; - - void CommitSelections(); - - // unused methods from CAbstractTimelineRowUI - void SetFocus() override {} - void SetNameReadOnly(bool) override {} - void OnChildVisibilityChanged() override {} - void PopulateSnappingList(CSnapper *) override {} - void DoStartDrag(CControlWindowListener *) override {} - void AcceptDropAfter(bool) override {} - void AcceptDropBefore(bool) override {} - void SetDropTarget(CDropTarget *) override {} - - void UpdateActionStatus() override {} - -private Q_SLOTS: - void Initialize() {} - void handleDirtyChanged(bool dirty); - void setTimeRatio(double inTimeRatio); - void handleVisibleChanged(bool visible); - void handleSelectAllKeys(); - void handleDeleteAllKeys(); - void handleRefreshRequested(); - void handleSelectKeysByTime(long inTime, bool inSelected); - -protected: - void SetDetailedView(bool inIsDetailedView); - - CPropertyTreeControl *m_TreeControl; - CPropertyToggleControl *m_ToggleControl; - CPropertyColorControl *m_PropertyColorControl; - CPropertyTimebarRow *m_TimebarRow; - CPropertyRow *m_propertyRow; - - bool m_DetailedView = false; - bool m_Highlighted = false; -}; - -#endif // PROPERTYROWUI_H diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.cpp b/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.cpp deleted file mode 100644 index 231a6d85..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.cpp +++ /dev/null @@ -1,521 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "PropertyTimebarRow.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "StudioUtils.h" -#include "PropertyRow.h" -#include "PropertyRowUI.h" -#include "MasterP.h" -#include "KeyframeContextMenu.h" -#include "PropertyTimelineKeyframe.h" -#include "HotKeys.h" -#include "MultiSelectAspect.h" -#include "Bindings/ITimelineItemProperty.h" -#include "IKeyframe.h" -#include "CoreUtils.h" - -//============================================================================= -/** - */ -CPropertyTimebarRow::CPropertyTimebarRow(CPropertyRowUI *inPropertyRowUI) - : m_PropertyRowUI(inPropertyRowUI) - , m_DetailedView(static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow())->GetProperty()) - , m_DirtyFlag(false) - , m_Refreshing(false) - , m_SnappingListProvider(nullptr) -{ - m_DetailedView.SetVisible(false); - - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - m_BackgroundColor = propertyRow->GetTimebarBackgroundColor(); - - AddChild(&m_DetailedView); - m_Refreshing = false; - RefreshKeyframes(); -} - -CPropertyTimebarRow::~CPropertyTimebarRow() -{ - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - CPropertyTimelineKeyframe *theDeletedKey = (*thePos); - RemoveChild(theDeletedKey); - delete theDeletedKey; - } -} - -//============================================================================= -/** - * Draws the this row background. - * @param inRenderer the renderer to draw to. - */ -void CPropertyTimebarRow::Draw(CRenderer *inRenderer) -{ - if (m_DirtyFlag) { - RefreshKeyframes(); - m_DirtyFlag = false; - } - - CRct theRect(GetSize()); - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - qt3dsdm::TDataTypePair theType = propertyRow->GetProperty()->GetType(); - if (theType.first == qt3dsdm::DataModelDataType::Float3 - && theType.second == qt3dsdm::AdditionalMetaDataType::Color) { - inRenderer->FillSolidRect(CRct(0, 0, theRect.size.x, theRect.size.y - 1), - m_BackgroundColor); - DrawColor(inRenderer); - } else { - inRenderer->FillSolidRect(CRct(0, 0, theRect.size.x, theRect.size.y - 1), - m_BackgroundColor); - } - - inRenderer->PushPen(CStudioPreferences::GetPropertyFloorColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x - 1, theRect.size.y - 1)); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * Draw a colorized background for this property row. - * If this is a color object then this will draw the background of this control - * as the color that the property is. This will draw a gradient between the - * colors over time to show somewhat what the colors look like. - * @param inRenderer the renderer to draw to. - */ -void CPropertyTimebarRow::DrawColor(CRenderer *inRenderer) -{ - QT3DS_PROFILE(DrawColor); - - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - ITimelineItemProperty *theProperty = propertyRow->GetProperty(); - ASSERT(theProperty->GetChannelCount() == 3); // sanity check - - CColor thePreviousColor; - thePreviousColor.SetRed(::dtol(theProperty->GetChannelValueAtTime(0, 0))); - thePreviousColor.SetGreen(::dtol(theProperty->GetChannelValueAtTime(1, 0))); - thePreviousColor.SetBlue(::dtol(theProperty->GetChannelValueAtTime(2, 0))); - - long thePreviousTime = 0; - long theLastPosition = 0; - CColor theCurrentColor; - - long theKeyframeCount = theProperty->GetKeyframeCount(); - - // Go through all the keyframes and draw a gradient from the previous key to the current key. - // Only use the first channel for the keyframes, assume they are all at the same time. - for (long theIndex = 0; theIndex < theKeyframeCount; ++theIndex) { - long theCurrentTime = theProperty->GetKeyframeByIndex(theIndex)->GetTime(); - // Get the color at the specified time. - theCurrentColor.SetRed(::dtol(theProperty->GetChannelValueAtTime(0, theCurrentTime))); - theCurrentColor.SetGreen(::dtol(theProperty->GetChannelValueAtTime(1, theCurrentTime))); - theCurrentColor.SetBlue(::dtol(theProperty->GetChannelValueAtTime(2, theCurrentTime))); - - long thePreviousPixel = ::TimeToPos(thePreviousTime, m_TimeRatio); - long theCurrentPixel = ::TimeToPos(theCurrentTime, m_TimeRatio); - - // Draw a gradient from the previous keyframe position to the current one. - inRenderer->DrawGradient( - CRct(thePreviousPixel, 0, theCurrentPixel - thePreviousPixel, GetSize().y), - thePreviousColor, theCurrentColor); - thePreviousTime = theCurrentTime; - thePreviousColor = theCurrentColor; - theLastPosition = theCurrentPixel; - } - // Fill in from the last keyframe to the end of the bar. - inRenderer->DrawGradient(CRct(theLastPosition, 0, GetSize().x - theLastPosition, GetSize().y), - thePreviousColor, thePreviousColor); -} - -//============================================================================= -/** - * OnMouseOver event, handles the highlighting of the row. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -void CPropertyTimebarRow::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - m_PropertyRowUI->OnMouseOver(); -} - -//============================================================================= -/** - * OnMouseOut event, handles the de-highlighting of this row. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -void CPropertyTimebarRow::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - m_PropertyRowUI->OnMouseOut(); -} - -//============================================================================= -/** - * OnMouseRDown event, pops up a context menu - * @param inPoint the location of the mouse over this control. - * @param inFlags the modifier key states (shift, alt, and ctrl). - */ -bool CPropertyTimebarRow::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // Only do it if a child has not handled the mouse down. - bool theRetVal = CControl::OnMouseRDown(inPoint, inFlags); - if (!theRetVal) { - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - propertyRow->Select(); - CKeyframeContextMenu theMenu(propertyRow->GetProperty()->GetKeyframesManager(), - propertyRow->GetProperty()); - DoPopup(&theMenu, inPoint); - theRetVal = true; - } - - return theRetVal; -} - -//============================================================================= -/** - * OnMouseOut event, handles the de-highlighting of this row. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -void CPropertyTimebarRow::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - QT3DS_PROFILE(OnMouseMove); - CControl::OnMouseMove(inPoint, inFlags); -} -//============================================================================= -/** - * Set this control to being highlighted or not. - * @param inIsHighlighted true if this is to be highlighted. - */ -void CPropertyTimebarRow::SetHighlighted(bool inIsHighlighted) -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - if (inIsHighlighted) - m_BackgroundColor = propertyRow->GetTimebarHighlightBackgroundColor(); - else - m_BackgroundColor = propertyRow->GetTimebarBackgroundColor(); - - Invalidate(); -} - -//============================================================================= -/** - * Get the state row that this belongs to. - */ -CPropertyRowUI *CPropertyTimebarRow::GetPropertyRowUI() -{ - return m_PropertyRowUI; -} - -//============================================================================= -/** - * Sets teh time ratio - * - * @param inTimeRatio the new ratio - */ -void CPropertyTimebarRow::SetTimeRatio(double inTimeRatio) -{ - m_TimeRatio = inTimeRatio; - - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - (*thePos)->SetTimeRatio(inTimeRatio); - } - m_DetailedView.SetTimeRatio(inTimeRatio); - - Invalidate(); -} - -void CPropertyTimebarRow::SetDetailedView(bool inDetailedView) -{ - m_DetailedView.SetVisible(inDetailedView); -} - -//============================================================================= -/** - * Sets teh size of this control. - * @param inSize size to set the row - */ -void CPropertyTimebarRow::SetSize(CPt inSize) -{ - CControl::SetSize(inSize); - - m_DetailedView.SetSize(inSize); -} - -//============================================================================= -/** - * called when keyframes need to be updated, this funciton has two loops: - * the first loops through and deletes any keys no longer in the sskf list. the - * second adds any keys in the sskf list that are not already in the list - * - */ -void CPropertyTimebarRow::RefreshKeyframes() -{ - m_Refreshing = true; - QT3DS_PROFILE(RefreshKeyframes); - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - - // First Loop clears any keys that do not correlate to a supersetkey - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - while (thePos != m_Keyframes.end()) { - CPropertyTimelineKeyframe *theTimelineKey = (*thePos); - CPt theSize = theTimelineKey->GetSize(); - IKeyframe *theTempKey = nullptr; - theTempKey = propertyRow->GetProperty()->GetKeyframeByTime(theTimelineKey->GetTime()); - - // If we find a key at this time, then the timeline key doesn't need to be deleted - if (!theTempKey) { - RemoveChild(theTimelineKey); - delete theTimelineKey; - thePos = m_Keyframes.erase(thePos); - } else if (theTempKey->IsDynamic() != theTimelineKey->IsDynamic()) { - theTimelineKey->SetDynamic(theTempKey->IsDynamic()); - } else { - // Set the position - theTimelineKey->SetPosition( - ::TimeToPos(theTempKey->GetTime(), m_TimeRatio) - (theSize.x / 2), 0); - ++thePos; - } - } - - // Second Loop adds teh remaining keys - long theKeyframeCount = propertyRow->GetProperty()->GetKeyframeCount(); - for (long theKey = 0; theKey < theKeyframeCount; ++theKey) { - bool theFoundFlag = false; - IKeyframe *theTempKey = propertyRow->GetProperty()->GetKeyframeByIndex(theKey); - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - - long theKeyframeTime = theTempKey->GetTime(); - // each key needs to be compared to all the keys in the sskf list to see if it has to be - // added. - for (; thePos != m_Keyframes.end() && !theFoundFlag; ++thePos) { - CPropertyTimelineKeyframe *theCurrentKey = (*thePos); - if (theCurrentKey->GetTime() == theKeyframeTime) { - theFoundFlag = true; - } - } - if (!theFoundFlag) { - // If we don't have a timeline key, then we have to make a new one - CPropertyTimelineKeyframe *thePropertyTimelineKey = - new CPropertyTimelineKeyframe(this, m_TimeRatio); - thePropertyTimelineKey->SetTime(theKeyframeTime); - thePropertyTimelineKey->Select(theTempKey->IsSelected()); - thePropertyTimelineKey->SetDynamic(theTempKey->IsDynamic()); - thePropertyTimelineKey->SetSize(CPt(15, 16)); - CPt theSize = thePropertyTimelineKey->GetSize(); - long theXPosition = ::TimeToPos(theKeyframeTime, m_TimeRatio) - (theSize.x / 2); - thePropertyTimelineKey->SetPosition(theXPosition, 0); - AddChild(thePropertyTimelineKey); - m_Keyframes.push_back(thePropertyTimelineKey); - } - } - - if (m_DetailedView.IsVisible()) - m_DetailedView.RefreshKeyframes(); - - m_Refreshing = false; -} - -void CPropertyTimebarRow::Invalidate(bool inInvalidate) -{ - if (!m_Refreshing) { - CControl::Invalidate(inInvalidate); - } -} - -//============================================================================= -/** - * Handler for when a child key is selected - * - * @param inTime time of the key - */ -void CPropertyTimebarRow::OnKeySelected(long inTime, bool inSelected) -{ - if (inTime >= 0) { - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - propertyRow->GetProperty()->SelectKeyframes(inSelected, inTime); - Invalidate(); - } -} - -//============================================================================= -/** - * Deselects all keyframes - */ -void CPropertyTimebarRow::DeselectAllKeyframes() -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - propertyRow->GetProperty()->SelectKeyframes(false); -} - -//============================================================================= -/** - * called when a child changes and the keyframes need to be refreshed - * - * @param inDirtyFlag true if this object is now dirty - * - */ -void CPropertyTimebarRow::SetDirty(bool inDirtyFlag) -{ - if (m_DirtyFlag == inDirtyFlag) - return; - - m_DirtyFlag = inDirtyFlag; - Invalidate(); -} - -//============================================================================= -/** - * SelectKeysInRect: selects any keyframes inside the rect - * - * @param inRect is used to select keyframes - * @param inModifierKeyDown indicates if the control modifier is down - */ -void CPropertyTimebarRow::SelectKeysInRect(CRct inRect, bool inModifierKeyDown) -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - CMultiSelectAspect<TTimelineKeyframeList> theMultiSelectAspect(m_Keyframes, - propertyRow->GetProperty()); - theMultiSelectAspect.MultiSelect(inRect, inModifierKeyDown); -} - -//============================================================================= -/** - * CommitSelections: commits all the master keyframe selections by setting their - * previous selection state to the current selection state. - * This will prevent the keyframes in the current selection - *from - * switching states as we select other keyframes. - * - * @param NONE - * @return NONE - */ - -void CPropertyTimebarRow::CommitSelections() -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - CMultiSelectAspect<TTimelineKeyframeList> theMultiSelectAspect(m_Keyframes, - propertyRow->GetProperty()); - theMultiSelectAspect.CommitSelections(); -} - -//============================================================================= -/** - * true if there are selected keys on this object - */ -bool CPropertyTimebarRow::HasSelectedKeys() -{ - bool theRetVal = false; - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end() && !theRetVal; ++thePos) { - if ((*thePos)->IsSelected()) { - theRetVal = true; - } - } - return theRetVal; -} - -//============================================================================= -/** - * selects all keys for this timebar row - */ -void CPropertyTimebarRow::SelectAllKeys() -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - propertyRow->GetProperty()->SelectKeyframes(true, (*thePos)->GetTime()); - (*thePos)->Select(true); - Invalidate(); - } -} - -//============================================================================= -/** - * Set this control as being visible or not. - * If the control is not visible then it will not be drawn and will not - * get mouse clicks. - * @param inIsVisible true if this control is to be visible. - */ -void CPropertyTimebarRow::SetVisible(bool inIsVisible) -{ - if (inIsVisible != IsVisible()) { - CControl::SetVisible(inIsVisible); - SetDirty(true); - } -} - -bool CPropertyTimebarRow::HasKeyframe(long inTime) const -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - return propertyRow->GetProperty()->GetKeyframeByTime(inTime) != nullptr; -} - -//============================================================================= -/** - * @param inTime -1 for all keyframes - */ -void CPropertyTimebarRow::SelectKeysByTime(long inTime, bool inSelected) -{ - TTimelineKeyframeList::iterator thePos = m_Keyframes.begin(); - bool theFoundFlag = false; - for (; thePos != m_Keyframes.end() && !theFoundFlag; ++thePos) { - CPropertyTimelineKeyframe *theKey = (*thePos); - if (inTime == -1 || theKey->GetTime() == inTime) { - theKey->Select(inSelected); - theFoundFlag = (inTime != -1); - } - } - Invalidate(); -} - -void CPropertyTimebarRow::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - m_SnappingListProvider = inProvider; -} - -ISnappingListProvider &CPropertyTimebarRow::GetSnappingListProvider() const -{ - // sk - If you hit this, it means the setup is incorrect. e.g. the parent row (which is most - // probably a staterow) isn't pass 'down' this info. - ASSERT(m_SnappingListProvider); - return *m_SnappingListProvider; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.h b/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.h deleted file mode 100644 index 687bc840..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTimebarRow.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PROPERTY_TIMEBAR_ROW_H -#define INCLUDED_PROPERTY_TIMEBAR_ROW_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "Control.h" -#include "PropertyTimebarGraph.h" -#include "StateRow.h" - -//============================================================================== -// forwards -//============================================================================== -class CPropertyRowUI; -class CPropertyTimelineKeyframe; -class ISnappingListProvider; - -class CPropertyTimebarRow : public CControl -{ - typedef std::vector<CPropertyTimelineKeyframe *> TTimelineKeyframeList; - -public: - CPropertyTimebarRow(CPropertyRowUI *inPropertyRowUI); - virtual ~CPropertyTimebarRow(); - - void Draw(CRenderer *inRenderer) override; - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void SetHighlighted(bool inIsHighlighted); - void RefreshKeyframes(); - - void SetSize(CPt inSize) override; - - CPropertyRowUI *GetPropertyRowUI(); - - void SetTimeRatio(double inTimeRatio); - - void SetDetailedView(bool inDetailedView); - void OnKeySelected(long inTime, bool inSelected); - void DeselectAllKeyframes(); - void SetDirty(bool inDirtyFlag); - void CommitSelections(); - void SelectKeysInRect(CRct inRect, bool inModifierKeyDown); - void SelectAllKeys(); - bool HasSelectedKeys(); - void Invalidate(bool inInvalidate = true) override; - void SetVisible(bool inIsVisible) override; - - bool HasKeyframe(long inTime) const; - void SelectKeysByTime(long inTime, bool inSelected); - - void SetSnappingListProvider(ISnappingListProvider *inProvider); - ISnappingListProvider &GetSnappingListProvider() const; - -protected: - void DrawColor(CRenderer *inRenderer); - -protected: - TTimelineKeyframeList m_Keyframes; ///< Properties Keyframe List (STL) - CPropertyRowUI *m_PropertyRowUI; - CPropertyTimebarGraph m_DetailedView; - ::CColor m_BackgroundColor; - double m_TimeRatio; - - bool m_DirtyFlag; - bool m_Refreshing; - ISnappingListProvider *m_SnappingListProvider; -}; -#endif // INCLUDED_STATE_TIMEBAR_ROW_H diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.cpp b/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.cpp deleted file mode 100644 index 4f970d59..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" -#include "Dialogs.h" - -//============================================================================== -// Includes -//============================================================================== -#include "PropertyTimelineKeyframe.h" -#include "PropertyTimebarRow.h" -#include "Renderer.h" -#include "PropertyRow.h" -#include "PropertyRowUI.h" -#include "KeyframeContextMenu.h" -#include "HotKeys.h" -#include "ResourceCache.h" -#include "TimelineControl.h" -#include "Bindings/ITimelineItemProperty.h" -#include "StudioUtils.h" -#include "TimeEditDlg.h" - -CPropertyTimelineKeyframe::CPropertyTimelineKeyframe(CPropertyTimebarRow *inParentRow, - double inTimeRatio) - : m_Selected(false) - , m_IsMouseDown(false) - , m_IsDragging(false) -{ - m_ParentRow = inParentRow; - m_TimeRatio = inTimeRatio; - CResourceCache *theCache = CResourceCache::GetInstance(); - m_Icon = theCache->GetBitmap("Keyframe-Property-Normal.png"); - m_DisabledIcon = theCache->GetBitmap("Keyframe-Property-Disabled.png"); - m_SelectedIcon = theCache->GetBitmap("Keyframe-Property-Selected.png"); - m_DynamicIcon = theCache->GetBitmap("Keyframe-PropertyDynamic-Normal.png"); - m_DynamicSelectedIcon = theCache->GetBitmap("Keyframe-PropertyDynamic-Selected.png"); - m_RectOverHandled = false; - m_PreviousSelectState = false; -} - -CPropertyTimelineKeyframe::~CPropertyTimelineKeyframe() -{ -} - -//============================================================================= -/** - * SetRectOverHandled: Sets if mouse rectangle has been handled - * param@ inState indicates if the rectangle over has been handled. - * return@ NONE - */ -void CPropertyTimelineKeyframe::SetRectOverHandled(bool inState) -{ - m_RectOverHandled = inState; -} - -//============================================================================= -/** - * GetRectOverHandled: GetRectOverHandled - * param@ NONE - * return@ m_RectOverHandled, which indicates if the rectangle over has been handled - */ -bool CPropertyTimelineKeyframe::GetRectOverHandled() -{ - return m_RectOverHandled; -} - -//============================================================================= -/** - * SetPreviousSelectState: Sets if the current keyframe was previously selected - * param@ inState is used to set m_PreviousSelectState. - * return@ NONE - */ -void CPropertyTimelineKeyframe::SetPreviousSelectState(bool inState) -{ - m_PreviousSelectState = inState; -} - -//============================================================================= -/** - * GetPreviousSelectState: Returns the keyframe's previous select state - * param@ NONE - * return@ m_PreviousSelectState that stores the select state for the keyframe - */ -bool CPropertyTimelineKeyframe::GetPreviousSelectState() -{ - return m_PreviousSelectState; -} - -//============================================================================= -/** - * Gets teh correct image and draws - */ -void CPropertyTimelineKeyframe::Draw(CRenderer *inRenderer) -{ - if (m_Selected) { - inRenderer->DrawBitmap(CPt(0, 0), GetImage()); - } else { - inRenderer->DrawBitmap(CPt(2, 0), GetImage()); - } -} - -//============================================================================= -/** - * Gets the current bitmap depending on the state of the button, postion of the - * mouse, etc. Returns the image for the up state by default. - */ -QPixmap CPropertyTimelineKeyframe::GetImage() -{ - if (!IsEnabled()) - return m_DisabledIcon; - else if (m_IsDynamic) { - if (m_Selected) - return m_DynamicSelectedIcon; - else - return m_DynamicIcon; - } else if (m_Selected) - return m_SelectedIcon; - else - return m_Icon; -} - -//============================================================================= -/** - * Handler for left-click events. Allows keyframe dragging. Children are - * allowed to handle this event before the parent does. - * @param inPoint the point where the mouse is - * @param inFlags the state of modifier keys when the event occurred - * @return true - */ -bool CPropertyTimelineKeyframe::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // Store the mouse down location in screen coordinates so that we can check the dragging buffer - // in OnMouseMove - m_MouseDownLoc = inPoint; - - if (!CControl::OnMouseDown(inPoint, inFlags)) { - // If the control key is down then we change state, otherwise - if (!((CHotKeys::MODIFIER_CONTROL & inFlags) == CHotKeys::MODIFIER_CONTROL)) { - if (!m_Selected) - GetProperty()->ClearKeySelection(); - - m_Selected = true; - } else { - m_Selected = !m_Selected; - } - m_ParentRow->OnKeySelected(m_Time, m_Selected); - // TODO : sk - Remove this when we are clear on the fact that UpdateClientScene & - // FireChangeEvent do nothing useful here. - // This call makes no sense. However, if you run into some wierd - //behavior related to mouse down events, this might be a clue. - // I am leaving this just in case this speeds up debugging for anyone - //else looking at this. - // CAssetTimelineKeyframe::OnMouseDown does similar things. - // m_Doc->UpdateClientScene( true ); - // m_ParentRow->GetPropertyRow()->GetProperty()->FireChangeEvent( false ); - m_IsMouseDown = true; - - m_Snapper.Clear(); - m_Snapper.SetSource(this); - m_Snapper.SetSnappingSelectedKeyframes(false); - m_ParentRow->GetSnappingListProvider().PopulateSnappingList(&m_Snapper); - m_Snapper.BeginDrag(inPoint.x); - - // display the time range tooltip - RefreshToolTip(inPoint); - } - - return true; -} - -//============================================================================= -/** - * Handler for right-click events. Pops up a context menu. Children are - * allowed to handle this event before the parent does. - * @param inPoint the point where the mouse is - * @param inFlags the state of modifier keys when the event occurred - * @return true - */ -bool CPropertyTimelineKeyframe::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseRDown(inPoint, inFlags)) { - if (!m_Selected) { - GetProperty()->ClearKeySelection(); - m_Selected = true; - m_ParentRow->OnKeySelected(m_Time, m_Selected); - } - - CKeyframeContextMenu theMenu(GetProperty()->GetKeyframesManager(), GetProperty()); - theMenu.SetTime(GetTime()); - DoPopup(&theMenu, inPoint); - } - - return true; -} - -//============================================================================= -/** - * called when this key is selected - * @param inState the state this key is selected to - */ -void CPropertyTimelineKeyframe::Select(bool inState) -{ - if (m_Selected != inState) { - m_Selected = inState; - Invalidate(); - } -} - -//============================================================================= -/** - * handler for the mouse up event - * @param inFlags the state of things when the mouse button was released - * @param inPoint the point where the mouse is - */ -void CPropertyTimelineKeyframe::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); - - // If this key is selected, then we need to make sure that it moved all the way to the - // mouse up location - if (m_Selected && m_IsMouseDown && m_IsDragging) { - long theNewTime = m_Snapper.ProcessDrag(m_Time, inPoint.x, inFlags); - long theDiffTime = theNewTime - m_Time; - - // theDiffTime can get updated if its invalid. - theDiffTime = GetProperty()->OffsetSelectedKeyframes(theDiffTime); - // Set this key's time so it won't be recalced in Refresh keyframes in the row - SetTime(m_Time + theDiffTime); - } - - m_IsMouseDown = false; - m_IsDragging = false; - - GetProperty()->CommitChangedKeyframes(); - HideMoveableWindow(); - Invalidate(); -} - -//============================================================================= -/** - * handler for the onMouse Move event. Offsets selected keys. - * - * @param inFlags the state of things when the mouse was moved - * @param inPoint the point where the mouse is - */ -void CPropertyTimelineKeyframe::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - - // If the mouse is down and this is slected, then offst the keys - if (m_IsMouseDown && m_Selected) { - // If we are not yet dragging the keyframe - if (!m_IsDragging) { - long theDiff = ::abs(inPoint.x) - m_MouseDownLoc.x; - // Figure out if the mouse has moved far enough to start the drag, and readjust the drag - // postion on the snapper - m_IsDragging = (::abs(theDiff) > DRAGBUFFER); - if (m_IsDragging && (::abs(theDiff) - DRAGBUFFER) > 2) { - m_Snapper.BeginDrag(m_MouseDownLoc.x); - } else - m_Snapper.BeginDrag(inPoint.x); - } - - // If we are already dragging the keyframe, procceed as normal - if (m_IsDragging) { - long theNewTime = m_Snapper.ProcessDrag(m_Time, inPoint.x, inFlags); - long theDiffTime = theNewTime - m_Time; - - if (theDiffTime != 0) { - // theDiffTime can get updated if its invalid. - theDiffTime = GetProperty()->OffsetSelectedKeyframes(theDiffTime); - // Set this key's time so it won't be recalced in Refresh keyframes in the row - SetTime(m_Time + theDiffTime); - Invalidate(); - } - } - - // display the time range tooltip - RefreshToolTip(inPoint); - } -} - -//============================================================================= -/** - * Sets teh time ratio - * - * @param inTimeRatio the new ratio - */ -void CPropertyTimelineKeyframe::SetTimeRatio(double inTimeRatio) -{ - m_TimeRatio = inTimeRatio; - CPt theSize = GetSize(); - SetPosition(::TimeToPos(GetTime(), m_TimeRatio) - (theSize.x / 2), 0); -} - -//============================================================================= -/** - * Pass the double click notification on to the row and have it process it. - * The row will do object-specific actions on doubleclicks. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - * @return true stating that the event was processed. - */ -bool CPropertyTimelineKeyframe::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inPoint); - Q_UNUSED(inFlags); - - GetProperty()->OnEditKeyframeTime(m_Time, ASSETKEYFRAME); - return true; -} - -//============================================================================= -/** - * @return true if selected - */ -bool CPropertyTimelineKeyframe::IsSelected() -{ - return m_Selected; -} - -//============================================================================= -/** -* Updates the ToolTip and moves it to the correct place on screen. -* @param inPoint the point that the tooltip is supposed to be placed. -*/ -void CPropertyTimelineKeyframe::RefreshToolTip(CPt inPoint) -{ - CRct theTimelineBounds(m_ParentRow->GetPropertyRowUI()->GetTopControl()->GetBounds()); - - // format label - Q3DStudio::CString theCommentText = " " + ::FormatTimeString(GetTime()); - - inPoint.y = GetPosition().y - GetSize().y; - inPoint.x = GetSize().x / 2; - ShowMoveableWindow(inPoint, theCommentText, theTimelineBounds); -} - -//============================================================================= -/** -* Helper function to retrieve the ITimelineItemProperty -*/ -ITimelineItemProperty *CPropertyTimelineKeyframe::GetProperty() const -{ - auto propertyRow = static_cast<CPropertyRow *>(m_ParentRow->GetPropertyRowUI()->GetTimelineRow()); - return propertyRow->GetProperty(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.h b/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.h deleted file mode 100644 index 40c7f05b..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTimelineKeyframe.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PROPERTY_TIMELINE_KEYFRAME -#define INCLUDED_PROPERTY_TIMELINE_KEYFRAME 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "Control.h" -#include "TimelineKeyframe.h" -#include "Snapper.h" - -#include <QPixmap> - -//============================================================================== -// Forwards -//============================================================================== -class CRenderer; -class CPropertyTimebarRow; -class ITimelineItemProperty; - -class CPropertyTimelineKeyframe : public CControl, public CTimelineKeyframe -{ - -public: - CPropertyTimelineKeyframe(CPropertyTimebarRow *inParentRow, double inTimeRatio); - ~CPropertyTimelineKeyframe(); - void Draw(CRenderer *inRenderer) override; - QPixmap GetImage(); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void Select(bool inState); - void SetTimeRatio(double inTimeRatio); - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool IsSelected(); - void SetRectOverHandled(bool inState); - bool GetRectOverHandled(); - void SetPreviousSelectState(bool inState); - bool GetPreviousSelectState(); - -protected: - void RefreshToolTip(CPt inPoint); - ITimelineItemProperty *GetProperty() const; - -protected: - bool m_Selected; - bool m_RectOverHandled; ///< Indicates if the mouse rect over has been handled. - bool m_PreviousSelectState; ///< Stores the previous select state for the keyframe. - CPropertyTimebarRow *m_ParentRow; - bool m_IsMouseDown; - CPt m_MouseDownLoc; ///< Location of the mouse after an OnMouseDownEvent, in client coordinates - bool m_IsDragging; ///< Indicates whether or not the keyframe is currently being dragged, - ///determined by the pixel buffer - double m_TimeRatio; - CSnapper m_Snapper; - QPixmap m_Icon; - QPixmap m_DisabledIcon; - QPixmap m_SelectedIcon; - QPixmap m_DynamicIcon; - QPixmap m_DynamicSelectedIcon; -}; - -#endif // INCLUDED_PROPERTY_TIMELINE_KEYFRAME diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.cpp b/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.cpp deleted file mode 100644 index 0c633c30..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "PropertyToggleControl.h" -#include "TimelineRow.h" -#include "PropertyRow.h" -#include "PropertyRowUI.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "HotKeys.h" - -CPropertyToggleControl::CPropertyToggleControl(CPropertyRowUI *inPropertyRow) - : m_PropertyRowUI(inPropertyRow) -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - m_BackgroundColor = propertyRow->GetTimebarBackgroundColor(); -} - -CPropertyToggleControl::~CPropertyToggleControl() -{ -} - -void CPropertyToggleControl::Draw(CRenderer *inRenderer) -{ - CRct theRect(GetSize()); - inRenderer->FillSolidRect(QRect(0, 0, theRect.size.x + 1, theRect.size.y), m_BackgroundColor); - - // Draw the line at the bottom of this control - inRenderer->PushPen(CStudioPreferences::GetPropertyFloorColor()); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - - // Draw the line on the left side of this control - inRenderer->MoveTo(CPt(0, 0)); - inRenderer->LineTo(CPt(0, theRect.size.y - 1)); - - // Draw the highlight - inRenderer->PushPen(CStudioPreferences::GetButtonHighlightColor()); - inRenderer->MoveTo(CPt(1, 0)); - inRenderer->LineTo(CPt(1, theRect.size.y - 1)); - inRenderer->PopPen(); - - // Draw the line on the right side of this control - inRenderer->PushPen(CStudioPreferences::GetButtonShadowColor()); - inRenderer->MoveTo(CPt(theRect.size.x - 1, 0)); - inRenderer->LineTo(CPt(theRect.size.x - 1, theRect.size.y - 1)); - inRenderer->PopPen(); -} - -void CPropertyToggleControl::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - m_PropertyRowUI->OnMouseOver(); -} - -void CPropertyToggleControl::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - m_PropertyRowUI->OnMouseOut(); -} - -void CPropertyToggleControl::SetHighlighted(bool inIsHighlighted) -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - if (inIsHighlighted) - m_BackgroundColor = propertyRow->GetTimebarHighlightBackgroundColor(); - else - m_BackgroundColor = propertyRow->GetTimebarBackgroundColor(); - - Invalidate(); -} - -//============================================================================== -/** - * Handles the OnMouseDownEvent - */ -bool CPropertyToggleControl::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - auto propertyRow = static_cast<CPropertyRow *>(m_PropertyRowUI->GetTimelineRow()); - propertyRow->Select((CHotKeys::MODIFIER_SHIFT & inFlags) == CHotKeys::MODIFIER_SHIFT); - } - - return true; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.h b/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.h deleted file mode 100644 index e75cc2b3..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyToggleControl.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PROPERTY_TOGGLE_CONTROL_H -#define INCLUDED_PROPERTY_TOGGLE_CONTROL_H 1 - -#pragma once - -#include "Control.h" -#include "CColor.h" - -class CPropertyRowUI; - -class CPropertyToggleControl : public CControl -{ -public: - CPropertyToggleControl(CPropertyRowUI *inPropertyRow); - virtual ~CPropertyToggleControl(); - - void Draw(CRenderer *inRenderer) override; - - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void SetHighlighted(bool inIsHightlighted); - -protected: - CPropertyRowUI *m_PropertyRowUI; - ::CColor m_BackgroundColor; -}; -#endif // INCLUDED_PROPERTY_TOGGLE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.cpp b/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.cpp deleted file mode 100644 index fbaf9ff9..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "PropertyTreeControl.h" -#include "PropertyRow.h" -#include "PropertyRowUI.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "StudioUtils.h" -#include "HotKeys.h" -#include "ResourceCache.h" -#include "BaseTimelineTreeControl.h" -#include "Bindings/ITimelineItemProperty.h" -#include "CoreUtils.h" - -CPropertyTreeControl::CPropertyTreeControl(CPropertyRowUI *inPropRowUI) - : m_Icon(CResourceCache::GetInstance()->GetBitmap("Objects-Property-Normal.png"), - CResourceCache::GetInstance()->GetBitmap("Objects-Property-Disabled.png")) -{ - m_PropRowUI = inPropRowUI; - - auto propertyRow = static_cast<CPropertyRow *>(m_PropRowUI->GetTimelineRow()); - CTimelineRow *theParentRow = propertyRow->GetParentRow(); - if (theParentRow) // property row typically should never exists on its own, but to be safe. - m_BackgroundColor = propertyRow->GetTimebarBackgroundColor(); - else - m_BackgroundColor = CStudioPreferences::GetPropertyBackgroundColor(); - - AddChild(&m_Icon); - - m_Text.SetData(propertyRow->GetProperty()->GetName()); - m_Text.SetAlignment(CTextEdit::LEFT); - m_Text.SetReadOnly(true); - - AddChild(&m_Text); - - SetIndent(0); -} - -CPropertyTreeControl::~CPropertyTreeControl() -{ -} - -void CPropertyTreeControl::Draw(CRenderer *inRenderer) -{ - CRct theRect(GetSize()); - - inRenderer->FillSolidRect(theRect, m_BackgroundColor); - - // Draw the line at the bottom of this control - CColor theShadowColor = CStudioPreferences::GetPropertyFloorColor(); - inRenderer->PushPen(theShadowColor); - inRenderer->MoveTo(CPt(0, theRect.size.y - 1)); - inRenderer->LineTo(CPt(theRect.size.x, theRect.size.y - 1)); - inRenderer->PopPen(); - - ::CColor theTextColor = CStudioPreferences::GetNormalColor(); - auto propertyRow = static_cast<CPropertyRow *>(m_PropRowUI->GetTimelineRow()); - if (propertyRow->GetProperty()->IsMaster()) - theTextColor = CStudioPreferences::GetMasterColor(); - m_Text.SetTextColor(theTextColor); -} - -void CPropertyTreeControl::SetIndent(long inIndent) -{ - m_Indent = inIndent; - - // place it it's size x2 to the right since we don't have a toggle. - m_Icon.SetPosition(CPt(m_Indent + m_Icon.GetSize().x, 0)); - - m_Text.SetPosition(CPt(m_Icon.GetPosition().x + m_Icon.GetSize().x + 5, 0)); - m_Text.SetSize(CPt(200, m_Icon.GetSize().y - 1)); -} - -long CPropertyTreeControl::GetIndent() -{ - return m_Indent; -} - -void CPropertyTreeControl::SetHighlighted(bool inIsHighlighted) -{ - auto propertyRow = static_cast<CPropertyRow *>(m_PropRowUI->GetTimelineRow()); - CTimelineRow *theParentRow = propertyRow->GetParentRow(); - if (theParentRow) // property row typically should never exists on its own, but to be safe. - m_BackgroundColor = (inIsHighlighted) ? propertyRow->GetTimebarHighlightBackgroundColor() - : propertyRow->GetTimebarBackgroundColor(); - else - m_BackgroundColor = (inIsHighlighted) ? CStudioPreferences::GetPropertyMouseOverColor() - : CStudioPreferences::GetPropertyBackgroundColor(); - - Invalidate(); -} - -//============================================================================== -/** - * HACK: Trying to scroll the timeline during a drag and drop operation. - * - * The Property Tree Control will never have a drop candidate, so this function - * returns nullptr. However, we still need to scroll the timeline in case we are - * at the top or bottom of the window. This is hackish for two reasons. 1) It - * points out that CPropertyTreeControl and CStateTreeControl should have a - * common base class that handles similar code. 2) The TreeControls should not - * have to scroll the timeline automatically. It should be handled through a - * timer on the scroller when the mouse is being dragged and hovering near the - * border of the scroller. But all of that will be saved for another day. - * @param inMousePoint location of the mouse - * @param inFlags not used (modifier key flags) - * @return nullptr (no drop candidate is ever found) - */ -CDropTarget *CPropertyTreeControl::FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inFlags); - - CPt theSize(GetSize()); - - // If the mouse is towards the top of this row, make sure that this row and the - // one above it are visible (scroll upwards) - if (inMousePoint.y <= ::dtol(theSize.y / 2.0f)) - EnsureVisible(CRct(CPt(0, -theSize.y), theSize)); - // Otherwise, the mouse is towards the bottom of this row, so make sure this row - // and the one below it are visible (scroll downwards) - else - EnsureVisible(CRct(CPt(theSize.x, theSize.y * 2))); - - return nullptr; -} - -void CPropertyTreeControl::OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOver(inPoint, inFlags); - - m_PropRowUI->OnMouseOver(); -} - -void CPropertyTreeControl::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - m_PropRowUI->OnMouseOut(); -} - -//============================================================================== -/** - * Handles the OnMouseDownEvent - */ -bool CPropertyTreeControl::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - auto propertyRow = static_cast<CPropertyRow *>(m_PropRowUI->GetTimelineRow()); - propertyRow->Select((CHotKeys::MODIFIER_SHIFT & inFlags) == CHotKeys::MODIFIER_SHIFT); - } - - return true; -} - -bool CPropertyTreeControl::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDoubleClick(inPoint, inFlags)) { - m_PropRowUI->OnMouseDoubleClick(); - } - return true; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.h b/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.h deleted file mode 100644 index f86a50b0..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/PropertyTreeControl.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_PROPERTY_TREE_CONTROL_H -#define INCLUDED_PROPERTY_TREE_CONTROL_H 1 - -#pragma once - -#include "Control.h" -#include "SIcon.h" -#include "StringEdit.h" - -class CPropertyRowUI; - -class CPropertyTreeControl : public CControl -{ -public: - CPropertyTreeControl(CPropertyRowUI *inPropRowUI); - virtual ~CPropertyTreeControl(); - - void Draw(CRenderer *inRenderer) override; - - void SetIndent(long inIndent); - long GetIndent(); - - void SetHighlighted(bool inIsHighlighted); - - CDropTarget *FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) override; - - void OnMouseOver(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - -protected: - long m_Indent; - CPropertyRowUI *m_PropRowUI; - CSIcon m_Icon; - CStringEdit m_Text; - ::CColor m_BackgroundColor; -}; -#endif // INCLUDED_PROPERTY_TREE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/SlideRow.cpp b/src/Authoring/Studio/Palettes/Timeline/SlideRow.cpp index eb013f5a..04dfe7fc 100644 --- a/src/Authoring/Studio/Palettes/Timeline/SlideRow.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/SlideRow.cpp @@ -30,7 +30,6 @@ #include "stdafx.h" #include "SlideRow.h" -#include "BlankToggleControl.h" #include "ColorControl.h" #include "Bindings/ITimelineItemBinding.h" diff --git a/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.cpp b/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.cpp deleted file mode 100644 index 2f4b7d05..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "SlideRowUI.h" - -#include "SlideRow.h" - -#include "ITimelineControl.h" -#include "SlideTimebarRow.h" - -CSlideRowUI::CSlideRowUI(CBaseStateRow *baseStateRow, CAbstractTimelineRowUI *parentUiRow) - : CBaseStateRowUI(baseStateRow, parentUiRow) -{ -} - -void CSlideRowUI::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - Q_UNUSED(inProvider); -} - -ISnappingListProvider *CSlideRowUI::GetSnappingListProvider() const -{ - Q_ASSERT(m_TimelineControl); - return m_TimelineControl->GetSnappingListProvider(); -} - -//============================================================================= -/** - * Create a new CStateTimebarRow. - * This is virtual and used for objects to return their type specific - * timebar rows if they want to. - * @return the created timebar row. - */CBaseTimebarlessRow *CSlideRowUI::CreateTimebarRow() -{ - return new CSlideTimebarRow(this); - -} diff --git a/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.h b/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.h deleted file mode 100644 index a684cd06..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/SlideRowUI.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef SLIDEROWUI_H -#define SLIDEROWUI_H - -#include "BaseStateRowUI.h" - -class CSlideRowUI : public CBaseStateRowUI -{ - Q_OBJECT -public: - CSlideRowUI(CBaseStateRow *baseStateRow, CAbstractTimelineRowUI *parentUiRow); - - CSlideRowUI(ITimelineItemBinding *inTimelineItem); - - void SetSnappingListProvider(ISnappingListProvider *inProvider) override; - ISnappingListProvider *GetSnappingListProvider() const override; - - CBaseTimebarlessRow *CreateTimebarRow() override; -}; - -#endif // SLIDEROWUI_H diff --git a/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.cpp b/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.cpp deleted file mode 100644 index c9ab2211..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "SlideTimebarRow.h" -#include "SlideRow.h" -#include "SlideRowUI.h" - -CSlideTimebarRow::CSlideTimebarRow(CSlideRowUI *inSlideRow) - : m_SlideRowUi(inSlideRow) -{ -} - -CSlideTimebarRow::~CSlideTimebarRow() -{ -} - -void CSlideTimebarRow::CommitSelections() -{ -} - -void CSlideTimebarRow::SelectKeysInRect(CRct inRect, bool inModifierKeyDown) -{ - Q_UNUSED(inRect); - Q_UNUSED(inModifierKeyDown); -} - -void CSlideTimebarRow::SelectKeysByTime(long inTime, bool inSelected) -{ - Q_UNUSED(inTime); - Q_UNUSED(inSelected); -} - -void CSlideTimebarRow::SelectAllKeys() -{ -} - -void CSlideTimebarRow::PopulateSnappingList(CSnapper *inSnapper) -{ - Q_UNUSED(inSnapper); -} - -CBaseStateRowUI *CSlideTimebarRow::GetBaseStateRowUI() const -{ - return m_SlideRowUi; -} - -// This is not applicable to a SlideTimebarRow!! -ISnappingListProvider &CSlideTimebarRow::GetSnappingListProvider() const -{ - throw; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.h b/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.h deleted file mode 100644 index e36870b9..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/SlideTimebarRow.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TIME_CONTEXT_TIMEBAR_ROW_H -#define INCLUDED_TIME_CONTEXT_TIMEBAR_ROW_H 1 - -#pragma once - -#include "BaseTimebarlessRow.h" - -class CSlideRowUI; - -class CSlideTimebarRow : public CBaseTimebarlessRow -{ -public: - CSlideTimebarRow(CSlideRowUI *inSlideRow); - virtual ~CSlideTimebarRow(); - - void CommitSelections() override; - - void SelectKeysInRect(CRct inRect, bool inModifierKeyDown) override; - void SelectKeysByTime(long inTime, bool inSelected) override; - void SelectAllKeys() override; - - void PopulateSnappingList(CSnapper *inSnappingList) override; - ISnappingListProvider &GetSnappingListProvider() const override; - -protected: - CBaseStateRowUI *GetBaseStateRowUI() const override; - -protected: - CSlideRowUI *m_SlideRowUi; -}; -#endif // INCLUDED_TIME_CONTEXT_TIMEBAR_ROW_H diff --git a/src/Authoring/Studio/Palettes/Timeline/StateRow.cpp b/src/Authoring/Studio/Palettes/Timeline/StateRow.cpp index 708cddb4..7e21b29b 100644 --- a/src/Authoring/Studio/Palettes/Timeline/StateRow.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/StateRow.cpp @@ -37,12 +37,7 @@ // Includes //============================================================================== #include "StateRow.h" -#include "TimelineControl.h" -#include "TimelineTimelineLayout.h" #include "PropertyRow.h" -#include "StateTimebarRow.h" -#include "BaseTimebarlessRow.h" -#include "BaseTimelineTreeControl.h" #include "Bindings/ITimelineItemBinding.h" //============================================================================= diff --git a/src/Authoring/Studio/Palettes/Timeline/StateRowUI.cpp b/src/Authoring/Studio/Palettes/Timeline/StateRowUI.cpp deleted file mode 100644 index 7fcbc8d1..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateRowUI.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "StateRowUI.h" - -#include "ColorControl.h" -#include "StateTimebarRow.h" -#include "StateRow.h" -#include "ToggleControl.h" -#include "BaseTimelineTreeControl.h" -#include "TimelineUIFactory.h" -#include "StateRow.h" -#include "ITimelineControl.h" -#include "PropertyRow.h" - -#include "Bindings/ITimelineItemBinding.h" - -CStateRowUI::CStateRowUI(CStateRow *stateRow, CAbstractTimelineRowUI *parentUiRow) - : CBaseStateRowUI(stateRow, parentUiRow) -{ - connect(stateRow, &CStateRow::timeChanged, - this, &CStateRowUI::handleTimeChanged); - connect(stateRow, &CStateRow::layoutRecalcRequested, - this, &CStateRowUI::handleRecalcLayoutRequested); - -} - -void CStateRowUI::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - CStateTimebarRow *theTimebarControl = dynamic_cast<CStateTimebarRow *>(m_TimebarControl); - if (theTimebarControl) - theTimebarControl->SetSnappingListProvider(inProvider); -} - -ISnappingListProvider *CStateRowUI::GetSnappingListProvider() const -{ - CStateTimebarRow *theTimebarControl = dynamic_cast<CStateTimebarRow *>(m_TimebarControl); - return (theTimebarControl) ? &theTimebarControl->GetSnappingListProvider() : nullptr; - -} - -//============================================================================= -/** - * Set the indent of this control. - * This controls how far to the right the toggle and text display on this - * control. The indent should be increased for every level of sub-controls. - * @param inIndent how much this control should be indented. - */ -void CStateRowUI::SetIndent(long inIndent) -{ - if (!initialized()) - return; - - CAbstractTimelineRowUI::SetIndent(inIndent); - - m_TreeControl->SetIndent(inIndent); - - auto baseStateRow = static_cast<CStateRow *>(m_timelineRow); - - // KDAB_TODO avoid deep copy - auto stateRows = baseStateRow->GetStateRows(); - - auto thePos = stateRows.begin(); - for (; thePos != stateRows.end(); ++thePos) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(*thePos); - uiRow->SetIndent(inIndent + CTimelineRow::TREE_INDENT); - } - - // For each property on this object - // KDAB_TODO avoid deep copy - auto propertyRows = baseStateRow->GetPropertyRows(); - auto thePropPos = propertyRows.begin(); - for (; thePropPos != propertyRows.end(); ++thePropPos) { - CPropertyRow *thePropRow = (*thePropPos); - if (thePropRow) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(thePropRow); - uiRow->SetIndent(inIndent + CTimelineRow::TREE_INDENT); - } - } -} -//============================================================================= -/** - * Trigger any external applications where applicable. - */ -void CStateRowUI::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inPoint); - Q_UNUSED(inFlags); - - auto timelineItemBinding = m_timelineRow->GetTimelineItemBinding(); - if (!timelineItemBinding->OpenAssociatedEditor()) // if not handled, fall backon the base class - CBaseStateRowUI::OnMouseDoubleClick(inPoint, inFlags); -} - -void CStateRowUI::handleTimeChanged() -{ - if (!initialized()) - return; - - m_TimebarControl->UpdateTime(m_baseStateRow->GetStartTime(), - m_baseStateRow->GetEndTime()); - - GetTopControl()->OnLayoutChanged(); -} - -void CStateRowUI::handleRecalcLayoutRequested() -{ - GetTopControl()->OnLayoutChanged(); -} - -CBlankToggleControl *CStateRowUI::CreateToggleControl() -{ - auto timelineItemBinding = m_timelineRow->GetTimelineItemBinding(); - return (timelineItemBinding->ShowToggleControls()) - ? new CToggleControl(this, timelineItemBinding) - : CBaseStateRowUI::CreateToggleControl(); -} - -//============================================================================= -/** - * Create a new CStateTimebarRow. - * This is virtual and used for objects to return their type specific - * timebar rows if they want to. - * @return the created timebar row. - */ -CBaseTimebarlessRow *CStateRowUI::CreateTimebarRow() -{ - auto stateTimebarRow = new CStateTimebarRow(this); - stateTimebarRow->SetTimeRatio(m_baseStateRow->GetTimeRatio()); - return stateTimebarRow; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/StateRowUI.h b/src/Authoring/Studio/Palettes/Timeline/StateRowUI.h deleted file mode 100644 index 1a4c94bb..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateRowUI.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef STATEROWUI_H -#define STATEROWUI_H - -#include "BaseStateRowUI.h" - -class CStateRow; - -class CStateRowUI : public CBaseStateRowUI -{ - Q_OBJECT -public: - CStateRowUI(CStateRow *stateRow, CAbstractTimelineRowUI *parentUiRow); - - void SetSnappingListProvider(ISnappingListProvider *inProvider) override; - ISnappingListProvider *GetSnappingListProvider() const override; - - void SetIndent(long inIndent) override; - - // CControl - void OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - -private Q_SLOTS: - void handleTimeChanged(); - void handleRecalcLayoutRequested(); - -protected: - CBlankToggleControl *CreateToggleControl() override; - CBaseTimebarlessRow *CreateTimebarRow() override; -}; - -#endif // STATEROWUI_H diff --git a/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.cpp b/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.cpp deleted file mode 100644 index e1579936..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "StateTimebarRow.h" -#include "Renderer.h" -#include "StateRow.h" -#include "StateRowUI.h" -#include "StudioPreferences.h" -#include "TimebarControl.h" -#include "MasterP.h" -#include "Snapper.h" -#include "Bindings/ITimelineItemBinding.h" - -//============================================================================= -/** - * Creates a new CStateTimebarRow for the StateRow. - * @param inStateRow the State Row that this is on. - * @param inCreateTimebar true if the constructor is responsible for creating a timebar, otherwise - * the derived class will take care of the construction. - * - */ -CStateTimebarRow::CStateTimebarRow(CStateRowUI *inStateRow, bool inCreateTimebar /*=true*/) - : CStateTimebarlessRow(inStateRow) - , m_Timebar(nullptr) -{ - if (inCreateTimebar) { - m_Timebar = new CTimebarControl(this, inStateRow->GetTimelineRow()->GetTimelineItemBinding()); - m_Timebar->SetMinimumSize(CPt(0, CStudioPreferences::GetRowSize())); - - AddChild(m_Timebar); - } -} - -CStateTimebarRow::~CStateTimebarRow() -{ - delete m_Timebar; -} - -//============================================================================= -/** - * OnMouseRDown event, handles context menus for this object. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -bool CStateTimebarRow::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CStateTimebarlessRow::OnMouseRDown(inPoint, inFlags)) { - CPt theTimebarPoint = inPoint - m_Timebar->GetPosition(); - m_Timebar->ShowContextMenu(theTimebarPoint, false); - } - return true; -} - -//============================================================================= -/** - * Set the amount of time that is being represented per pixel. - * @param inTimerPerPixel the amound of time being represented per pixel. - */ -void CStateTimebarRow::SetTimeRatio(double inTimeRatio) -{ - CStateTimebarlessRow::SetTimeRatio(inTimeRatio); - - m_Timebar->SetTimeRatio(inTimeRatio); -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been selected. - */ -void CStateTimebarRow::OnSelect() -{ - CStateTimebarlessRow::OnSelect(); - - m_Timebar->SetSelected(true); -} - -//============================================================================= -/** - * Notification that the object that this row is representing has been deselected. - */ -void CStateTimebarRow::OnDeselect() -{ - CStateTimebarlessRow::OnDeselect(); - - m_Timebar->SetSelected(false); -} - -//============================================================================= -/** - * Notification from the Asset that it's time has changed. - * @param inStartTime the new start time. - * @param inEndTime the new end time. - */ -void CStateTimebarRow::UpdateTime(long inStartTime, long inEndTime) -{ - m_Timebar->Refresh(inStartTime, inEndTime); - Invalidate(); -} - -void CStateTimebarRow::PopulateSnappingList(CSnapper *inSnappingList) -{ - if (inSnappingList->GetSource() != m_Timebar) { - inSnappingList->AddTime(m_Timebar->GetStartTime()); - inSnappingList->AddTime(m_Timebar->GetEndTime()); - } - m_Timebar->PopulateSnappingList(inSnappingList); - CStateTimebarlessRow::PopulateSnappingList(inSnappingList); -} - -//============================================================================= -/** - * called when meta data for this row is changed... should be overridden by the - * timebar row - */ -void CStateTimebarRow::RefreshRowMetaData() -{ - Invalidate(); - m_Timebar->RefreshMetaData(); -} - -void CStateTimebarRow::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - m_Timebar->SetSnappingListProvider(inProvider); -} - -ISnappingListProvider &CStateTimebarRow::GetSnappingListProvider() const -{ - return m_Timebar->GetSnappingListProvider(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.h b/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.h deleted file mode 100644 index 0330b080..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateTimebarRow.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_STATE_TIMEBAR_ROW_H -#define INCLUDED_STATE_TIMEBAR_ROW_H 1 - -#pragma once - -#include "Control.h" -#include "StateTimebarlessRow.h" - -class CStateRow; -class CTimebarControl; -class CSnapper; -class ITimelineItemBinding; - -class CStateTimebarRow : public CStateTimebarlessRow -{ -public: - CStateTimebarRow(CStateRowUI *inStateRow, bool inCreateTimebar = true); - virtual ~CStateTimebarRow(); - - // CControl - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void SetTimeRatio(double inTimeRatio) override; - - void OnSelect() override; - void OnDeselect() override; - void UpdateTime(long inStartTime, long inEndTime) override; - - void PopulateSnappingList(CSnapper *inSnappingList) override; - void RefreshRowMetaData() override; - - void SetSnappingListProvider(ISnappingListProvider *inProvider); - ISnappingListProvider &GetSnappingListProvider() const override; - -protected: - CTimebarControl *m_Timebar; -}; -#endif // INCLUDED_STATE_TIMEBAR_ROW_H diff --git a/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.cpp b/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.cpp deleted file mode 100644 index 0ecbe0aa..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "StateTimebarlessRow.h" -#include "IKeyframe.h" -#include "Renderer.h" -#include "StateRow.h" -#include "MasterP.h" -#include "KeyframeContextMenu.h" -#include "Snapper.h" -#include "MultiSelectAspect.h" -#include "PropertyTimebarRow.h" -#include "PropertyRow.h" -#include "AssetTimelineKeyframe.h" -#include "Bindings/ITimelineItemBinding.h" -#include "StudioUtils.h" -#include "StateRowUI.h" - -//============================================================================= -/** - * Creates a new CStateTimebarRow for the StateRow. - * @param inStateRow the State Row that this is on. - */ -CStateTimebarlessRow::CStateTimebarlessRow(CStateRowUI *inStateRow) - : m_StateRowUI(inStateRow) - , m_Selected(false) - , m_Refreshing(false) -{ - auto timelineRow = m_StateRowUI->GetTimelineRow(); - m_BackgroundColor = timelineRow->GetTimebarBackgroundColor(timelineRow->GetObjectType()); -} - -CStateTimebarlessRow::~CStateTimebarlessRow() -{ - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - CAssetTimelineKeyframe *theDeletedKey = (*thePos); - RemoveChild(theDeletedKey); - delete theDeletedKey; - } -} - -void CStateTimebarlessRow::OnDraw(CRenderer *inRenderer, CRct &inDirtyRect, bool inIgnoreValidation) -{ - CControl::OnDraw(inRenderer, inDirtyRect, inIgnoreValidation); -} - -//============================================================================= -/** - * Draws the this row background. - * @param inRenderer the renderer to draw to. - */ -void CStateTimebarlessRow::Draw(CRenderer *inRenderer) -{ - QT3DS_PROFILE(Draw); - - if (m_DirtyFlag) { - RefreshKeyframes(); - m_DirtyFlag = false; - } - - CBaseTimebarlessRow::Draw(inRenderer); -} - -//============================================================================= -/** - * OnMouseRDown event, handles context menus for this object. - * @param inPoint the location of the mouse over this control. - * @param inFlags the mouse state flags. - */ -bool CStateTimebarlessRow::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - auto stateRow = static_cast<CStateRow *>(m_StateRowUI->GetTimelineRow()); - stateRow->Select(Qt::NoModifier); // ensure this is selected, but doesn't - // affect any key selections, because this - // can be triggered from a key being - // selected - return CControl::OnMouseRDown(inPoint, inFlags); -} - -//============================================================================= -/** - * Set the amount of time that is being represented per pixel. - * @param inTimerPerPixel the amound of time being represented per pixel. - */ -void CStateTimebarlessRow::SetTimeRatio(double inTimeRatio) -{ - CBaseTimebarlessRow::SetTimeRatio(inTimeRatio); - - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - (*thePos)->SetTimeRatio(inTimeRatio); - } -} - -//============================================================================= -/** - * Get the state row that this belongs to. - */ -CStateRowUI *CStateTimebarlessRow::GetStateRowUI() -{ - return m_StateRowUI; -} - -//============================================================================= -/** - * Handler for when a child key is selected - * - * @param inTime time of the key - */ -void CStateTimebarlessRow::OnKeySelected(long inTime, bool inSelected, - bool inClearPreviouslySelectedKeys) -{ - ITimelineItemBinding *theTimelineItemBinding = - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding(); - if (inSelected) - theTimelineItemBinding->SetSelected(false); - - if (inClearPreviouslySelectedKeys) - theTimelineItemBinding->ClearKeySelection(); - - theTimelineItemBinding->SelectKeyframes(inSelected, inTime); - RefreshKeyframes(); - Invalidate(); -} - -CBaseStateRowUI *CStateTimebarlessRow::GetBaseStateRowUI() const -{ - return m_StateRowUI; -} - -//============================================================================= -/** - * Checks the data binding, instead of the property rows since they may not be created - * (delayed-loading) if this is not expanded. - */ -bool CStateTimebarlessRow::PropertiesHaveKeyframe(long inTime) -{ - bool theResult = false; - - ITimelineItemBinding *theTimelineItemBinding = - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding(); - long theNumProps = theTimelineItemBinding->GetPropertyCount(); - for (long theIndex = 0; theIndex < theNumProps; ++theIndex) { - ITimelineItemProperty *theProp = theTimelineItemBinding->GetProperty(theIndex); - if (theProp && theProp->GetKeyframeByTime(inTime)) { - theResult = true; - break; - } - } - return theResult; -} - -//============================================================================= -/** - * called when keyframes need to be updated, this funciton has two loops: - * the first loops through and deletes any keys no longer in the sskf list. the - * second adds any keys in the sskf list that are not already in the list - * - */ -void CStateTimebarlessRow::RefreshKeyframes() -{ - QT3DS_PROFILE(RefreshKeyframes); - - m_Refreshing = true; - - ITimelineItemBinding *theTimelineItemBinding = - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding(); - long theKeyframeCount = theTimelineItemBinding->GetKeyframeCount(); - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - - // First Loop clears any keys that do not correlate to a supersetkey - while (thePos != m_Keyframes.end()) { - CAssetTimelineKeyframe *theTimelineKey = (*thePos); - IKeyframe *theTempKey = nullptr; - theTempKey = theTimelineItemBinding->GetKeyframeByTime(theTimelineKey->GetTime()); - - // If we find a key at this time, then the timeline key doesn't need to be deleted - if (!theTempKey || !PropertiesHaveKeyframe(theTimelineKey->GetTime())) { - RemoveChild(theTimelineKey); - delete theTimelineKey; - thePos = m_Keyframes.erase(thePos); - } else if (theTempKey->IsDynamic() != theTimelineKey->IsDynamic()) { - theTimelineKey->SetDynamic(theTempKey->IsDynamic()); - } else { - // Set the position - theTimelineKey->SetPosition(::TimeToPos(theTempKey->GetTime(), m_TimeRatio) - - (theTimelineKey->GetSize().x / 2), - 0); - ++thePos; - } - } - - // Second Loop adds the remaining keys - for (long theKey = 0; theKey < theKeyframeCount; ++theKey) { - bool theFoundFlag = false; - IKeyframe *theTempKey = theTimelineItemBinding->GetKeyframeByIndex(theKey); - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - - // each key needs to be compared to all the keys in the sskf list to see if it has to be - // added. - for (; thePos != m_Keyframes.end() && !theFoundFlag; ++thePos) { - CAssetTimelineKeyframe *theCurrentKey = (*thePos); - if (theCurrentKey->GetTime() == theTempKey->GetTime()) { - theFoundFlag = true; - } - } - if (!theFoundFlag && PropertiesHaveKeyframe(theTempKey->GetTime())) { - // If we don't have a timeline key, then we have to make a new one - CAssetTimelineKeyframe *theAssetTimelineKey = - new CAssetTimelineKeyframe(this, m_TimeRatio); - theAssetTimelineKey->SetTime(theTempKey->GetTime()); - theAssetTimelineKey->Select(theTempKey->IsSelected()); - theAssetTimelineKey->SetDynamic(theTempKey->IsDynamic()); - theAssetTimelineKey->SetSize(CPt(17, 16)); - theAssetTimelineKey->SetPosition(::TimeToPos(theTempKey->GetTime(), m_TimeRatio) - - (theAssetTimelineKey->GetSize().x / 2), - 0); - AddChild(theAssetTimelineKey); - m_Keyframes.push_back(theAssetTimelineKey); - } - } - m_Refreshing = false; -} - -void CStateTimebarlessRow::Invalidate(bool inInvalidate) -{ - if (!m_Refreshing) { - CControl::Invalidate(inInvalidate); - } -} - -//============================================================================= -/** - * called when a list has a member change selection - * @param inTime -1 to affect all keyframes. - * - */ -void CStateTimebarlessRow::SelectKeysByTime(long inTime, bool inSelected) -{ - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - bool theFoundFlag = false; - for (; thePos != m_Keyframes.end() && !theFoundFlag; ++thePos) { - CAssetTimelineKeyframe *theKey = (*thePos); - if (inTime == -1 || theKey->GetTime() == inTime) { - theKey->Select(inSelected); - theFoundFlag = (inTime != -1); - } - } - Invalidate(); -} - -//============================================================================= -/** - * SelectKeysInRect: selects any keyframes inside the rect - * - * @param inRect the Rect to select the keyframes in - * @return NONE. - */ -void CStateTimebarlessRow::SelectKeysInRect(CRct inRect, bool inModifierKeyDown) -{ - ITimelineItemBinding *theTimelineItemBinding = - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding(); - CMultiSelectAspect<TTimelineAssetKeyframeList> theMultiSelectAspect( - m_Keyframes, theTimelineItemBinding); - theMultiSelectAspect.MultiSelect(inRect, inModifierKeyDown); -} - -//============================================================================= -/** - * CommitSelections: commits all the master keyframe selections by setting their - * previous selection state to the current selection state. - * This will prevent the current keyframe states from - *changing. - * - * @param NONE - * @return NONE - */ - -void CStateTimebarlessRow::CommitSelections() -{ - ITimelineItemBinding *theTimelineItemBinding = - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding(); - CMultiSelectAspect<TTimelineAssetKeyframeList> theMultiSelectAspect( - m_Keyframes, theTimelineItemBinding); - theMultiSelectAspect.CommitSelections(); -} - -//============================================================================= -/** - * true if there are selected keys on this object - */ -bool CStateTimebarlessRow::HasSelectedKeys() -{ - bool theRetVal = false; - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end() && !theRetVal; ++thePos) { - if ((*thePos)->IsSelected()) { - theRetVal = true; - } - } - return theRetVal; -} - -//============================================================================= -/** - * selects all keys for this timebar row - */ -void CStateTimebarlessRow::SelectAllKeys() -{ - m_StateRowUI->GetTimelineRow()->GetTimelineItemBinding()->SelectKeyframes(true, -1); - - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) - (*thePos)->Select(true); - - Invalidate(); -} - -//============================================================================= -/** - * Populates the snapping list with any snapping points that may be on this. - * This will add the timebar ends, master keyframes to the snapping list, and - * time labels to the snapping list. - * @param inSnapper the snapper to add the points to. - */ -void CStateTimebarlessRow::PopulateSnappingList(CSnapper *inSnapper) -{ - // Only add points if this is not the object originating the snapping. - if (inSnapper->GetSource() != this) { - // Add Keyframes - TTimelineAssetKeyframeList::iterator thePos = m_Keyframes.begin(); - for (; thePos != m_Keyframes.end(); ++thePos) { - if (inSnapper->IsSnappingSelectedKeyframes()) - inSnapper->AddTime((*thePos)->GetTime()); - else if (!(*thePos)->IsSelected()) - inSnapper->AddTime((*thePos)->GetTime()); - } - } -} diff --git a/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.h b/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.h deleted file mode 100644 index 4cdcce7d..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/StateTimebarlessRow.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_STATE_TIMEBARLESS_ROW_H -#define INCLUDED_STATE_TIMEBARLESS_ROW_H 1 - -//============================================================================== -// Includes -//============================================================================== -#include "BaseTimebarlessRow.h" -#include "DispatchListeners.h" - -//============================================================================== -// Forwards -//============================================================================== -class CStateRowUI; -class CSnapper; -class CAssetTimelineKeyframe; -class ITimelineItemBinding; - -class CStateTimebarlessRow : public CBaseTimebarlessRow -{ - typedef std::vector<CAssetTimelineKeyframe *> TTimelineAssetKeyframeList; - -public: - CStateTimebarlessRow(CStateRowUI *inStateRow); - virtual ~CStateTimebarlessRow(); - - void OnDraw(CRenderer *inRenderer, CRct &inDirtyRect, bool inIgnoreValidation = false) override; - void Draw(CRenderer *inRenderer) override; - - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void OnKeySelected(long inTime, bool inState, bool inClearPreviouslySelectedKeys); - - void SetTimeRatio(double inTimeRatio) override; - - virtual void RefreshKeyframes(); - void Invalidate(bool inInvalidate = true) override; - void CommitSelections() override; - void SelectKeysInRect(CRct inRect, bool inModifierKeyDown) override; - void SelectAllKeys() override; - void SelectKeysByTime(long inTime, bool inSelected) override; - bool HasSelectedKeys(); - CStateRowUI *GetStateRowUI(); - void PopulateSnappingList(CSnapper *inSnapper) override; - -protected: - CBaseStateRowUI *GetBaseStateRowUI() const override; - bool PropertiesHaveKeyframe(long inTime); - -protected: - CStateRowUI *m_StateRowUI; - bool m_Selected; - TTimelineAssetKeyframeList m_Keyframes; ///<Master Keyframe list ( STL ) - bool m_Refreshing; -}; -#endif // INCLUDED_STATE_TIMEBARLESS_ROW_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.cpp b/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.cpp deleted file mode 100644 index f6c01e1a..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "TimeMeasure.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "StudioUtils.h" -#include "TimelineTimelineLayout.h" -#include "Snapper.h" -#include "Qt3DSDMSignals.h" - -const long AUTO_TICK_AMNT = 60; -using namespace Q3DStudio; - -//============================================================================= -/** - * Create a new time measure. - * @param inLayout the layout this is representing, used for modifying time. - * @param inTimeRatio the current time ratio. - * @param inIsTransparent true if the background of this control should not be drawn. - */ -CTimeMeasure::CTimeMeasure(CTimelineTimelineLayout *inLayout, double inTimeRatio, - bool inFillBackground /*= true */) - : CBaseMeasure(inTimeRatio, inFillBackground) - , m_ScrollDir(0) - , m_TimePerPixel(0) - , m_IsMouseDown(false) - , m_TimelineLayout(inLayout) -{ - SetTimeRatio(inTimeRatio); - SetName("TimeMeasure"); - - m_EdgeMargin = 2; - // the large tickmark is shorter than the medium to leave room for the text - m_LargeHashOffset = 5; -} - -CTimeMeasure::~CTimeMeasure() -{ -} - -//============================================================================= -/** - * Set the amount of time that is represented for each pixel. - * @param inTimePerPixel the amount of time represented for each pixel. - */ -void CTimeMeasure::SetTimeRatio(double inTimeRatio) -{ - m_Ratio = inTimeRatio; - - double theTimePerPixel = (double)(1 / inTimeRatio); - - // Only go through this if it has actually changed - if (theTimePerPixel != m_TimePerPixel) { - m_TimePerPixel = theTimePerPixel; - - // Go through the possible hash settings and find the one that best suits the - // time per pixel. - double theMillisPerLargeHash = theTimePerPixel * 50; - if (theMillisPerLargeHash <= 100) // 100ms - theMillisPerLargeHash = 100; - else if (theMillisPerLargeHash <= 200) // 200ms - theMillisPerLargeHash = 200; - else if (theMillisPerLargeHash <= 500) // .5s - theMillisPerLargeHash = 500; - else if (theMillisPerLargeHash <= 1000) // 1s - theMillisPerLargeHash = 1000; - else if (theMillisPerLargeHash <= 2000) // 2s - theMillisPerLargeHash = 2000; - else if (theMillisPerLargeHash <= 5000) // 5s - theMillisPerLargeHash = 5000; - else if (theMillisPerLargeHash <= 10000) // 10s - theMillisPerLargeHash = 10000; - else if (theMillisPerLargeHash <= 20000) // 20s - theMillisPerLargeHash = 20000; - else if (theMillisPerLargeHash <= 30000) // 30s - theMillisPerLargeHash = 30000; - else if (theMillisPerLargeHash <= 60000) // 1m - theMillisPerLargeHash = 60000; - else if (theMillisPerLargeHash <= 120000) // 2m - theMillisPerLargeHash = 120000; - else if (theMillisPerLargeHash <= 300000) // 5m - theMillisPerLargeHash = 300000; - else if (theMillisPerLargeHash <= 600000) // 10m - theMillisPerLargeHash = 600000; - else if (theMillisPerLargeHash <= 1200000) // 20m - theMillisPerLargeHash = 1200000; - else if (theMillisPerLargeHash <= 1800000) // 30m - theMillisPerLargeHash = 1800000; - else if (theMillisPerLargeHash <= 3600000) // 1h - theMillisPerLargeHash = 3600000; - else - theMillisPerLargeHash = 7200000; // 2h - - // Set the distances between the hashes - m_LargeHashInterval = theMillisPerLargeHash; - m_MediumHashInterval = theMillisPerLargeHash / 2; - m_SmallHashInterval = theMillisPerLargeHash / 10; - - // update to StudioPreferences so that the ',' '.' and '<' '>' keys would respond - // accordingly - CStudioPreferences::SetTimeAdvanceAmount(static_cast<long>(m_SmallHashInterval)); - CStudioPreferences::SetBigTimeAdvanceAmount(static_cast<long>(m_MediumHashInterval)); - - Invalidate(); - } -} -//============================================================================= -/** - * Get the time formatted as a string. - * This will figure out the best way to display the time and return it as a - * string. - * @param inTime the time to display in milliseconds. - * @return the time formatted in a string. - */ -Q3DStudio::CString CTimeMeasure::FormatTime(long inTime) -{ - long theHours = inTime / 3600000; - long theMinutes = inTime % 3600000 / 60000; - long theSeconds = inTime % 60000 / 1000; - long theMillis = inTime % 1000; - - bool theHoursOnlyFlag = theHours != 0 && theMinutes == 0 && theSeconds == 0 && theMillis == 0; - bool theMinutesOnlyFlag = - !theHoursOnlyFlag && theMinutes != 0 && theSeconds == 0 && theMillis == 0; - bool theSecondsOnlyFlag = !theMinutesOnlyFlag && theMillis == 0; - - Q3DStudio::CString theTime; - // If only hours are being displayed then format it as hours. - if (theHoursOnlyFlag) { - theTime.Format(_LSTR("%dh"), theHours); - } - // If only minutes are being displayed then format it as minutes. - else if (theMinutesOnlyFlag) { - theTime.Format(_LSTR("%dm"), theMinutes); - } - // If only seconds are being displayed then format as seconds - else if (theSecondsOnlyFlag) { - theTime.Format(_LSTR("%ds"), theSeconds); - } - // If the intervals are correct then this should only be tenths of seconds, so do that. - else { - theTime.Format(_LSTR("0.%ds"), theMillis / 100); - } - - return theTime; -} - -//============================================================================= -/** - * Set the amount of time that this time measure is offset by. - * @param inTimeOffset the offset time in milliseconds. - */ -void CTimeMeasure::SetTimeOffset(long inTimeOffset) -{ - if (inTimeOffset != m_Offset) { - m_Offset = inTimeOffset; - - Invalidate(); - } -} - -//============================================================================= -/** - * Notification that the left mouse button was clicked. - * This tells the timeline to move the playhead to the current loc. - * @param inPoint the location where the mouse was clicked. - * @param inFlags the state of the mouse. - */ -bool CTimeMeasure::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - m_IsMouseDown = true; - - m_TimelineLayout->OnTimeMeasureMouseDown(inPoint, inFlags); - } - - return true; -} - -//============================================================================= -/** - * Notification that the mouse is moving over this control. - * If the mouse was clicked on this control this will drag the playhead. - * @param inPoint the location where the mouse was clicked. - * @param inFlags the state of the mouse. - */ -void CTimeMeasure::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - m_TimerConnection = std::shared_ptr<qt3dsdm::ISignalConnection>(); - - // subtract out the button width since the playhead is never allowed into that area on the right - // side - // of the timeline and use it for the initial autoscrolling place - if (inPoint.x > 0 && inPoint.x <= GetSize().x - CStudioPreferences::GetDefaultButtonWidth()) { - CControl::OnMouseMove(inPoint, inFlags); - if (m_IsMouseDown) - m_TimelineLayout->OnTimeMeasureMouseDown(inPoint, inFlags); - m_ScrollDir = 0; - } else if (m_IsMouseDown) { - if (inPoint.x < 0) - m_ScrollDir = -1; - else if (inPoint.x > GetSize().x - CStudioPreferences::GetDefaultButtonWidth()) - m_ScrollDir = 1; - m_TimerConnection = ITickTock::GetInstance().AddTimer( - 150, true, std::bind(&CTimeMeasure::OnTimer, this), "CTimeMeasure::OnMouseMove"); - OnTimer(); - } -} - -//============================================================================= -/** - * Call back for the timer that was set in on mouse move - */ -void CTimeMeasure::OnTimer() -{ - CPt theOffset; - if (m_ScrollDir > 0) - theOffset.x = - GetSize().x - 2 * CStudioPreferences::GetDefaultButtonWidth() + AUTO_TICK_AMNT; - else if (m_ScrollDir < 0) - theOffset.x = -AUTO_TICK_AMNT; - m_TimelineLayout->OnTimeMeasureMouseDown(theOffset, 0); - ; -} - -//============================================================================= -/** - * Notification that the mouse was unclicked. - * This stops dragging of the playhead if it was dragging it. - * @param inPoint the location where the mouse was unclicked. - * @param inFlags the state of the mouse. - */ -void CTimeMeasure::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); - m_TimerConnection = std::shared_ptr<qt3dsdm::ISignalConnection>(); - m_IsMouseDown = false; -} - -//============================================================================= -/** - * Notification that the mouse was unclicked. - * This stops dragging of the playhead if it was dragging it. - * @param inPoint the location where the mouse was unclicked. - * @param inFlags the state of the mouse. - */ -void CTimeMeasure::OnMouseRUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); - m_TimerConnection = std::shared_ptr<qt3dsdm::ISignalConnection>(); - m_IsMouseDown = false; -} - -//============================================================================= -/** - * Add the tick marks to the snapping list. - * This uses the user preference for the tick marks and adds them. - */ -void CTimeMeasure::PopulateSnappingList(CSnapper *inSnapper) -{ - // Only if this is supposed to snap to time markers. - if (CStudioPreferences::IsTimelineSnappingGridActive()) { - // Check the resolution to snap to - ESnapGridResolution theResolution = CStudioPreferences::GetTimelineSnappingGridResolution(); - double thePeriodicInterval; - if (theResolution == SNAPGRID_TICKMARKS) { - thePeriodicInterval = m_SmallHashInterval; - } else if (theResolution == SNAPGRID_HALFSECONDS) { - thePeriodicInterval = m_MediumHashInterval; - } else { - thePeriodicInterval = m_LargeHashInterval; - } - - // Set a periodic interval for snapping - inSnapper->SetPeriodicInterval(::dtol(thePeriodicInterval)); - } -} - -void CTimeMeasure::OnLoseFocus() -{ - m_TimerConnection = std::shared_ptr<qt3dsdm::ISignalConnection>(); - m_IsMouseDown = false; -} - -//============================================================================= -/** - * Draw the time at the specified position. - * @param inRenderer the renderer to draw to. - * @param inPosition the position to draw the time to, the time will be centered here. - * @param inTime the time to draw. - */ -void CTimeMeasure::DrawMeasureText(CRenderer *inRenderer, long inPosition, long inMeasure) -{ - Q3DStudio::CString theTimeFormat(FormatTime(inMeasure)); - // Offset the position by half the text size to center it over the hash. - const auto textSize = inRenderer->GetTextSize(theTimeFormat.toQString()); - inPosition -= ::dtol(textSize.width() / 2); - - inRenderer->DrawText((float)inPosition, -3, theTimeFormat.toQString(), - QRect(0, 0, GetSize().x, GetSize().y), - CStudioPreferences::GetRulerTickColor().getQColor()); -} - -//============================================================================= -/** - * Calculate the position of a time value on the time measure - */ -long CTimeMeasure::CalculatePos(double inNewValue) -{ - return ::TimeToPos(inNewValue, m_Ratio); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.h b/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.h deleted file mode 100644 index badc3249..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimeMeasure.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TIME_MEASURE_H -#define INCLUDED_TIME_MEASURE_H 1 - -#pragma once - -#include "BaseMeasure.h" -#include "ITickTock.h" - -class CTimelineTimelineLayout; -class CSnapper; - -class CTimeMeasure : public CBaseMeasure -{ -public: - CTimeMeasure(CTimelineTimelineLayout *inLayout, double inTimeRatio, - bool inFillBackground = true); - virtual ~CTimeMeasure(); - - void SetTimeRatio(double inTimeRatio); - void SetTimeOffset(long inTimeOffset); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseRUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - - void PopulateSnappingList(CSnapper *inSnapper); - - virtual void OnTimer(); - void OnLoseFocus() override; - -protected: - // CBaseMeasure - void DrawMeasureText(CRenderer *inRenderer, long inPosition, long inMeasure) override; - long CalculatePos(double inNewValue) override; - - Q3DStudio::CString FormatTime(long inTime); - - long m_ScrollDir; - double m_TimePerPixel; - bool m_IsMouseDown; - CTimelineTimelineLayout *m_TimelineLayout; - std::shared_ptr<qt3dsdm::ISignalConnection> m_TimerConnection; -}; -#endif // INCLUDED_TIME_MEASURE_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimebarControl.cpp b/src/Authoring/Studio/Palettes/Timeline/TimebarControl.cpp deleted file mode 100644 index 5d2b1092..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimebarControl.cpp +++ /dev/null @@ -1,694 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "TimebarControl.h" -#include "StateTimebarRow.h" -#include "StateRow.h" -#include "StateRowUI.h" -#include "Renderer.h" -#include "ColorControl.h" -#include "StudioPreferences.h" -#include "Views.h" -#include "TimelineControl.h" -#include "TimelineTimelineLayout.h" -#include "ResourceCache.h" -#include "HotKeys.h" -#include "Preferences.h" -#include "Bindings/ITimelineItemBinding.h" -#include "Bindings/ITimelineTimebar.h" -#include "StudioApp.h" -#include "Core.h" -#include "Doc.h" -#include "CoreUtils.h" -#include "StudioUtils.h" -#include "MasterP.h" - -const float SCALING_FACTOR = 0.50; - -//============================================================================= -/** - * Create a timebar control on the specified state timebar row. - * Attaches a new ToolTip to it that displays the time range this timebar control - * encompasses. - * @param inRow the row on which this timebar is attached. - */ -CTimebarControl::CTimebarControl(CStateTimebarRow *inRow, - ITimelineItemBinding *inTimelineItemBinding) - : m_IsSelected(false) - , m_IsMouseDown(false) - , m_MaybeDragStart(false) - , m_LeftLeftTip(this, true) - , m_LeftTip(this, true) - , m_RightTip(this, false) - , m_RightRightTip(this, false) - , m_SnappingListProvider(nullptr) -{ - m_TimebarRow = inRow; - m_TimelineItemBinding = inTimelineItemBinding; - // Start/End times - ITimelineTimebar *theTimelineTimebar = GetTimebar(); - m_StartTime = theTimelineTimebar->GetStartTime(); - m_EndTime = theTimelineTimebar->GetEndTime(); - bool theShowHandleBars = theTimelineTimebar->ShowHandleBars(); - m_LeftLeftTip.ShowHandles(theShowHandleBars); - m_RightRightTip.ShowHandles(theShowHandleBars); - - m_LeftLeftTip.SetSize(CStudioPreferences::GetTimebarTipSize(), - CStudioPreferences::GetRowSize()); - m_LeftTip.SetPosition(CPt(0, 0)); - m_LeftTip.SetSize(CStudioPreferences::GetTimebarInnerTipSize(), - CStudioPreferences::GetRowSize()); - m_LeftTip.SetPosition(CPt(m_LeftLeftTip.GetSize().x, 0)); - - m_RightTip.SetSize(CStudioPreferences::GetTimebarInnerTipSize(), - CStudioPreferences::GetRowSize()); - m_RightRightTip.SetSize(CStudioPreferences::GetTimebarTipSize(), - CStudioPreferences::GetRowSize()); - - m_EditControl = new CCommentEdit(theTimelineTimebar); - m_EditControl->SetPosition(CStudioPreferences::GetTimebarTipSize() * 2, 1); - m_EditControl->SetSize(CPt(100, 15)); - m_EditControl->SetFillBackground(false); - AddChild(m_EditControl); - AddChild(&m_LeftTip); - AddChild(&m_RightTip); - AddChild(&m_RightRightTip); - AddChild(&m_LeftLeftTip); -} - -//============================================================================= -/** - * Destructor - */ -CTimebarControl::~CTimebarControl() -{ - delete m_EditControl; -} - -//============================================================================= -/** - * Draw this timebar control to the renderer. - * @param inRenderer the renderer to draw to. - */ -void CTimebarControl::Draw(CRenderer *inRenderer) -{ - CStateRowUI *theRowUI = m_TimebarRow->GetStateRowUI(); - auto theRow = static_cast<CBaseStateRow *>(theRowUI->GetTimelineRow()); - CRct theRect(GetSize()); - - ::CColor theNormalColor = GetTimebar()->GetTimebarColor(); - ::CColor theSelectedColor = CColorControl::CalculateSelectedColor(theNormalColor); - - ::CColor theBorderColor = CStudioPreferences::GetTimeBarBorderColor(); - ::CColor theDarkExtendedColor = CStudioPreferences::GetExtendedObjectDarkColor(); - ::CColor theLightExtendedColor = CStudioPreferences::GetExtendedObjectLightColor(); - - long theTipOffset = CStudioPreferences::GetTimebarTipSize(); - - if (!IsEnabled()) { - theNormalColor = CStudioPreferences::GetLockedTimebarColor(); - theBorderColor = CStudioPreferences::GetLockedBorderColor(); - theDarkExtendedColor = CStudioPreferences::GetExtendedLockedDarkColor(); - theLightExtendedColor = CStudioPreferences::GetExtendedLockedLightColor(); - } - - // Calculate the start/end/activestart - long theObjectLifeStart = ::TimeToPos(m_StartTime, m_TimeRatio); - long theStartPos = ::TimeToPos(theRow->GetActiveStart(), m_TimeRatio) - theObjectLifeStart; - long theEndPos = ::TimeToPos(theRow->GetActiveEnd(), m_TimeRatio) - theObjectLifeStart; - long theObjectLifeEnd = ::TimeToPos(m_EndTime, m_TimeRatio) - theObjectLifeStart; - - CRct theGradientRct(theStartPos + theTipOffset, 0, theEndPos - theStartPos, theRect.size.y - 1); - - if (theEndPos > theStartPos) { - inRenderer->DrawGradientBitmap(theGradientRct, theNormalColor, 0, SCALING_FACTOR); - // Calculate the gradient rect a bit differently depending on selection - if (m_IsSelected) { - CRct theSelectedRct(CPt(theGradientRct.position.x, theGradientRct.position.y + 3), - CPt(theGradientRct.size.x, theGradientRct.size.y - 7)); - inRenderer->FillSolidRect(theSelectedRct, theSelectedColor); - } - } - - inRenderer->PushPen(theBorderColor); - // Check to see if we need some hashes at the end - if (theObjectLifeEnd > theEndPos) { - long theUpdatedStartTime = theEndPos; - if (theStartPos > theUpdatedStartTime) - theUpdatedStartTime = theStartPos; - else { - inRenderer->MoveTo(theEndPos + theTipOffset, 0); - inRenderer->LineTo(theEndPos + theTipOffset, theRect.size.y - 1); - } - CRct theClippingRect(CPt(theUpdatedStartTime + theTipOffset + 1, 0), - CPt(theObjectLifeEnd - theUpdatedStartTime - 1, theRect.size.y - 1)); - inRenderer->PushClippingRect(theClippingRect); - - // Draw the hashed background - DrawHashedBackgroundX(inRenderer, theDarkExtendedColor, theLightExtendedColor, - theClippingRect); - inRenderer->PopClippingRect(); - } - - // Check to see if we need some hashes at the beginning - if (theStartPos > 0) { - long theUpdatedEndTime = theStartPos; - if (theObjectLifeEnd < theUpdatedEndTime) - theUpdatedEndTime = theObjectLifeEnd; - else { - inRenderer->MoveTo(theStartPos + theTipOffset, 0); - inRenderer->LineTo(theStartPos + theTipOffset, theRect.size.y - 1); - } - CRct theClippingRect(CPt(theTipOffset, 0), CPt(theUpdatedEndTime, theRect.size.y - 1)); - inRenderer->PushClippingRect(theClippingRect); - - // Draw the hashed background - DrawHashedBackgroundX(inRenderer, theDarkExtendedColor, theLightExtendedColor, - theClippingRect); - inRenderer->PopClippingRect(); - } - - // Draw the border stuff - inRenderer->MoveTo(CPt(theTipOffset, 0)); - inRenderer->LineTo(CPt(theTipOffset, theRect.size.y - 1)); - inRenderer->MoveTo(CPt(theObjectLifeEnd + theTipOffset, 0)); - inRenderer->LineTo(CPt(theObjectLifeEnd + theTipOffset, theRect.size.y - 1)); - - inRenderer->PopPen(); - // Setting the position with the active time - m_EditControl->SetPosition(CStudioPreferences::GetTimebarTipSize() * 2, 1); -} - -//============================================================================= -/** - * Draws a hashed background in a given clipping rect - * - * @param inStartX the x position to start from - * @param inSizeY the y size the you want the lines to range from - * @param inEndX one after the last place where lines can be drawn from - * @inRenderer the renderer to draw to - * @param inFirstColor the first hash color - * @param inSecondColor the second hash color - * @para inRect the clipping rect - */ -void CTimebarControl::DrawHashedBackgroundX(CRenderer *inRenderer, ::CColor inFirstColor, - ::CColor inSecondColor, CRct inRect) -{ - inRenderer->FillSolidRect(inRect, inFirstColor); - if (m_IsSelected) { - CRct theSelectedRct(CPt(inRect.position.x, inRect.position.y + 4), - CPt(inRect.size.x, inRect.size.y - 8)); - inRenderer->FillSolidRect( - theSelectedRct, CColorControl::CalculateSelectedColor(GetTimebar()->GetTimebarColor())); - } - - inRenderer->FillHashed(inRect, inSecondColor); -} - -//============================================================================= -/** - * Set the current time ratio. - * The time ratio controls the length of this control and is the ratio of - * pixels to milliseconds. - * @param inTimeRatio the new time ratio. - */ -void CTimebarControl::SetTimeRatio(double inTimeRatio) -{ - m_TimeRatio = inTimeRatio; - - Refresh(); -} - -//============================================================================= -/** - * Set the size of this control. - * @param inSize the new size of this control. - */ -void CTimebarControl::SetSize(CPt inSize) -{ - CControl::SetSize(CPt(inSize.x, inSize.y)); - - CStateRowUI *theRowUI = m_TimebarRow->GetStateRowUI(); - auto theRow = static_cast<CBaseStateRow *>(theRowUI->GetTimelineRow()); - long theTipSize = - CStudioPreferences::GetTimebarTipSize() + CStudioPreferences::GetTimebarInnerTipSize(); - long theCommentSize = CStudioPreferences::GetDefaultCommentSize(); - if (inSize.x < theCommentSize) - theCommentSize = inSize.x; - - // Recalculate the comment size depending on where the timebar is and how large it is - long theDiff = ::dtol((theRow->GetActiveEnd() - theRow->GetActiveStart()) * m_TimeRatio); - if (theDiff < theCommentSize) { - theCommentSize = theDiff - theTipSize; - if (theCommentSize < 0) - theCommentSize = 0; - } - - m_EditControl->SetSize(CPt(theCommentSize, 15)); - - // Set the two right tips depending on where the right side is - m_RightTip.SetPosition(CPt(inSize.x - theTipSize, 0)); - m_RightRightTip.SetPosition(CPt(inSize.x - m_RightRightTip.GetSize().x + 1, 0)); -} - -//============================================================================= -/** - * Set whether this control is selected or not. - * If this is selected then it will modify how this control looks. - * @param inIsSelected true if this control is to be selected. - */ -void CTimebarControl::SetSelected(bool inIsSelected) -{ - if (inIsSelected != m_IsSelected) { - m_IsSelected = inIsSelected; - m_EditControl->SetSelected(m_IsSelected); - Invalidate(); - } -} - -void CTimebarControl::RefreshMetaData() -{ - m_EditControl->RefreshMetaData(); -} - -//============================================================================= -/** - * Request for this control to refresh it's properties. - * This checks the size of the asset and adjusts it's size the the asset's - * length. Called when the time ratio or properties have changed. - * If the time has changed then Refresh( long, long ) must be called with the - * new times. - */ -void CTimebarControl::Refresh() -{ - Refresh(m_StartTime, m_EndTime); -} - -//============================================================================= -/** - * Request for this control to refresh it's properties. - * This updates all the properties of this control and resize it as necessary. - * Called when the time changes on the asset, the time ratio changes or any - * properties that this displays change. - * @param inStartTime the asset's start time. - * @param inEndTime the asset's end time. - */ -void CTimebarControl::Refresh(long inStartTime, long inEndTime) -{ - m_StartTime = inStartTime; - m_EndTime = inEndTime; - - long thePosition = ::TimeToPos(inStartTime, m_TimeRatio); - long theSize = ::dtol((inEndTime - inStartTime) * m_TimeRatio); - - SetPosition(thePosition - CStudioPreferences::GetTimebarTipSize(), GetPosition().y); - - SetSize(CPt(theSize + 2 * CStudioPreferences::GetTimebarTipSize(), GetMinimumSize().y)); - if (IsInvalidated()) - m_TimebarRow->Invalidate(); -} - -//============================================================================= -/** - * Get the interface to the timebar item in the data model - */ -ITimelineTimebar *CTimebarControl::GetTimebar() -{ - return m_TimelineItemBinding->GetTimelineItem()->GetTimebar(); -} - -//============================================================================= -/** -* Updates the ToolTip and moves it to the correct place on screen. -* @param inPoint the point that the tooltip is supposed to be placed. -*/ -void CTimebarControl::RefreshToolTip(CPt inPoint) -{ - Q3DStudio::CString theCommentText; - CStateRowUI *theRowUI= m_TimebarRow->GetStateRowUI(); - auto theRow = static_cast<CBaseStateRow *>(theRowUI->GetTimelineRow()); - - CRct theTimelineBounds(GetTopControlBounds()); - // format label as: startTime - endTime (timeDifference) - theCommentText = " " + FormatTimeString(theRow->GetStartTime()) + " - " - + FormatTimeString(theRow->GetEndTime()) + " (" - + FormatTimeString(theRow->GetEndTime() - theRow->GetStartTime()) + ")"; - inPoint.y = GetPosition().y - GetSize().y; - ShowMoveableWindow(inPoint, theCommentText, theTimelineBounds); -} - -//============================================================================= -/** - * OnMouseDoubleClick: Pop up a dialog box for the editing of the timebar start - * and end time. - */ -bool CTimebarControl::OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDoubleClick(inPoint, inFlags) - && !m_TimelineItemBinding->IsLockedEnabled()) { - CDurationEditDlg theDurationEditDlg; - theDurationEditDlg.showDialog(m_StartTime, m_EndTime, g_StudioApp.GetCore()->GetDoc(), - this); - } - - return true; -} - -//============================================================================= -/** - * Allows this timebar control to add any times it wishes to the snapper list - * @param inSnapper the Snapper that is handling the snapping functions for this timebar - */ -void CTimebarControl::PopulateSnappingList(CSnapper *inSnapper) -{ - Q_UNUSED(inSnapper); -} - -//============================================================================= -/** - * Start drag handler, puts this control into drag mode. - * @param inPoint the point where the mouse was clicked. - * @param inFlags the mouse state. - */ -bool CTimebarControl::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - m_IsMouseDown = true; - m_MaybeDragStart = true; - m_MouseDownLoc = inPoint; - - OnBeginDrag(); - - auto row = static_cast<CBaseStateRow *>(m_TimebarRow->GetStateRowUI()->GetTimelineRow()); - row->Select(Qt::NoModifier); - - m_Snapper.Clear(); - m_Snapper.SetSource(this); - - GetSnappingListProvider().PopulateSnappingList(&m_Snapper); - m_Snapper.BeginDrag(inPoint.x); - - if (HasFocus(m_EditControl) && !m_EditControl->HitTest(inPoint)) { - m_EditControl->OnLoseFocus(); - } - - // display the time range tooltip - RefreshToolTip(inPoint); - } - return true; -} - -//============================================================================= -/** - * Puts up the context menu. - * @param inPoint the point where the mouse was clicked. - * @param inFlags the mouse state. - */ -bool CTimebarControl::OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseRDown(inPoint, inFlags)) { - if (m_IsMouseDown) { - m_IsMouseDown = false; - CommitTimeChange(); - HideMoveableWindow(); - } - // only right-clicking ON the timebar will show the timebar (text and color) properties' - // options - ShowContextMenu(inPoint, true); - } - - return true; -} - -//============================================================================= -/** - * Notification that the drag has finished. - * @param inPoint the point where the mouse was let go. - * @param inFlags the state of the mouse. - */ -void CTimebarControl::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // try to prevent stuck mousetips on exceptions - try { - CControl::OnMouseUp(inPoint, inFlags); - CommitTimeChange(); - } catch (...) { - } - m_IsMouseDown = false; - m_MaybeDragStart = false; - HideMoveableWindow(); -} - -//============================================================================= -/** - * Handler for the mouse move messages. - * If the mouse is down then this will drag the control and offset the timebar. - * @param inPoint the current location of the mouse. - * @param inFlags the state of the mouse. - */ -void CTimebarControl::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - - bool theCommentEditMode = m_EditControl->GetEditMode(); - - // If we are in edit Comment mode or locked, then we do not drag the timebar. - if (!theCommentEditMode && m_IsMouseDown && !m_TimelineItemBinding->IsLockedEnabled()) { - QT3DS_PROFILE(OnMouseMove); - - if (m_MaybeDragStart) { - // Dragging in the first 5 pixels will be ignored to avoid unconsciously accidental - // moves - CPt theDragDistance = inPoint - m_MouseDownLoc; - if (theDragDistance.x * theDragDistance.x + theDragDistance.y * theDragDistance.y <= 25) - return; - - m_MaybeDragStart = false; - } - - long theNewTime = m_Snapper.ProcessDrag(m_StartTime, inPoint.x, inFlags); - if (theNewTime < 0) - theNewTime = 0; - long theDiffTime = theNewTime - m_StartTime; - - if (theDiffTime) { - GetTimebar()->OffsetTime(theDiffTime); - // display the time range tooltip - RefreshToolTip(inPoint); - } - } -} - -//============================================================================= -/** - * Call from the left TimebarTab to resize the control. - * @param inTime the time to set the start time to. - */ -void CTimebarControl::ResizeTimebarLeftTo(long inTime) -{ - // TOOD: sk - Figure out what this does - // if ( inTime != 0 ) - { - // The whole idea is to not do anything additional once times passes 0 (negatively) - // unless it is valid that time is negative on the timebar - if (inTime < 0 && m_StartTime > 0) - inTime = -m_StartTime; // so that it decrements to 0 - - if (m_StartTime > 0 || (m_StartTime == 0 && inTime > 0)) - GetTimebar()->ChangeTime(inTime, true); - } -} - -//============================================================================= -/** - * Call from the right TimebarTab to resize the control. - * @param inTime the time to set the start time to. - */ -void CTimebarControl::ResizeTimebarRightTo(long inTime) -{ - GetTimebar()->ChangeTime(inTime, false); -} - -//============================================================================= -/** - * Sets the Actual string of text - * @param inText the text to set the comment text to - */ -void CTimebarControl::SetText(const Q3DStudio::CString &inText) -{ - m_EditControl->SetData(inText); -} - -//============================================================================= -/** - * Sets the Text Color on the edit control - * @param inColor the color - */ -void CTimebarControl::SetTextColor(::CColor inColor) -{ - m_EditControl->SetTextColor(inColor); -} - -long CTimebarControl::GetStartTime() -{ - return m_StartTime; -} - -long CTimebarControl::GetEndTime() -{ - return m_EndTime; -} - -//============================================================================= -/** - * Sets whether or not this control is enabled. - * If the control is not enabled then it is still drawn and still intercepts - * mouse clicks, but it will not actually process them. - * @param inIsEnabled true if this control is to be enabled. - */ -void CTimebarControl::SetEnabled(bool inIsEnabled) -{ - CControl::SetEnabled(inIsEnabled); -} - -//============================================================================= -/** - * COMMENT!!!!!!!!!!!!!!!!!!!!!! - */ -void CTimebarControl::OnLoseFocus() -{ - if (m_IsMouseDown) { - m_IsMouseDown = false; - CommitTimeChange(); - HideMoveableWindow(); - } - CControl::OnLoseFocus(); -} - -//============================================================================= -/** - * Setup prior to dragging. - */ -void CTimebarControl::OnBeginDrag() -{ - GetTimebar()->OnBeginDrag(); -} - -void CTimebarControl::ChangeStartTime(long inTime) -{ - ResizeTimebarLeftTo(inTime); -} - -void CTimebarControl::ChangeEndTime(long inTime) -{ - ResizeTimebarRightTo(inTime); -} - -void CTimebarControl::Commit() -{ - GetTimebar()->CommitTimeChange(); -} -void CTimebarControl::Rollback() -{ - GetTimebar()->RollbackTimeChange(); -} - -void CTimebarControl::ShowContextMenu(CPt inPoint, bool inShowTimebarPropertiesOptions) -{ - CTimebarKeyframeContextMenu theMenu(this, m_TimelineItemBinding->GetKeyframesManager(), - inShowTimebarPropertiesOptions); - DoPopup(&theMenu, inPoint); -} - -void CTimebarControl::CommitTimeChange() -{ - GetTimebar()->CommitTimeChange(); -} - -//============================================================================= -/** - * The binding is a keyframes holder - */ -ITimelineItemKeyframesHolder *CTimebarControl::GetKeyframesHolder() -{ - return m_TimelineItemBinding; -} - -//============================================================================= -/** - * Start editing the timebar comment - */ -void CTimebarControl::OnEditTimeComment() -{ - GrabFocus(m_EditControl); - m_EditControl->DoChangeComment(); -} - -//============================================================================= -/** - * Need to invalidate all timebars to redraw - */ -void CTimebarControl::OnToggleTimebarHandles() -{ - Invalidate(); -} - -void CTimebarControl::SetTimebarTime() -{ - GetTimebar()->SetTimebarTime(this); -} - -::CColor CTimebarControl::GetTimebarColor() -{ - return GetTimebar()->GetTimebarColor(); -} - -void CTimebarControl::SetTimebarColor(const ::CColor &inColor) -{ - GetTimebar()->SetTimebarColor(inColor); -} - -void CTimebarControl::SetSnappingListProvider(ISnappingListProvider *inProvider) -{ - m_SnappingListProvider = inProvider; -} - -ISnappingListProvider &CTimebarControl::GetSnappingListProvider() const -{ - // sk - If you hit this, it means the setup order is incorrect. e.g. loading children is done - // depth first, ie your child's children is loaded before parent, doesn't work that way. - return *m_SnappingListProvider; -} - -CRct CTimebarControl::GetTopControlBounds() const -{ - return m_TimebarRow->GetStateRowUI()->GetTopControl()->GetBounds(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimebarControl.h b/src/Authoring/Studio/Palettes/Timeline/TimebarControl.h deleted file mode 100644 index 2d6e709d..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimebarControl.h +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TIMEBAR_CONTROL_H -#define INCLUDED_TIMEBAR_CONTROL_H 1 - -#pragma once - -#include "Control.h" -#include "Snapper.h" -#include "CommentEdit.h" -#include "TimebarTip.h" -#include "DurationEditDlg.h" -#include "KeyframeContextMenu.h" - -class CStateTimebarRow; -class ITimelineItemBinding; -class ISnappingListProvider; - -//============================================================================= -/** - * Interface to a timebar control - */ -class ITimebarControl -{ -public: - virtual ~ITimebarControl() {} - - virtual ITimelineItemKeyframesHolder *GetKeyframesHolder() = 0; - virtual void OnEditTimeComment() = 0; - virtual void OnToggleTimebarHandles() = 0; - virtual void SetTimebarTime() = 0; - virtual ::CColor GetTimebarColor() = 0; - virtual void SetTimebarColor(const ::CColor &inColor) = 0; -}; - -class CTimebarControl : public CControl, public ITimeChangeCallback, public ITimebarControl -{ -public: - CTimebarControl(CStateTimebarRow *inRow, ITimelineItemBinding *inTimelineItemBinding); - virtual ~CTimebarControl(); - void Draw(CRenderer *inRenderer) override; - void SetSize(CPt inSize) override; - void SetSelected(bool inIsSelected); - void SetTimeRatio(double inTimeRatio); - void Refresh(); - void Refresh(long inStartTime, long inEndTime); - void RefreshMetaData(); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseRDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseDoubleClick(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void ResizeTimebarLeftTo(long inTime); - void ResizeTimebarRightTo(long inTime); - void SetText(const Q3DStudio::CString &inText); - void SetTextColor(::CColor inColor = ::CColor(0, 0, 0)); - void SetEnabled(bool inIsEnabled) override; - - long GetStartTime(); - long GetEndTime(); - - virtual void PopulateSnappingList(CSnapper *inSnapper); - void OnLoseFocus() override; - - void OnBeginDrag(); - - // ITimeChangeCallback - void ChangeStartTime(long) override; - void ChangeEndTime(long) override; - void Commit() override; - void Rollback() override; - - void ShowContextMenu(CPt inPoint, bool inShowTimebarPropertiesOptions); - void CommitTimeChange(); - - // ITimebarControl - ITimelineItemKeyframesHolder *GetKeyframesHolder() override; - void OnEditTimeComment() override; - void OnToggleTimebarHandles() override; - void SetTimebarTime() override; - ::CColor GetTimebarColor() override; - void SetTimebarColor(const ::CColor &inColor) override; - - void SetSnappingListProvider(ISnappingListProvider *inProvider); - ISnappingListProvider &GetSnappingListProvider() const; - - CRct GetTopControlBounds() const; - -protected: - ITimelineTimebar *GetTimebar(); - - void RefreshToolTip(CPt inPoint); - void DrawHashedBackgroundX(CRenderer *inRenderer, ::CColor inFirstColor, ::CColor inSecondColor, - CRct inRect); - - CStateTimebarRow *m_TimebarRow; - bool m_IsSelected; - double m_TimeRatio; - bool m_IsMouseDown; - bool m_MaybeDragStart; - CPt m_MouseDownLoc; - long m_StartTime; - long m_EndTime; - - CTimebarTip m_LeftLeftTip; - CTimebarTip m_LeftTip; - - CTimebarTip m_RightTip; - CTimebarTip m_RightRightTip; - CCommentEdit *m_EditControl; - CSnapper m_Snapper; - - ITimelineItemBinding *m_TimelineItemBinding; - ISnappingListProvider *m_SnappingListProvider; -}; -#endif // INCLUDED_TIMEBAR_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimebarTip.cpp b/src/Authoring/Studio/Palettes/Timeline/TimebarTip.cpp deleted file mode 100644 index 9968a838..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimebarTip.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "TimebarTip.h" -#include "TimebarControl.h" -#include "MouseCursor.h" -#include "TimelineControl.h" -#include "ResourceCache.h" -#include "Renderer.h" -#include "StudioUtils.h" - -#include <QApplication> - -//============================================================================= -/** - * Create a timebar tip for the timebar. - * This handles displaying the resize cursor and processing the mouse commands. - * @param inTimebar the timebar on which this tip is attached. - * @param inIsLeft true if this is the left timebar tip. - */ -CTimebarTip::CTimebarTip(CTimebarControl *inTimebar, bool inIsLeft, bool inHasHandle /*=false*/) - : m_IsMouseDown(false) - , m_MaybeDragStart(false) - , m_HasHandle(false) -{ - m_Timebar = inTimebar; - m_IsLeft = inIsLeft; - - ShowHandles(inHasHandle); -} - -//============================================================================= -/** - * Destructor - */ -CTimebarTip::~CTimebarTip() -{ -} - -//============================================================================= -/** -* Updates the ToolTip and moves it to the correct place on screen. -* @param inPoint the point that the tooltip is supposed to be placed. -*/ -void CTimebarTip::RefreshToolTip(CPt inPoint) -{ - Q3DStudio::CString theCommentText; - - // format label as: startTime - endTime (timeDifference) - theCommentText = " " + FormatTimeString(m_Timebar->GetStartTime()) + " - " - + FormatTimeString(m_Timebar->GetEndTime()) + " (" - + FormatTimeString(m_Timebar->GetEndTime() - m_Timebar->GetStartTime()) + ")"; - - CRct theTimelineBounds(m_Timebar->GetTopControlBounds()); - inPoint.y = GetPosition().y - GetSize().y; - ShowMoveableWindow(inPoint, theCommentText, theTimelineBounds); -} - -//============================================================================= -/** - * Starts the dragging of the timebar tip. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - */ -bool CTimebarTip::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseDown(inPoint, inFlags); - - m_Timebar->OnBeginDrag(); - - m_Snapper.Clear(); - m_Snapper.SetSource(m_Timebar); - m_Timebar->GetSnappingListProvider().PopulateSnappingList(&m_Snapper); - m_Snapper.BeginDrag(inPoint.x); - - m_IsMouseDown = true; - m_MaybeDragStart = true; - m_MouseDownLoc = inPoint; - - setCursorIfNotSet(CMouseCursor::CURSOR_RESIZE_LEFTRIGHT); - - // display the time range tooltip - RefreshToolTip(inPoint); - - return true; -} - -//============================================================================= -/** - * Ends the dragging of the tip and commits the commands. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - */ -void CTimebarTip::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // try to prevent stuck mousetips on exceptions - try { - CControl::OnMouseUp(inPoint, inFlags); - - // Commit the current command so it will not be merged with drag commands if this gets - // dragged again. - m_Timebar->CommitTimeChange(); - } catch (...) { - } - - m_IsMouseDown = false; - m_MaybeDragStart = false; - HideMoveableWindow(); - resetCursor(); -} - -//============================================================================= -/** - * If the mouse is down then this handles the resizing of the timebar. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse. - */ -void CTimebarTip::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - - // Don't show the cursor if the mouse is down from someone else. - if (!(inFlags & CHotKeys::MOUSE_RBUTTON) && !(inFlags & CHotKeys::MOUSE_LBUTTON)) - setCursorIfNotSet(CMouseCursor::CURSOR_RESIZE_LEFTRIGHT); - - if (m_IsMouseDown) { - if (m_MaybeDragStart) { - // Dragging in the first 5 pixels will be ignored to avoid unconsciously accidental - // moves - CPt theDragDistance = inPoint - m_MouseDownLoc; - if (theDragDistance.x * theDragDistance.x + theDragDistance.y * theDragDistance.y <= 25) - return; - - m_MaybeDragStart = false; - } - - // Figure out which method to call based on which tip we are. - if (m_IsLeft) { - long theNewTime = m_Snapper.ProcessDrag(m_Timebar->GetStartTime(), inPoint.x, inFlags); - m_Timebar->ResizeTimebarLeftTo(theNewTime); - } else { - long theNewTime = m_Snapper.ProcessDrag(m_Timebar->GetEndTime(), inPoint.x, inFlags); - m_Timebar->ResizeTimebarRightTo(theNewTime); - } - - // display the time range tooltip - RefreshToolTip(inPoint); - } -} - -//============================================================================= -/** - * Resets the cursor back to normal. - * @param inPoint the location of the mouse. - * @param inFlags the state of the mouse/modifier buttons. - */ -void CTimebarTip::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - - resetCursor(); -} - -//============================================================================= -/** - * Draws timebar handles if necessary. - */ -void CTimebarTip::Draw(CRenderer *inRenderer) -{ - if (m_HasHandle) { // to show or not is based on Studio preferences - bool theShowHandle = - CPreferences::GetUserPreferences("Timeline").GetValue("ShowTimebarHandles", false); - if (theShowHandle) { - if (IsEnabled()) - inRenderer->DrawBitmap(CPt(0, 0), m_HandleImage); - else - inRenderer->DrawBitmap(CPt(0, 0), m_HandleDisabledImage); - } - } -} - -void CTimebarTip::ShowHandles(bool inShowHandles) -{ - m_HasHandle = inShowHandles; - - // If this tip can have a handle - if (m_HasHandle) { - if (!m_HandleImage) { - // If this is a tip on the left side, load the images for the left side - const char *theBitMap = - (m_IsLeft) ? "timebarhandle-left.png" : "timebarhandle-right.png"; - m_HandleImage = CResourceCache::GetInstance()->GetBitmap(theBitMap); - } - - if (!m_HandleDisabledImage) { - const char *theBitMap = - (m_IsLeft) ? "timebarhandle-disabled-left.png" : "timebarhandle-disabled-right.png"; - m_HandleDisabledImage = CResourceCache::GetInstance()->GetBitmap(theBitMap); - } - } -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimebarTip.h b/src/Authoring/Studio/Palettes/Timeline/TimebarTip.h deleted file mode 100644 index 4aca03a7..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimebarTip.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_TIMEBAR_TIP -#define INCLUDED_TIMEBAR_TIP 1 -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "Control.h" -#include "Snapper.h" - -#include <QCursor> -#include <QPixmap> -//============================================================================== -// Forwards -//============================================================================== -class CTimebarControl; -class CRenderer; - -//============================================================================== -/** - * Class for the tips of timebar controls. Allows the user to resize timebars - * by grabbing the tips. - */ -class CTimebarTip : public CControl -{ -public: - CTimebarTip(CTimebarControl *inTimebarControl, bool inIsLeft, bool inHasHandle = false); - virtual ~CTimebarTip(); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void Draw(CRenderer *inRenderer) override; - - void ShowHandles(bool inShowHandles); - -protected: - void RefreshToolTip(CPt inPoint); - - CTimebarControl *m_Timebar; - bool m_IsMouseDown; - bool m_MaybeDragStart; - CPt m_MouseDownLoc; - bool m_IsLeft; - bool m_HasHandle; - QPixmap m_HandleImage; - QPixmap m_HandleDisabledImage; - CSnapper m_Snapper; -}; - -#endif // INCLUDED_TIMEBAR_TIP diff --git a/src/Authoring/Studio/Palettes/Timeline/Timeline.qml b/src/Authoring/Studio/Palettes/Timeline/Timeline.qml index 6e10a12c..dd4bc088 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Timeline.qml +++ b/src/Authoring/Studio/Palettes/Timeline/Timeline.qml @@ -169,6 +169,7 @@ Rectangle { Layout.minimumHeight: 80 Layout.preferredHeight: (timelineItemsList.count + 1) * itemHeight Layout.preferredWidth: root.width + boundsBehavior: Flickable.StopAtBounds contentHeight: height contentWidth: 2000 diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineControl.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineControl.cpp deleted file mode 100644 index 053cf46b..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineControl.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "TimelineControl.h" -#include "TimelineSplitter.h" -#include "StudioApp.h" -#include "Dispatch.h" -#include "TimelineTreeLayout.h" -#include "TimelineTimelineLayout.h" -#include "SlideRow.h" -#include "IDoc.h" -#include "InsertionLine.h" -#include "InsertionOverlay.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "BreadCrumbControl.h" -#include "BaseTimelineTreeControl.h" -#include "Bindings/TimelineTranslationManager.h" -#include "Doc.h" -#include "Core.h" -#include "MasterP.h" -#include "TimelineUIFactory.h" -#include "AbstractTimelineRowUI.h" - -// Data model specific -#include "TimelineDropTarget.h" - -#include "ClientDataModelBridge.h" -#include "Qt3DSDMStudioSystem.h" -#include "Qt3DSDMSlides.h" - -IMPLEMENT_OBJECT_COUNTER(CTimelineControl) - -CTimelineControl::CTimelineControl(const QSize &preferredSize) - : m_SuspendRecalcLayout(false) - , m_TranslationManager(nullptr) - , m_time(0) - , m_preferredSize(preferredSize) -{ - ADDTO_OBJECT_COUNTER(CTimelineControl) - - m_TranslationManager = new CTimelineTranslationManager(); - - m_Splitter = new CTimelineSplitter(); - AddChild(m_Splitter); - - CDoc *theDoc = g_StudioApp.GetCore()->GetDoc(); - m_TreeLayout = new CTimelineTreeLayout(this, theDoc); - m_Splitter->AddChild(m_TreeLayout); - - m_TimelineLayout = new CTimelineTimelineLayout(this, theDoc); - m_Splitter->AddChild(m_TimelineLayout); - - m_Splitter->SetSplitDirection(CSplitter::SPLIT_VERTICAL); - m_Splitter->SetSplitLocation(CStudioPreferences::GetTimelineSplitterLocation()); - - CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); - theDispatch->AddPresentationChangeListener(this); - theDispatch->AddClientPlayChangeListener(this); - - // Insertion line - m_InsertionLine = new CInsertionLine(); - m_InsertionLine->SetName("TimelineInsertionLine"); - AddChild(m_InsertionLine); - - // Insertion overlay marker - m_InsertionOverlay = new CInsertionOverlay(); - m_InsertionOverlay->SetName("TimelineInsertionOverlay"); - AddChild(m_InsertionOverlay); - - m_Splitter->SetPosition(CPt(0, CStudioPreferences::GetHeaderHeight())); - - m_BreadCrumbToolbar = new CBreadCrumbControl(); - AddChild(m_BreadCrumbToolbar); - - SetPreferredSize(CPt(400, 200)); -} - -CTimelineControl::~CTimelineControl() -{ - CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); - theDispatch->RemovePresentationChangeListener(this); - theDispatch->RemoveClientPlayChangeListener(this); - - delete m_InsertionOverlay; - delete m_InsertionLine; - delete m_TimelineLayout; - delete m_TreeLayout; - delete m_Splitter; - delete m_BreadCrumbToolbar; - - REMOVEFROM_OBJECT_COUNTER(CTimelineControl) -} - -CPt CTimelineControl::GetPreferredSize() -{ - return CPt(m_preferredSize.width(), m_preferredSize.height()); -} - -//============================================================================= -/** - * Returns the playhead time - */ -long CTimelineControl::GetTime() -{ - return m_time; -} - -//============================================================================= -/** - * Clear the contents of this view. - * This will empty out this view and leave it ready for inspecting other objects. - */ -void CTimelineControl::ClearView() -{ - m_TimelineLayout->ClearRows(); - m_TreeLayout->ClearRows(); - m_ActiveSlide = 0; - - // clean out all previous translations, because the bindings are not guaranteed to be valid when - // switching from one slide to another. - m_TranslationManager->Clear(); -} - -//============================================================================= -/** - * Populates this view with the provided state. - * This will set the state as being the root object on this view. ClearView - * should be called before this is called. - * The object will become the root object of this and will become the active - * root of the doc. - * @param inState the state to be viewed as the root asset. - */ -void CTimelineControl::ViewSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide) -{ - m_ActiveSlide = inSlide; - - qt3dsdm::ISlideSystem *theSlideSystem = GetDoc()->GetStudioSystem()->GetSlideSystem(); - qt3dsdm::Qt3DSDMInstanceHandle theSlideInstance = theSlideSystem->GetSlideInstance(inSlide); - CSlideRow *theSlideRow = TimelineUIFactory::instance()->createSlideRow(nullptr, - m_TranslationManager->GetOrCreate(theSlideInstance)); - - auto uiRow = TimelineUIFactory::instance()->uiForRow(theSlideRow); - uiRow->SetTimelineControl(this); - - m_TreeLayout->AddRow(theSlideRow); - m_TimelineLayout->AddRow(theSlideRow); - - // Since this would be loading the entire context's assets, fire the OnTimelineLayoutChange - // event just once. - SuspendLayoutChanges(true); - try { - theSlideRow->LoadChildren(); - theSlideRow->Expand(); - } catch (...) { // restore the 'states' before passing the exception up - SuspendLayoutChanges(false); - throw; - } - // Update breadcrumbs - m_BreadCrumbToolbar->RefreshTrail(m_TranslationManager->GetBreadCrumbProvider()); - - SuspendLayoutChanges(false); - OnLayoutChanged(); -} - -//============================================================================= -/** - * Notification from the StudioFullSystem signal provider that a we have a new active slide. - * This will populate this view with the new context. - */ -void CTimelineControl::OnActiveSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide) -{ - if (m_ActiveSlide == inSlide) - return; - - ClearView(); - ViewSlide(inSlide); - - double theStoredRatio = m_TimelineLayout->GetTimelineRatio(inSlide); - if (theStoredRatio != -1) - m_TimelineLayout->SetTimeRatio(theStoredRatio); - else - m_TimelineLayout->OnScalingReset(); - - m_TimelineLayout->RecalcLayout(); -} - -void CTimelineControl::OnNewPresentation() -{ - m_TranslationManager->OnNewPresentation(); - - // Register callback - qt3dsdm::IStudioFullSystemSignalProvider *theSignalProvider = - GetDoc()->GetStudioSystem()->GetFullSystemSignalProvider(); - m_Connections.push_back(theSignalProvider->ConnectActiveSlide( - std::bind(&CTimelineControl::OnActiveSlide, this, std::placeholders::_3))); - m_Connections.push_back(theSignalProvider->ConnectSlideDeleted( - std::bind(&CTimelineControl::OnDeleteSlide, this, std::placeholders::_1))); - CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); - m_Connections.push_back(theDispatch->ConnectSelectionChange( - std::bind(&CTimelineControl::OnSelectionChange, this, std::placeholders::_1))); -} - -//============================================================================= -/** - * Notification from the dispatch that the presentation is being closed. - * This will clear all the objects from this presentation. - */ -void CTimelineControl::OnClosingPresentation() -{ - ClearView(); - m_TimelineLayout->ClearAllTimeRatios(); - m_BreadCrumbToolbar->RefreshTrail(nullptr); - - m_Connections.clear(); -} - -//============================================================================= -/** - * Accessor for the root object being displayed in this view. - */ -qt3dsdm::Qt3DSDMSlideHandle CTimelineControl::GetActiveSlide() -{ - return m_ActiveSlide; -} - -//============================================================================= -/** - * Gets the timeline layout which is the portion of the timeline to the right - * of the splitter. The timeline layout contains the timebars. - */ -CTimelineTimelineLayout *CTimelineControl::GetTimelineLayout() -{ - return m_TimelineLayout; -} - -//============================================================================= -/** - * Gets the tree layout which is the portion of the timeline to the left - * of the splitter. The tree layout contains the tree controls for expanding - * rows in the timeline. - */ -CTimelineTreeLayout *CTimelineControl::GetTreeLayout() -{ - return m_TreeLayout; -} - -//============================================================================= -/** - * Notification from the dispatch that the presentation is going into play mode. - */ -void CTimelineControl::OnPlayStart() -{ -} - -//============================================================================= -/** - * Notification from the dispatch that the presentation is exiting play state. - */ -void CTimelineControl::OnPlayStop() -{ -} - -//============================================================================= -/** - * Notification from the dispatch that the time has changed. - * This is used to update the playhead location and view time. - * @param inNewTime the new time that this should display. - */ -void CTimelineControl::OnTimeChanged(long inNewTime) -{ - SetTime(inNewTime); -} - -//============================================================================== -// CSelectionChangeListener -//============================================================================== -void CTimelineControl::OnSelectionChange(Q3DStudio::SSelectedValue inNewSelectable) -{ - // testing for nullptr selection OR if the selected is not displayed in the timeline - bool theLoseFocus = !inNewSelectable.empty(); - if (!theLoseFocus) { - Q3DStudio::SelectedValueTypes::Enum theSelectionType = inNewSelectable.getType(); - // for now, its just DataModel objects - theLoseFocus = theSelectionType != Q3DStudio::SelectedValueTypes::Instance; // DataModel objects - } - if (theLoseFocus) - m_TreeLayout->OnLoseFocus(); - - GetTranslationManager()->OnSelectionChange(inNewSelectable); - - // The drag&drop doesn't have any sort of callback after a drop - // so for now, this acts as a "event-trigger" after a drop ( because new items are always - // selcted after a drop ) - HideInsertionMarkers(); -} - -//============================================================================= -/** - * Callback when individual rows has affected the layout, such that the treelayout needs to be - * synchronized with the timelinelayout or vice versa. - */ -void CTimelineControl::OnLayoutChanged() -{ - if (m_SuspendRecalcLayout) // optimization where this is explicitly shutoff. - return; - - m_TreeLayout->RecalcLayout(); - m_TimelineLayout->OnTimelineLayoutChanged(); -} - -//============================================================================= -/** - * typically for displaying tooltip - */ -CRct CTimelineControl::GetBounds() const -{ - return CRct(GetGlobalPosition(CPt(0, 0)), GetSize()); -} - -void CTimelineControl::HideTimelineMoveableTooltip() -{ - HideMoveableWindow(); -} - -//============================================================================= -/** - * For snapping timebars/keyframes - */ -ISnappingListProvider *CTimelineControl::GetSnappingListProvider() const -{ - return m_TimelineLayout; -} - -//============================================================================= -/** - * Sets the current time as seen in this palette. - * This will update the Playhead time and the time view time. - * @param inNewTime the time to set on this. - */ -void CTimelineControl::SetTime(long inNewTime) -{ - m_time = inNewTime; - m_TimelineLayout->SetTime(inNewTime); -} - -void CTimelineControl::HideInsertionMarkers() -{ - bool theInvalidate = false; - if (m_InsertionOverlay->IsVisible()) { - m_InsertionOverlay->SetVisible(false); - theInvalidate = true; - } - if (m_InsertionLine->IsVisible()) { - m_InsertionLine->SetVisible(false); - theInvalidate = true; - } - if (theInvalidate) { - m_TreeLayout->Invalidate(); - Invalidate(); - } -} - -void CTimelineControl::SetSize(CPt inSize) -{ - CControl::SetSize(inSize); - - m_Splitter->SetSize(CPt(inSize.x, inSize.y)); -} - -//============================================================================= -/** - * Scrolls both sides of the timeline along the y-axis so that they stay synced. - * @param inSource Scroller that generated the scroll messsage - * @param inPositionY New vertical scroll bar position - */ -void CTimelineControl::SetScrollPositionY(CScroller *inSource, long inPositionY) -{ - m_TreeLayout->SetScrollPositionY(inSource, inPositionY); - m_TimelineLayout->SetScrollPositionY(inSource, inPositionY); -} - -//============================================================================= -/** - * Override OnDraw to provide Timeline only draw profiling stats. - */ -void CTimelineControl::OnDraw(CRenderer *inRenderer, CRct &inDirtyRect, bool inIgnoreValidation) -{ - QT3DS_PROFILE(OnDraw); - CControl::OnDraw(inRenderer, inDirtyRect, inIgnoreValidation); -} - -//============================================================================= -/** - * Fills the whole control with the base (gray) color, then other controls will - * draw on top of that. - * @param inRenderer renderer to draw to - */ -void CTimelineControl::Draw(CRenderer *inRenderer) -{ - const auto size = GetSize(); - inRenderer->FillSolidRect(QRect(0, 0, size.x, size.y), CStudioPreferences::GetBaseColor()); -} - -//============================================================================= -/** - * Overriden from CControl. We want to propagate keydown (specifically F2) - * messages to the selected row regardless if the control has focus or not. - */ -void CTimelineControl::OnGainFocus() -{ - CControl::OnGainFocus(); - - CBaseStateRow *theRow = m_TranslationManager->GetSelectedRow(); - if (theRow) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(theRow); - uiRow->SetFocus(); - } -} - -//============================================================================= -/** - * Overridden to draw insertion lines - */ -CDropTarget *CTimelineControl::FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) -{ - CDropTarget *theDropTarget = CControl::FindDropCandidate(inMousePoint, inFlags); - - bool theHideInsertionMarkers = true; - CTimeLineDropTarget *theTimelineDropTarget = nullptr; - if (theDropTarget - && (theTimelineDropTarget = dynamic_cast<CTimeLineDropTarget *>(theDropTarget))) { - CControl *theInsertionOverControl = theTimelineDropTarget->GetInsertionMarkerRow(); - if (theInsertionOverControl) { - CRct theTreeRect = GetVisibleTreeLayoutArea(); - EDROPDESTINATION theDropDest = theTimelineDropTarget->GetDestination(); - switch (theDropDest) { - case EDROPDESTINATION_ABOVE: - case EDROPDESTINATION_BELOW: { - // the insertion line starts from the indent to the end of the row - long theIndent = theTimelineDropTarget->GetInsertionMarkerIndent(); - if (theDropDest == EDROPDESTINATION_ABOVE) - m_InsertionLine->SetPosition(theInsertionOverControl->GetGlobalPosition( - CPt(theIndent, -GetPosition().y))); - else - m_InsertionLine->SetPosition(theInsertionOverControl->GetGlobalPosition(CPt( - theIndent, theInsertionOverControl->GetSize().y - 1 - GetPosition().y))); - - long theWidth = - theTreeRect.size.x + theTreeRect.position.x - m_InsertionLine->GetPosition().x; - m_InsertionLine->SetLineWidth(theWidth); - m_InsertionLine->SetVisible(true); - m_InsertionOverlay->SetVisible(false); - } break; - case EDROPDESTINATION_ON: { - // insertion overlay spans the width of the row - m_InsertionOverlay->SetPosition(theInsertionOverControl->GetGlobalPosition( - CPt(theTreeRect.position.x, -GetPosition().y))); - - long theWidth = theTreeRect.size.x + theTreeRect.position.x - - m_InsertionOverlay->GetPosition().x; - m_InsertionOverlay->SetWidth(theWidth); - m_InsertionOverlay->SetVisible(true); - m_InsertionLine->SetVisible(false); - } break; - } - theHideInsertionMarkers = false; - } - } - // not drawn - if (theHideInsertionMarkers) - HideInsertionMarkers(); - - return theDropTarget; -} - -void CTimelineControl::OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseOut(inPoint, inFlags); - HideInsertionMarkers(); -} - -void CTimelineControl::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); - HideInsertionMarkers(); -} - -//============================================================================= -/** - * Gets the insertion line for the timeline. The insertion line should be used - * to indicate when you can drag-and-drop and item between two other items. - * Call SetVisible on this control to show/hide it. - * @return the insertion line control - */ -CInsertionLine *CTimelineControl::GetInsertionLine() -{ - return m_InsertionLine; -} - -//============================================================================= -/** - * Gets the insertion overlay marker for the timeline. This control should be - * used to indicate that you can drag-and-drop and object onto another item in - * the timeline. Call SetVisible on this control to show/hide it. - * @return the insertion overlay marker for the timeline - */ -CInsertionOverlay *CTimelineControl::GetInsertionOverlay() -{ - return m_InsertionOverlay; -} - -//============================================================================= -/** - * Fetches the bounding rect for the CTimelineTreeLayout section of the - * timeline. This is the section that contains toggles and text names of items - * in the timeline. The actual tree layout might be bigger than this rect - * specifies. This is because portions of the tree layout might be overlapped - * by other controls. - * @return rectangle describing visible area of the tree control - */ -CRct CTimelineControl::GetVisibleTreeLayoutArea() -{ - return m_TreeLayout->GetVisibleArea(); -} - -void CTimelineControl::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, - QWidget *actionParent) -{ - m_TimelineLayout->RegisterGlobalKeyboardShortcuts(inShortcutHandler, actionParent); -} - -//============================================================================= -/** - * event that takes place just before a save or export, on lose focus will commit changes - * in text boxes - */ -void CTimelineControl::OnSavingPresentation(const Qt3DSFile *inNewPresentationFile) -{ - Q_UNUSED(inNewPresentationFile); - OnLoseFocus(); -} - -//============================================================================= -/** - * Notification from the StudioFullSystem signal provider that a slide has been deleted. - */ -void CTimelineControl::OnDeleteSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide) -{ - m_TimelineLayout->DeleteTimelineRatio(inSlide); -} - -//============================================================================== -/** - * When caller knows that there are 'batch' changes to the timeline layout, - * to prevent unnecessary calls to recalclayout - */ -void CTimelineControl::SuspendLayoutChanges(bool inSuspend) -{ - m_SuspendRecalcLayout = inSuspend; -} - -CDoc *CTimelineControl::GetDoc() -{ - return g_StudioApp.GetCore()->GetDoc(); -} - -CClientDataModelBridge *CTimelineControl::GetBridge() -{ - return GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineControl.h b/src/Authoring/Studio/Palettes/Timeline/TimelineControl.h deleted file mode 100644 index 0cd6719e..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineControl.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1999-2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#ifndef INCLUDED_TIMELINE_CONTROL_H -#define INCLUDED_TIMELINE_CONTROL_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "Control.h" -#include "DispatchListeners.h" -#include "TimelineRow.h" -#include "ITimelineControl.h" - -#include "Qt3DSDMHandles.h" -#include "Qt3DSDMSignals.h" -#include "SelectedValueImpl.h" - -//============================================================================== -// Forwards -//============================================================================== -class CDoc; -class CDropTarget; -class CTimelineSplitter; -class CTimelineTreeLayout; -class CTimelineTimelineLayout; -class CScroller; -class CInsertionLine; -class CInsertionOverlay; -class CRenderer; -class CHotKeys; -class CBreadCrumbControl; -class CTimelineTranslationManager; -class CClientDataModelBridge; - -//============================================================================== -// Classes -//============================================================================== - -class CTimelineControl : public CControl, - public CPresentationChangeListener, - public CClientPlayChangeListener, - public ITimelineControl -{ -public: - CTimelineControl(const QSize &preferredSize); - ~CTimelineControl(); - - DEFINE_OBJECT_COUNTER(CTimelineControl) - - // CControl - void OnDraw(CRenderer *inRenderer, CRct &inDirtyRect, bool inIgnoreValidation = false) override; - void Draw(CRenderer *inRenderer) override; - void OnGainFocus() override; - CDropTarget *FindDropCandidate(CPt &inMousePoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseOut(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - CPt GetPreferredSize() override; - - // Presentation Change Listener - void OnNewPresentation() override; - void OnClosingPresentation() override; - void OnSavingPresentation(const Qt3DSFile *inNewPresentationFile) override; - - // ClientPlayChangeListener - void OnPlayStart() override; - void OnPlayStop() override; - void OnTimeChanged(long inNewTime) override; - - // CSelectionChangeListener, - virtual void OnSelectionChange(Q3DStudio::SSelectedValue inNewSelectable); - - // ITimelineControl - void OnLayoutChanged() override; - CRct GetBounds() const override; - void HideTimelineMoveableTooltip() override; - ISnappingListProvider *GetSnappingListProvider() const override; - - void ClearView(); - void ViewSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide); - qt3dsdm::Qt3DSDMSlideHandle GetActiveSlide(); - - CTimelineTimelineLayout *GetTimelineLayout(); - CTimelineTreeLayout *GetTreeLayout(); - - void SetSize(CPt inSize) override; - long GetTime(); - void SetScrollPositionY(CScroller *inSource, long inPositionY); - - CInsertionLine *GetInsertionLine(); - CInsertionOverlay *GetInsertionOverlay(); - CRct GetVisibleTreeLayoutArea(); - - void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent); - - CTimelineTranslationManager *GetTranslationManager() const { return m_TranslationManager; } - -protected: - void SuspendLayoutChanges(bool inSuspend); - void SetTime(long inNewTime); - - void HideInsertionMarkers(); - - // DataModel callbacks - void OnActiveSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide); - void OnDeleteSlide(qt3dsdm::Qt3DSDMSlideHandle inSlide); - - // Helper functions - inline CDoc *GetDoc(); - inline CClientDataModelBridge *GetBridge(); - - CTimelineSplitter *m_Splitter; - CTimelineTreeLayout *m_TreeLayout; - CTimelineTimelineLayout *m_TimelineLayout; - qt3dsdm::Qt3DSDMSlideHandle m_ActiveSlide; - CInsertionLine - *m_InsertionLine; ///< Drag-and-drop insertion line for dropping between timeline items - CInsertionOverlay - *m_InsertionOverlay; ///< Drag-and-drop insertion marker for dropping on a timeline item - CBreadCrumbControl *m_BreadCrumbToolbar; - bool m_SuspendRecalcLayout; - - CTimelineTranslationManager *m_TranslationManager; - - std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> - m_Connections; /// connections to the DataModel - long m_time; - QSize m_preferredSize; -}; -#endif // INCLUDED_TIMELINE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.cpp deleted file mode 100644 index fe072db6..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#include "stdafx.h" - -//============================================================================= -// Includes -//============================================================================= -#include "TimelineSplitter.h" -#include "StudioPreferences.h" - -//============================================================================= -/** - * Constructor - */ -CTimelineSplitter::CTimelineSplitter() -{ -} - -//============================================================================= -/** - * Destructor - */ -CTimelineSplitter::~CTimelineSplitter() -{ -} - -//============================================================================= -/** - * Set the location of the splitter bar. Overridden so that this location can - * be stored in the user's preferences. - * @param inSplitLocation the location of the splitter bar, in pixels from the right/top. - */ -void CTimelineSplitter::SetSplitLocation(long inPixels) -{ - CSplitter::SetSplitLocation(inPixels); - CStudioPreferences::SetTimelineSplitterLocation(inPixels); -}
\ No newline at end of file diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.h b/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.h deleted file mode 100644 index f9ba681a..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineSplitter.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#ifndef TIMELINE_SPLITTER_INCLUDED -#define TIMELINE_SPLITTER_INCLUDED 1 - -#pragma once - -//============================================================================= -// Includes -//============================================================================= -#include "Splitter.h" - -//============================================================================= -/** - * Overridden splitter, specific to the timeline, which stores the split location - * so that it can be retrieved between program sessions. - */ -class CTimelineSplitter : public CSplitter -{ -public: - CTimelineSplitter(); - virtual ~CTimelineSplitter(); - void SetSplitLocation(long inPixels) override; -}; - -#endif diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.cpp deleted file mode 100644 index 0cb32093..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#include "AbstractTimelineRowUI.h" -#include "stdafx.h" - -//============================================================================= -// Includes -//============================================================================= -#include "TimelineTimelineLayout.h" -#include "TimeMeasure.h" -#include "ScalableScroller.h" -#include "StudioUtils.h" -#include "TimelineRow.h" -#include "TimelineControl.h" -#include "StateRow.h" -#include "Snapper.h" -#include "Bindings/TimelineTranslationManager.h" -#include "ControlData.h" -#include "HotKeys.h" -#include "TimelineUIFactory.h" - -#include "foundation/Qt3DSLogging.h" -#include <QtWidgets/qaction.h> - -//============================================================================= -// Defines -//============================================================================= -// For Win the modifier key for keyframe multi selection is the control key. -#define MODIFIER_KEY CHotKeys::MODIFIER_CONTROL - -//============================================================================= -// Class constants -//============================================================================= -const double CTimelineTimelineLayout::SCALING_PERCENTAGE_INC = 1.1; -const double CTimelineTimelineLayout::SCALING_PERCENTAGE_DEC = 0.9; -const double CTimelineTimelineLayout::MAX_ZOOM_OUT = 7e-005; - -//============================================================================= -/** - * Constructor - */ -CTimelineTimelineLayout::CTimelineTimelineLayout(CTimelineControl *inTimelineControl, IDoc *inDoc) - : m_Playhead(this, inDoc) - , m_IsLayoutChanged(false) - , m_IsMouseDown(false) -{ - m_ControlData->SetMouseWheelEnabled(true); - m_TimelineControl = inTimelineControl; - - m_TimeRatio = DEFAULT_TIME_RATIO + .01; - m_TimeMeasure = new CTimeMeasure(this, m_TimeRatio); - m_Scroller = new CScalableScroller(); - - m_Scroller->SetVerticalScrollMode(CScroller::ALWAYS); - m_Scroller->SetHorizontalScrollMode(CScroller::ALWAYS); - m_Scroller->AddScrollListener(this); - m_BoundingRect = new CAreaBoundingRect(); - m_BoundingRect->SetName("TimelineAreaBoundingRect"); - m_BoundingRect->SetVisible(false); - m_BoundingRect->SetAlpha(128); - - AddChild(m_TimeMeasure); - AddChild(m_Scroller); - AddChild(&m_Playhead); - AddChild(m_BoundingRect); - - // Blank control filling in the bottom of the timeline, under the rows - CBlankControl *theTimelineBlankControl = new CBlankControl(); - m_TimebarList = new CFlowLayout(theTimelineBlankControl); - - m_Scroller->AddChild(m_TimebarList); - m_Scroller->SetScalingListener(this); - m_TimebarList->SetName("TimelineTimelineLayoutList"); - - // Initializing flags for keyframe multi select to work. - m_CommitKeyframeSelection = false; -} - -//============================================================================= -/** - * Destructor - */ -CTimelineTimelineLayout::~CTimelineTimelineLayout() -{ - delete m_TimeMeasure; - delete m_Scroller; - delete m_TimebarList; - delete m_BoundingRect; -} - -//============================================================================= -/** - * Clear all the StateRows out of the top-level list. - * This is used when the current presentation is being cleared out. - */ -void CTimelineTimelineLayout::ClearRows() -{ - TTimelineRowList::iterator thePos = m_Rows.begin(); - for (; thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = (*thePos); - auto uiRow = TimelineUIFactory::instance()->uiForRow(theRow); - m_TimebarList->RemoveChild(uiRow->GetTimebarControl()); - } - - m_Rows.clear(); -} - -//============================================================================= -/** - * Set the size of this control. - * Overrrides CControl::SetSize so that this can redo the layout of all inner - * controls. - * @param inSize the new size of this control. - */ -void CTimelineTimelineLayout::SetSize(CPt inSize) -{ - CControl::SetSize(inSize); - - RecalcLayout(); -} - -//============================================================================= -/** - * Recalculate the positioning of all the child components. - */ -void CTimelineTimelineLayout::RecalcLayout() -{ - CPt mySize = GetSize(); - // Put the time measure on top taking 21 pixels high. - m_TimeMeasure->SetSize(CPt(mySize.x, 21)); - m_TimeMeasure->SetPosition(CPt(0, 0)); - - // Make the scroller take up the rest of the space. - m_Scroller->SetSize(CPt(mySize.x, mySize.y - 42)); - m_Scroller->SetPosition(CPt(0, 21)); - - // Make it the full length of the view, minus the bottom scroll bar. - m_Playhead.SetSize(CPt(13, GetSize().y - m_Scroller->GetHorizontalBar()->GetSize().y - 21)); - - long theMinTime = -(m_Playhead.GetCenterOffset()); - - if (!m_Rows.empty()) { - long theLatestTime = 0; - TTimelineRowList::iterator thePos = m_Rows.begin(); - for (; thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = (*thePos); - long theRowLatestTime = theRow->GetLatestEndTime(); - if (theRowLatestTime > theLatestTime) - theLatestTime = theRowLatestTime; - } - - long theMinWidth = ::TimeToPos(theLatestTime, m_TimeRatio) + END_BUFFER_SIZE; - long theMinHeight = m_TimebarList->GetMinimumSize().y; - - CPt theVisSize = m_Scroller->GetVisibleSize(); - - if (theMinHeight < theVisSize.y) - theMinHeight = theVisSize.y; - if (theMinWidth < theVisSize.x) - theMinWidth = theVisSize.x; - - m_TimebarList->ResetMinMaxPref(); - m_TimebarList->SetAbsoluteSize(CPt(theMinWidth, theMinHeight)); - } - - // Set up the limits. - m_Playhead.SetMinMaxPosition(theMinTime, mySize.x - m_Scroller->GetVerticalBar()->GetSize().x); - - // Set playhead to time 0. - SetTime(m_TimelineControl->GetTranslationManager()->GetCurrentViewTime(), true); - - // Reset! so that this isn't unnecessarily run - m_IsLayoutChanged = false; -} - -//============================================================================= -/** - * Add a timeline row to this object. - * This will add the row as a top level object. - * @param inRow the row to be added. - */ -void CTimelineTimelineLayout::AddRow(CTimelineRow *inRow) -{ - CAbstractTimelineRowUI *uiRow = TimelineUIFactory::instance()->uiForRow(inRow); - m_Rows.push_back(inRow); - - m_TimebarList->AddChild(uiRow->GetTimebarControl()); - - inRow->SetTimeRatio(m_TimeRatio); - // For keyframe/timebar snapping. - uiRow->SetSnappingListProvider(this); -} - -//============================================================================= -/** - * Call from the ScalableScroller that it is scaling the right side of the timebar. - * @param inLength the length that the thumb wants to be. - * @param inTotalLength the maximum length that the thumb can be. - * @param inOffset the offset of the thumb position. - */ -void CTimelineTimelineLayout::OnScalingRight(long inLength, long inTotalLength, long inOffset) -{ - double theViewSize = m_Scroller->GetVisibleSize().x; - double theClientSize = m_Scroller->GetContaineeSize().x; - double theLength = inLength; - double theTotalLength = inTotalLength; - - double theTimeRatio = - (theViewSize * theTotalLength) / (theClientSize * theLength) * m_TimeRatio; - - // This means the bar was dragged to the far end, just prevent it for getting wacky. - if (theTimeRatio > 0) { - // This will set the time ratio, but will cap it at 1 or MAX_ZOOM_OUT so if the Time ratio - // less than max, don't need to move the timeline - SetTimeRatio(theTimeRatio); - if (theTimeRatio < 1) { - double theMaxVisPos = m_Scroller->GetMaxVisiblePosition().x; - long theVisiblePosition = ::dtol(theMaxVisPos * inOffset / (inTotalLength - inLength)); - m_Scroller->SetVisiblePosition( - CPt(theVisiblePosition, m_Scroller->GetVisiblePosition().y)); - } - } -} - -//============================================================================= -/** - * Under construction. - */ -void CTimelineTimelineLayout::OnScalingLeft(long inLength, long inTotalLength, long inOffset) -{ - // Hey- look at that, doesn't matter which side you're scaling. - // Hey, nice comment especially the function header - OnScalingRight(inLength, inTotalLength, inOffset); -} - -void CTimelineTimelineLayout::OnScalingReset() -{ - SetTimeRatio(DEFAULT_TIME_RATIO); -} - -//============================================================================= -/** - * Set the TimeRatio to be used. - * This will propagate the time ratio down to all the child items. - * @param inTimeRatio the time ratio to be set. - */ -void CTimelineTimelineLayout::SetTimeRatio(double inTimeRatio) -{ - if (inTimeRatio != m_TimeRatio) { - if (inTimeRatio > 1) - inTimeRatio = 1; - // if ( inTimeRatio < MAX_ZOOM_OUT ) - // inTimeRatio = MAX_ZOOM_OUT; - - m_TimeRatio = inTimeRatio; - m_TimeMeasure->SetTimeRatio(inTimeRatio); - - TTimelineRowList::iterator thePos = m_Rows.begin(); - for (; thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = (*thePos); - theRow->SetTimeRatio(inTimeRatio); - } - - RecalcLayout(); - - // store the timeline ratio - SetTimelineRatio(m_TimelineControl->GetActiveSlide(), m_TimeRatio); - qCInfo(qt3ds::TRACE_INFO) << "Set time ratio: " << inTimeRatio; - } -} - -//============================================================================== -/** - * When timeline layout has changed. RecalcLayout should be called to adjust the scrollbars if - * a asset is expanded/collapsed in the timeline. - */ -void CTimelineTimelineLayout::OnTimelineLayoutChanged() -{ - RecalcLayout(); - - // In addition, this has to be 'marked' for if SetScrollerPositionY is called due to - // new assets being added, RecalcLayout has to be called again. - m_IsLayoutChanged = true; -} - -/** - * Deletes the time zoom ratio for a particular slide. - * @param inContext the time context of that slide to delete - */ -void CTimelineTimelineLayout::DeleteTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide) -{ - m_TimelineRatio.erase(inSlide); -} - -/** - * Clear all entries - */ -void CTimelineTimelineLayout::ClearAllTimeRatios() -{ - m_TimelineRatio.clear(); -} - -/** - * Retrieves the time zoom ratio for a particular slide - * @param inContext the time context of that slide to retrieve zoom ratio - * @return the zoom ratio, or -1 if it's not found - */ -double CTimelineTimelineLayout::GetTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide) -{ - TSlideRatioMap::iterator theResult = m_TimelineRatio.find(inSlide); - if (theResult != m_TimelineRatio.end()) - return theResult->second; - else - return -1; -} - -/** - * Sets the time zoom ratio for a particular slide - * @param inContext the time context of that slide - * @param inRatio the zoom factor - */ -void CTimelineTimelineLayout::SetTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide, double inRatio) -{ - m_TimelineRatio[inSlide] = inRatio; -} - -//============================================================================= -/** - * For testing purposes. - */ -long CTimelineTimelineLayout::GetMaximumTimebarTime() -{ - return 30000; -} - -//============================================================================= -/** - * Call from the TimelineView to notifiy this that some of its objects got filtered. - * This was used for redoing the layout but is no longer necessary. - */ -void CTimelineTimelineLayout::Filter() -{ -} - -//============================================================================= -/** - * Notification from the CScroller that it is scrolling. - * This will update the other views with the verticall scrolling and update - * the TimeMeasure with the horizontal scroll amount. - * @param inScrollAmount the amount that was scrolled by. - */ -void CTimelineTimelineLayout::OnScroll(CScroller *inSource, CPt inScrollAmount) -{ - Q_UNUSED(inSource); - - m_TimelineControl->SetScrollPositionY(m_Scroller, m_Scroller->GetVisiblePosition().y); - - long theTimeOffset = GetViewTimeOffset(); - m_TimeMeasure->SetTimeOffset(theTimeOffset); - - long thePlayheadPos = - ::TimeToPos(m_TimelineControl->GetTranslationManager()->GetCurrentViewTime() - - theTimeOffset, - m_TimeRatio) - - m_Playhead.GetCenterOffset(); - - m_Playhead.SetPosition(CPt(thePlayheadPos, 0)); - - m_DragBeginPoint += inScrollAmount; -} - -void CTimelineTimelineLayout::SetScrollPositionY(CScroller *inSource, long inPositionY, - bool inAbsolute) -{ - Q_UNUSED(inSource); - - CPt theVisPos = m_Scroller->GetVisiblePosition(); - - if (!inAbsolute) { - CPt theMaxSize = m_Scroller->GetMaxVisiblePosition(); - - CRct theVisibleRect(CPt(theVisPos.x, theMaxSize.y - theVisPos.y), - m_Scroller->GetVisibleSize()); - CPt thePoint(theVisPos.x, inPositionY); - if (!theVisibleRect.IsInRect(thePoint)) - m_Scroller->SetVisiblePosition(CPt(theVisPos.x, inPositionY)); - } else { - // For new assets added, RecalcLayout needs be called here if there was a layout changed - // because - // m_TimebarList->GetMinimumSize( ).y is only updated at this point, otherwise the tree and - // layout will - // go out of sync. - if (m_IsLayoutChanged) - RecalcLayout(); - - m_Scroller->SetVisiblePosition(CPt(theVisPos.x, inPositionY)); - } -} - -//============================================================================= -/** - * Get the scroller control this is using. - * Meant for testing purposes. - * @return the scroller this is using. - */ -CScalableScroller *CTimelineTimelineLayout::GetScroller() -{ - return m_Scroller; -} - -//============================================================================= -/** - * Get the playhead control this is using. - * Meant for testing purposes. - * @return the playhead this is using. - */ -CPlayhead *CTimelineTimelineLayout::GetPlayhead() -{ - return &m_Playhead; -} - -//============================================================================= -/** - * Scroll the contents of the timeline horizontally. - * This is used mainly by the playhead to scroll the view when it gets to the - * edge. - * @param inAmount the amount to scroll the view by. - * @return the amount actually scrolled, limited by min/max values. - */ -long CTimelineTimelineLayout::ScrollLayout(long inAmount) -{ - // Log the current position for returning - CPt thePosition = m_Scroller->GetVisiblePosition(); - - m_Scroller->SetVisiblePosition(CPt(thePosition.x + inAmount, thePosition.y)); - - // Return how much was actually scrolled, let the scroller handle min/max scroll amounts. - return m_Scroller->GetVisiblePosition().x - thePosition.x; -} - -//============================================================================= -/** - * Recalculate what the time is based on the location of the playhead. - * This will call SetTime on the TimelineView with the new time. - * @param inUpdateClient true if the client time should be updated. - */ -void CTimelineTimelineLayout::RecalcTime(bool inUpdateClient, long inFlags) -{ - long theOffset = m_Playhead.GetPosition().x + m_Playhead.GetCenterOffset() - + m_Scroller->GetVisiblePosition().x; - - long theTime = ::PosToTime(theOffset, m_TimeRatio); - m_Snapper.InterpretTimeEx(theTime, inFlags); - - // Update the time - m_Playhead.UpdateTime(theTime, inUpdateClient); -} - -//============================================================================= -/** - * Call from the timeline view that the time is changing. - * @param inNewTime the new time. - * @param inIsSecondary flag to prevent infinite recursion. - */ -void CTimelineTimelineLayout::SetTime(long inNewTime, bool inIsSecondary) -{ - long theOffset = ::TimeToPos(inNewTime, m_TimeRatio); - theOffset -= m_Scroller->GetVisiblePosition().x + m_Playhead.GetCenterOffset(); - - long theViewSize = m_Scroller->GetVisibleSize().x; - - if (!inIsSecondary) { - if (theOffset < -m_Playhead.GetCenterOffset()) { - long thePos = ::TimeToPos(inNewTime, m_TimeRatio) - m_Playhead.GetCenterOffset(); - m_Scroller->SetVisiblePosition(CPt(thePos, m_Scroller->GetVisiblePosition().y)); - } else if (theOffset > (theViewSize - (m_Playhead.GetCenterOffset() + 20))) { - long thePos = ::TimeToPos(inNewTime, m_TimeRatio) + 20; - thePos -= theViewSize; - m_Scroller->SetVisiblePosition(CPt(thePos, m_Scroller->GetVisiblePosition().y)); - } - SetTime(inNewTime, true); - } else { - m_Playhead.SetPosition(CPt(theOffset, m_Playhead.GetPosition().y)); - } -} - -//============================================================================= -/** - * Notification that the TimeMeasure was clicked on. - * This is used to reposition the playhead wherever the mouse was clicked. - * @param inPoint the location of the mouse local to the time measure. - */ -void CTimelineTimelineLayout::OnTimeMeasureMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - Q_UNUSED(inFlags); - - m_Snapper.Clear(); - m_Snapper.SetSource(&m_Playhead); - PopulateSnappingList(&m_Snapper); - m_Snapper.SetSnappingKeyframes(true); - - m_Playhead.SetPosition( - CPt(inPoint.x - m_Playhead.GetCenterOffset(), m_Playhead.GetPosition().y)); - RecalcTime(true, inFlags); -} - -//============================================================================= -/** - * Handles left-clicks. Starts a drag operation if a child does not handle the - * message. - * @param inPoint location of the mouse when event occurred - * @param inFlags state of modifier keys when event occurred - */ -bool CTimelineTimelineLayout::OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - if (!CControl::OnMouseDown(inPoint, inFlags)) { - m_BoundingRect->SetSize(CPt(0, 0)); - m_BoundingRect->SetVisible(true); - - // Do not deselect all keyframes as the user intends to select more keyframes, - // when the modifier key is pressed. - if (!(inFlags & MODIFIER_KEY)) - m_TimelineControl->GetTranslationManager()->ClearKeyframeSelection(); - - m_IsMouseDown = true; - m_DragBeginPoint = inPoint; - } - return true; -} - -void CTimelineTimelineLayout::OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseMove(inPoint, inFlags); - - if (m_IsMouseDown) { - CPt theSize; - CRct theRect; - - // Tests if the user has pressed the modifier key, while moving the mouse. - bool theModifierKeyDown; - if (inFlags & MODIFIER_KEY) - theModifierKeyDown = true; - else - theModifierKeyDown = false; - - // Calculate the rect for the bounding box - theSize = CPt(inPoint.x - m_DragBeginPoint.x, inPoint.y - m_DragBeginPoint.y); - theRect = CRct(m_DragBeginPoint, theSize); - theRect.Normalize(); - m_BoundingRect->SetPosition(theRect.position); - m_BoundingRect->SetSize(theRect.size); - theRect.Offset(-m_Scroller->GetPosition()); - theRect.Offset(m_Scroller->GetVisiblePosition()); - - // Select all keys inside the rect - - TTimelineRowList::iterator thePos = m_Rows.begin(); - - for (; thePos != m_Rows.end(); ++thePos) { - CStateRow *theRow = reinterpret_cast<CStateRow *>(*thePos); - auto rowUi = TimelineUIFactory::instance()->uiForRow(theRow); - rowUi->SelectKeysInRect(theRect, theModifierKeyDown, m_CommitKeyframeSelection); - } - m_CommitKeyframeSelection = false; - } -} - -void CTimelineTimelineLayout::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - // try to prevent stuck mousetips on exceptions - try { - CControl::OnMouseUp(inPoint, inFlags); - m_BoundingRect->SetVisible(false); - } catch (...) { - } - - m_IsMouseDown = false; - - // Commits the key frame selection. This finalises the keyframes selection - // in the rect. When the mouse is down again, we would be able to append - // the commited keyframes with the new batch of keyframes. - m_CommitKeyframeSelection = true; -} - -void CTimelineTimelineLayout::PopulateSnappingList(CSnapper *inSnappingList) -{ - CRct theArea(m_Scroller->GetVisibleSize()); - theArea.Offset(-m_Scroller->GetPosition()); - theArea.Offset(m_Scroller->GetVisiblePosition()); - - inSnappingList->SetVisibleArea(theArea.position.y, theArea.size.y); - - inSnappingList->SetTimeRatio(m_TimeRatio); - if (inSnappingList->GetSource() != &m_Playhead) - inSnappingList->AddTime(m_Playhead.GetCurrentTime()); - - m_TimeMeasure->PopulateSnappingList(inSnappingList); - - TTimelineRowList::iterator theRowIter = m_Rows.begin(); - for (; theRowIter != m_Rows.end(); ++theRowIter) { - auto uiRow = TimelineUIFactory::instance()->uiForRow(*theRowIter); - uiRow->PopulateSnappingList(inSnappingList); - } -} - -long CTimelineTimelineLayout::GetViewTimeOffset() -{ - return ::dtol(m_Scroller->GetVisiblePosition().x / m_TimeRatio); -} - -CTimeMeasure *CTimelineTimelineLayout::GetTimeMeasure() -{ - return m_TimeMeasure; -} - -//============================================================================= -/** - * Register all the events for hotkeys that are active for the entire application. - * Hotkeys for the entire application are ones that are not view specific in - * scope. - * @param inShortcutHandler the global shortcut handler. - */ -void CTimelineTimelineLayout::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, - QWidget *actionParent) -{ - Q_UNUSED(inShortcutHandler) - -#ifdef KDAB_TEMPORARILY_REMOVED - ADD_GLOBAL_SHORTCUT(actionParent, - QKeySequence(Qt::Key_Plus), - CTimelineTimelineLayout::OnScalingZoomIn); - ADD_GLOBAL_SHORTCUT(actionParent, - QKeySequence(Qt::Key_Minus), - CTimelineTimelineLayout::OnScalingZoomOut); -#endif -} - -//============================================================================= -/** - * Call from the Hotkey that it is zooming in the timebar. - */ - -void CTimelineTimelineLayout::OnScalingZoomIn() -{ - double theTimeRatio = m_TimeRatio * SCALING_PERCENTAGE_INC; - - SetTimeRatio(theTimeRatio); - CenterToPlayhead(); -} - -//============================================================================= -/** - * Call from the Hotkey that it is zooming out of the timebar. - */ - -void CTimelineTimelineLayout::OnScalingZoomOut() -{ - double theTimeRatio = m_TimeRatio * SCALING_PERCENTAGE_DEC; - - SetTimeRatio(theTimeRatio); - CenterToPlayhead(); -} - -void CTimelineTimelineLayout::CenterToPlayhead() -{ - long theTime = m_Playhead.GetCurrentTime(); - long thePos = ::TimeToPos(theTime, m_TimeRatio); - long theNewPosX = thePos - (m_Scroller->GetSize().x / 2); - - m_Scroller->SetVisiblePosition(CPt(theNewPosX, m_Scroller->GetVisiblePosition().y)); -} - -//============================================================================== -/** - * Handle mouse wheel messages to allow zooming - */ -bool CTimelineTimelineLayout::OnMouseWheel(CPt inPoint, long inAmount, Qt::KeyboardModifiers inFlags) -{ - bool theRetVal = false; - if (inFlags & CHotKeys::MODIFIER_CONTROL) { - if (inAmount > 0) - OnScalingZoomIn(); - else - OnScalingZoomOut(); - theRetVal = true; - } else - theRetVal = CControl::OnMouseWheel(inPoint, inAmount, inFlags); - return theRetVal; -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.h b/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.h deleted file mode 100644 index afc7ef02..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineTimelineLayout.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#ifndef INCLUDED_TIMELINE_TIMELINE_LAYOUT_H -#define INCLUDED_TIMELINE_TIMELINE_LAYOUT_H 1 - -#pragma once - -//============================================================================= -// Includes -//============================================================================= -#include "Control.h" -#include <vector> -#include "ScalableScrollerBar.h" -#include "Scroller.h" -#include "Pt.h" -#include "Snapper.h" -#include "AreaBoundingRect.h" -#include "Playhead.h" -#include "Qt3DSDMHandles.h" - -#include "TimelineRow.h" - -//============================================================================= -// Forwards -//============================================================================= -class CScalableScroller; -class CFlowLayout; -class CTimelineControl; -class CSnapper; -class IDoc; -class CHotKeys; -class CTimeMeasure; -class CPlayhead; - -//============================================================================= -/** - * Right-hand pane of the Timeline containing timebars, keyframes, etc. - */ -class CTimelineTimelineLayout : public QObject, - public CControl, - public CScalingListener, - public CScrollListener, - public ISnappingListProvider -{ - Q_OBJECT - - typedef std::vector<CTimelineRow *> TTimelineRowList; - typedef std::map<qt3dsdm::Qt3DSDMSlideHandle, double> TSlideRatioMap; - -public: - static const long END_BUFFER_SIZE = 20; - static const double SCALING_PERCENTAGE_INC; - static const double SCALING_PERCENTAGE_DEC; - static const double MAX_ZOOM_OUT; - - CTimelineTimelineLayout(CTimelineControl *inView, IDoc *inDoc); - virtual ~CTimelineTimelineLayout(); - - void SetSize(CPt inSize) override; - - void AddRow(CTimelineRow *inRow); - - void OnScalingRight(long inLength, long inTotalLength, long inOffset) override; - void OnScalingLeft(long inLength, long inTotalLength, long inOffset) override; - void OnScalingReset() override; - - long ScrollLayout(long inAmount); - - void Filter(); - - void OnScroll(CScroller *inScroller, CPt inScrollAmount) override; - void SetScrollPositionY(CScroller *inSource, long inPositionY, bool inAbsolute = true); - - void ClearRows(); - - bool OnMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseMove(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - bool OnMouseWheel(CPt inPoint, long inAmount, Qt::KeyboardModifiers inFlags) override; - - CScalableScroller *GetScroller(); - CPlayhead *GetPlayhead(); - CTimeMeasure *GetTimeMeasure(); - void RecalcTime(bool inUpdateClient, long inFlags); - void SetTime(long inTime, bool inIsSecondary = false); - void OnTimeMeasureMouseDown(CPt inPoint, Qt::KeyboardModifiers inFlags); - long GetViewTimeOffset(); - void RecalcLayout(); - void RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget *actionParent); - void SetTimeRatio(double inTimeRatio); - void OnTimelineLayoutChanged(); - - void DeleteTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide); - void ClearAllTimeRatios(); - double GetTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide); - - // ISnappingListProvider - void PopulateSnappingList(CSnapper *inSnappingList) override; - -protected: - void SetTimelineRatio(qt3dsdm::Qt3DSDMSlideHandle inSlide, double inRatio); - - long GetMaximumTimebarTime(); - void OnScalingZoomIn(); - void OnScalingZoomOut(); - void CenterToPlayhead(); - - bool m_CommitKeyframeSelection; ///< flag for saving previous keyframe selection when the mouse - ///is released. - CTimelineControl *m_TimelineControl; - CTimeMeasure *m_TimeMeasure; - CScalableScroller *m_Scroller; - CFlowLayout *m_TimebarList; - double m_TimeRatio = DEFAULT_TIME_RATIO; - - TTimelineRowList m_Rows; - CPlayhead m_Playhead; - CSnapper m_Snapper; - bool m_IsLayoutChanged; ///< flag to keep track of a need for a delayed RecalcLayout - - bool m_IsMouseDown; - CPt m_DragBeginPoint; - CAreaBoundingRect *m_BoundingRect; - - TSlideRatioMap m_TimelineRatio; ///< stores the time zooming ratios for each slide -}; -#endif // INCLUDED_TIMELINE_TIMELINE_LAYOUT_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.cpp deleted file mode 100644 index a9a7dda4..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#include "stdafx.h" - -//============================================================================= -// Includes -//============================================================================= -#include "TimelineTreeLayout.h" -#include "FlowLayout.h" -#include "Scroller.h" -#include "StateRow.h" -#include "FilterToolbar.h" -#include "ToggleToolbar.h" -#include "StudioPreferences.h" -#include "TimelineControl.h" -#include "Renderer.h" -#include "ToggleBlankControl.h" -#include "ColorBlankControl.h" -#include "TreeBlankControl.h" -#include "AbstractTimelineRowUI.h" -#include "TimelineUIFactory.h" - -//============================================================================= -/** - * Constructor - */ -CTimelineTreeLayout::CTimelineTreeLayout(CTimelineControl *inTimelineControl, IDoc *inDoc) - : m_IsScrolling(false) -{ - m_TimelineControl = inTimelineControl; - - m_ColorScroller = new CScroller(); - m_ColorScroller->SetHorizontalScrollMode(CScroller::NEVER); - m_ColorScroller->SetVerticalScrollMode(CScroller::NEVER); - m_ColorScroller->AddScrollListener(this); - - m_ColorBlankControl = new CColorBlankControl(); - m_ColorList = new CFlowLayout(m_ColorBlankControl); - m_ColorScroller->AddChild(m_ColorList); - - m_ToggleScroller = new CScroller(); - m_ToggleScroller->SetHorizontalScrollMode(CScroller::NEVER); - m_ToggleScroller->SetVerticalScrollMode(CScroller::NEVER); - - m_ToggleBlankControl = new CToggleBlankControl(); - m_ToggleList = new CFlowLayout(m_ToggleBlankControl); - m_ToggleScroller->AddChild(m_ToggleList); - m_ToggleScroller->AddScrollListener(this); - - m_TreeScroller = new CScroller(); - m_TreeScroller->SetVerticalScrollMode(CScroller::NEVER); - m_TreeScroller->SetHorizontalScrollMode(CScroller::ALWAYS); - m_TreeScroller->AddScrollListener(this); - - m_TreeBlankControl = new CTreeBlankControl(); - m_TreeList = new CFlowLayout(m_TreeBlankControl); - m_TreeScroller->AddChild(m_TreeList); - - m_FilterToolbar = new CFilterToolbar(this); - m_ToggleToolbar = new CToggleToolbar(this); - - AddChild(m_TreeScroller); - AddChild(m_ToggleScroller); - AddChild(m_ToggleToolbar); - AddChild(m_ColorScroller); -} - -//============================================================================= -/** - * Destructor - */ -CTimelineTreeLayout::~CTimelineTreeLayout() -{ - m_ColorScroller->RemoveChild(m_ColorList); - m_ToggleScroller->RemoveChild(m_ToggleList); - m_TreeScroller->RemoveChild(m_TreeList); - - RemoveChild(m_TreeScroller); - RemoveChild(m_ToggleScroller); - RemoveChild(m_FilterToolbar); - RemoveChild(m_ToggleToolbar); - RemoveChild(m_ColorScroller); - // RemoveChild( m_BreadCrumbToolbar ); - - delete m_FilterToolbar; - delete m_ToggleToolbar; - delete m_ColorScroller; - delete m_ColorList; - delete m_ToggleScroller; - delete m_ToggleList; - delete m_TreeList; - delete m_TreeScroller; - // delete m_BreadCrumbToolbar; - - // Delete all the rows, this control is responsible for the rows, maybe it should not - // be but currently it is. - TTimelineRowList::iterator thePos = m_Rows.begin(); - for (; thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = (*thePos); - theRow->Dispose(); // Dispose will delete the row as well - } -} - -//============================================================================= -/** - * Clear out all the contents of this tree layout. - * This will also delete all the rows, so make sure it is called after the - * TimelineTimelineLayout::ClearRows is called. - */ -void CTimelineTreeLayout::ClearRows() -{ - TTimelineRowList::iterator thePos = m_Rows.begin(); - for (; thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = (*thePos); - auto uiRow = TimelineUIFactory::instance()->uiForRow(theRow); - - m_ColorList->RemoveChild(uiRow->GetColorControl()); - m_TreeList->RemoveChild(uiRow->GetTreeControl()); - m_ToggleList->RemoveChild(uiRow->GetToggleControl()); - - theRow->Dispose(); - } - - m_Rows.clear(); -} - -//============================================================================= -/** - * Set the filter back to it's default state. - */ -void CTimelineTreeLayout::ResetFilter() -{ - m_FilterToolbar->FilterBehaviors(false); - m_FilterToolbar->FilterProperties(false); - m_FilterToolbar->FilterMaterials(false); - m_FilterToolbar->FilterShy(false); -} - -//============================================================================= -/** - * Set the size of this control. - * Overrides CControl::SetSize so that RecalcLayout can be called. - */ -void CTimelineTreeLayout::SetSize(CPt inSize) -{ - if (inSize != GetSize()) { - CControl::SetSize(inSize); - - RecalcLayout(); - } -} - -//============================================================================= -/** - * Recalculate the layout of all the child components. - * Called when this changes size and all the children need to be repositioned. - */ -void CTimelineTreeLayout::RecalcLayout() -{ - CPt mySize = GetSize(); - long theHeaderHeight = CStudioPreferences::GetHeaderHeight(); - - m_FilterToolbar->SetSize(CPt(120, theHeaderHeight)); - m_FilterToolbar->SetPosition(0, 0); - - m_ToggleToolbar->SetSize(CPt(61, theHeaderHeight)); - m_ToggleToolbar->SetPosition(mySize.x - m_ToggleToolbar->GetSize().x, 0); - - m_ColorScroller->SetSize(CPt(CStudioPreferences::GetRowSize(), mySize.y - theHeaderHeight - - m_TreeScroller->GetHorizontalBar()->GetMinimumSize().y - - theHeaderHeight)); - m_ColorScroller->SetPosition(0, theHeaderHeight); - - m_ToggleScroller->SetSize(CPt(m_ToggleToolbar->GetSize().x, mySize.y - theHeaderHeight - - m_TreeScroller->GetHorizontalBar()->GetMinimumSize().y - - theHeaderHeight)); - m_ToggleScroller->SetPosition(mySize.x - m_ToggleScroller->GetSize().x, theHeaderHeight); - - m_TreeScroller->SetSize( - CPt(mySize.x, mySize.y - m_FilterToolbar->GetSize().y - theHeaderHeight)); - m_TreeScroller->SetPosition(0, theHeaderHeight); - - m_TreeScroller->SetAdditionalClippingRect( - CRct(m_ColorScroller->GetSize().x, 0, - m_ToggleScroller->GetPosition().x - m_ColorScroller->GetSize().x, - m_TreeScroller->GetSize().y)); -} - -//============================================================================= -/** - * Add another top level item to the left side of the timeline. - * If there is already a top level item then this one will be appended to the - * list. - * @param inRow the row to be added. - */ -void CTimelineTreeLayout::AddRow(CTimelineRow *inRow) -{ - CAbstractTimelineRowUI *uiRow = TimelineUIFactory::instance()->uiForRow(inRow); - m_ColorList->AddChild(uiRow->GetColorControl()); - m_TreeList->AddChild(uiRow->GetTreeControl()); - m_ToggleList->AddChild(uiRow->GetToggleControl()); - - m_Rows.push_back(inRow); - - uiRow->SetIndent(20); - - inRow->Filter(m_Filter); -} - -//============================================================================= -/** - * Applies the current filter settings to the timeline. Although the filter - * preferences can be set independently, they are not actually applied until - * this function is called. - */ -void CTimelineTreeLayout::Filter() -{ - for (TTimelineRowList::iterator thePos = m_Rows.begin(); thePos != m_Rows.end(); ++thePos) { - CTimelineRow *theRow = *thePos; - theRow->Filter(m_Filter); - } - - // TODO: sk - it is unclear to me what this is trying to do.. I am leavint this here till it - // becomes obvious it is totally redundant OR someone finds a related bug - /* - // Call OnSelect( ) on the selected object (if there is one) to get the timeline to scroll down. - CAsset* theSelectedObject = dynamic_cast<CAsset*>( m_Doc->GetSelectedObject( ) ); - if ( theSelectedObject ) - theSelectedObject->OnSelect( ); - - m_TimelineControl->GetTimelineLayout( )->RecalcLayout( ); - */ -} - -void CTimelineTreeLayout::OnScroll(CScroller *inSource, CPt inScrollAmount) -{ - Q_UNUSED(inScrollAmount); - - // SetScrollPositionY triggers another onScroll event and potentially causes the position - // to be set incorrectly. - if (!m_IsScrolling) { - m_IsScrolling = true; - m_TreeBlankControl->SetVisiblePositionX(inSource->GetVisiblePosition().x); - m_TimelineControl->SetScrollPositionY(inSource, inSource->GetVisiblePosition().y); - m_IsScrolling = false; - } -} - -//============================================================================= -/** - * Set the vertical position of all the scrollers in this view. - * This is used to sync up the positions with the timebar scroller view. - * @param inScrollPositionY the position of the scroller. - */ -void CTimelineTreeLayout::SetScrollPositionY(CScroller *inSource, long inScrollPositionY, - bool inAbsolute) -{ - Q_UNUSED(inSource); - - if (!inAbsolute) { - CRct theVisibleRect(m_ColorScroller->GetVisiblePosition(), - m_ColorScroller->GetVisibleSize()); - CPt thePoint(m_ColorScroller->GetVisiblePosition().x, inScrollPositionY); - if (!theVisibleRect.IsInRect(thePoint)) { - m_ColorScroller->SetVisiblePosition( - CPt(m_ColorScroller->GetVisiblePosition().x, inScrollPositionY)); - m_TreeScroller->SetVisiblePosition( - CPt(m_TreeScroller->GetVisiblePosition().x, inScrollPositionY)); - m_ToggleScroller->SetVisiblePosition( - CPt(m_ToggleScroller->GetVisiblePosition().x, inScrollPositionY)); - } - } else { - m_ColorScroller->SetVisiblePosition( - CPt(m_ColorScroller->GetVisiblePosition().x, inScrollPositionY)); - m_TreeScroller->SetVisiblePosition( - CPt(m_TreeScroller->GetVisiblePosition().x, inScrollPositionY)); - m_ToggleScroller->SetVisiblePosition( - CPt(m_ToggleScroller->GetVisiblePosition().x, inScrollPositionY)); - } -} - -//============================================================================= -/** - * This is overridden so the Gesture can Notify Drop Listeners that its time to Drop. - * If the gesture is dragging something then wee will drop. - */ -void CTimelineTreeLayout::OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) -{ - CControl::OnMouseUp(inPoint, inFlags); -} - -//============================================================================= -/** - * @return rectangle describing the visible area of the tree control - */ -CRct CTimelineTreeLayout::GetVisibleArea() -{ - CPt theUpperLeftCorner; - CPt theSize; - - theUpperLeftCorner.x = m_ColorScroller->GetSize().x; - theUpperLeftCorner.y = CStudioPreferences::GetHeaderHeight(); - theSize.x = m_ToggleScroller->GetPosition().x - theUpperLeftCorner.x; - theSize.y = ::abs(m_ToggleScroller->GetPosition().y - m_ToggleScroller->GetSize().y) - - theUpperLeftCorner.y; - - return CRct(theUpperLeftCorner, theSize); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.h b/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.h deleted file mode 100644 index d426dc7b..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineTreeLayout.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================= -// Prefix -//============================================================================= -#ifndef INCLUDED_TIMELINE_TREE_LAYOUT_H -#define INCLUDED_TIMELINE_TREE_LAYOUT_H 1 - -#pragma once - -//============================================================================= -// Includes -//============================================================================= -#include "Control.h" -#include "TimelineFilter.h" -#include "Scroller.h" -#include <vector> - -//============================================================================= -// Forwards -//============================================================================= -class CFlowLayout; -class CScroller; -class CFilterToolbar; -class CTimelineRow; -class CToggleToolbar; -class CTimelineControl; -class IDoc; -class CRenderer; -class CToggleBlankControl; -class CColorBlankControl; -class CTreeBlankControl; - -//============================================================================= -/** - * Class for tree control on the timeline palette. - */ -class CTimelineTreeLayout : public CControl, public CScrollListener -{ - typedef std::vector<CTimelineRow *> TTimelineRowList; - -public: - CTimelineTreeLayout(CTimelineControl *inTimelineControl, IDoc *inDoc); - virtual ~CTimelineTreeLayout(); - - // CControl - void OnMouseUp(CPt inPoint, Qt::KeyboardModifiers inFlags) override; - void SetSize(CPt inSize) override; - - virtual void AddRow(CTimelineRow *inRow); - - /// Returns a filter object so that filter preferences can be set. You must call Filter() in - /// order to apply the filters once you make your changes. - CFilter *GetFilter() { return &m_Filter; } - void Filter(); - - void OnScroll(CScroller *inScroller, CPt inScrollAmount) override; - void SetScrollPositionY(CScroller *inSource, long inPositionY, bool inAbsolute = true); - - void ClearRows(); - - void ResetFilter(); - CRct GetVisibleArea(); - void RecalcLayout(); - -protected: - CFilter m_Filter; - CFilterToolbar - *m_FilterToolbar; ///< Control at the top of the timeline containing filter buttons. - CToggleToolbar - *m_ToggleToolbar; ///< Control at the top containing a header for the toggle column. - - CScroller *m_ColorScroller; - CFlowLayout *m_ColorList; - CColorBlankControl *m_ColorBlankControl; - - CScroller *m_ToggleScroller; - CFlowLayout *m_ToggleList; - CToggleBlankControl *m_ToggleBlankControl; - - CScroller *m_TreeScroller; - CFlowLayout *m_TreeList; - CTreeBlankControl *m_TreeBlankControl; - - TTimelineRowList m_Rows; - CTimelineControl *m_TimelineControl; ///< Parent control of this control - - bool - m_IsScrolling; ///< Flag to not process onScroll that was triggered from a previous onScroll -}; -#endif // INCLUDED_TIMELINE_TREE_LAYOUT_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineUIFactory.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineUIFactory.cpp index e4ab15f5..32d3958e 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineUIFactory.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineUIFactory.cpp @@ -31,9 +31,6 @@ #include "StateRow.h" #include "SlideRow.h" #include "PropertyRow.h" -#include "SlideRowUI.h" -#include "StateRowUI.h" -#include "PropertyRowUI.h" #include "Bindings/ITimelineItemProperty.h" @@ -60,9 +57,7 @@ CPropertyRow *TimelineUIFactory::createPropertyRow(CBaseStateRow *parentRow, ITimelineItemProperty *inTimelineItemPropertyBinding) { auto propertyRow = new CPropertyRow(inTimelineItemPropertyBinding, parentRow); - createRowUI(propertyRow, parentRow); - parentRow->AddPropertyRow(propertyRow, nextRow); inTimelineItemPropertyBinding->Bind(propertyRow); return propertyRow; @@ -72,22 +67,8 @@ CStateRow *TimelineUIFactory::createStateRow(CBaseStateRow *parentRow, ITimelineItemBinding *inTimelineItem) { auto stateRow = new CStateRow(parentRow); - auto stateRowUI = createRowUI(stateRow, parentRow); - Q_ASSERT(stateRowUI); + stateRow->Initialize(inTimelineItem); - CAbstractTimelineRowUI *parentUiRow =nullptr; - ISnappingListProvider *snappingListProvider = nullptr; - do { - parentUiRow = m_uiRows.value(parentRow, nullptr); - if (parentUiRow) { - snappingListProvider = parentUiRow->GetSnappingListProvider(); - parentRow = dynamic_cast<CBaseStateRow*>(parentRow->GetParentRow()); - } - } while (parentUiRow && !snappingListProvider); - if (parentUiRow) { - Q_ASSERT(snappingListProvider); - stateRowUI->SetSnappingListProvider(snappingListProvider); - } return stateRow; } @@ -96,35 +77,12 @@ CSlideRow *TimelineUIFactory::createSlideRow(CBaseStateRow *parentRow, ITimelineItemBinding *inTimelineItem) { auto slideRow = new CSlideRow(parentRow); - auto slideRowUI = createRowUI(slideRow, parentRow); - Q_ASSERT(slideRowUI); + slideRow->Initialize(inTimelineItem); - CAbstractTimelineRowUI *parentUiRow = m_uiRows.value(parentRow, nullptr); - if (parentUiRow) - slideRowUI->SetSnappingListProvider(parentUiRow->GetSnappingListProvider()); return slideRow; } -CAbstractTimelineRowUI *TimelineUIFactory::createRowUI(CTimelineRow *row, CTimelineRow *parentRow) -{ - CAbstractTimelineRowUI *parentUiRow = m_uiRows.value(parentRow, nullptr); - CAbstractTimelineRowUI *uiRow = nullptr; - if (auto castedRow = qobject_cast<CSlideRow *>(row)) { - uiRow = new CSlideRowUI(castedRow, parentUiRow); - } else if (auto castedRow = qobject_cast<CStateRow *>(row)) { - uiRow = new CStateRowUI(castedRow, parentUiRow); - } else if (auto castedRow = qobject_cast<CPropertyRow *>(row)) { - uiRow = new CPropertyRowUI(castedRow, parentUiRow); - } - - if (uiRow) { - m_uiRows[row] = uiRow; - } - - return uiRow; -} - void TimelineUIFactory::deleteRowUI(CTimelineRow *row) { auto it = m_uiRows.find(row); diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp index da51d34d..b1821235 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp @@ -269,7 +269,7 @@ void TimelineView::OnActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, in m_translationManager->Clear(); m_activeSlide = inSlide; - + qDebug() << "OnActiveSlide"; auto *theSlideSystem = GetDoc()->GetStudioSystem()->GetSlideSystem(); auto theSlideInstance = theSlideSystem->GetSlideInstance(inSlide); diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.cpp b/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.cpp deleted file mode 100644 index c9ffff8e..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "ToggleBlankControl.h" -#include "Renderer.h" -#include "StudioPreferences.h" - -//============================================================================= -/** - * Constructor - */ -CToggleBlankControl::CToggleBlankControl(CColor inColor) - : CBlankControl(inColor) -{ -} - -//============================================================================= -/** - * Destructor - */ -CToggleBlankControl::~CToggleBlankControl() -{ -} - -//============================================================================= -/** - * Handles custom drawing of the blank control underneath the tree control - * on the timeline palette. - */ -void CToggleBlankControl::Draw(CRenderer *inRenderer) -{ - CBlankControl::Draw(inRenderer); - - // Draw the line on the right side of this control - CPt theSize = GetSize(); - inRenderer->PushPen(CStudioPreferences::GetButtonShadowColor()); - inRenderer->MoveTo(theSize.x - 1, 0); - inRenderer->LineTo(theSize.x - 1, theSize.y - 1); - inRenderer->PopPen(); - - // Draw the line on the left side of this control - inRenderer->PushPen(CStudioPreferences::GetPropertyFloorColor()); - inRenderer->MoveTo(CPt(0, 0)); - inRenderer->LineTo(CPt(0, theSize.y - 1)); - inRenderer->PopPen(); - - // Draw the highlight - inRenderer->PushPen(CStudioPreferences::GetButtonHighlightColor()); - inRenderer->MoveTo(CPt(1, 0)); - inRenderer->LineTo(CPt(1, theSize.y - 1)); - inRenderer->PopPen(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.h b/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.h deleted file mode 100644 index ac07f7db..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleBlankControl.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TOGGLE_BLANK_CONTROL_H -#define INCLUDED_TOGGLE_BLANK_CONTROL_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "BlankControl.h" - -//============================================================================== -// Forwards -//============================================================================== -class CRenderer; - -//============================================================================= -/** - * Extends the blank control to draw items specific to the tree view side of the - * timeline palette. - */ -class CToggleBlankControl : public CBlankControl -{ -public: - CToggleBlankControl(CColor inColor = CStudioPreferences::GetBaseColor()); - virtual ~CToggleBlankControl(); - void Draw(CRenderer *inRenderer) override; - -protected: -}; - -#endif // INCLUDED_TOGGLE_BLANK_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleControl.cpp b/src/Authoring/Studio/Palettes/Timeline/ToggleControl.cpp deleted file mode 100644 index 845b8fc6..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleControl.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "stdafx.h" - -#include "ToggleControl.h" -#include "Renderer.h" -#include "StateRow.h" -#include "StateRowUI.h" -#include "BlankControl.h" -#include "HotKeys.h" -#include "TimelineUIFactory.h" -#include "AbstractTimelineRowUI.h" - -#include "Bindings/ITimelineItemBinding.h" - -CToggleControl::CToggleControl(CStateRowUI *inStateRowUI, ITimelineItemBinding *inTimelineItemBinding) - : CBlankToggleControl(inStateRowUI) - , m_TimelineItemBinding(inTimelineItemBinding) -{ - long theLeftOffset = 4; - - m_Shy = new CToggleButton(); - m_Shy->SetName("ShyToggle"); - m_Shy->SetUpImage("Toggle-Empty.png"); - m_Shy->SetDownImage("Toggle-Shy.png"); - m_Shy->SetPosition(CPt(theLeftOffset, 0)); - CPt theShySize = m_Shy->GetSize(); - - m_Visible = new CToggleButton(); - m_Visible->SetName("VisibilityToggle"); - m_Visible->SetUpImage("Toggle-Empty.png"); - m_Visible->SetDownImage("Toggle-HideShow.png"); - m_Visible->SetUpDisabledImage("Toggle-Empty.png"); // show empty if disabled - m_Visible->SetDisabledImage("Toggle-HideShow-disabled.png"); - m_Visible->SetPosition(CPt(theShySize.x + 7, 0)); - CPt theVisibleSize = m_Visible->GetSize(); - - m_Locked = new CToggleButton(); - m_Locked->SetName("LockToggle"); - m_Locked->SetUpImage("Toggle-Empty.png"); - m_Locked->SetDownImage("Toggle-Lock.png"); - m_Locked->SetPosition(CPt(theVisibleSize.x + theShySize.x + 10, 0)); - CPt theLockedSize = m_Locked->GetSize(); - - AddChild(m_Shy); - AddChild(m_Visible); - AddChild(m_Locked); - - SetAbsoluteSize(CPt(theShySize.x + theVisibleSize.x + theLockedSize.x + 1, theShySize.y)); - - // Button down listeners - QObject::connect(m_Shy,&CToggleButton::SigToggle, - std::bind(&CToggleControl::OnShyClicked, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_Visible,&CToggleButton::SigToggle, - std::bind(&CToggleControl::OnVisibleClicked, this, - std::placeholders::_1, std::placeholders::_2)); - QObject::connect(m_Locked,&CToggleButton::SigToggle, - std::bind(&CToggleControl::OnLockClicked, this, - std::placeholders::_1, std::placeholders::_2)); - - - - ITimelineItem *theTimelineItem = m_TimelineItemBinding->GetTimelineItem(); - // Initial toggle state of the eye visibility button - // Note GetViewToggleOff==FALSE means visible - m_Visible->SetToggleState(theTimelineItem->IsVisible()); - - // Initial toggle state of the button - m_Locked->SetToggleState(theTimelineItem->IsLocked()); - - // Initial toggle state of the button - m_Shy->SetToggleState(theTimelineItem->IsShy()); - - // sk - if anything, this should be checked in the data model level, not here. - // The tri-state (on, off, dim) of visibility depends on two bools: - // GetViewToggleOff and IsEnabled. Ensure that any bogus 4th permutation - // is detected ASAP - // ASSERT( !inStateRow->GetState( )->GetViewToggleOff( ) || - // !inStateRow->GetState( )->IsEnabled( ) ); -} - -CToggleControl::~CToggleControl() -{ - delete m_Shy; - delete m_Visible; - delete m_Locked; -} - -//============================================================================== -/** - * Handles clicking on the Shy button. Toggles the shy state on the asset. Shy - * objects can be filtered out of the timeline. - */ -void CToggleControl::OnShyClicked(CToggleButton *, CToggleButton::EButtonState inButtonState) -{ - m_TimelineItemBinding->GetTimelineItem()->SetShy(inButtonState - == CToggleButton::EBUTTONSTATE_DOWN); - - m_StateRow->Filter(*m_StateRow->GetFilter()); - CTimelineRow *theParentRow = m_StateRow->GetParentRow(); - if (theParentRow != nullptr) { - auto parentRowUI = TimelineUIFactory::instance()->uiForRow(theParentRow); - parentRowUI->OnChildVisibilityChanged(); - } -} - -//============================================================================== -/** - * Handles clicking on the Visible button. Toggles the Visible state on the asset. - */ -void CToggleControl::OnVisibleClicked(CToggleButton *inButton, - CToggleButton::EButtonState inButtonState) -{ - Q_UNUSED(inButton); - - m_TimelineItemBinding->GetTimelineItem()->SetVisible(inButtonState - == CToggleButton::EBUTTONSTATE_DOWN); - m_StateRow->Filter(*m_StateRow->GetFilter()); -} - -//============================================================================== -/** - * Handles clicking on the Lock button. Toggles the Lock state on the asset. - */ -void CToggleControl::OnLockClicked(CToggleButton *inButton, - CToggleButton::EButtonState inButtonState) -{ - Q_UNUSED(inButton); - - m_TimelineItemBinding->GetTimelineItem()->SetLocked(inButtonState - == CToggleButton::EBUTTONSTATE_DOWN); - m_StateRow->Filter(*m_StateRow->GetFilter()); -} - -//============================================================================== -/** - * Refreshes the state of this control accd to the asset state - */ -void CToggleControl::Refresh() -{ - CBlankToggleControl::Refresh(); - - ITimelineItem *theTimelineItem = m_TimelineItemBinding->GetTimelineItem(); - m_Shy->SetToggleState(theTimelineItem->IsShy()); - m_Locked->SetToggleState(theTimelineItem->IsLocked()); - - bool theEnabled = m_TimelineItemBinding->IsVisibleEnabled(); - m_Visible->SetEnabled(theEnabled); - if (theEnabled) // only valid to update this if the enabled flag is true. - m_Visible->SetToggleState(theTimelineItem->IsVisible()); - - this->Invalidate(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleControl.h b/src/Authoring/Studio/Palettes/Timeline/ToggleControl.h deleted file mode 100644 index 978b1954..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleControl.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TOGGLE_CONTROL_H -#define INCLUDED_TOGGLE_CONTROL_H 1 - -#pragma once - -#include "BlankToggleControl.h" -#include "ToggleButton.h" - -class CStateRowUI; -class CBlankControl; -class ITimelineItemBinding; - -class CToggleControl : public CBlankToggleControl -{ -public: - CToggleControl(CStateRowUI *inStateRow, ITimelineItemBinding *inTimelineItemBinding); - virtual ~CToggleControl(); - - void OnShyClicked(CToggleButton *inButton, CToggleButton::EButtonState inState); - void OnVisibleClicked(CToggleButton *inButton, CToggleButton::EButtonState inState); - void OnLockClicked(CToggleButton *inButton, CToggleButton::EButtonState inState); - - void Refresh() override; - -protected: - CToggleButton *m_Shy; - CToggleButton *m_Visible; - CToggleButton *m_Locked; - - ITimelineItemBinding *m_TimelineItemBinding; -}; -#endif // INCLUDED_TOGGLE_CONTROL_H diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.cpp b/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.cpp deleted file mode 100644 index da95d447..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== - -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== - -#include "ToggleToolbar.h" -#include "Renderer.h" -#include "StudioPreferences.h" -#include "TimelineTreeLayout.h" - -//============================================================================= -/** - * Constructor - */ -CToggleToolbar::CToggleToolbar(CTimelineTreeLayout *inTreeLayout) - : CFlowLayout(new CBlankControl(CStudioPreferences::GetTopRowColor())) -{ - m_TreeLayout = inTreeLayout; - - m_Color = CStudioPreferences::GetBaseColor(); - - SetFlowDirection(FLOW_HORIZONTAL); - SetAlignment(ALIGN_TOP, ALIGN_LEFT); - SetLeftMargin(1); - - CProceduralButton<CToggleButton>::SBorderOptions theBorderOptions(false, false, false, false); - - m_FltrShyBtn = new CProceduralButton<CToggleButton>(); - m_FltrShyBtn->SetUpImage("Toggle-Shy.png"); - m_FltrShyBtn->SetDownImage("Toggle-Shy.png"); - m_FltrShyBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrShyBtn->SetCenterImage(true, true); - m_FltrShyBtn->SetAbsoluteSize(CPt(20, 20)); - m_FltrShyBtn->SetTooltipText(QObject::tr("Hide shy objects")); - m_FltrShyBtn->SetFillStyleUp(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - m_FltrShyBtn->SetFillStyleDown(CProceduralButton<CToggleButton>::EFILLSTYLE_FLOOD); - m_FltrShyBtn->SetFillStyleOver(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - QObject::connect(m_FltrShyBtn,&CToggleButton::SigToggle, - std::bind(&CToggleToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - AddChild(m_FltrShyBtn); - m_FltrShyBtn->SetToggleState(false); - - m_FltrVisibleBtn = new CProceduralButton<CToggleButton>(); - m_FltrVisibleBtn->SetUpImage("filter-toggle-eye-up.png"); - m_FltrVisibleBtn->SetDownImage("filter-toggle-eye-down.png"); - m_FltrVisibleBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrVisibleBtn->SetCenterImage(true, true); - m_FltrVisibleBtn->SetAbsoluteSize(CPt(20, 20)); - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Hide inactive objects")); - m_FltrVisibleBtn->SetFillStyleUp(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - m_FltrVisibleBtn->SetFillStyleDown(CProceduralButton<CToggleButton>::EFILLSTYLE_FLOOD); - m_FltrVisibleBtn->SetFillStyleOver(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - QObject::connect(m_FltrVisibleBtn,&CToggleButton::SigToggle, - std::bind(&CToggleToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - AddChild(m_FltrVisibleBtn); - m_FltrVisibleBtn->SetToggleState(false); - - m_FltrLockBtn = new CProceduralButton<CToggleButton>(); - m_FltrLockBtn->SetUpImage("Toggle-Lock.png"); - m_FltrLockBtn->SetDownImage("Toggle-Lock.png"); - m_FltrLockBtn->SetBorderVisibilityAll(theBorderOptions); - m_FltrLockBtn->SetCenterImage(true, true); - m_FltrLockBtn->SetAbsoluteSize(CPt(20, 20)); - m_FltrLockBtn->SetTooltipText(QObject::tr("Hide locked objects")); - m_FltrLockBtn->SetFillStyleUp(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - m_FltrLockBtn->SetFillStyleDown(CProceduralButton<CToggleButton>::EFILLSTYLE_FLOOD); - m_FltrLockBtn->SetFillStyleOver(CProceduralButton<CToggleButton>::EFILLSTYLE_NONE); - QObject::connect(m_FltrLockBtn,&CToggleButton::SigToggle, - std::bind(&CToggleToolbar::OnButtonToggled, this, - std::placeholders::_1, std::placeholders::_2)); - AddChild(m_FltrLockBtn); - m_FltrLockBtn->SetToggleState(false); -} - -//============================================================================= -/** - * Destructor - */ -CToggleToolbar::~CToggleToolbar() -{ - delete m_FltrShyBtn; - delete m_FltrVisibleBtn; - delete m_FltrLockBtn; -} - -//============================================================================= -/** - * Fills in the background color and highlighting for this control. - */ -void CToggleToolbar::Draw(CRenderer *inRenderer) -{ - CRct theRect(0, 0, GetSize().x, GetSize().y - 1); - inRenderer->FillSolidRect(theRect, m_Color); - CFlowLayout::Draw(inRenderer); -} - -//============================================================================= -/** - * Handles turning a filter on or off in response to a button being pressed. - * @param inButton button that generated the event - * @param inState new state of the button after being toggled - */ -void CToggleToolbar::OnButtonToggled(CToggleButton *inButton, CButtonControl::EButtonState inState) -{ - bool theFilterNeedsApplied = (inState == CButtonControl::EBUTTONSTATE_UP); - - if (inButton == m_FltrShyBtn) - FilterShy(theFilterNeedsApplied); - else if (inButton == m_FltrVisibleBtn) - FilterVisible(theFilterNeedsApplied); - else if (inButton == m_FltrLockBtn) - FilterLocked(theFilterNeedsApplied); -} - -//============================================================================= -/** - * Turns filtering on and off for shy objects. - * @param inFilter true to filter shy objects out of the timeline, false to show - * shy objects in the timeline. - */ -void CToggleToolbar::FilterShy(bool inFilter) -{ - if (inFilter) - m_FltrShyBtn->SetTooltipText(QObject::tr("Hide shy objects")); - else - m_FltrShyBtn->SetTooltipText(QObject::tr("Show shy objects")); - - m_TreeLayout->GetFilter()->SetShy(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for visible objects. - * @param inFilter true to filter visible objects out of the timeline, false to show - * visible objects in the timeline. - */ -void CToggleToolbar::FilterVisible(bool inFilter) -{ - if (inFilter) - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Hide inactive objects")); - else - m_FltrVisibleBtn->SetTooltipText(QObject::tr("Show inactive objects")); - - m_TreeLayout->GetFilter()->SetVisible(inFilter); - m_TreeLayout->Filter(); -} - -//============================================================================= -/** - * Turns filtering on and off for locked objects. - * @param inFilter true to filter locked objects out of the timeline, false to show - * locked objects in the timeline. - */ -void CToggleToolbar::FilterLocked(bool inFilter) -{ - if (inFilter) - m_FltrLockBtn->SetTooltipText(QObject::tr("Hide locked objects")); - else - m_FltrLockBtn->SetTooltipText(QObject::tr("Show locked objects")); - - m_TreeLayout->GetFilter()->SetLocked(inFilter); - m_TreeLayout->Filter(); -} diff --git a/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.h b/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.h deleted file mode 100644 index f3685af4..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/ToggleToolbar.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== - -#ifndef INCLUDED_TOGGLE_TOOLBAR_H -#define INCLUDED_TOGGLE_TOOLBAR_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== - -#include "FlowLayout.h" -#include "ProceduralButton.h" -#include "ToggleButton.h" - -//============================================================================== -// Forwards -//============================================================================== - -class CRenderer; -class CTimelineTreeLayout; - -//============================================================================= -/** - * Control at the top of the time display and a header for the toggle column. - */ -class CToggleToolbar : public CFlowLayout -{ -public: - CToggleToolbar(CTimelineTreeLayout *inTreeLayout); - virtual ~CToggleToolbar(); - void Draw(CRenderer *inRenderer) override; - - void FilterShy(bool inFilter); - void FilterVisible(bool inFilter); - void FilterLocked(bool inFilter); - void OnButtonToggled(CToggleButton *inButton, CToggleButton::EButtonState inState); - -protected: - CProceduralButton<CToggleButton> *m_FltrShyBtn; - CProceduralButton<CToggleButton> *m_FltrVisibleBtn; - CProceduralButton<CToggleButton> *m_FltrLockBtn; - CTimelineTreeLayout *m_TreeLayout; - CColor m_Color; -}; - -#endif // INCLUDED_TOGGLE_TOOLBAR_H diff --git a/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.cpp b/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.cpp deleted file mode 100644 index b49eabb5..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//============================================================================== -// Prefix -//============================================================================== -#include "stdafx.h" - -//============================================================================== -// Includes -//============================================================================== -#include "TreeBlankControl.h" -#include "Renderer.h" - -//============================================================================= -/** - * Constructor - */ -CTreeBlankControl::CTreeBlankControl(CColor inColor) - : CBlankControl(inColor) - , m_LeftEdgeOffset(0) -{ -} - -//============================================================================= -/** - * Destructor - */ -CTreeBlankControl::~CTreeBlankControl() -{ -} - -//============================================================================= -/** - * Handles custom drawing of the blank control underneath the tree control - * on the timeline palette. - */ -void CTreeBlankControl::Draw(CRenderer *inRenderer) -{ - CBlankControl::Draw(inRenderer); - - // Draw the highlight on the left side of this control - CPt theSize = GetSize(); - inRenderer->PushPen(CStudioPreferences::GetButtonHighlightColor()); - inRenderer->MoveTo(CStudioPreferences::GetRowSize() + m_LeftEdgeOffset, 0); - inRenderer->LineTo(CStudioPreferences::GetRowSize() + m_LeftEdgeOffset, theSize.y - 1); - inRenderer->PopPen(); -} - -//============================================================================= -/** - * xxx - */ -void CTreeBlankControl::SetVisiblePositionX(long inPosition) -{ - m_LeftEdgeOffset = inPosition; -}
\ No newline at end of file diff --git a/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.h b/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.h deleted file mode 100644 index 0d0df3ab..00000000 --- a/src/Authoring/Studio/Palettes/Timeline/TreeBlankControl.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2002 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef INCLUDED_TREE_BLANK_CONTROL_H -#define INCLUDED_TREE_BLANK_CONTROL_H 1 - -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "BlankControl.h" - -//============================================================================== -// Forwards -//============================================================================== -class CRenderer; - -//============================================================================= -/** - * Extends the blank control to draw items specific to the tree view side of the - * timeline palette. - */ -class CTreeBlankControl : public CBlankControl -{ -public: - CTreeBlankControl(CColor inColor = CStudioPreferences::GetBaseColor()); - virtual ~CTreeBlankControl(); - void Draw(CRenderer *inRenderer) override; - void SetVisiblePositionX(long inPosition); - -protected: - long m_LeftEdgeOffset; ///< Visibility offset of the left edge in case timeline is scrolled - ///horizontally -}; - -#endif // INCLUDED_TREE_BLANK_CONTROL_H |