-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial changes for native window callbacks
- Loading branch information
Showing
7 changed files
with
207 additions
and
86 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/uk/co/caprica/vlcj/player/base/MouseButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* This file is part of VLCJ. | ||
* | ||
* VLCJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VLCJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright 2009-2024 Caprica Software Limited. | ||
*/ | ||
|
||
package uk.co.caprica.vlcj.player.base; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Enumeration of video output mouse buttons. | ||
*/ | ||
public enum MouseButton { | ||
|
||
LEFT ( 0), | ||
MIDDLE( 1), | ||
RIGHT ( 2); | ||
|
||
private static final Map<Integer, MouseButton> INT_MAP = new HashMap<Integer, MouseButton>(); | ||
|
||
static { | ||
for (MouseButton value : MouseButton.values()) { | ||
INT_MAP.put(value.intValue, value); | ||
} | ||
} | ||
|
||
public static MouseButton mouseButton(int intValue) { | ||
return INT_MAP.get(intValue); | ||
} | ||
|
||
private final int intValue; | ||
|
||
MouseButton(int intValue) { | ||
this.intValue = intValue; | ||
} | ||
|
||
public int intValue() { | ||
return intValue; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
...prica/vlcj/player/embedded/videosurface/videoengine/VideoEngineResizeCallbackHandler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...prica/vlcj/player/embedded/videosurface/videoengine/VideoEngineWindowCallbackHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* This file is part of VLCJ. | ||
* | ||
* VLCJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VLCJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright 2009-2024 Caprica Software Limited. | ||
*/ | ||
|
||
package uk.co.caprica.vlcj.player.embedded.videosurface.videoengine; | ||
|
||
import com.sun.jna.Pointer; | ||
import uk.co.caprica.vlcj.binding.internal.libvlc_video_output_resize_cb; | ||
import uk.co.caprica.vlcj.binding.internal.libvlc_video_output_mouse_move_cb; | ||
import uk.co.caprica.vlcj.binding.internal.libvlc_video_output_mouse_press_cb; | ||
import uk.co.caprica.vlcj.binding.internal.libvlc_video_output_mouse_release_cb; | ||
import uk.co.caprica.vlcj.player.base.MouseButton; | ||
|
||
/** | ||
* Handler component that bridges a vlcj application with the native video engine window callback. | ||
*/ | ||
public final class VideoEngineWindowCallbackHandler implements VideoEngineWindowCallback { | ||
|
||
/** | ||
* Opaque pointer associated with the callbacks. | ||
*/ | ||
private final Pointer opaque; | ||
|
||
/** | ||
* Opaque pointer for the native report size changed callback. | ||
* <p> | ||
* This pointer <strong>must</strong> be passed with the native callback method. | ||
*/ | ||
private final Pointer reportOpaque; | ||
|
||
/** | ||
* Native callback. | ||
*/ | ||
private final libvlc_video_output_resize_cb resize; | ||
|
||
private final libvlc_video_output_mouse_move_cb mouseMove; | ||
|
||
private final libvlc_video_output_mouse_press_cb mousePress; | ||
|
||
private final libvlc_video_output_mouse_release_cb mouseRelease; | ||
|
||
/** | ||
* Create a window callback handler. | ||
* | ||
* @param opaque opaque pointer associated with the callbacks | ||
* @param reportOpaque opaque pointer for the native report callbacks | ||
* @param resize native callback for window resizes | ||
* @param mouseMove native callback for mouse moves | ||
* @param mousePress native callback for mouse presses | ||
* @param mouseRelease native callback for mouse releases | ||
*/ | ||
public VideoEngineWindowCallbackHandler(Pointer opaque, Pointer reportOpaque, libvlc_video_output_resize_cb resize, libvlc_video_output_mouse_move_cb mouseMove, libvlc_video_output_mouse_press_cb mousePress, libvlc_video_output_mouse_release_cb mouseRelease) { | ||
this.opaque = opaque; | ||
this.reportOpaque = reportOpaque; | ||
this.resize = resize; | ||
this.mouseMove = mouseMove; | ||
this.mousePress = mousePress; | ||
this.mouseRelease = mouseRelease; | ||
} | ||
|
||
@Override | ||
public void setSize(int width, int height) { | ||
if (resize != null) { | ||
resize.reportSizeChanged(reportOpaque, width, height); | ||
} | ||
} | ||
|
||
@Override | ||
public void mouseMoved(int x, int y) { | ||
if (mouseMove != null) { | ||
mouseMove.mouseMove(reportOpaque, x, y); | ||
} | ||
} | ||
|
||
@Override | ||
public void mousePressed(MouseButton mouseButton) { | ||
if (mousePress != null) { | ||
mousePress.mousePress(reportOpaque, mouseButton.intValue()); | ||
} | ||
} | ||
|
||
@Override | ||
public void mouseReleased(MouseButton mouseButton) { | ||
if (mouseRelease != null) { | ||
mouseRelease.mouseRelease(reportOpaque, mouseButton.intValue()); | ||
} | ||
} | ||
} |