| 146 | } |
| 147 | |
| 148 | UIHandle::Result TrackPanelResizeHandle::Drag |
| 149 | (const TrackPanelMouseEvent &evt, AudacityProject *pProject) |
| 150 | { |
| 151 | auto &tracks = TrackList::Get( *pProject ); |
| 152 | auto theChannel = FindChannel(); |
| 153 | if (!theChannel) |
| 154 | return RefreshCode::Cancelled; |
| 155 | |
| 156 | auto &view = ChannelView::Get(*theChannel); |
| 157 | |
| 158 | if (view.GetMinimized() && mMode == IsResizingBetweenLinkedTracks) |
| 159 | return RefreshCode::Cancelled; |
| 160 | |
| 161 | const wxMouseEvent &event = evt.event; |
| 162 | |
| 163 | int delta = (event.m_y - mMouseClickY); |
| 164 | |
| 165 | // On first drag, jump out of minimized mode. Initial height |
| 166 | // will be height of minimized track. |
| 167 | // |
| 168 | // This used to be in HandleResizeClick(), but simply clicking |
| 169 | // on a resize border would switch the minimized state. |
| 170 | if (view.GetMinimized()) { |
| 171 | auto channels = GetTrack(*theChannel).Channels(); |
| 172 | for (auto pChannel : channels) { |
| 173 | auto &channelView = ChannelView::Get(*pChannel); |
| 174 | channelView.SetExpandedHeight(channelView.GetHeight()); |
| 175 | channelView.SetMinimized(false); |
| 176 | } |
| 177 | |
| 178 | if (channels.size() > 1) { |
| 179 | // Initial values must be reset since they weren't based on the |
| 180 | // minimized heights. |
| 181 | auto &channelView = ChannelView::Get(**channels.begin()); |
| 182 | mInitialUpperTrackHeight = channelView.GetHeight(); |
| 183 | mInitialTrackHeight = channelView.GetHeight(); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | // Common pieces of code for MONO_WAVE_PAN and otherwise. |
| 188 | auto doResizeBelow = [&] (Channel *prev) { |
| 189 | // TODO: more-than-two-channels |
| 190 | |
| 191 | auto &prevView = ChannelView::Get(*prev); |
| 192 | |
| 193 | double proportion = static_cast < double >(mInitialTrackHeight) |
| 194 | / (mInitialTrackHeight + mInitialUpperTrackHeight); |
| 195 | |
| 196 | int newTrackHeight = static_cast < int > |
| 197 | (mInitialTrackHeight + delta * proportion); |
| 198 | |
| 199 | int newUpperTrackHeight = static_cast < int > |
| 200 | (mInitialUpperTrackHeight + delta * (1.0 - proportion)); |
| 201 | |
| 202 | //make sure neither track is smaller than its minimum height |
| 203 | if (newTrackHeight < view.GetMinimizedHeight()) |
| 204 | newTrackHeight = view.GetMinimizedHeight(); |
| 205 | if (newUpperTrackHeight < prevView.GetMinimizedHeight()) |
nothing calls this directly
no test coverage detected