~zsombi/ubuntu-ui-toolkit/40-visualize-options

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/plugin/uclistitem.cpp

prereq sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
}
48
48
/******************************************************************************
49
49
 * SnapAnimator
 
50
 *
 
51
 * The class handles the animation executed when the ListItemAction panel is
 
52
 * swiped. The animation is executed from the swipe position the mouse/touch is
 
53
 * released to the desired position given in snap(). The action panel is assumed
 
54
 * to be anchored to the ListItem.contentItem left or right, depending on which
 
55
 * action list is swiped in. Therefore the animator only changes the ListItem.contentItem
 
56
 * x coordinate.
 
57
 * The animation is defined by the style.
50
58
 */
51
59
UCListItemSnapAnimator::UCListItemSnapAnimator(UCListItem *item)
52
60
    : QObject(item)
59
67
    item = 0;
60
68
}
61
69
 
 
70
/*
 
71
 * Snap the ListItem.contentItem in or out, depending on the position specified
 
72
 * in "to" parameter. If the position is 0, a snap out will be executed - see
 
73
 * snapOut(). In any other cases a snap in action will be performed - see snapIn().
 
74
 */
62
75
bool UCListItemSnapAnimator::snap(qreal to)
63
76
{
64
77
    if (!item) {
90
103
    return true;
91
104
}
92
105
 
 
106
/*
 
107
 * The function completes a running snap animation.
 
108
 */
93
109
void UCListItemSnapAnimator::complete()
94
110
{
95
111
    QQuickPropertyAnimation *snap = getDefaultAnimation();
98
114
    }
99
115
}
100
116
 
 
117
/*
 
118
 * Snap out is performed when the ListItem.contentItem returns back to its original
 
119
 * X coordinates (0). At this point both leading and trailing action panels will
 
120
 * be disconnected, ascending Flickables will get unlocked (interactive value restored
 
121
 * to the state before they were locked) and ListItem.contentMoving will be reset.
 
122
 */
101
123
void UCListItemSnapAnimator::snapOut()
102
124
{
103
125
    if (senderSignalIndex() >= 0) {
112
134
        // no need to listen flickables any longer
113
135
        listItem->attachedProperties->listenToRebind(item, false);
114
136
    }
115
 
    // disconnect actions - FIXME this will be used later
 
137
    // disconnect actions
116
138
    listItem->grabPanel(listItem->leadingActions, false);
117
139
    listItem->grabPanel(listItem->trailingActions, false);
118
 
    // set contentMoved to false - FIXME used later
 
140
    // set contentMoved to false
119
141
    listItem->setContentMoving(false);
120
142
}
121
143
 
 
144
/*
 
145
 * Snap in only resets the ListItem.contentMoving property, but will keep leading/trailing
 
146
 * actions connected as well as all ascendant Flickables locked (interactive = false).
 
147
 */
122
148
void UCListItemSnapAnimator::snapIn()
123
149
{
124
150
    if (senderSignalIndex() >= 0) {
126
152
        QQuickAbstractAnimation *snap = getDefaultAnimation();
127
153
        QObject::disconnect(snap, 0, 0, 0);
128
154
    }
 
155
    // turn content moving off
129
156
    UCListItemPrivate *listItem = UCListItemPrivate::get(item);
130
157
    listItem->setContentMoving(false);
131
158
}
132
159
 
 
160
/*
 
161
 * Returns the animation specified by the style.
 
162
 */
133
163
QQuickPropertyAnimation *UCListItemSnapAnimator::getDefaultAnimation()
134
164
{
135
165
    UCListItemPrivate *listItem = UCListItemPrivate::get(item);