refactored shitty unusable code
Signed-off-by: rattatwinko <seppmutterman@gmail.com>
This commit is contained in:
@@ -3,26 +3,18 @@ package io.swtc;
|
||||
import com.github.sarxos.webcam.Webcam;
|
||||
import io.swtc.proccessing.WebcamCaptureLoop;
|
||||
import io.swtc.proccessing.CameraPanel;
|
||||
import io.swtc.proccessing.FilterPanel;
|
||||
import io.swtc.recording.VideoRecorder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Blender-style UI where the Effects panel is triggered by a Tab click
|
||||
*/
|
||||
public class SwingIFrame {
|
||||
private final JFrame mainFrame;
|
||||
private final BlenderDesktopPane desktopPane;
|
||||
@@ -66,17 +58,16 @@ public class SwingIFrame {
|
||||
|
||||
tabbedPane.addTab("View", cameraPanel);
|
||||
tabbedPane.addTab("Capture", createCapturePanel(cameraPanel, webcam));
|
||||
// Add a placeholder tab that acts as a button
|
||||
tabbedPane.addTab("Open Effect Panel", new JPanel());
|
||||
tabbedPane.addTab("Effects", new JPanel());
|
||||
|
||||
contentPanel.add(tabbedPane, BorderLayout.CENTER);
|
||||
tabbedPane.setPreferredSize(null);
|
||||
|
||||
// Logic to open/show the Effects Frame when the tab is clicked
|
||||
// where we show the effectpanel (io.swtc.proccessing.FilterPanel.java)
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (tabbedPane.getSelectedIndex() == 2) { // "Effects +" tab index
|
||||
// Revert selection back to "View" so the tab doesn't stay stuck on the empty panel
|
||||
if (tabbedPane.getSelectedIndex() == 2) {
|
||||
tabbedPane.setSelectedIndex(0);
|
||||
|
||||
EffectsPanelFrame effectsFrame = cameraToEffects.get(cameraFrame);
|
||||
@@ -234,6 +225,8 @@ public class SwingIFrame {
|
||||
this.connections = connections;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintChildren(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
@@ -273,16 +266,41 @@ public class SwingIFrame {
|
||||
}
|
||||
|
||||
static class EffectsPanelFrame extends JInternalFrame {
|
||||
|
||||
public EffectsPanelFrame(String title, CameraPanel cameraPanel, JInternalFrame cameraFrame) {
|
||||
super(title, true, true, true, true);
|
||||
add(new FilterPanel(cameraPanel));
|
||||
|
||||
// Repaint curves when moving or iconifying
|
||||
// Hide instead of dispose so it can be reopened
|
||||
setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
|
||||
|
||||
// Add your FilterPanel
|
||||
add(new io.swtc.proccessing.FilterPanel(cameraPanel));
|
||||
|
||||
// Repaint desktop pane when this frame closes so the Bézier disappears
|
||||
addInternalFrameListener(new InternalFrameAdapter() {
|
||||
@Override
|
||||
public void internalFrameClosing(InternalFrameEvent e) {
|
||||
if (getDesktopPane() != null) {
|
||||
getDesktopPane().repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Repaint curves when moving or resizing
|
||||
addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
@Override public void componentMoved(java.awt.event.ComponentEvent e) {
|
||||
if(getDesktopPane() != null) getDesktopPane().repaint();
|
||||
@Override
|
||||
public void componentMoved(java.awt.event.ComponentEvent e) {
|
||||
if (getDesktopPane() != null)
|
||||
getDesktopPane().repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(java.awt.event.ComponentEvent e) {
|
||||
if (getDesktopPane() != null)
|
||||
getDesktopPane().repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user