Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC Browser Plugins
Commits
3e3894e1
Commit
3e3894e1
authored
Jan 02, 2013
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windowed mac plugin: draft for mouse event handling
parent
cc39dc8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
npapi/vlcplugin_mac.mm
npapi/vlcplugin_mac.mm
+93
-0
No files found.
npapi/vlcplugin_mac.mm
View file @
3e3894e1
...
...
@@ -45,8 +45,15 @@
CGImageRef
_sliderTrackCenter
;
CGImageRef
_knob
;
BOOL
_wasPlayingBeforeMouseDown
;
BOOL
_isScrubbing
;
CGFloat
_mouseDownXDelta
;
}
-
(
BOOL
)
_isPlaying
;
-
(
void
)
handleMouseDown
:(
CGPoint
)
point
;
-
(
void
)
handleMouseUp
:(
CGPoint
)
point
;
-
(
void
)
handleMouseDragged
:(
CGPoint
)
point
;
@end
...
...
@@ -155,9 +162,33 @@ bool VlcPluginMac::handle_event(void *event)
if
(
cocoaEvent
->
data
.
mouse
.
clickCount
>=
2
)
VlcPluginMac
::
toggle_fullscreen
();
CGPoint
point
=
CGPointMake
(
cocoaEvent
->
data
.
mouse
.
pluginX
,
// Flip the y coordinate
npwindow
.
height
-
cocoaEvent
->
data
.
mouse
.
pluginY
);
[
controllerLayer
handleMouseDown
:[
rootLayer
convertPoint
:
point
toLayer
:
controllerLayer
]];
return
true
;
}
case
NPCocoaEventMouseUp
:
{
CGPoint
point
=
CGPointMake
(
cocoaEvent
->
data
.
mouse
.
pluginX
,
// Flip the y coordinate
npwindow
.
height
-
cocoaEvent
->
data
.
mouse
.
pluginY
);
[
controllerLayer
handleMouseUp
:[
rootLayer
convertPoint
:
point
toLayer
:
controllerLayer
]];
return
true
;
}
case
NPCocoaEventMouseDragged
:
{
CGPoint
point
=
CGPointMake
(
cocoaEvent
->
data
.
mouse
.
pluginX
,
// Flip the y coordinate
npwindow
.
height
-
cocoaEvent
->
data
.
mouse
.
pluginY
);
[
controllerLayer
handleMouseDragged
:[
rootLayer
convertPoint
:
point
toLayer
:
controllerLayer
]];
return
true
;
}
case
NPCocoaEventKeyUp
:
case
NPCocoaEventKeyDown
:
case
NPCocoaEventFocusChanged
:
...
...
@@ -415,5 +446,67 @@ static CGImageRef createImageNamed(NSString *name)
[
self
_drawSliderInContext
:
cgContext
];
}
#pragma mark -
#pragma mark event handling
-
(
void
)
_setNewTimeForThumbCenterX
:(
CGFloat
)
centerX
{
CGRect
innerRect
=
[
self
_innerSliderRect
];
CGFloat
fraction
=
(
centerX
-
CGRectGetMinX
(
innerRect
))
/
CGRectGetWidth
(
innerRect
);
if
(
fraction
>
1.0
)
fraction
=
1.0
;
else
if
(
fraction
<
0.0
)
fraction
=
0.0
;
printf
(
"duration needed
\n
"
);
[
self
setNeedsDisplay
];
}
-
(
void
)
handleMouseDown
:(
CGPoint
)
point
{
if
(
CGRectContainsPoint
([
self
_sliderRect
],
point
))
{
_wasPlayingBeforeMouseDown
=
[
self
_isPlaying
];
_isScrubbing
=
YES
;
printf
(
"should pause
\n
"
);
if
(
CGRectContainsPoint
([
self
_sliderThumbRect
],
point
))
_mouseDownXDelta
=
point
.
x
-
CGRectGetMidX
([
self
_sliderThumbRect
]);
else
{
[
self
_setNewTimeForThumbCenterX
:
point
.
x
];
_mouseDownXDelta
=
0
;
}
}
}
-
(
void
)
handleMouseUp
:(
CGPoint
)
point
{
if
(
_isScrubbing
)
{
_isScrubbing
=
NO
;
_mouseDownXDelta
=
0
;
if
(
_wasPlayingBeforeMouseDown
)
printf
(
"start to play
\n
"
);
return
;
}
if
(
CGRectContainsPoint
([
self
_playPauseButtonRect
],
point
))
{
printf
(
"toggle play/pause
\n
"
);
return
;
}
}
-
(
void
)
handleMouseDragged
:(
CGPoint
)
point
{
if
(
!
_isScrubbing
)
return
;
point
.
x
-=
_mouseDownXDelta
;
[
self
_setNewTimeForThumbCenterX
:
point
.
x
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment