src/tracks/labeltrack/ui/LabelTrackView.cpp
/// TODO: Investigate what happens with large
/// numbers of labels, might need a binary search
/// rather than a linear one.
Investigate what happens with large
numbers of labels, might need a binary search
rather than a linear one.
Investigate what happens with large numbers of labels might need a binary search rather than a linear one .
void LabelTrackView::OverGlyph(
   const LabelTrack &track, LabelTrackHit &hit, int x, int y)
{
   int result=0;
   const int d1=10; 
   const int d2=5;  
   hit.mMouseOverLabelLeft  = -1;
   hit.mMouseOverLabelRight = -1;
   hit.mMouseOverLabel = -1;
   hit.mEdge = 0;
   const auto pTrack = &track;
   const auto &mLabels = pTrack->GetLabels();
   { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
      if (OverTextBox(&labelStruct, x, y))
      {
         result = 0;
         hit.mMouseOverLabel = -1;
         hit.mMouseOverLabelLeft = -1;
         hit.mMouseOverLabelRight = -1;
         break;
      }
      if( abs(labelStruct.y - (y - (mTextHeight+3)/2)) < d1 &&
               abs(labelStruct.x1 - d2 -x) < d1)
      {
         hit.mMouseOverLabelRight = i;
         if(abs(labelStruct.x1 - x) < d2 )
         {
            result |= 4;
            if( abs(labelStruct.x1-labelStruct.x) < 5.0 )
            {
               result |=1;
               hit.mMouseOverLabelLeft = i;
            }
         }
         result |= 2;
      }
      else if(   abs(labelStruct.y - (y - (mTextHeight+3)/2)) < d1 &&
            abs(labelStruct.x + d2 - x) < d1 )
      {
         hit.mMouseOverLabelLeft = i;
         if(abs(labelStruct.x - x) < d2 )
            result |= 4;
         result |= 1;
      }
      else if (x >= labelStruct.x && x <= labelStruct.x1 &&
         abs(y - (labelStruct.y + mTextHeight / 2)) < d1)
      {
         hit.mMouseOverLabel = i;
         result = 3;
      }
   }}
   hit.mEdge = result;
}
void LabelTrackView :: OverGlyph ( const LabelTrack & track , LabelTrackHit & hit , int x , int y ) { int result = 0 ; const int d1 = 10 ; const int d2 = 5 ; hit . mMouseOverLabelLeft = -1 ; hit . mMouseOverLabelRight = -1 ; hit . mMouseOverLabel = -1 ; hit . mEdge = 0 ; const auto pTrack = & track ; const auto & mLabels = pTrack -> GetLabels ( ) ; { int i = -1 ; for ( const auto & labelStruct : mLabels ) { ++ i ; if ( OverTextBox ( & labelStruct , x , y ) ) { result = 0 ; hit . mMouseOverLabel = -1 ; hit . mMouseOverLabelLeft = -1 ; hit . mMouseOverLabelRight = -1 ; break ; } if ( abs ( labelStruct . y - ( y - ( mTextHeight + 3 ) / 2 ) ) < d1 && abs ( labelStruct . x1 - d2 - x ) < d1 ) { hit . mMouseOverLabelRight = i ; if ( abs ( labelStruct . x1 - x ) < d2 ) { result |= 4 ; if ( abs ( labelStruct . x1 - labelStruct . x ) < 5.0 ) { result |= 1 ; hit . mMouseOverLabelLeft = i ; } } result |= 2 ; } else if ( abs ( labelStruct . y - ( y - ( mTextHeight + 3 ) / 2 ) ) < d1 && abs ( labelStruct . x + d2 - x ) < d1 ) { hit . mMouseOverLabelLeft = i ; if ( abs ( labelStruct . x - x ) < d2 ) result |= 4 ; result |= 1 ; } else if ( x >= labelStruct . x && x <= labelStruct . x1 && abs ( y - ( labelStruct . y + mTextHeight / 2 ) ) < d1 ) { hit . mMouseOverLabel = i ; result = 3 ; } } } hit . mEdge = result ; }
TODO: Investigate what happens with large
numbers of labels, might need a binary search
rather than a linear one.
TODO : Investigate what happens with large numbers of labels might need a binary search rather than a linear one .
//Determine the NEW selection. //distance in pixels, used for have we hit drag handle. //distance in pixels, used for have we hit drag handle center. //If not over a label, reset it // give text box better priority for selecting // reset selection state //over left or right selection bound //Check right bound first, since it is drawn after left bound, //so give it precedence for matching/highlighting. // If left and right co-incident at this resolution, then we drag both. // We were more stringent about co-incidence here in the past. // Use else-if here rather than else to avoid detecting left and right // of the same label.