Exemple #1
0
bool FindWnd::Find(int _mode)
{
	bool update = false;
	switch(m_type)
	{
		case TYPE_ITEM_NAME:
			update = FindMediaItem(_mode, false, TakeNameMatch);
		break;
		case TYPE_ITEM_NAME_ALL_TAKES:
			update = FindMediaItem(_mode, true, TakeNameMatch);
		break;
		case TYPE_ITEM_FILENAME:
			update = FindMediaItem(_mode, false, TakeFilenameMatch);
		break;
		case TYPE_ITEM_FILENAME_ALL_TAKES:
			update = FindMediaItem(_mode, true, TakeFilenameMatch);
		break;
		case TYPE_ITEM_NOTES:
			update = FindMediaItem(_mode, false, NULL, ItemNotesMatch);
		break;
		case TYPE_TRACK_NAME:
			update = FindTrack(_mode, TrackNameMatch);
		break;
		case TYPE_TRACK_NOTES:
			update = FindTrack(_mode, TrackNotesMatch);
		break;
		case TYPE_MARKER_REGION:
			update = FindMarkerRegion(_mode);
	}
	return update;
}
Exemple #2
0
// Returns a state constant.
wxAccStatus TrackPanelAx::GetState( int childId, long* state )
{
#if defined(__WXMSW__)
   if( childId > 0 )
   {
      Track *t = FindTrack( childId );

      *state = wxACC_STATE_SYSTEM_FOCUSABLE | wxACC_STATE_SYSTEM_SELECTABLE;
      if (t)
      {
         if( t == mFocusedTrack )
         {
            *state |= wxACC_STATE_SYSTEM_FOCUSED;
         }

         if( t->GetSelected() )
         {
            *state |= wxACC_STATE_SYSTEM_SELECTED;
         }
      }
   }
   else     // childId == wxACC_SELF
   {
      *state = wxACC_STATE_SYSTEM_FOCUSABLE + wxACC_STATE_SYSTEM_FOCUSED;
   }
#endif

#if defined(__WXMAC__)
   *state = wxACC_STATE_SYSTEM_FOCUSABLE | wxACC_STATE_SYSTEM_SELECTABLE;

   if( childId > 0 )
   {
      Track *t = FindTrack( childId );

      if (t)
      {
         if( t == mFocusedTrack )
         {
            *state |= wxACC_STATE_SYSTEM_FOCUSED;
         }

         if( t->GetSelected() )
         {
            *state |= wxACC_STATE_SYSTEM_SELECTED;
         }
      }
   }
#endif

   return wxACC_OK;
}
std::vector<UIHandlePtr> TrackControls::HitTest
(const TrackPanelMouseState &st,
 const AudacityProject *WXUNUSED(project))
{
   // Hits are mutually exclusive, results single

   const wxMouseState &state = st.state;
   const wxRect &rect = st.rect;
   UIHandlePtr result;
   std::vector<UIHandlePtr> results;

   auto pTrack = FindTrack();
   // shared pointer to this:
   auto sThis = pTrack->GetTrackControl();

   if (NULL != (result = CloseButtonHandle::HitTest(
      mCloseHandle, state, rect, this)))
      results.push_back(result);

   if (NULL != (result = MenuButtonHandle::HitTest(
      mMenuHandle, state, rect, sThis)))
      results.push_back(result);

   if (NULL != (result = MinimizeButtonHandle::HitTest(
      mMinimizeHandle, state, rect, this)))
      results.push_back(result);

   if (results.empty()) {
      if (NULL != (result = TrackSelectHandle::HitAnywhere(
         mSelectHandle, pTrack)))
         results.push_back(result);
   }

   return results;
}
static void spinSelectCB(Widget w, SpaceWindow *window, SpinCallbackStruct *cb)
{
    int particleIndex;
    particleIndex = FindTrack((StdHepWindow *)window,
                        cb->event->xbutton.x,cb->event->xbutton.y);
    SelectTrack((StdHepWindow *) window, particleIndex);
}
// Gets the name of the specified object.
wxAccStatus TrackPanelAx::GetName( int childId, wxString* name )
{
#if defined(__WXMSW__)
   if( childId == wxACC_SELF )
   {
      *name = _( "TrackView" );
   }
   else
   {
      Track *t = FindTrack( childId );

      if( t == NULL )
      {
         return wxACC_FAIL;
      }
      else
      {
         *name = t->GetName();
         if( *name == t->GetDefaultName() )
         {
            /* i18n-hint: The %d is replaced by th enumber of the track.*/
            name->Printf(_("Track %d"), TrackNum( t ) );
         }

         // LLL: Remove these during "refactor"
         if( t->GetMute() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               on this track mute is on.*/
            *name->Append( _( " Mute On" ) );
         }
         
         if( t->GetSolo() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               on this track solo is on.*/
            *name->Append( _( " Solo On" ) );
         }
         if( t->GetSelected() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this track is selected.*/
            *name->Append( _( " Select On" ) );
         }
      }
   }

   return wxACC_OK;
#endif

#if defined(__WXMAC__)
   return wxACC_NOT_IMPLEMENTED;
#endif
}
	void LocalCollection::HandleExistingInfos (const QList<MediaInfo>& infos)
	{
		Q_FOREACH (const auto& info, infos)
		{
			const auto& path = info.LocalPath_;
			const auto trackIdx = FindTrack (path);
			const auto trackAlbum = GetTrackAlbum (trackIdx);
			if (!trackAlbum)
			{
				qWarning () << Q_FUNC_INFO
						<< "no album for track"
						<< path;
				continue;
			}

			const auto pos = std::find_if (trackAlbum->Tracks_.begin (), trackAlbum->Tracks_.end (),
					[trackIdx] (decltype (trackAlbum->Tracks_.front ()) track)
						{ return track.ID_ == trackIdx; });
			const auto& track = pos != trackAlbum->Tracks_.end () ?
					*pos :
					Collection::Track ();
			const auto& artist = GetArtist (AlbumID2ArtistID_ [trackAlbum->ID_]);
			if (artist.Name_ == info.Artist_ &&
					trackAlbum->Name_ == info.Album_ &&
					trackAlbum->Year_ == info.Year_ &&
					track.Number_ == info.TrackNumber_ &&
					track.Name_ == info.Title_ &&
					track.Genres_ == info.Genres_)
				continue;

			auto stats = GetTrackStats (path);
			RemoveTrack (path);

			const auto& newArts = Storage_->AddToCollection ({ info });
			HandleNewArtists (newArts);

			const auto newTrackIdx = FindTrack (path);
			stats.TrackID_ = newTrackIdx;
			Storage_->SetTrackStats (stats);
		}
	}
