Пример #1
0
  protected void paintChords(TGPainter painter) {
    int maxHeight = 0;
    int fromX = 15;
    int fromY = 10;
    int vScroll = this.composite.getVerticalBar().getSelection();
    for (TGChord graphicChord : this.graphicChords) {
      TGChordImpl chord = (TGChordImpl) graphicChord;

      Color color = getChordColor(chord);
      chord.setBackgroundColor(this.composite.getBackground());
      chord.setColor(color);
      chord.setNoteColor(color);
      chord.setTonicColor(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
      chord.setFirstFretSpacing(CHORD_FIRST_FRET_SPACING);
      chord.setStringSpacing(CHORD_STRING_SPACING);
      chord.setFretSpacing(CHORD_FRET_SPACING);
      chord.setNoteSize(CHORD_NOTE_SIZE);
      chord.setFirstFretFont(getFont(painter.getGC()));
      chord.setStyle(ViewLayout.DISPLAY_CHORD_DIAGRAM);
      chord.update(painter, true);
      if (fromX + chord.getWidth() >= ((getBounds().x + getBounds().width) - 20)) {
        fromX = 15;
        fromY += chord.getHeight() + 10;
      }
      chord.setEditing(true);
      chord.setPosX(fromX);
      chord.setPosY(fromY - vScroll);
      chord.paint(painter, (chord.getWidth() / 2), 0);

      fromX += chord.getWidth() + 10;
      maxHeight = Math.max(maxHeight, chord.getHeight());
    }
    this.height = (fromY + maxHeight + 10);
    this.updateScroll();
  }
Пример #2
0
 protected TGChordImpl getChord(int x, int y, boolean setAsSelected) {
   for (TGChord graphicChord : this.graphicChords) {
     TGChordImpl chord = (TGChordImpl) graphicChord;
     int x1 = chord.getPosX();
     int x2 = x1 + chord.getWidth();
     int y1 = chord.getPosY();
     int y2 = y1 + chord.getHeight();
     if (x > x1 && x < x2 && y > y1 && y < y2) {
       if (setAsSelected) {
         if (this.selectedChord != null) {
           this.selectedChord.dispose();
         }
         this.selectedChord = chord;
         chord.dispose();
       }
       return chord;
     }
   }
   return null;
 }