holding CTRL + ALT + SHIFT will now release the mouse. Also fixed mouse re-centering issue (i believe. I cannot test for sure on my system)

This commit is contained in:
Diego Waxemberg
2013-12-12 19:45:35 -05:00
parent af3369ec5c
commit c8235da7bb
3 changed files with 149 additions and 95 deletions

View File

@@ -26,23 +26,33 @@ import com.limelight.nvstream.NvConnectionListener.Stage;
public class StreamFrame extends JFrame {
private static final long serialVersionUID = 1L;
private int centerX;
private int centerY;
private KeyboardHandler keyboard;
private MouseHandler mouse;
private JProgressBar spinner;
private JLabel spinnerLabel;
private Cursor noCursor;
private NvConnection conn;
public StreamFrame() {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setSize(1280,720);
centerX = dim.width/2-this.getSize().width/2;
centerY = dim.height/2-this.getSize().height/2;
}
public void freeMouse() {
mouse.free();
showCursor();
}
public void captureMouse() {
mouse.capture();
hideCursor();
}
public void build(NvConnection conn, boolean fullscreen) {
this.conn = conn;
@@ -59,11 +69,11 @@ public class StreamFrame extends JFrame {
this.setLocation(centerX, 0);
this.setBackground(Color.BLACK);
if (fullscreen) {
makeFullScreen();
}
hideCursor();
this.setVisible(true);
}
@@ -83,60 +93,66 @@ public class StreamFrame extends JFrame {
}
}
private void hideCursor() {
// Transparent 16 x 16 pixel cursor image.
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Create a new blank cursor.
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
cursorImg, new Point(0, 0), "blank cursor");
public void hideCursor() {
if (noCursor == null) {
// Transparent 16 x 16 pixel cursor image.
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Create a new blank cursor.
noCursor = Toolkit.getDefaultToolkit().createCustomCursor(
cursorImg, new Point(0, 0), "blank cursor");
}
// Set the blank cursor to the JFrame.
this.getContentPane().setCursor(blankCursor);
this.setCursor(noCursor);
this.getContentPane().setCursor(noCursor);
}
public void showCursor() {
this.setCursor(Cursor.getDefaultCursor());
this.getContentPane().setCursor(Cursor.getDefaultCursor());
}
public void showSpinner(Stage stage) {
if (spinner == null) {
Container c = this.getContentPane();
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
spinner = new JProgressBar();
spinner.setIndeterminate(true);
spinner.setMaximumSize(new Dimension(150, 30));
spinnerLabel = new JLabel();
spinnerLabel.setForeground(Color.white);
Box spinBox = Box.createHorizontalBox();
spinBox.add(Box.createHorizontalGlue());
spinBox.add(spinner);
spinBox.add(Box.createHorizontalGlue());
Box lblBox = Box.createHorizontalBox();
lblBox.add(Box.createHorizontalGlue());
lblBox.add(spinnerLabel);
lblBox.add(Box.createHorizontalGlue());
panel.add(Box.createVerticalGlue());
panel.add(spinBox);
panel.add(Box.createVerticalStrut(10));
panel.add(lblBox);
panel.add(Box.createVerticalGlue());
c.setLayout(new BorderLayout());
c.add(panel, "Center");
}
spinnerLabel.setText("Starting " + stage.getName() + "...");
}
public void hideSpinner() {
spinner.setVisible(false);
spinnerLabel.setVisible(false);
}
public void close() {
dispose();
conn.stop();