Exemple #7
0
bool AudioView::DClickLabel(wxMouseEvent &event)
{
  VTrack *t = FindTrack(event.m_x, event.m_y, true);
  
  if (t) {
    t->Toggle();
    REDRAW(trackPanel);
  	REDRAW(rulerPanel);
    return true;
  }
  else
    return false;
}
Exemple #8
0
//------------------------------------------------
//	fetch track info, and queue it up for download
//------------------------------------------------
TRef TLSpotify::TSession::DownloadTrack(const TString& Url)
{
	//	lookup track info
	TRef TrackRef = FindTrack( Url );

	//	if that failed, the track (url) doesn't exist
	if ( !TrackRef.IsValid() )
		return TrackRef;

	//	queue up for download
	m_DownloadTracks.AddUnique( TrackRef );

	return TrackRef;
}
	void SyncUnmountableManager::AddFiles (const AddFilesParams& params)
	{
		auto coll = Core::Instance ().GetLocalCollection ();

		const auto& format = params.TCParams_.FormatID_;

		auto syncer = params.Syncer_;
		for (const auto& file : params.Files_)
		{
			const auto trackId = coll->FindTrack (file);
			if (trackId < 0)
				continue;

			const auto trackNumber = coll->GetCollectionModel ()->
					GetTrackData (trackId, LocalCollectionModel::Role::TrackNumber).toInt ();
			const auto& trackTitle = coll->GetCollectionModel ()->
					GetTrackData (trackId, LocalCollectionModel::Role::TrackTitle).toString ();

			const auto album = coll->GetTrackAlbum (trackId);
			if (!album)
				continue;

			const auto& artists = coll->GetAlbumArtists (album->ID_);
			if (artists.isEmpty ())
				continue;

			const auto& artist = coll->GetArtist (artists.at (0));

			syncer->SetFileInfo (file,
					{
						format.isEmpty () ?
							QFileInfo (file).suffix ().toLower () :
							format,
						trackNumber,
						trackTitle,
						artist.Name_,
						album->Name_,
						album->Year_,
						album->CoverPath_,
						QStringList ()
					});

			Source2Params_ [file] = params;
		}

		SyncManagerBase::AddFiles (params.Files_, params.TCParams_);
	}
