- // no photo, just reset selection
- DataPoint currPoint = getCurrentPoint();
- if (currPoint != null && currPoint.getPhoto() == null) {
- _selection.selectPhotoAndPoint(-1, _selection.getCurrentPointIndex()); // keep point
+ // no photo, but maybe need to deselect point
+ if (currPoint != null && currPoint.getPhoto() != null) {
+ pointIndex = -1;
+ }
+ }
+ // Has the new point got an audio file?
+ DataPoint selectedPoint = _track.getPoint(pointIndex);
+ int audioIndex = _selection.getCurrentAudioIndex();
+ if (selectedPoint != null) {
+ if (selectedPoint.getAudio() != null) audioIndex = _audioList.getAudioIndex(selectedPoint.getAudio());
+ }
+ else {
+ if (selectedPoint != currPoint && currPoint.getAudio() != null) {audioIndex = -1;}
+ }
+ // give to selection object
+ _selection.selectPointPhotoAudio(pointIndex, inPhotoIndex, audioIndex);
+ }
+
+ /**
+ * Select the given audio object and its point if any
+ * @param inAudioIndex index of audio item to select
+ */
+ public void selectAudio(int inAudioIndex)
+ {
+ if (_selection.getCurrentAudioIndex() == inAudioIndex) {return;}
+ // Audio selection takes priority, deselecting point if necessary
+ AudioFile audio = _audioList.getAudio(inAudioIndex);
+ int pointIndex = _selection.getCurrentPointIndex();
+ DataPoint currPoint = getCurrentPoint();
+ if (audio != null)
+ {
+ // Find point object and its index
+ if (audio.isConnected()) {
+ pointIndex = _track.getPointIndex(audio.getDataPoint());