summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Timeline/PropertyRow.cpp
blob: 986d8326c647d88b04a122cce27964deae930ae3 (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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/****************************************************************************
**
** 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 "PropertyRow.h"
#include "TimelineControl.h"
#include "PropertyColorControl.h"
#include "PropertyToggleControl.h"
#include "PropertyTreeControl.h"
#include "PropertyTimebarRow.h"
#include "BlankControl.h"
#include "StudioPreferences.h"
#include "StateRow.h"
#include "Bindings/ITimelineItemProperty.h"

//=============================================================================
/**
 * Create a property row for inProperty.
 * @param inProperty the property that this is displaying.
 */
CPropertyRow::CPropertyRow(ITimelineItemProperty *inProperty)
    : m_Highlighted(false)
    , m_DetailedView(false)
    , m_TimeRatio(0.0f)
    , m_Property(inProperty)
{
    m_IsViewable = true;

    m_TreeControl = new CPropertyTreeControl(this);
    m_ToggleControl = new CPropertyToggleControl(this);
    m_TimebarRow = new CPropertyTimebarRow(this);

    m_PropertyColorControl = new CPropertyColorControl(this);
    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" );
}

CPropertyRow::~CPropertyRow()
{
    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 *CPropertyRow::GetColorControl()
{
    return m_PropertyColorControl;
}

//=============================================================================
/**
 * Get the tree control object for this row.
 * @return the tree control object for this row.
 */
CControl *CPropertyRow::GetTreeControl()
{
    return m_TreeControl;
}

//=============================================================================
/**
 * Get the toggle control object for this row.
 * @return the toggle control object for this row.
 */
CControl *CPropertyRow::GetToggleControl()
{
    return m_ToggleControl;
}

//=============================================================================
/**
 * Get the timebar control for this row.
 * @return the timebar control for this row.
 */
CControl *CPropertyRow::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 CPropertyRow::SetIndent(long inIndent)
{
    m_TreeControl->SetIndent(inIndent);
}

//=============================================================================
/**
 * Notification from one of the child controls that the mouse just entered.
 * This is used to handle the highlighting of the entire row.
 */
void CPropertyRow::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 CPropertyRow::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 CPropertyRow::OnMouseDoubleClick()
{
    SetDetailedView(!m_DetailedView);
}

//=============================================================================
/**
 * 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 CPropertyRow::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();
}

//=============================================================================
/**
 * Filter this property.
 * This controls whether or not this row should be displayed. The filter will
 * be stored and used for future operations that may change whether or not
 * this should be visible.
 * @param inFilter the filter to filter on.
 * @param inFilterChildren true if the call is recursive.
 */
void CPropertyRow::Filter(const CFilter &inFilter, bool inFilterChildren /*= true*/)
{
    Q_UNUSED(inFilterChildren);

    m_Filter = inFilter;

    bool theVisibleFlag = inFilter.Filter(m_Property);
    m_TreeControl->SetVisible(theVisibleFlag);
    m_TimebarRow->SetVisible(theVisibleFlag);
    m_ToggleControl->SetVisible(theVisibleFlag);
    m_PropertyColorControl->SetVisible(theVisibleFlag);
    m_IsViewable = theVisibleFlag;
}

//=============================================================================
/**
 * @return true if this property is animated and is not currently being filtered out
 */
bool CPropertyRow::IsViewable() const
{
    return m_Filter.GetProperties();
}

//=============================================================================
/**
 * Call from one of the child controls to select this object.
 * Currently this just causes the Asset to be selected.
 */
void CPropertyRow::Select(bool inIsShiftKeyPressed /*= false */)
{
    m_Property->SetSelected();

    if (inIsShiftKeyPressed)
        m_TimebarRow->SelectAllKeys();
    else
        m_Property->ClearKeySelection();
}

ISnappingListProvider *CPropertyRow::GetSnappingListProvider() const
{
    return &m_TimebarRow->GetSnappingListProvider();
}

void CPropertyRow::SetSnappingListProvider(ISnappingListProvider *inProvider)
{
    m_TimebarRow->SetSnappingListProvider(inProvider);
}

//=============================================================================
/**
 * Retrieves the background color for the row based upon the type of asset
 * passed in.  Overridden so that properties can have a different background
 * color than their parent asset does.
 * @return background color to use for this row
 */
::CColor CPropertyRow::GetTimebarBackgroundColor()
{
    return CStudioPreferences::GetPropertyBackgroundColor();
}

//=============================================================================
/**
 * Retrieves the background color for the row when the mouse is over the row
 * based upon the type of asset passed in.  Overridden so that properties can
 * have a different highlight background color than their parent asset does.
 * @return background color to use for this row when the mouse is over it
 */
::CColor CPropertyRow::GetTimebarHighlightBackgroundColor()
{
    return CStudioPreferences::GetPropertyMouseOverColor();
}

//=============================================================================
/**
 * Set the amount of time that is represented by a pixel.
 * This modifies the length of this control.
 * @param inTimePerPixel the time per pixel.
 */
void CPropertyRow::SetTimeRatio(double inTimeRatio)
{
    m_TimeRatio = inTimeRatio;
    m_TimebarRow->SetTimeRatio(inTimeRatio);
}

//=============================================================================
/**
 * Selects all keyframes of this property that are inside inRect
 *
 * @param inRect theRect to check
 */
void CPropertyRow::SelectKeysInRect(CRct inRect, bool inModifierKeyDown)
{
    CRct theOffsetRect = inRect;
    CRct myRect(CPt(0, 0), m_TimebarRow->GetSize());
    theOffsetRect.Offset(-m_TimebarRow->GetPosition());
    m_TimebarRow->SelectKeysInRect(theOffsetRect, inModifierKeyDown);
}

//=============================================================================
/**
 * 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 CPropertyRow::CommitSelections()
{
    m_TimebarRow->CommitSelections();
}

//=============================================================================
/**
 * Selects all keyframes
 */
void CPropertyRow::SelectAllKeys()
{
    m_TimebarRow->SelectAllKeys();
}

//=============================================================================
/**
 * Deletes keyframes on this property row
 */
void CPropertyRow::DeleteAllKeys()
{
    m_Property->DeleteAllKeys();
    m_TimebarRow->Invalidate();
}

//=============================================================================
/**
 * Sets all the child control enable states
 * @param inEnabled the state to set the controls to
 */
void CPropertyRow::SetEnabled(bool inEnabled)
{
    m_TreeControl->SetEnabled(inEnabled);
    m_ToggleControl->SetEnabled(inEnabled);
    m_PropertyColorControl->SetEnabled(inEnabled);
    m_TimebarRow->SetEnabled(inEnabled);
}

//=============================================================================
/**
 * Callback from the ITimelineProperty.
 */
void CPropertyRow::Refresh()
{
    if (m_TimebarRow->IsVisible())
        m_TimebarRow->SetDirty(true);
}