Exemple #10
0
wxAccStatus TrackPanelAx::GetValue( int WXUNUSED(childId), wxString* WXUNUSED(strValue) )
#endif
{
#if defined(__WXMSW__)
   return wxACC_NOT_IMPLEMENTED;
#endif

#if defined(__WXMAC__)
   if( childId == wxACC_SELF )
   {
      *strValue = _( "TrackView" );
   }
   else
   {
      Track *t = FindTrack( childId );

      if( t == NULL )
      {
         return wxACC_FAIL;
      }
      else
      {
         *strValue = t->GetName();
         if( *strValue == t->GetDefaultName() )
         {
            strValue->Printf(_("Track %d"), TrackNum( t ) );
         }

         // LLL: Remove these during "refactor"
         if( t->GetMute() )
         {
            strValue->Append( _( " Mute On" ) );
         }

         if( t->GetSolo() )
         {
            strValue->Append( _( " Solo On" ) );
         }
         if( t->GetSelected() )
         {
            strValue->Append( _( " Select On" ) );
         }
      }
   }
   return wxACC_OK;
#endif
}
Exemple #11
0
bool AudioView::ClickLabel(wxMouseEvent &event)
{
  VTrack *t = FindTrack(event.m_x, event.m_y, true);

  SelectNone();
  
  if (t) {
	t->selected = true;

	sel0 = 0.0;
	sel1 = t->GetMaxLen();
  }

  REDRAW(trackPanel);
  REDRAW(rulerPanel);
  
  return true;
}
Exemple #12
0
void AudioView::TrackSetCursor(wxMouseEvent &event)
{
  if (event.ButtonDown())
	return;

  wxRect r;

  VTrack *t = FindTrack(event.m_x, event.m_y, false, &r);

  if (t) {
	if (event.m_y >= r.y + r.height - 12 && event.m_y < r.y + r.height)
	  trackPanel->SetCursor(*trackPanel->resizeCursor);
	else
	  trackPanel->SetCursor(*trackPanel->mainCursor);
  }
  else
	trackPanel->SetCursor(*trackPanel->noneCursor);
}
Exemple #13
0
// Gets the name of the specified object.
wxAccStatus TrackPanelAx::GetName( int childId, wxString* name )
{
   if( childId == wxACC_SELF )
   {
      *name = _( "TrackView" );
   }
   else
   {
      Track *t = FindTrack( childId );

      if( t == NULL )
      {
         *name = _( "Track Accessible out of sync" );
         return wxACC_FAIL;
      }
      else
      {
         *name = t->GetName();
         if( *name == t->GetDefaultName() )
         {
            name->Printf(_("Track %d"), TrackNum( t ) );
         }

         // LLL: Remove these during "refactor"
         if( t->GetMute() )
         {
            *name->Append( _( " Mute On" ) );
         }
         
         if( t->GetSolo() )
         {
            *name->Append( _( " Solo On" ) );
         }
         if( t->GetSelected() )
         {
            *name->Append( _( " Select On" ) );
         }
      }
   }

   return wxACC_OK;
}
Exemple #14
0
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
wxAccStatus TrackPanelAx::GetLocation( wxRect& rect, int elementId )
{
   wxRect client;

   if( elementId == wxACC_SELF )
   {
      rect = mTrackPanel->GetRect();
   }
   else
   {
      Track *t = FindTrack( elementId );

      if( t == NULL )
      {
         return wxACC_FAIL;
      }

      rect = mTrackPanel->FindTrackRect( t, true );
   }

   rect.SetPosition( mTrackPanel->GetParent()->ClientToScreen( rect.GetPosition() ) );

   return wxACC_OK;
}
Exemple #15
0
// Returns a state constant.
wxAccStatus TrackPanelAx::GetState( int childId, long* state )
{
  *state = wxACC_STATE_SYSTEM_FOCUSABLE | wxACC_STATE_SYSTEM_SELECTABLE;

   if( childId > 0 )
   {
      Track *t = FindTrack( childId );

      if (t)
      {
         if( t == mFocusedTrack )
         {
            *state |= wxACC_STATE_SYSTEM_FOCUSED;
         }

         if( t->GetSelected() )
         {
            *state |= wxACC_STATE_SYSTEM_SELECTED;
         }
      }
   }

   return wxACC_OK;
}
Exemple #16
0
	void LocalCollection::RemoveTrack (const QString& path)
	{
		const int id = FindTrack (path);
		if (id == -1)
			return;

		auto album = GetTrackAlbum (id);
		try
		{
			Storage_->RemoveTrack (id);
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "error removing track:"
					<< e.what ();
			throw;
		}

		CollectionModel_->RemoveTrack (id);

		Path2Track_.remove (path);
		Track2Path_.remove (id);
		Track2Album_.remove (id);
		PresentPaths_.remove (path);

		if (!album)
			return;

		auto pos = std::remove_if (album->Tracks_.begin (), album->Tracks_.end (),
				[id] (decltype (album->Tracks_.front ()) item) { return item.ID_ == id; });
		album->Tracks_.erase (pos, album->Tracks_.end ());

		if (album->Tracks_.isEmpty ())
			RemoveAlbum (album->ID_);
	}
