[vlc-commits] Windowed Mac plugin: added fullscreen button to toolbar
Felix Paul Kühne
git at videolan.org
Thu Jan 3 22:13:03 CET 2013
npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Jan 3 22:12:45 2013 +0100| [d9a4f8dbac877374b3799c26f827e8ccc7a43873] | committer: Felix Paul Kühne
Windowed Mac plugin: added fullscreen button to toolbar
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=d9a4f8dbac877374b3799c26f827e8ccc7a43873
---
npapi/vlcplugin_mac.h | 3 ---
npapi/vlcplugin_mac.mm | 44 +++++++++++++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/npapi/vlcplugin_mac.h b/npapi/vlcplugin_mac.h
index 2d89c74..dfe4b0c 100644
--- a/npapi/vlcplugin_mac.h
+++ b/npapi/vlcplugin_mac.h
@@ -34,8 +34,6 @@ public:
VlcPluginMac(NPP, NPuint16_t);
virtual ~VlcPluginMac();
- int setSize(unsigned width, unsigned height);
-
void toggle_fullscreen();
void set_fullscreen( int );
int get_fullscreen();
@@ -49,7 +47,6 @@ public:
void update_controls();
void popup_menu() {/* STUB */}
-
bool handle_event(void *event);
NPError get_root_layer(void *value);
diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index d2e9757..4040f7e 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -44,6 +44,9 @@
CGImageRef _sliderTrackRight;
CGImageRef _sliderTrackCenter;
+ CGImageRef _enterFullscreen;
+ CGImageRef _leaveFullscreen;
+
CGImageRef _knob;
BOOL _wasPlayingBeforeMouseDown;
@@ -52,11 +55,13 @@
double _position;
BOOL _isPlaying;
+ BOOL _isFullscreen;
VlcPluginMac *_cppPlugin;
}
@property (readwrite) double mediaPosition;
@property (readwrite) BOOL isPlaying;
+ at property (readwrite) BOOL isFullscreen;
@property (readwrite) VlcPluginMac * cppPlugin;
- (void)handleMouseDown:(CGPoint)point;
@@ -65,6 +70,12 @@
@end
+ at interface VLCControllerLayer (Internal)
+- (CGRect)_playPauseButtonRect;
+- (CGRect)_fullscreenButtonRect;
+- (CGRect)_sliderRect;
+ at end
+
static CALayer * rootLayer;
static VLCNoMediaLayer * noMediaLayer;
static VLCControllerLayer * controllerLayer;
@@ -92,14 +103,16 @@ void VlcPluginMac::toggle_fullscreen()
return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(getMD());
+ this->update_controls();
}
-void VlcPluginMac::set_fullscreen(int yes)
+void VlcPluginMac::set_fullscreen(int i_value)
{
if (!get_options().get_enable_fs())
return;
if (playlist_isplaying())
- libvlc_set_fullscreen(getMD(), yes);
+ libvlc_set_fullscreen(getMD(), i_value);
+ this->update_controls();
}
int VlcPluginMac::get_fullscreen()
@@ -124,6 +137,7 @@ void VlcPluginMac::update_controls()
{
[controllerLayer setMediaPosition: libvlc_media_player_get_position(getMD())];
[controllerLayer setIsPlaying: playlist_isplaying()];
+ [controllerLayer setIsFullscreen:this->get_fullscreen()];
[controllerLayer setNeedsDisplay];
}
@@ -330,6 +344,7 @@ bool VlcPluginMac::handle_event(void *event)
@synthesize mediaPosition = _position;
@synthesize isPlaying = _isPlaying;
+ at synthesize isFullscreen = _isFullscreen;
@synthesize cppPlugin = _cppPlugin;
static CGImageRef createImageNamed(NSString *name)
@@ -362,6 +377,9 @@ static CGImageRef createImageNamed(NSString *name)
_sliderTrackRight = createImageNamed(@"SliderTrackRight");
_sliderTrackCenter = createImageNamed(@"SliderTrackCenter");
+ _enterFullscreen = createImageNamed(@"enter-fullscreen");
+ _leaveFullscreen = createImageNamed(@"leave-fullscreen");
+
_knob = createImageNamed(@"Knob");
}
@@ -377,6 +395,9 @@ static CGImageRef createImageNamed(NSString *name)
CGImageRelease(_sliderTrackRight);
CGImageRelease(_sliderTrackCenter);
+ CGImageRelease(_enterFullscreen);
+ CGImageRelease(_leaveFullscreen);
+
CGImageRelease(_knob);
[super dealloc];
@@ -387,16 +408,21 @@ static CGImageRef createImageNamed(NSString *name)
- (CGRect)_playPauseButtonRect
{
- return CGRectMake(4, (25 - CGImageGetHeight(_playImage)) / 2, CGImageGetWidth(_playImage), CGImageGetHeight(_playImage));
+ return CGRectMake(4., (25. - CGImageGetHeight(_playImage)) / 2., CGImageGetWidth(_playImage), CGImageGetHeight(_playImage));
+}
+
+- (CGRect)_fullscreenButtonRect
+{
+ return CGRectMake( CGRectGetMaxX([self _sliderRect]), (25. - CGImageGetHeight(_enterFullscreen)) / 2., CGImageGetWidth(_enterFullscreen), CGImageGetHeight(_enterFullscreen));
}
- (CGRect)_sliderRect
{
- CGFloat sliderYPosition = (self.bounds.size.height - CGImageGetHeight(_sliderTrackLeft)) / 2.0;
+ CGFloat sliderYPosition = (self.bounds.size.height - CGImageGetHeight(_sliderTrackLeft)) / 2.;
CGFloat playPauseButtonWidth = [self _playPauseButtonRect].size.width;
return CGRectMake(playPauseButtonWidth + 7, sliderYPosition,
- self.bounds.size.width - playPauseButtonWidth - 10, CGImageGetHeight(_sliderTrackLeft));
+ self.bounds.size.width - playPauseButtonWidth - 15 - CGImageGetWidth(_enterFullscreen), CGImageGetHeight(_sliderTrackLeft));
}
- (CGRect)_sliderThumbRect
@@ -441,6 +467,10 @@ static CGImageRef createImageNamed(NSString *name)
CGImageGetWidth(_sliderTrackRight), CGImageGetHeight(_sliderTrackRight));
CGContextDrawImage(context, sliderRightTrackRect, _sliderTrackRight);
+ // Draw fullscreen button
+ CGRect fullscreenButtonRect = [self _fullscreenButtonRect];
+ fullscreenButtonRect.origin.x = CGRectGetMaxX(sliderRightTrackRect) + 5;
+ CGContextDrawImage(context, fullscreenButtonRect, self.isFullscreen ? _leaveFullscreen : _enterFullscreen);
}
- (void)drawInContext:(CGContextRef)cgContext
@@ -504,6 +534,10 @@ static CGImageRef createImageNamed(NSString *name)
self.cppPlugin->playlist_togglePause();
return;
}
+ if (CGRectContainsPoint([self _fullscreenButtonRect], point)) {
+ self.cppPlugin->toggle_fullscreen();
+ return;
+ }
}
- (void)handleMouseDragged:(CGPoint)point
More information about the vlc-commits
mailing list