Changeset 1102 for trunk/src/org/apollo/gui/FrameRenderPasses.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/gui/FrameRenderPasses.java
r355 r1102 1 1 package org.apollo.gui; 2 2 3 import java.awt.Color;4 import java.awt.FontMetrics;5 import java.awt.Graphics;6 import java.awt.Graphics2D;7 import java.awt.Rectangle;8 import java.awt.Stroke;9 import java.awt.geom.Area;10 import java.awt.geom.Rectangle2D;11 3 import java.util.LinkedList; 12 4 13 import org.apollo.AudioFrameKeyboardActions; 14 import org.apollo.AudioFrameMouseActions; 5 import org.apollo.ApolloGestureActions; 15 6 import org.apollo.audio.util.Timeline; 16 7 import org.apollo.items.FramePlaybackLauncher; … … 19 10 import org.apollo.widgets.LinkedTrack; 20 11 import org.apollo.widgets.SampledTrack; 12 import org.expeditee.core.Clip; 13 import org.expeditee.core.Colour; 14 import org.expeditee.core.Dimension; 15 import org.expeditee.core.Fill; 16 import org.expeditee.core.Point; 17 import org.expeditee.core.Stroke; 18 import org.expeditee.core.TextLayout; 19 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 20 import org.expeditee.gio.EcosystemManager; 21 import org.expeditee.gio.GraphicsManager; 22 import org.expeditee.gio.gesture.StandardGestureActions; 23 import org.expeditee.gio.input.KBMInputEvent.Key; 24 import org.expeditee.gio.input.StandardInputEventListeners; 21 25 import org.expeditee.gui.Browser; 22 26 import org.expeditee.gui.FrameGraphics; 23 import org.expeditee.gui.FrameMouseActions;24 27 import org.expeditee.gui.FreeItems; 25 28 import org.expeditee.gui.FrameGraphics.FrameRenderPass; 26 29 import org.expeditee.items.Item; 27 import org.expeditee.items.widgets. InteractiveWidget;30 import org.expeditee.items.widgets.Widget; 28 31 import org.expeditee.items.widgets.WidgetCorner; 29 32 import org.expeditee.items.widgets.WidgetEdge; … … 31 34 /** 32 35 * All final effects rendered here - to give extra feedback to the user and simply to make 33 * it more ap ealing.36 * it more appealing. 34 37 * @author Brook Novak 35 38 * … … 37 40 public class FrameRenderPasses implements FrameRenderPass { 38 41 39 private static final Colo r SHADED_EXPANDED_BACKING_COLOR = new Color(80, 80, 80, 140);40 private static final Colo r Y_HELPER_LINES_COLOR = Color.DARK_GRAY;42 private static final Colour SHADED_EXPANDED_BACKING_COLOR = Colour.FromRGBA255(80, 80, 80, 140); 43 private static final Colour Y_HELPER_LINES_COLOR = Colour.DARK_GREY; 41 44 private static final Stroke Y_HELPER_LINES_STROKE = OverdubbedFrameTimeAxis.TRACK_TIMELINE_STROKE; 42 45 … … 48 51 private boolean shouldDrawFullscreenHelpers = false; 49 52 50 private FrameRenderPasses() { 53 private FrameRenderPasses() 54 { 51 55 FrameGraphics.addFrameRenderPass(this); 52 56 } 53 57 54 public static FrameRenderPasses getInstance() { 58 public static FrameRenderPasses getInstance() 59 { 55 60 return instance; 56 61 } 57 62 58 public void paintFinalPass(Graphics g) { 63 public void paintFinalPass() 64 { 59 65 if (Browser._theBrowser == null) return; 60 int frameHeight = Browser._theBrowser.getContentPane().getHeight(); 66 67 GraphicsManager gm = EcosystemManager.getGraphicsManager(); 68 69 int frameHeight = EcosystemManager.getGraphicsManager().getWindowSize().getHeight(); 61 70 if (ExpandedTrackManager.getInstance().isAnyExpandedTrackVisible() 62 71 && !FreeItems.getInstance().isEmpty()) { … … 67 76 for (Item i : FreeItems.getInstance()) { 68 77 if (i instanceof WidgetCorner) { 69 InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource();78 Widget iw = ((WidgetCorner)i).getWidgetSource(); 70 79 71 80 if (iw != null && iw instanceof SampledTrack) { … … 84 93 if (toPaint != null) { 85 94 for (SampledTrack trackWidget : toPaint) { 86 if (g.getClip() == null 87 || g.getClip().intersects(trackWidget.getComponant().getBounds())) 88 trackWidget.paintInFreeSpace(g, true); 89 95 if (gm.peekClip() == null || gm.peekClip().isNotClipped() || (!gm.peekClip().isFullyClipped() && gm.peekClip().getBounds().intersects(trackWidget.getBounds()))) { 96 trackWidget.paintInFreeSpace(true); 97 } 90 98 } 91 99 } … … 93 101 } 94 102 95 OverdubbedFrameTimeAxis.getInstance().paint( g);103 OverdubbedFrameTimeAxis.getInstance().paint(); 96 104 97 105 TimeAxis timeAxis = OverdubbedFrameTimeAxis.getInstance().getTimeAxis(); 98 106 Timeline lastTimeline = OverdubbedFrameTimeAxis.getInstance().getLastTimeline(); 99 107 100 FramePlaybackBarRenderer.getInstance().paint( (Graphics2D)g);108 FramePlaybackBarRenderer.getInstance().paint(); 101 109 102 110 if (timeHelperLinesToPaint != null && timeAxis != null && lastTimeline != null) { 103 111 104 Rectangler = OverdubbedFrameTimeAxis.getInstance().getCurrentTimelineArea();112 AxisAlignedBoxBounds r = OverdubbedFrameTimeAxis.getInstance().getCurrentTimelineArea(); 105 113 106 114 // Draw helper bar and text 107 115 for (Integer x : timeHelperLinesToPaint) { 108 116 109 ((Graphics2D)g).setStroke(OverdubbedFrameTimeAxis.TRACK_TIMELINE_STROKE); 110 g.setColor(Color.RED); 111 112 if (shouldDrawFullscreenHelpers) 113 g.drawLine(x, 0, x, frameHeight); 114 else 115 g.drawLine(x, r.y, x, r.y + r.height); 116 117 if (shouldDrawFullscreenHelpers) { 118 gm.drawLine(new Point(x, 0), new Point(x, frameHeight), Colour.RED, OverdubbedFrameTimeAxis.TRACK_TIMELINE_STROKE); 119 } else { 120 gm.drawLine(new Point(x, r.getMinY()), new Point(x, r.getMinY() + r.getHeight()), Colour.RED, OverdubbedFrameTimeAxis.TRACK_TIMELINE_STROKE); 121 } 122 117 123 long ms = lastTimeline.getMSTimeAtX(x) - lastTimeline.getFirstInitiationTime(); 118 124 … … 120 126 if (ms < 0) label = "-" + label; 121 127 122 FontMetrics fm = g.getFontMetrics(SampledTrackGraphViewPort.TIME_HELPER_FONT); 123 Rectangle2D rect = fm.getStringBounds(label, g); 128 //FontMetrics fm = g.getFontMetrics(SampledTrackGraphViewPort.TIME_HELPER_FONT); 129 //Rectangle2D rect = fm.getStringBounds(label, g); 130 TextLayout layout = EcosystemManager.getTextLayoutManager().layoutStringSimple(label, SampledTrackGraphViewPort.TIME_HELPER_FONT); 131 AxisAlignedBoxBounds rect = layout.getPixelBounds(0, 0); 124 132 int labelWidth = (int)(rect.getWidth()); 125 133 int labelHeight = (int)(rect.getHeight()); 126 134 127 int y = r.y + (r.height / 2) - ((labelHeight + 4) / 2); 128 129 130 g.setColor(SampledTrackGraphViewPort.TIME_HELPER_COLOR); 131 g.fillRect(x + 2, y, labelWidth + 3, labelHeight + 4); 132 133 g.setColor(SampledTrackGraphViewPort.TIME_HELPER_BORDERCOLOR); 134 ((Graphics2D)g).setStroke(SampledTrackGraphViewPort.ZOOM_BACKING_BORDER_STROKE); 135 g.fillRect(x + 2, y, labelWidth + 3, labelHeight + 4); 136 137 g.setFont(SampledTrackGraphViewPort.TIME_HELPER_FONT); 138 g.setColor(Color.BLACK); 139 g.drawString(label, x + 4, y + labelHeight); 140 141 135 int y = r.getMinY() + (r.getHeight() / 2) - ((labelHeight + 4) / 2); 136 137 gm.drawRectangle(new Point(x + 2, y), new Dimension(labelWidth + 3, labelHeight + 4), 0.0, new Fill(SampledTrackGraphViewPort.TIME_HELPER_COLOR), SampledTrackGraphViewPort.TIME_HELPER_BORDERCOLOR, SampledTrackGraphViewPort.ZOOM_BACKING_BORDER_STROKE, null); 138 139 gm.drawTextLayout(layout, new Point(x + 4, y + labelHeight), Colour.BLACK); 142 140 } 143 141 … … 146 144 // Draw Y helper 147 145 if (yAxisTimelineHelperToPaint != null) { 148 149 ((Graphics2D)g).setStroke(Y_HELPER_LINES_STROKE); 150 g.setColor(Y_HELPER_LINES_COLOR); 151 152 g.drawLine( 153 0, 154 yAxisTimelineHelperToPaint.value, 155 Browser._theBrowser.getContentPane().getWidth(), 156 yAxisTimelineHelperToPaint.value); 157 158 } 159 160 161 } 162 163 public void paintPreLayeredPanePass(Graphics g) { 146 gm.drawLine(0, yAxisTimelineHelperToPaint.value, EcosystemManager.getGraphicsManager().getWindowSize().getWidth(), yAxisTimelineHelperToPaint.value, Y_HELPER_LINES_COLOR, Y_HELPER_LINES_STROKE); 147 } 148 149 150 } 151 152 public void paintPreLayeredPanePass() 153 { 164 154 if (Browser._theBrowser == null) return; 165 155 166 156 if (ExpandedTrackManager.getInstance().isAnyExpandedTrackVisible()) { 167 168 g.setColor(SHADED_EXPANDED_BACKING_COLOR); 169 g.fillRect(0, 0, 170 Browser._theBrowser.getContentPane().getWidth(), 171 Browser._theBrowser.getContentPane().getHeight()); 172 } 173 174 } 175 176 public Area paintStarted(Area currentClip) { 157 Dimension windowSize = EcosystemManager.getGraphicsManager().getWindowSize(); 158 EcosystemManager.getGraphicsManager().drawRectangle(Point.ORIGIN, windowSize, 0.0, new Fill(SHADED_EXPANDED_BACKING_COLOR), null, null, null); 159 } 160 161 } 162 163 public Clip paintStarted(Clip currentClip) 164 { 177 165 if (Browser._theBrowser == null) return currentClip; 178 166 179 LinkedList< InteractiveWidget> seen = null;167 LinkedList<Widget> seen = null; 180 168 181 169 //boolean idDirty = false; … … 189 177 timeHelperLinesToPaint = null; 190 178 yAxisTimelineHelperToPaint = null; 191 shouldDrawFullscreenHelpers = AudioFrameKeyboardActions.isControlDown() ||192 ( AudioFrameKeyboardActions.isShiftDown() && !FreeItems.getInstance().isEmpty());179 shouldDrawFullscreenHelpers = StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL) || 180 (StandardInputEventListeners.kbmStateListener.isKeyDown(Key.SHIFT) && !FreeItems.getInstance().isEmpty()); 193 181 194 182 // Get free tracks and paint line helpers 195 if (!FreeItems.getInstance().isEmpty() || FrameMouseActions.getlastHighlightedItem() != null) {183 if (!FreeItems.getInstance().isEmpty() || StandardGestureActions.getlastHighlightedItem() != null) { 196 184 197 185 LinkedList<Item> possibles = new LinkedList<Item>(FreeItems.getInstance()); 198 if (FreeItems.getInstance().isEmpty() && 199 FrameMouseActions.getlastHighlightedItem() != null)200 possibles.add(FrameMouseActions.getlastHighlightedItem());186 if (FreeItems.getInstance().isEmpty() && StandardGestureActions.getlastHighlightedItem() != null) { 187 possibles.add(StandardGestureActions.getlastHighlightedItem()); 188 } 201 189 202 190 for (Item i : possibles) { 203 191 204 InteractiveWidget iw = null;192 Widget iw = null; 205 193 206 194 if (i instanceof WidgetCorner) { … … 216 204 217 205 if (seen == null) { 218 seen = new LinkedList< InteractiveWidget>();206 seen = new LinkedList<Widget>(); 219 207 } else if (seen.contains(iw)) { 220 208 continue; … … 235 223 } 236 224 237 if ((A udioFrameMouseActions.isYAxisRestictionOn() || AudioFrameMouseActions.isSnapOn())225 if ((ApolloGestureActions.isYAxisRestictionOn() || ApolloGestureActions.isSnapOn()) 238 226 && !FreeItems.getInstance().isEmpty()) { 239 227 … … 255 243 } 256 244 257 private void invalidateHelperLines(Area currentClip) { 258 if (currentClip != null) { 259 260 if (timeHelperLinesToPaint != null && !timeHelperLinesToPaint.isEmpty()) { 261 currentClip.add(new Area(OverdubbedFrameTimeAxis.getInstance().getCurrentTimelineArea())); 262 if (shouldDrawFullscreenHelpers) { 263 int fsHeight = Browser._theBrowser.getContentPane().getHeight(); 264 for (Integer n : timeHelperLinesToPaint) { 265 currentClip.add(new Area(new Rectangle(n - 1, 0, 3, fsHeight))); 266 } 267 } 268 } 269 270 if (yAxisTimelineHelperToPaint != null && shouldDrawFullscreenHelpers) { 271 272 currentClip.add(new Area(new Rectangle( 273 0, 274 yAxisTimelineHelperToPaint.value - 1, 275 Browser._theBrowser.getContentPane().getWidth(), 276 3))); 277 278 } 279 } 280 } 281 282 283 284 245 private void invalidateHelperLines(Clip currentClip) 246 { 247 if (currentClip == null) return; 248 249 if (timeHelperLinesToPaint != null && !timeHelperLinesToPaint.isEmpty()) { 250 currentClip.includeBounds(OverdubbedFrameTimeAxis.getInstance().getCurrentTimelineArea().clone()); 251 if (shouldDrawFullscreenHelpers) { 252 int fsHeight = EcosystemManager.getGraphicsManager().getWindowSize().getHeight(); 253 for (Integer n : timeHelperLinesToPaint) { 254 currentClip.includeBounds(new AxisAlignedBoxBounds(n - 1, 0, 3, fsHeight)); 255 } 256 } 257 } 258 259 if (yAxisTimelineHelperToPaint != null && shouldDrawFullscreenHelpers) { 260 261 currentClip.includeBounds(new AxisAlignedBoxBounds( 262 0, 263 yAxisTimelineHelperToPaint.value - 1, 264 EcosystemManager.getGraphicsManager().getWindowSize().getWidth(), 265 3)); 266 267 } 268 } 285 269 }
Note:
See TracChangeset
for help on using the changeset viewer.