unsigned TrackControls::DoContextMenu
   (const wxRect &rect, wxWindow *pParent, wxPoint *)
{
   wxRect buttonRect;
   TrackInfo::GetTitleBarRect(rect, buttonRect);

   auto track = FindTrack();
   if (!track)
      return RefreshCode::RefreshNone;

   InitMenuData data{ track.get(), pParent, RefreshCode::RefreshNone };

   const auto pTable = &TrackMenuTable::Instance();
   auto pMenu = PopupMenuTable::BuildMenu(pParent, pTable, &data);

   PopupMenuTable *const pExtension = GetMenuExtension(track.get());
   if (pExtension)
      pMenu->Extend(pExtension);

   pParent->PopupMenu
      (pMenu.get(), buttonRect.x + 1, buttonRect.y + buttonRect.height + 1);

   return data.result;
}
Exemple #18
0
// Gets the name of the specified object.
wxAccStatus TrackPanelAx::GetName( int childId, wxString* name )
{
#if defined(__WXMSW__)
   if( childId == wxACC_SELF )
   {
      *name = _( "TrackView" );
   }
   else
   {
      Track *t = FindTrack( childId );

      if( t == NULL )
      {
         return wxACC_FAIL;
      }
      else
      {
         *name = t->GetName();
         if( *name == t->GetDefaultName() )
         {
            /* i18n-hint: The %d is replaced by th enumber of the track.*/
            name->Printf(_("Track %d"), TrackNum( t ) );
         }

         if (t->GetKind() == Track::Label)
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this is a Label track.*/
            name->Append( wxT(" ") + wxString(_("Label Track")));
         }
         else if (t->GetKind() == Track::Time)
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this is a Time track.*/
            name->Append( wxT(" ") + wxString(_("Time Track")));
         }
         else if (t->GetKind() == Track::Note)
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this is a Note track.*/
            name->Append( wxT(" ") + wxString(_("Note Track")));
         }

         // LLL: Remove these during "refactor"
         if( t->GetMute() )
         {
            // The following comment also applies to the solo, selected,
            // and synclockselected states.
            // Many of translations of the strings with a leading space omitted
            // the leading space. Therefore a space has been added using wxT(" ").
            // Because screen readers won't be affected by multiple spaces, the
            // leading spaces have not been removed, so that no new translations are needed.
            /* i18n-hint: This is for screen reader software and indicates that
               on this track mute is on.*/
            name->Append( wxT(" ") + wxString(_( " Mute On" )) );
         }

         if( t->GetSolo() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               on this track solo is on.*/
            name->Append( wxT(" ") + wxString(_( " Solo On" )) );
         }
         if( t->GetSelected() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this track is selected.*/
            name->Append( wxT(" ") + wxString(_( " Select On" )) );
         }
         if( t->IsSyncLockSelected() )
         {
            /* i18n-hint: This is for screen reader software and indicates that
               this track is shown with a sync-locked icon.*/
            // The absence of a dash between Sync and Locked is deliberate -
            // if present, Jaws reads it as "dash".
            name->Append( wxT(" ") + wxString(_( " Sync Lock Selected" )) );
         }
      }
   }

   return wxACC_OK;
