diff options
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java | 34 | ||||
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java | 53 |
2 files changed, 69 insertions, 18 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java index 4c7e82dc1..f26460240 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/MediaButton.java @@ -76,6 +76,8 @@ public class MediaButton extends TexSeqButton { private final float subZOffset; private boolean subEnabled; private float subLineHeightPct; + private float subLineDY = 0.25f; + private final Rectangle subBlend; private final List<ASSEventLine> assEventQueue = new ArrayList<ASSEventLine>(); private final Object assEventLock = new Object(); @@ -115,20 +117,33 @@ public class MediaButton extends TexSeqButton { this.subZOffset = Button.DEFAULT_LABEL_ZOFFSET; this.subLineHeightPct = subLineHeightPct; this.subLabel = new Label(renderModes, f, ""); - this.subLabel.setColor( new Vec4f( 1f, 1, 0f, 1.0f ) ); + this.subLabel.setColor( new Vec4f( 1, 1, 0, 1 ) ); this.subLabel.moveTo(0, 0, subZOffset); + this.subBlend = new Rectangle(renderModes, 1f, 1f, 0f); + this.subBlend.setColor( new Vec4f( 0, 0, 0, 0.2f ) ); } /** * Sets subtitle parameter * @param subFont subtitle font - * @param subLineHeightPct one subtitle line height percentage of this shape, default is 0.1f + * @param subLineHeightPct one subtitle line height percentage of this shape, default is 1/10 (0.1f) + * @param subLineDY y-axis offset to bottom in line-height, defaults to 1/4 (0.25f) */ - public void setSubtitleParams(final Font subFont, final float subLineHeightPct) { + public void setSubtitleParams(final Font subFont, final float subLineHeightPct, final float subLineDY) { this.subLabel.setFont(subFont); this.subLineHeightPct = subLineHeightPct; + this.subLineDY = subLineDY; this.subEnabled = true; } + /** + * Sets subtitle colors + * @param color color for the text, defaults to RGBA {@code 1, 1, 0, 1} + * @param blend blending alpha (darkness), defaults to 0.2f + */ + public void setSubtitleColor(final Vec4f color, final float blend) { + this.subLabel.setColor( color ); + this.subBlend.setColor( 0, 0, 0, blend ); + } public final ASSEventListener getASSEventListener() { return assEventListener; } private final ASSEventListener assEventListener = new ASSEventListener() { @@ -298,21 +313,24 @@ public class MediaButton extends TexSeqButton { subLabel.setText(ass.text); final AABBox subBox = subLabel.getBounds(gl.getGLProfile()); final float subLineHeight = subBox.getHeight() / ass.lines; - final float maxWidth = this.box.getWidth() * 0.95f; - float scale = ( this.box.getHeight() * subLineHeightPct ) / subLineHeight; + final float maxWidth = box.getWidth() * 0.95f; + float scale = ( box.getHeight() * subLineHeightPct ) / subLineHeight; if( scale * subBox.getWidth() > maxWidth ) { scale = maxWidth / subBox.getWidth(); } subLabel.setScale(scale, scale, 1); - final float dx = ( this.box.getWidth() - maxWidth ) * 0.5f; - final float dy = subLineHeight * scale * 0.25f; - this.subLabel.moveTo(dx, dy, subZOffset); + final float dx_s = ( box.getWidth() - maxWidth ) * 0.5f; + final float dy_s = subLineHeight * subLineDY * scale; + subLabel.moveTo(dx_s, dy_s, 2*subZOffset); + subBlend.setDimension(box.getWidth(), box.getHeight() * subLineHeightPct * ass.lines, 0f); + subBlend.setPosition(0, dy_s, 1*subZOffset); if( DEBUG_SUB ) { System.err.println("MediaButton: NEXT pts "+pts+", "+ass); } } } if( drawASS ) { + subBlend.draw(gl, renderer); final PMVMatrix4f pmv = renderer.getMatrix(); pmv.pushMv(); subLabel.applyMatToMv(pmv); diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java index 7c624a46b..07ed203f8 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java +++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java @@ -217,6 +217,7 @@ public class MediaPlayer extends Widget { final Button timeLabel; final float infoGroupHeight; final boolean[] hud_sticky = { false }; + final boolean[] info_full = { false }; { muteLabel = new Label(renderModes, fontSymbols, aratio/6f, fontSymbols.getUTF16String("music_off")); // volume_mute, headset_off muteLabel.setName("mp.mute"); @@ -283,7 +284,7 @@ public class MediaPlayer extends Widget { t0 = t1; final int ptsMS = mPlayer.getPTS().get(Clock.currentMillis()); final int durationMS = mPlayer.getDuration(); - infoLabel.setText(getInfo(ptsMS, durationMS, mPlayer, false)); + infoLabel.setText(getInfo(ptsMS, durationMS, mPlayer, info_full[0])); timeLabel.setText(getMultilineTime(ptsMS, durationMS)); ctrlSlider.setValue(ptsMS); } @@ -583,6 +584,24 @@ public class MediaPlayer extends Widget { }); this.addMouseListener(new Shape.MouseGestureAdapter() { @Override + public void mouseClicked(final MouseEvent e) { + final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment(); + final Vec3f p = shapeEvent.objPos; + if( p.y() > ( 1f - infoGroupHeight ) ) { + info_full[0] = !info_full[0]; + final float sxy = infoLabel.getScale().x(); + final float p_bottom_s = infoLabel.getPadding().bottom * sxy; + final float sxy2; + if( info_full[0] ) { + sxy2 = sxy * 0.5f; + } else { + sxy2 = sxy * 2f; + } + infoLabel.setScale(sxy2, sxy2, 1f); + infoLabel.setPaddding(new Padding(0, 0, p_bottom_s/sxy2, 0.5f)); + } + } + @Override public void mouseMoved(final MouseEvent e) { final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment(); final Vec3f p = shapeEvent.objPos; @@ -609,10 +628,21 @@ public class MediaPlayer extends Widget { * Sets subtitle parameter * @param subFont subtitle font * @param subLineHeightPct one subtitle line height percentage of this shape, default is 0.1f + * @param subLineDY y-axis offset to bottom in line-height, defaults to 1/4 (0.25f) + */ + public void setSubtitleParams(final Font subFont, final float subLineHeightPct, final float subLineDY) { + if( null != mButton ) { + mButton.setSubtitleParams(subFont, subLineHeightPct, subLineDY); + } + } + /** + * Sets subtitle colors + * @param color color for the text, defaults to RGBA {@code 1, 1, 0, 1} + * @param blend blending alpha (darkness), defaults to 0.2f */ - public void setSubtitleParams(final Font subFont, final float subLineHeightPct) { + public void setSubtitleColor(final Vec4f color, final float blend) { if( null != mButton ) { - mButton.setSubtitleParams(subFont, subLineHeightPct); + mButton.setSubtitleColor(color, blend); } } @@ -632,15 +662,18 @@ public class MediaPlayer extends Widget { final float aspect = (float)mPlayer.getWidth() / (float)mPlayer.getHeight(); final float pct = (float)ptsMS / (float)durationMS; if( full ) { - final String text1 = String.format("%s / %s (%.0f %%), %s (%01.2fx, vol %1.2f), A/R %0.2f, fps %02.1f", + final String text1 = String.format("%s / %s (%.0f %%), %s (%01.2fx, vol %1.2f), A/R %.2f, fps %02.1f, kbps %.2f", PTS.millisToTimeStr(ptsMS, false), PTS.millisToTimeStr(durationMS, false), pct*100, - mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, mPlayer.getFramerate()); - final String text2 = String.format("audio: id %d (%s), kbps %d, codec %s; sid %d (%s)", - mPlayer.getAID(), mPlayer.getLang(mPlayer.getAID()), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec(), + mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, + mPlayer.getFramerate(), mPlayer.getStreamBitrate()/1000.0f); + final String text2 = String.format("video: id %d (%s), kbps %.2f, codec %s", + mPlayer.getVID(), mPlayer.getLang(mPlayer.getVID()), mPlayer.getVideoBitrate()/1000.0f, mPlayer.getVideoCodec()); + final String text3 = String.format("audio: id %d (%s), kbps %.2f, codec %s; sid %d (%s)", + mPlayer.getAID(), mPlayer.getLang(mPlayer.getAID()), mPlayer.getAudioBitrate()/1000.0f, mPlayer.getAudioCodec(), mPlayer.getSID(), mPlayer.getLang(mPlayer.getSID()) ); - final String text3 = String.format("video: id %d, kbps %d, codec %s", - mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); - return text1+"\n"+text2+"\n"+text3+"\n"+mPlayer.getTitle()+chapter; + final String text4 = String.format("sub : id %d (%s), codec %s", + mPlayer.getSID(), mPlayer.getLang(mPlayer.getSID()), mPlayer.getSubtitleCodec()); + return text1+"\n"+text2+"\n"+text3+"\n"+text4+"\n"+mPlayer.getTitle()+chapter; } else { final String vinfo, ainfo, sinfo; if( mPlayer.getVID() != GLMediaPlayer.STREAM_ID_NONE ) { |