Changeset 1102 for trunk/src/org/apollo/widgets/LinkedTrack.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/widgets/LinkedTrack.java
r372 r1102 1 1 package org.apollo.widgets; 2 2 3 import java.awt.Color;4 import java.awt.Font;5 3 import java.awt.FontMetrics; 6 4 import java.awt.GradientPaint; … … 8 6 import java.awt.Graphics2D; 9 7 import java.awt.Paint; 10 import java.awt.Point;11 8 import java.awt.Rectangle; 12 import java.awt.Shape;13 import java.awt.Stroke;14 9 import java.awt.event.ActionEvent; 15 10 import java.awt.event.ActionListener; … … 19 14 import java.awt.event.MouseListener; 20 15 import java.awt.event.MouseMotionListener; 21 import java.awt.geom.Area;22 16 import java.awt.geom.Rectangle2D; 23 17 import java.util.LinkedList; … … 29 23 import javax.swing.SwingUtilities; 30 24 25 import org.apollo.ApolloGestureActions; 26 import org.apollo.ApolloKBMGestureTranslator; 31 27 import org.apollo.ApolloSystem; 32 import org.apollo.AudioFrameKeyboardActions;33 import org.apollo.AudioFrameMouseActions;34 28 import org.apollo.audio.ApolloSubjectChangedEvent; 35 29 import org.apollo.audio.SampledAudioManager; … … 62 56 import org.apollo.util.Mutable; 63 57 import org.apollo.util.ODFrameHeirarchyFetcher; 64 import org.apollo.util.PopupReaper;65 58 import org.apollo.util.StringEx; 66 59 import org.apollo.util.ODFrameHeirarchyFetcher.ODFrameReceiver; 60 import org.expeditee.core.Clip; 61 import org.expeditee.core.Colour; 62 import org.expeditee.core.EnforcedClipStack.EnforcedClipKey; 63 import org.expeditee.core.Fill; 64 import org.expeditee.core.Font; 65 import org.expeditee.core.Line; 66 import org.expeditee.core.Point; 67 import org.expeditee.core.Stroke; 68 import org.expeditee.core.TextLayout; 69 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 70 import org.expeditee.gio.EcosystemManager; 71 import org.expeditee.gio.GraphicsManager; 72 import org.expeditee.gio.TextLayoutManager; 73 import org.expeditee.gio.swing.MouseEventRouter; 74 import org.expeditee.gio.swing.SwingConversions; 75 import org.expeditee.gio.swing.SwingMiscManager; 67 76 import org.expeditee.gui.Browser; 68 import org.expeditee.gui.Display IO;77 import org.expeditee.gui.DisplayController; 69 78 import org.expeditee.gui.Frame; 70 import org.expeditee.gui.FrameGraphics;71 79 import org.expeditee.gui.FrameUtils; 72 80 import org.expeditee.gui.MessageBay; 73 import org.expeditee.gui.MouseEventRouter;74 81 import org.expeditee.gui.PopupManager; 75 82 import org.expeditee.items.Item; 76 83 import org.expeditee.items.ItemParentStateChangedEvent; 77 84 import org.expeditee.items.Text; 78 import org.expeditee.items.widgets.InteractiveWidget;79 85 import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException; 80 86 import org.expeditee.items.widgets.InteractiveWidgetNotAvailableException; 81 82 public class LinkedTrack extends InteractiveWidget implements ODFrameReceiver, Observer, MultitrackLoadListener, PlaybackClockListener { 87 import org.expeditee.items.widgets.SwingWidget; 88 import org.expeditee.items.widgets.Widget; 89 90 public class LinkedTrack extends SwingWidget implements ODFrameReceiver, Observer, MultitrackLoadListener, PlaybackClockListener { 83 91 84 92 private String virtualFilename; // immutable … … 92 100 93 101 private PlaybackPopup playbackControlPopup = null; 94 95 102 96 103 // private SoundDeskPopup soundDeskPopup = null; … … 116 123 private String abortMessage = null; 117 124 118 private static final Colo r FAILED_MESSAGE_COLOR = Color.RED;125 private static final Colour FAILED_MESSAGE_COLOR = Colour.RED; 119 126 private static final Font MESSAGE_FONT = TrackWidgetCommons.FREESPACE_TRACKNAME_FONT; 120 private static final Font HELPER_FONT = new Font("Arial", Font. BOLD, 12);121 122 private static final Colo r[] TRACK_COLOR_WHEEL = {123 new Color(66, 145, 255),124 new Color(255, 163, 33),125 new Color(155, 227, 48),127 private static final Font HELPER_FONT = new Font("Arial", Font.Style.BOLD, 12); 128 129 private static final Colour[] TRACK_COLOR_WHEEL = { 130 Colour.FromRGB255(66, 145, 255), 131 Colour.FromRGB255(255, 163, 33), 132 Colour.FromRGB255(155, 227, 48) 126 133 }; 127 private static final Colo r TRACK_LOAD_COLOR = Color.BLACK;128 private static final Colo r TRACK_FAIL_COLOR = Color.RED;129 130 private static final Colo r SELECTION_COLOR = new Color(0,0,0,100);134 private static final Colour TRACK_LOAD_COLOR = Colour.BLACK; 135 private static final Colour TRACK_FAIL_COLOR = Colour.RED; 136 137 private static final Colour SELECTION_COLOR = Colour.FromRGBA255(0,0,0,100); 131 138 132 139 private static final Stroke TRACK_BORDER = Strokes.SOLID_1; 133 140 private static final Stroke TRACK_SELECTED_BORDER = Strokes.SOLID_2; 134 private static final Colo r TRACK_BORDER_COLOR = Color.BLACK;135 private static final Colo r TRACK_SELECTED_BORDER_COLOR = new Color(253, 255, 201);141 private static final Colour TRACK_BORDER_COLOR = Colour.BLACK; 142 private static final Colour TRACK_SELECTED_BORDER_COLOR = Colour.FromRGB255(253, 255, 201); 136 143 137 144 … … 154 161 * @param args 155 162 */ 156 public LinkedTrack(Text source, String[] args) { 163 public LinkedTrack(Text source, String[] args) 164 { 157 165 super(source, new JPanel(), 158 166 100, -1, … … 187 195 playbackControlPopup = new PlaybackPopup(); 188 196 189 nameLabel = new EmulatedTextItem( _swingComponent, new Point(10, 20));190 nameLabel.setBackgroundColor(Colo r.WHITE);197 nameLabel = new EmulatedTextItem("", new Point(10, 20)); 198 nameLabel.setBackgroundColor(Colour.WHITE); 191 199 192 200 String metaName = getStrippedDataString(TrackWidgetCommons.META_NAME_TAG); … … 210 218 public void keyPressed(KeyEvent e) { 211 219 if ((state != PLAYING && state != STOPPED) || e.isControlDown()) return; 212 if (nameLabel.onKeyPressed(e, _swingComponent)) {213 e.consume();214 return;215 }216 220 } 217 221 … … 219 223 if ((state != PLAYING && state != STOPPED)) return; 220 224 else if (e.isControlDown()) { 221 if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT) { 222 AudioFrameKeyboardActions.adjustInitationTime(LinkedTrack.this, e.getKeyCode() == KeyEvent.VK_LEFT); 223 } else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_DOWN) { 224 AudioFrameKeyboardActions.adjustVerticlePosition(LinkedTrack.this, e.getKeyCode() == KeyEvent.VK_UP); 225 if (e.getKeyCode() == KeyEvent.VK_LEFT) { 226 ApolloGestureActions.adjustInitiationTime(LinkedTrack.this, -ApolloKBMGestureTranslator.TRACK_WIDGET_TIMELINE_ADJUSTMENT); 227 } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { 228 ApolloGestureActions.adjustInitiationTime(LinkedTrack.this, ApolloKBMGestureTranslator.TRACK_WIDGET_TIMELINE_ADJUSTMENT); 229 } else if (e.getKeyCode() == KeyEvent.VK_UP) { 230 ApolloGestureActions.adjustVerticalPosition(LinkedTrack.this, -ApolloKBMGestureTranslator.TRACK_WIDGET_VERTICAL_ADJUSTMENT); 231 } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { 232 ApolloGestureActions.adjustVerticalPosition(LinkedTrack.this, ApolloKBMGestureTranslator.TRACK_WIDGET_VERTICAL_ADJUSTMENT); 225 233 } 226 } else if (nameLabel.onKeyReleased(e, _swingComponent)) {227 e.consume();228 return;229 234 } 230 235 } … … 234 239 235 240 }); 236 237 241 238 242 updateBorderColor(); … … 346 350 playbackControlPopup.stopButton.setEnabled(false); 347 351 playbackControlPopup.playPauseButton.setEnabled(true); 348 playbackControlPopup.playPauseButton.setIcon(IconRepository.getIcon("play.png"));352 SwingMiscManager.setJButtonIcon(playbackControlPopup.playPauseButton, IconRepository.getIcon("play.png")); 349 353 350 354 … … 363 367 playbackControlPopup.rewindButton.setEnabled(false); 364 368 playbackControlPopup.playPauseButton.setEnabled(true); 365 playbackControlPopup.playPauseButton.setIcon(IconRepository.getIcon("pause.png"));369 SwingMiscManager.setJButtonIcon(playbackControlPopup.playPauseButton, IconRepository.getIcon("pause.png")); 366 370 367 371 setWidgetEdgeThickness(TrackWidgetCommons.PLAYING_TRACK_EDGE_THICKNESS); … … 408 412 409 413 invalidateSelf(); 410 FrameGraphics.refresh(true);414 DisplayController.requestRefresh(true); 411 415 } 412 416 … … 528 532 for (Track t : tracks) setTrackState(t, TRACKSTATE_READY); 529 533 invalidateSelf(); 530 FrameGraphics.refresh(true);534 DisplayController.requestRefresh(true); 531 535 break; 532 536 case MultitrackLoadListener.LOAD_FAILED_BAD_GRAPH: … … 552 556 setTrackState((String) state, TRACKSTATE_READY); 553 557 invalidateSelf(); 554 FrameGraphics.refresh(true);558 DisplayController.requestRefresh(true); 555 559 break; 556 560 … … 611 615 */ 612 616 @Override 613 public InteractiveWidget copy()617 public Widget copy() 614 618 throws InteractiveWidgetNotAvailableException, InteractiveWidgetInitialisationFailedException { 615 619 … … 632 636 source.setData(data); 633 637 634 return InteractiveWidget.createWidget((Text)source);638 return Widget.createWidget((Text)source); 635 639 636 640 } … … 640 644 */ 641 645 @Override 642 protected void onParentStateChanged(int eventType) { 646 protected void onParentStateChanged(int eventType) 647 { 643 648 super.onParentStateChanged(eventType); 644 649 … … 667 672 boolean inferInitTime = true; 668 673 669 if (A udioFrameMouseActions.isYAxisRestictionOn()) {674 if (ApolloGestureActions.isYAxisRestictionOn()) { 670 675 Mutable.Long ms = getInitiationTimeFromMeta(); 671 676 if (ms != null) { … … 683 688 684 689 // Also must not set initiation time if the frame is simply being displayed 685 inferInitTime &=686 (AudioFrameMouseActions.isMouseAnchoring() || AudioFrameMouseActions.isMouseStamping());687 690 //inferInitTime &= (AudioFrameMouseActions.isMouseAnchoring() || AudioFrameMouseActions.isMouseStamping()); 691 inferInitTime &= (eventType == ItemParentStateChangedEvent.EVENT_TYPE_ADDED); 692 688 693 if (inferInitTime) { 689 694 initTime = Mutable.createMutableLong(FrameLayoutDaemon.getInstance().getMSAtX(getX(), parent)); … … 731 736 if (MouseEventRouter.getCurrentMouseEvent() != null && 732 737 MouseEventRouter.getCurrentMouseEvent().getButton() == MouseEvent.BUTTON2) { 733 Frame suspended = Display IO.getCurrentFrame();738 Frame suspended = DisplayController.getCurrentFrame(); 734 739 if (suspended != null) { 735 740 FrameLayoutDaemon.getInstance().suspendLayout(suspended, this); … … 755 760 public void run() { 756 761 invalidateSelf(); 757 FrameGraphics.refresh(true);762 DisplayController.requestRefresh(true); 758 763 } 759 764 }); // NOTE TO REPEAT: Pick up a linked track and delete it directly from freespace … … 946 951 */ 947 952 @Override 948 public void paint (Graphics g) {953 public void paintSwingWidget(Graphics2D gm) { 949 954 950 955 if (Browser._theBrowser == null) return; 951 956 957 GraphicsManager g = EcosystemManager.getGraphicsManager(); 958 952 959 // Ensure that load bar or any text doesn't spill over widgets invalidation area 953 Area clip = FrameGraphics.getCurrentClip(); 954 955 Shape clipBackUp = g.getClip(); 956 957 Area tmpClip = (clip != null) ? clip : 958 new Area(new Rectangle(0, 0, 959 Browser._theBrowser.getContentPane().getWidth(), 960 Browser._theBrowser.getContentPane().getHeight())); 961 962 tmpClip.intersect(new Area(getBounds())); 963 964 if (tmpClip.isEmpty()) return; 965 966 g.setClip(tmpClip); 960 EnforcedClipKey clipKey = g.pushClip(new Clip(getBounds())); 967 961 968 962 // Paint backing 969 g.setColor(SampledTrackGraphView.DEFAULT_BACKGROUND_COLOR); 970 g.fillRect(getX(), getY(), getWidth(), getHeight()); 963 g.drawRectangle(getBounds(), 0.0, new Fill(SwingConversions.fromSwingColor(SampledTrackGraphView.DEFAULT_BACKGROUND_COLOR)), null, null, null); 971 964 972 965 String centralizedMessage = null; 966 Colour colour = null; 973 967 974 968 // Render according to the currently widget state … … 978 972 979 973 case FAILED_STATE: 974 centralizedMessage = failMessage; 975 assert(failMessage != null); 976 colour = FAILED_MESSAGE_COLOR; 977 break; 980 978 case EMPTY_STATE: 979 if (getLink() == null) { 980 centralizedMessage = "Click to create"; 981 } else { 982 centralizedMessage = "Nothing to play"; 983 } 984 985 colour = Colour.DARK_GREY; 986 break; 981 987 case LOADING_TRACK_GRAPH: 982 983 if (state == FAILED_STATE) { 984 centralizedMessage = failMessage; 985 assert(failMessage != null); 986 g.setColor(FAILED_MESSAGE_COLOR); 987 } else if (state == LOADING_TRACK_GRAPH){ 988 centralizedMessage = "Loading..."; 989 g.setColor(Color.DARK_GRAY); 990 } else { // empty 991 if (getLink() == null) { 992 centralizedMessage = "Click to create"; 993 } else { 994 centralizedMessage = "Nothing to play"; 995 } 996 997 g.setColor(Color.DARK_GRAY); 998 } 999 988 centralizedMessage = "Loading..."; 989 colour = Colour.DARK_GREY; 1000 990 break; 1001 991 … … 1008 998 1009 999 for (Track track : tracks) { 1010 track.paintTrackArea( (Graphics2D)g,x, y);1000 track.paintTrackArea(x, y); 1011 1001 if (track.isSelected) { 1012 1002 selected = track; 1013 1003 } else { 1014 track.paintTrackBorder( g,x, y);1004 track.paintTrackBorder(x, y); 1015 1005 1016 1006 if (track.area.height > 15) { // don't clutter up busy linked tracks 1017 drawTrackName(track, g, Color.DARK_GRAY);1007 drawTrackName(track, Colour.DARK_GREY); 1018 1008 } 1019 1009 … … 1025 1015 // the selected border is drawn last 1026 1016 if (selected != null) { 1027 selected.paintTrackBorder( g,x, y);1028 drawTrackName(selected, g, Color.BLACK);1017 selected.paintTrackBorder(x, y); 1018 drawTrackName(selected, Colour.BLACK); 1029 1019 } 1030 1020 … … 1038 1028 1039 1029 centralizedMessage = "Loading dubs..."; 1040 g.setColor(Color.BLACK);1030 colour = Colour.BLACK; 1041 1031 1042 1032 } else { … … 1045 1035 int selLeftX = XatFrame(selectionStart); 1046 1036 if (selectionLength > 1) { 1047 g.setColor(SELECTION_COLOR); 1048 g.fillRect( getX() + selLeftX, 1049 getY(), 1050 XatFrame(selectionStart + selectionLength) - selLeftX, 1051 getHeight()); 1037 colour = SELECTION_COLOR; 1038 AxisAlignedBoxBounds b = new AxisAlignedBoxBounds( getX() + selLeftX, 1039 getY(), 1040 XatFrame(selectionStart + selectionLength) - selLeftX, 1041 getHeight()); 1042 g.drawRectangle(b, 0.0, new Fill(colour), null, null, null); 1052 1043 } 1053 1054 // Draw selection start bar1055 ((Graphics2D)g).setStroke(SampledTrackGraphView.GRAPH_BAR_STROKE);1056 1044 1057 1045 // Note that if the start line is near the edges of the panel it can be concealed - thus … … 1063 1051 x = getWidth() - 1; 1064 1052 } 1065 1066 g.setColor(Color.RED); 1067 g.drawLine( 1053 colour = Colour.RED; 1054 Line l = new Line( 1068 1055 x, 1069 1056 getY(), 1070 1057 x, 1071 1058 getY() + getHeight()); 1059 g.drawLine(l, colour, SwingConversions.fromSwingStroke(SampledTrackGraphView.GRAPH_BAR_STROKE)); 1072 1060 1073 1061 … … 1076 1064 1077 1065 x = XatFrame(currentPlaybackFramePosition) + getX(); 1078 1079 ((Graphics2D)g).setStroke(SampledTrackGraphView.GRAPH_BAR_STROKE); 1080 g.setColor(SampledTrackGraphView.PLAYBACK_BAR_COLOR); 1081 g.drawLine(x, getY(), x, getY() + getHeight()); 1066 colour = SwingConversions.fromSwingColor(SampledTrackGraphView.PLAYBACK_BAR_COLOR); 1067 Line l2 = new Line(x, getY(), x, getY() + getHeight()); 1068 g.drawLine(l2, colour, SwingConversions.fromSwingStroke(SampledTrackGraphView.GRAPH_BAR_STROKE)); 1082 1069 1083 1070 } 1084 1071 1085 1072 } 1086 1087 1088 1073 1089 1074 break; … … 1094 1079 if (centralizedMessage != null) { 1095 1080 1096 FontMetrics fm = g.getFontMetrics(MESSAGE_FONT); 1097 Rectangle2D rect = fm.getStringBounds(centralizedMessage, g); 1081 TextLayoutManager t = EcosystemManager.getTextLayoutManager(); 1082 1083 TextLayout layout = t.layoutString(centralizedMessage, MESSAGE_FONT, Point.ORIGIN, null, Integer.MAX_VALUE, 0, true, false).get(0); 1084 1085 AxisAlignedBoxBounds layoutBounds = layout.getPixelBounds(0, 0); 1098 1086 1099 1087 // Calc centered position 1100 int x = getX() + ((getWidth() / 2) - (int)( rect.getWidth() / 2));1101 int y = getY() + ((getHeight() / 2) + (int)( rect.getHeight() / 2) - 4);1088 int x = getX() + ((getWidth() / 2) - (int)(layoutBounds.getWidth() / 2)); 1089 int y = getY() + ((getHeight() / 2) + (int)(layoutBounds.getHeight() / 2) - 4); 1102 1090 1103 1091 // Draw text 1104 g.setFont(MESSAGE_FONT); 1105 g.drawString(centralizedMessage, x, y); 1092 g.drawTextLayout(layout, new Point(x, y), colour); 1106 1093 1107 1094 // Draw add icon if waiting for a link 1108 1095 if (getLink() == null) { 1109 IconRepository.getIcon("goto.png").paintIcon(null,1096 /*IconRepository.getIcon("goto.png").paintIcon(null, 1110 1097 g, 1111 1098 x - 34, 1112 getY() + (getHeight() / 2) - 12); 1099 getY() + (getHeight() / 2) - 12);*/ 1100 g.drawImage(IconRepository.getIcon("goto.png"), new Point(x - 34, getY() + (getHeight() / 2) - 12)); 1113 1101 } 1114 1102 … … 1116 1104 1117 1105 // Paint name label over everything 1118 if (state != NOT_INITIALIZED && state != FAILED_STATE && state != EMPTY_STATE) 1119 nameLabel.paint(g); 1120 1121 g.setClip(clipBackUp); 1122 1123 super.paintLink((Graphics2D)g); 1124 1125 } 1126 1127 private void drawTrackName(Track track, Graphics g, Color textColor) { 1128 1106 if (state != NOT_INITIALIZED && state != FAILED_STATE && state != EMPTY_STATE) nameLabel.paint(); 1107 1108 g.popClip(clipKey); 1109 1110 } 1111 1112 private void drawTrackName(Track track, Colour textColor) 1113 { 1114 Graphics2D g = SwingMiscManager.getIfUsingSwingGraphicsManager().getCurrentSurface(); 1115 1129 1116 // Draw helper message for user to give meaningful information of what they 1130 1117 // are actually highlighting … … 1133 1120 helperMessage = helperMessage + " (" + track.getParentFrameName() + ")"; 1134 1121 1135 FontMetrics fm = g.getFontMetrics( HELPER_FONT);1122 FontMetrics fm = g.getFontMetrics(SwingMiscManager.getIfUsingSwingFontManager().getInternalFont(HELPER_FONT)); 1136 1123 Rectangle2D rect = fm.getStringBounds(helperMessage, g); 1137 1124 … … 1149 1136 1150 1137 // Draw text 1151 g.setColor( textColor);1152 g.setFont( HELPER_FONT);1138 g.setColor(SwingConversions.toSwingColor(textColor)); 1139 g.setFont(SwingMiscManager.getIfUsingSwingFontManager().getInternalFont(HELPER_FONT)); 1153 1140 g.drawString(helperMessage, xoff, yoff); 1154 1141 … … 1156 1143 1157 1144 @Override 1158 protected void paintInFreeSpace(Graphics g) { 1159 1160 super.paintInFreeSpace(g); 1161 1162 Shape clipBackUp = g.getClip(); 1163 Rectangle tmpClip = (clipBackUp != null) ? clipBackUp.getBounds() : 1164 new Rectangle(0, 0, 1165 Browser._theBrowser.getContentPane().getWidth(), 1166 Browser._theBrowser.getContentPane().getHeight()); 1167 1168 g.setClip(tmpClip.intersection(getBounds())); 1145 protected void paintInFreeSpace() 1146 { 1147 super.paintInFreeSpace(); 1148 1149 // Draw the name of the track 1150 1151 GraphicsManager g = EcosystemManager.getGraphicsManager(); 1152 1153 // Ensure that load bar or any text doesn't spill over widgets invalidation area 1154 EnforcedClipKey clipKey = g.pushClip(new Clip(getBounds())); 1169 1155 1170 1156 // Draw the name … … 1173 1159 name = "Unnamed"; 1174 1160 } 1175 1176 g.setFont(TrackWidgetCommons.FREESPACE_TRACKNAME_FONT); 1177 g.setColor(TrackWidgetCommons.FREESPACE_TRACKNAME_TEXT_COLOR); 1178 1179 // Center track name 1180 FontMetrics fm = g.getFontMetrics(TrackWidgetCommons.FREESPACE_TRACKNAME_FONT); 1181 Rectangle2D rect = fm.getStringBounds(name, g); 1182 1183 g.drawString( 1184 name, 1185 this.getX() + (int)((getWidth() - rect.getWidth()) / 2), 1186 this.getY() + (int)((getHeight() - rect.getHeight()) / 2) + (int)rect.getHeight() 1187 ); 1188 1189 g.setClip(clipBackUp); 1190 1191 1161 1162 List<TextLayout> layouts = EcosystemManager.getTextLayoutManager().layoutString(name, TrackWidgetCommons.FREESPACE_TRACKNAME_FONT, getBounds().getTopLeft(), null, getBounds().getWidth(), 0, true, false); 1163 1164 // Centre the track name 1165 int lineYDelta = 0; 1166 for (TextLayout layout : layouts) { 1167 AxisAlignedBoxBounds bounds = layout.getPixelBounds(getBounds().getMinX(), getBounds().getMinY() + lineYDelta); 1168 int centreXOffset = (getBounds().getWidth() - bounds.getWidth()) / 2; 1169 bounds.translate(centreXOffset, 0); 1170 g.drawTextLayout(layout, bounds.getTopLeft(), TrackWidgetCommons.FREESPACE_TRACKNAME_TEXT_COLOR); 1171 lineYDelta += bounds.getHeight(); 1172 } 1173 1174 g.popClip(clipKey); 1192 1175 } 1193 1176 … … 1205 1188 x = XatFrame(currentPlaybackFramePosition); 1206 1189 1207 FrameGraphics.invalidateArea(new Rectangle(1190 DisplayController.invalidateArea(new AxisAlignedBoxBounds( 1208 1191 x + offsetX, 1209 1192 offsetY, … … 1220 1203 x = XatFrame(currentPlaybackFramePosition); 1221 1204 1222 FrameGraphics.invalidateArea(new Rectangle(1205 DisplayController.invalidateArea(new AxisAlignedBoxBounds( 1223 1206 x + offsetX , 1224 1207 offsetY, … … 1462 1445 1463 1446 // Get border color currently used 1464 Colo r oldC = getSource().getBorderColor();1465 1466 Colo r newC = TrackWidgetCommons.getBorderColor(1447 Colour oldC = getSource().getBorderColor(); 1448 1449 Colour newC = TrackWidgetCommons.getBorderColor( 1467 1450 SoundDesk.getInstance().isSolo(masterMix.getChannelID()), 1468 1451 masterMix.isMuted()); … … 1518 1501 * 1519 1502 */ 1520 private class PlaybackPopup extends PlaybackControlPopup { 1521 1522 private static final long serialVersionUID = 1L; 1523 1503 private class PlaybackPopup extends PlaybackControlPopup 1504 { 1524 1505 public PlaybackPopup() { 1525 1506 miscButton.setActionCommand("goto"); 1526 miscButton.setIcon(IconRepository.getIcon("goto.png"));1507 SwingMiscManager.setJButtonIcon(miscButton, IconRepository.getIcon("goto.png")); 1527 1508 miscButton.setToolTipText("Goto linked frame"); 1528 1509 } 1529 1510 1530 1511 @Override 1531 public void onHide() {1532 super.onHide();1512 public void onHide() 1513 { 1533 1514 } 1534 1515 1535 1516 @Override 1536 public void onShow() {1537 super.onShow();1517 public void onShow() 1518 { 1538 1519 updateVolume((int)(100 * masterMix.getVolume())); 1539 1520 updateMute(masterMix.isMuted()); 1540 1521 updateSolo(SoundDesk.getInstance().isSolo(masterMix.getChannelID())); 1541 1522 } 1542 1543 public void actionPerformed(ActionEvent e) {1544 1523 1524 public void actionPerformed(ActionEvent e) 1525 { 1545 1526 if (e.getSource() == miscButton) { 1546 1527 … … 1670 1651 currentPlaybackFramePosition = -1; 1671 1652 setSelection(0, 0); // invalidates 1672 FrameGraphics.refresh(true);1653 DisplayController.requestRefresh(true); 1673 1654 1674 1655 } … … 1691 1672 } 1692 1673 1693 private class MouseActions implements MouseListener, MouseMotionListener { 1694 1695 public void mouseClicked(MouseEvent e) { 1674 private class MouseActions implements MouseListener, MouseMotionListener 1675 { 1676 public void mouseClicked(MouseEvent e) 1677 { 1696 1678 assert(state != EMPTY_STATE); 1697 1679 … … 1705 1687 } 1706 1688 1707 1708 public void mouseEntered(MouseEvent e){1689 public void mouseEntered(MouseEvent e) 1690 { 1709 1691 assert(state != EMPTY_STATE); 1710 1692 } 1711 1693 1712 1694 1713 public void mouseExited(MouseEvent e) { 1695 public void mouseExited(MouseEvent e) 1696 { 1714 1697 assert(state != EMPTY_STATE); 1715 1716 } 1717 1718 1719 public void mousePressed(MouseEvent e) { 1720 1698 } 1699 1700 1701 public void mousePressed(MouseEvent e) 1702 { 1721 1703 assert(state != EMPTY_STATE); 1722 1704 … … 1732 1714 setSelection(frameAtX(selectionStartX), 1); 1733 1715 1734 FrameGraphics.refresh(true); 1735 } 1736 1737 1738 public void mouseReleased(MouseEvent e) { 1739 1740 1716 DisplayController.requestRefresh(true); 1717 } 1718 1719 1720 public void mouseReleased(MouseEvent e) 1721 { 1741 1722 assert(state != EMPTY_STATE); 1742 1743 1723 1744 1724 // Was the release a simple click … … 1765 1745 return; 1766 1746 } 1767 1768 1769 } 1770 1771 1772 public void mouseDragged(MouseEvent e) { 1773 1747 } 1748 1749 1750 public void mouseDragged(MouseEvent e) 1751 { 1774 1752 assert(state != EMPTY_STATE); 1775 1753 … … 1800 1778 } 1801 1779 1802 FrameGraphics.refresh(true); 1803 } 1804 1805 public void mouseMoved(MouseEvent e) { 1780 DisplayController.requestRefresh(true); 1781 } 1782 1783 public void mouseMoved(MouseEvent e) 1784 { 1806 1785 assert(state != EMPTY_STATE); 1807 1786 1808 1787 if (state != PLAYING && state != STOPPED) return; 1809 1788 1810 if (nameLabel.onMouseMoved(e, _swingComponent)) { 1811 e.consume(); 1812 return; 1789 if (nameLabel != null) { 1790 nameLabel.gainFocus(); 1813 1791 } 1814 1792 … … 1822 1800 1823 1801 // Get rid of all popups 1824 PopupManager.getInstance().hideAuto hidePopups();1825 1826 Rectangle animationSource = _swingComponent.getBounds();1802 PopupManager.getInstance().hideAutoHidePopups(); 1803 1804 AxisAlignedBoxBounds animationSource = SwingConversions.fromSwingRectangle(_swingComponent.getBounds()); 1827 1805 1828 1806 // Determine where popup should show 1829 1807 int x = LinkedTrack.this.getX(); 1830 int y = LinkedTrack.this.getY() - playbackControlPopup.get Height() - 2; // by default show above1808 int y = LinkedTrack.this.getY() - playbackControlPopup.getFullBounds().getHeight() - 2; // by default show above 1831 1809 1832 1810 // I get sick.dizzy from the popup expanding from the whole thing... 1833 animationSource. height = 1;1834 animationSource. width = Math.min(animationSource.width, playbackControlPopup.getWidth());1811 animationSource.getSize().height = 1; 1812 animationSource.getSize().width = Math.min(animationSource.getWidth(), playbackControlPopup.getFullBounds().getWidth()); 1835 1813 1836 1814 if (y < 0) { 1837 1815 y = LinkedTrack.this.getY() + LinkedTrack.this.getHeight() + 2; 1838 animationSource. y = y - 2;1816 animationSource.getTopLeft().y = y - 2; 1839 1817 } 1840 1818 1841 1819 // Animate the popup 1842 PopupManager.getInstance().showPopup( 1843 playbackControlPopup, 1844 new Point(x, y), 1845 _swingComponent, 1846 PopupManager.getInstance().new ExpandShrinkAnimator( 1847 animationSource, 1848 Color.LIGHT_GRAY)); 1849 1850 PopupReaper.getInstance().initPopupLifetime( 1851 playbackControlPopup, 1852 PopupManager.getInstance().new ExpandShrinkAnimator( 1853 animationSource, 1854 Color.LIGHT_GRAY), 1855 TrackWidgetCommons.POPUP_LIFETIME); 1856 1820 playbackControlPopup.getAutoHideTime().setLifetime(TrackWidgetCommons.POPUP_LIFETIME); 1821 PopupManager.getInstance().add(playbackControlPopup); 1822 playbackControlPopup.show(); 1857 1823 } else { 1858 PopupReaper.getInstance().revivePopup(playbackControlPopup, TrackWidgetCommons.POPUP_LIFETIME);1824 playbackControlPopup.show(); 1859 1825 } 1860 1826 … … 1878 1844 if (shouldInvalidate) { 1879 1845 invalidateSelf(); 1880 FrameGraphics.refresh(true);1846 DisplayController.requestRefresh(true); 1881 1847 } 1882 1848 } … … 1888 1854 * @author Brook Novak 1889 1855 */ 1890 private class Track {1891 1856 private class Track 1857 { 1892 1858 private AbsoluteTrackNode absNode; // immutable. Never null 1893 1859 1894 1860 private Rectangle area; 1895 1861 1896 private Colo r baseColor;1862 private Colour baseColor; 1897 1863 1898 1864 boolean isSelected = false; … … 1900 1866 private int state = TRACKSTATE_READY; 1901 1867 1902 Track(AbsoluteTrackNode absNode) { 1868 Track(AbsoluteTrackNode absNode) 1869 { 1903 1870 assert(absNode != null); 1904 1871 this.absNode = absNode; 1905 1872 } 1906 1873 1907 public String getChannelID() { 1874 public String getChannelID() 1875 { 1908 1876 return absNode.getChannelID(); 1909 1877 } … … 1929 1897 } 1930 1898 1931 public void paintTrackArea(Graphics2D g, int x, int y) { 1899 public void paintTrackArea(int x, int y) 1900 { 1901 Graphics2D g = SwingMiscManager.getIfUsingSwingGraphicsManager().getCurrentSurface(); 1932 1902 1933 1903 if (state == TRACKSTATE_LOADING && LinkedTrack.this.state == PLAYBACK_LOADING) { 1934 g.setColor( TRACK_LOAD_COLOR);1904 g.setColor(SwingConversions.toSwingColor(TRACK_LOAD_COLOR)); 1935 1905 } else if (state == TRACKSTATE_FAILED) { 1936 g.setColor( TRACK_FAIL_COLOR);1906 g.setColor(SwingConversions.toSwingColor(TRACK_FAIL_COLOR)); 1937 1907 } else { 1938 g.setColor( baseColor);1908 g.setColor(SwingConversions.toSwingColor(baseColor)); 1939 1909 } 1940 1910 … … 1943 1913 1944 1914 GradientPaint gp = new GradientPaint( 1945 (int) (area.x + x + (area.width / 2)), area.y + y + (int)(area.height * 0.8), baseColor,1946 (int) (area.x + x + (area.width / 2)), area.y + y, TRACK_SELECTED_BORDER_COLOR);1915 (int) (area.x + x + (area.width / 2)), area.y + y + (int)(area.height * 0.8), SwingConversions.toSwingColor(baseColor), 1916 (int) (area.x + x + (area.width / 2)), area.y + y, SwingConversions.toSwingColor(TRACK_SELECTED_BORDER_COLOR)); 1947 1917 g.setPaint(gp); 1948 1918 } 1949 1919 1950 // Draw a filled rect - represented a track in the h eirarchy1920 // Draw a filled rect - represented a track in the hierarchy 1951 1921 g.fillRect(area.x + x, area.y + y, area.width, area.height); 1952 1922 … … 1957 1927 } 1958 1928 1959 public void paintTrackBorder(Graphics g, int x, int y) { 1929 public void paintTrackBorder(int x, int y) 1930 { 1931 Graphics g = SwingMiscManager.getIfUsingSwingGraphicsManager().getCurrentSurface(); 1960 1932 1961 1933 if (isSelected) { 1962 g.setColor( TRACK_SELECTED_BORDER_COLOR);1963 ((Graphics2D)g).setStroke( TRACK_SELECTED_BORDER);1934 g.setColor(SwingConversions.toSwingColor(TRACK_SELECTED_BORDER_COLOR)); 1935 ((Graphics2D)g).setStroke(SwingConversions.toSwingStroke(TRACK_SELECTED_BORDER)); 1964 1936 } else { 1965 g.setColor( TRACK_BORDER_COLOR);1966 ((Graphics2D)g).setStroke( TRACK_BORDER); // todo muted colors etc...1937 g.setColor(SwingConversions.toSwingColor(TRACK_BORDER_COLOR)); 1938 ((Graphics2D)g).setStroke(SwingConversions.toSwingStroke(TRACK_BORDER)); // todo muted colors etc... 1967 1939 } 1968 1940 … … 1972 1944 } 1973 1945 1946 // TODO: Why not? cts16 1974 1947 @Override 1975 1948 public boolean isWidgetEdgeThicknessAdjustable() {
Note:
See TracChangeset
for help on using the changeset viewer.