#endif

#if defined(__WXMAC__)
   return wxACC_NOT_IMPLEMENTED;
#endif
}
int Disc_CD_R::CheckItemData(const IOptItem *pDI)
{
   if ((pDI->getPreGapSize() != 0) && (!bWriteSAO))
   {
      _D(Lvl_Error, "Pad size other than 0 not allowed");
      return ODE_BadLayout;
   }
   if ((pDI->getPostGapSize() != 0) && (!bWriteSAO))
   {
      _D(Lvl_Error, "Pad size other than 0 not allowed");
      return ODE_BadLayout;
   }
   if (pDI->isIncremental())
   {
      _D(Lvl_Error, "Incremental tracks not allowed");
      return ODE_BadLayout; 
   }
   
   if (pDI->getItemType() == Item_Disc)
   {
      if (pDI->getFlags() & DIF_Disc_MasterizeCD)
      {
         const IOptItem *pItem = FindTrack(1);
         if (!pItem->isBlank())
         {
            _D(Lvl_Error, "SAO / DAO recording requires a blank disc to be inserted");
            return ODE_DiscNotEmpty;
         }

         bWriteSAO = true;
         lAdjustment = -150;
      }
      else
      {
         bWriteSAO   = false;
         lAdjustment = 0;
      }
      pLastTrack = 0;
   }
   else if (pDI->getItemType() == Item_Session)
   {
      if (pLastTrack)
      {
         _D(Lvl_Error, "Multisession SAO / DAO recording not allowed");
         return ODE_BadLayout;
      }
      if (pDI->hasCDText())
      {
         if (!bWriteSAO)
         {
            _D(Lvl_Error, "CD-Text allowed only in DAO / SAO mode");
            return ODE_BadLayout;
         }
         // other session options should follow, like interactive or cd-xa session etc
      }
      bCDXA = pDI->getFlags() & DIF_Session_CDXA ? true : false;
      bCDI  = pDI->getFlags() & DIF_Session_CDI  ? true : false;
      if (pDI->isPreemphasized())
      {
         _D(Lvl_Error, "Preemphasy not allowed for sessions");
         return ODE_BadLayout;
      }
   }
   else if (pDI->getItemType() == Item_Track)
   {
      int secsize = 2048;

      /*
       * ensure at least one index is present
       */
      if (pDI->getChildCount() == 0)
      {
         IOptItem *pIdx = const_cast<IOptItem*>(pDI)->addChild();
         pIdx->setItemNumber(1);
         pIdx->setFlags(DIF_RelativeSize);
         pIdx->setStartAddress(0);
         pIdx->setDataBlockCount(-1);
      }
   
      /* 
       * verify if track comes with cd-text
       */
      if (pDI->hasCDText())
      {
         if (!bWriteSAO)
         {
            _D(Lvl_Error, "CD-Text allowed only in DAO / SAO mode");
            return ODE_BadLayout;
         }
         if (pDI->getDataType() != Data_Audio)
         {
            _D(Lvl_Error, "CD-Text allowed only for audio tracks");
            return ODE_BadTrackMode;
         }
      }
      
      /*
       * verify that raw data comes only for sao recording
       */
      if ((pDI->getFlags() & DIF_Common_Type) != 0)
      {
         if (!bWriteSAO)
         {
            _D(Lvl_Error, "RAW tracks are only allowed in DAO recording");
            return ODE_BadLayout;
         }
      }

      /*
       * verify thar preemphasy is applied only to audio tracks
       */
      if (pDI->isPreemphasized())
      {
         if (pDI->getDataType() != Data_Audio)
         {
            _D(Lvl_Error, "Preemphasy not allowed for data tracks");
            return ODE_BadLayout;
         }
      }
     
      /*
       * position track
       */ 
      if (bWriteSAO)
      {
         int32 gap = 0;
         int32 est = 0;

         if ((pDI->getChildCount() > 0) && (pDI->getChild(0)->getItemNumber() == 0))   // index 0!
            gap = pDI->getChild(0)->getBlockCount();
         else
            gap = pDI->getPreGapSize();

         if (!pLastTrack)
         {
            est = 2*75;
         }
         else if (pDI->getDataType() != Data_Audio)
         {
            if (pLastTrack->getDataType() != pDI->getDataType())
               est = 3*75;
            else
               est = 2*75;
         }
         else if (pLastTrack->getDataType() != Data_Audio)
         {
            est = 2*75;
         }
        
         if ((gap != 0) && (est != gap))
         {
            _D(Lvl_Warning, "Desired gap length (%ld) is different than acceptable (%ld)", gap, est);
            return ODE_BadLayout;
         }
         else if (gap == 0)
         {
            const_cast<IOptItem*>(pDI)->setPreGapSize(est);
         }
         lSAOTrackGap = pDI->getPreGapSize();
      }
         
      switch (pDI->getDataType())
      {
         case Data_Audio:
            {
               secsize = 2352;
            }
            break;

         case Data_Mode1:
            {
               if (pDI->getFlags() & DIF_Common_RawData)
                  secsize = 2352;
               else
                  secsize = 2048;
            }
            break;

         case Data_Mode2:
            {
               if (pDI->getFlags() & DIF_Common_RawData)
                  secsize = 2352;
               else
                  secsize = 2336;
            }
            break;

         case Data_Mode2Form1:
            {
               if (!(bCDXA | bCDI))
               {
                  _D(Lvl_Error, "XA tracks allowed only for XA / Interactive sessions");
                  return ODE_BadLayout;
               }
               if (pDI->getFlags() & DIF_Common_RawData)
                  secsize = 2352;
               else
                  secsize = 2048;
            }
            break;

         case Data_Mode2Form2:
            {
               if (!(bCDXA | bCDI))
               {
                  _D(Lvl_Error, "XA tracks allowed only for XA / Interactive sessions");
                  return ODE_BadLayout;
               }
               if (pDI->getFlags() & DIF_Common_RawData)
                  secsize = 2352;
               else
                  secsize = 2336;
            }
            break;

         default:
            _D(Lvl_Error, "Unrecognized data type selected");
            return ODE_BadLayout;
      }

      if (pDI->getFlags() & DIF_Common_SubChannel)
         secsize += 96;

      const_cast<IOptItem*>(pDI)->setSectorSize(secsize);
      pLastTrack = pDI;
   }
   else if (pDI->getItemType() == Item_Index)
   {
      if (!bWriteSAO) 
      {
         _D(Lvl_Error, "Indices allowed only in DAO / SAO mode");
         return ODE_BadLayout;
      }
#warning INDICES NOT IMPLEMENTED
      _D(Lvl_Error, "Indices are not implemented yet");
      return ODE_BadLayout;
   }

   return Disc::CheckItemData(pDI);
} 
Exemple #20
0
std::shared_ptr<TrackPanelCell> Track::ContextMenuDelegate()
{
   return FindTrack()->GetTrackControl();
}
Exemple #21
0
bool AudioView::ClickTrack(wxMouseEvent &event)
{
  wxRect r;
  int num;

  VTrack *t = FindTrack(event.m_x, event.m_y, false, &r, &num);

  if (t) {
	capturedTrack = t;
	capturedRect = r;
	capturedNum = num;
	
	mouseClickX = event.m_x;
	mouseClickY = event.m_y;

	mouseMostRecentX = event.m_x;
	mouseMostRecentY = event.m_y;

	if (mouseClickY >= r.y + r.height - 12 && mouseClickY < r.y + r.height) {
	  resizing = true;
	  initialTrackHeight = t->GetHeight();
	}
	else {
	  resizing = false;

	  if (event.ShiftDown()) { // Extend selection
		double selend = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);
		
		if (selend > sel1) {
		  sel1 = selend;
		}
		else if (selend < sel0) {
		  sel0 = selend;
		} else {
		  // This is not ideal.  Fix???
		  sel1 = selend;
		  selstart = sel0;
		}
	  } 
	  else if (event.ControlDown()) {// Drag Track
		selstart = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);

		dragging = true;
	  }
	  else { // Selecting
		dragging = false;

		selstart = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);
		
		SelectNone();
		t->selected = true;
		
		sel0 = selstart;
		sel1 = selstart;
	  }
	}
	
    REDRAW(trackPanel);
  	REDRAW(rulerPanel);
	
	return true;
  }
  else {
	// No track was selected

	SelectNone();
	resizing = false;
	dragging = false;
    REDRAW(trackPanel);
  	REDRAW(rulerPanel);
    
    return true;
  }
}
Exemple #22
0
bool AudioView::DragTrack(wxMouseEvent &event)
{
  VTrack *t;
  wxRect r;
  int num;
  
  if (capturedTrack) {
	t = capturedTrack;
	r = capturedRect;
	num = capturedNum;
  }
  else
	t = FindTrack(event.m_x, event.m_y, false, &r, &num);
  
  if (t) {
	mouseMostRecentX = event.m_x;
	mouseMostRecentY = event.m_y;

	if (resizing) {
	  int delta = (event.m_y - mouseClickY);
	  int newTrackHeight = initialTrackHeight + delta;
	  if (newTrackHeight < 20)
		newTrackHeight = 20;
	  t->SetHeight(newTrackHeight);
	  REDRAW(trackPanel);
	}
    else if (dragging) {
      double selend = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);

	  if (selend < 0.0)
		selend = 0.0;
      
      if (selend != selstart) {
        t->Offset(selend - selstart);
        REDRAW(trackPanel);
      }
    
      selstart = selend;
    }
    else {
	  // Selecting

      double selend = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);
      
	  if (selend < 0.0)
		selend = 0.0;

      if (selend >= selstart) {
		sel0 = selstart;
		sel1 = selend;
	  }
	  else {
		sel0 = selend;
		sel1 = selstart;
	  }

	  // Handle which tracks are selected

	  int num2;
	  if (0 != FindTrack(event.m_x, event.m_y, false, NULL, &num2)) {
		// The tracks numbered num...num2 should be selected
		
		TrackList *tracks = GetTracks();
		VTrack *t = tracks->First();
		int i=1;
		while(t) {
		  t->selected = (i>=num && i<=num2) || (i>=num2 && i<=num);
		  t = tracks->Next();
		  i++;
		}
	  }

	  wxString str;
	  str.Printf("Selection: %lf - %lf seconds",sel0,sel1);
	  status->SetLabel(str);

      REDRAW(trackPanel);
    }
 
    return true;
  }
  else
    return false;
}