summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Timeline/Bindings/UICDMTimelineItemProperty.h
blob: ddd4b64728d9c1abd200663f2c0e5154ea6d9720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************************
**
** 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_UICDMTIMELINE_ITEM_PROPERTY_H
#define INCLUDED_UICDMTIMELINE_ITEM_PROPERTY_H 1

#pragma once

#include "ITimelineItemProperty.h"
#include "UICDMTimelineKeyframe.h"
#include "UICDMTimeline.h"
#include "UICDMPropertyDefinition.h"

class CTimelineTranslationManager;
class CCmdDataModelSetKeyframeValue;
class CUICDMTimelineItemBinding;

//=============================================================================
/**
 * A data model item's property.
 * Typically only animated properties show up in the Timeline.
 */
//=============================================================================
class CUICDMTimelineItemProperty : public ITimelineItemProperty
{
public:
    CUICDMTimelineItemProperty(CTimelineTranslationManager *inTransMgr,
                               UICDM::CUICDMPropertyHandle inPropertyHandle,
                               UICDM::CUICDMInstanceHandle inInstance);
    virtual ~CUICDMTimelineItemProperty();

    // ITimelineProperty
    Q3DStudio::CString GetName() const override;
    bool IsMaster() const override;
    UICDM::TDataTypePair GetType() const override;
    float GetMaximumValue() const override;
    float GetMinimumValue() const override;
    void SetSelected() override;
    void ClearKeySelection() override;
    void DeleteAllKeys() override;
    ITimelineKeyframesManager *GetKeyframesManager() const override;
    IKeyframe *GetKeyframeByTime(long inTime) const override;
    IKeyframe *GetKeyframeByIndex(long inIndex) const override;
    long GetKeyframeCount() const override;
    long GetChannelCount() const override;
    float GetChannelValueAtTime(long inChannelIndex, long inTime) override;
    void SetChannelValueAtTime(long inChannelIndex, long inTime, float inValue) override;
    long OffsetSelectedKeyframes(long inOffset) override;
    void CommitChangedKeyframes() override;
    void OnEditKeyframeTime(long inCurrentTime, long inObjectAssociation) override;
    bool IsDynamicAnimation() override;
    // IKeyframeSelector
    void SelectKeyframes(bool inSelected, long inTime = -1) override;

    void Bind(CPropertyRow *inRow) override;
    void Release() override;
    CPropertyRow *GetRow() override;

    bool RefreshKeyframe(UICDM::CUICDMKeyframeHandle inKeyframe,
                         ETimelineKeyframeTransaction inTransaction);
    IKeyframe *GetKeyframeByHandle(UICDM::CUICDMKeyframeHandle inKeyframe);
    void DoSelectKeyframes(bool inSelected, long inTime, bool inParentTriggered,
                           CUICDMTimelineItemBinding *inParent);

    void RefreshKeyFrames(void);

protected:
    void InitializeCachedVariables(UICDM::CUICDMInstanceHandle inInstance);
    bool CreateKeyframeIfNonExistent(UICDM::CUICDMKeyframeHandle inKeyframe,
                                     UICDM::CUICDMAnimationHandle inOwningAnimation);
    void OnPropertyLinkStatusChanged(UICDM::CUICDMSlideHandle inSlide,
                                     UICDM::CUICDMInstanceHandle inInstance,
                                     UICDM::CUICDMPropertyHandle inProperty);
    void CreateKeyframes();
    void ReleaseKeyframes();

protected:
    typedef std::vector<CUICDMTimelineKeyframe *> TKeyframeList;

    CPropertyRow *m_Row;
    UICDM::CUICDMInstanceHandle m_InstanceHandle;
    UICDM::CUICDMPropertyHandle m_PropertyHandle;
    CTimelineTranslationManager *m_TransMgr;
    std::vector<UICDM::CUICDMAnimationHandle> m_AnimationHandles;
    TKeyframeList m_Keyframes;
    CCmdDataModelSetKeyframeValue
        *m_SetKeyframeValueCommand; // for merging modifying keyframe values via graph
    UICDM::TDataTypePair m_Type;
    Q3DStudio::CString m_Name;
    std::vector<std::shared_ptr<UICDM::ISignalConnection>> m_Signals;
};

#endif // INCLUDED_UICDMTIMELINE_ITEM_PROPERTY_H