Commit 35e0ddd8 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Trying to improve performance. Espc. when it comes to painting the skin preview.

parent 466a0eb1
rd /S /Q build
md build
cd src
javac -d ../build vlcskineditor/Main.java
javac -O -d ../build vlcskineditor/Main.java
cd ..
md build\vlcskineditor\icons
copy src\vlcskineditor\icons build\vlcskineditor\icons\
......
......@@ -2,7 +2,7 @@
mkdir -p build/vlcskineditor/icons
cd src/
`javac -d ../build vlcskineditor/Main.java`
`javac -O -d ../build vlcskineditor/Main.java`
cd ..
cp src/vlcskineditor/icons/* build/vlcskineditor/icons
echo "Main-Class: vlcskineditor.Main" > manifest_no_nb
......
......@@ -79,10 +79,14 @@ public class GlobalVariables implements ActionListener{
paused_cb,seekable_cb,mute_cb,ontop_cb,random_cb,loop_cb,repeat_cb,dvd_cb;
JSlider slider_s;
JButton ok_btn,help_btn;
private Skin s;
/** Creates a new instance of GlobalVariables */
public GlobalVariables() {
/** Creates a new instance of GlobalVariables
* @param s_ The parent skin
*/
public GlobalVariables(Skin s_) {
s = s_;
}
/**
* Parses text variables in a string
......@@ -369,6 +373,15 @@ public class GlobalVariables implements ActionListener{
playlist_isRepeat = Boolean.parseBoolean(repeat_cb.getSelectedItem().toString());
dvd_isActive = Boolean.parseBoolean(dvd_cb.getSelectedItem().toString());
slider_value = (float)(slider_s.getValue())/100;
for(Window w:s.windows) {
for(Layout l:w.layouts) {
for(Item i:l.items) {
i.updateToGlobalVariables();
}
}
}
}
/**
* Handles actions triggered by components listened to
......
......@@ -64,6 +64,8 @@ public abstract class Item {
public int offsetx = 0;
public int offsety = 0;
protected boolean vis = true;
/** Determines whether the process of creating the object has finished **/
public boolean created = false;
......@@ -148,4 +150,10 @@ public abstract class Item {
}
id = newid;
}
/**
* Invokes the item to update its variables that depend on the global variables
*/
public void updateToGlobalVariables() {
vis = s.gvars.parseBoolean(visible);
}
}
......@@ -435,7 +435,7 @@ public class Layout implements ActionListener{
}
/**
* Generates the XML code represented by this Layout.
* @param ident Indentation
* @param indent Indentation
* @return The XML code.
*/
public String returnCode(String indent) {
......
......@@ -46,12 +46,12 @@ import vlcskineditor.resources.SubBitmap;
*/
public class Main extends javax.swing.JFrame implements ActionListener, TreeSelectionListener, WindowListener, MouseListener{
private static final long serialVersionUID = 70L; //For completions sake
private static final long serialVersionUID = 071;
private final String updateURL_s = "http://www.videolan.org/vlc/skineditor_update.php";
//The version identification of the current build.
public final String VERSION = "0.7.x.dev";
public final String VERSION = "0.7.1.dev";
//The directory in which the VLC executable is found
String vlc_dir = "";
//The directory from which VLC loads its skins
......@@ -610,7 +610,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
/**
* Shows a dialog from which the user can choose to either create a new skin, open an existing skin or quit the skin editor.
*/
private void showWelcomeDialog() {
public void showWelcomeDialog() {
Object[] options= {"Create a new skin", "Open an exisiting skin","Quit"};
int n = JOptionPane.showOptionDialog(this,"What would you like to do?","Welcome to the VLC Skin Editor",
JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]);
......@@ -673,7 +673,10 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
if(!opened) showWelcomeDialog();
return;
}
opening = true;
opening = true;
if(pvwin!=null) {
pvwin.clearLayout();
}
ProgressWindow pwin = new ProgressWindow(this,"");
if(f.toString().toLowerCase().endsWith(".vlt")) {
String vltname = f.getName().replaceAll(".vlt","");
......@@ -765,8 +768,7 @@ public class Main extends javax.swing.JFrame implements ActionListener, TreeSele
}
pwin.setText("Parsing XML...");
pwin.setVisible(true);
setTitle(f.toString()+" - VLC Skin Editor "+VERSION);
pvwin.clearLayout();
setTitle(f.toString()+" - VLC Skin Editor "+VERSION);
m_file_png.setEnabled(false);
s.open(f);
selected_resource = null;
......
......@@ -37,6 +37,8 @@ import vlcskineditor.history.*;
*/
public class PreviewWindow extends JPanel implements MouseListener, MouseMotionListener, ActionListener {
public static final long serialVersionUID = 071;
/**
* The JFrame in which a Layout of a Skin will be shown.
*/
......
......@@ -97,7 +97,7 @@ public class Skin implements ActionListener{
JTextField theme_magnet_tf, theme_alpha_tf, theme_movealpha_tf;
JButton theme_ok_btn, theme_cancel_btn, theme_help_btn;
public GlobalVariables gvars = new GlobalVariables();
public GlobalVariables gvars = new GlobalVariables(this);
//Central window handle for all editing dialogs of res/win/layout/items
public JFrame edit_frame;
......@@ -132,13 +132,21 @@ public class Skin implements ActionListener{
catch (Exception ex) {
ex.printStackTrace();
String stackTrace ="";
for (int i=0;i<ex.getStackTrace().length;i++) {
/*for (int i=0;i<ex.getStackTrace().length;i++) {
stackTrace+=ex.getStackTrace()[i].toString()+"\n";
}
}*/
JOptionPane.showMessageDialog(null,ex.toString()+"\n\n"+stackTrace,ex.getMessage(),JOptionPane.ERROR_MESSAGE);
update();
m.showWelcomeDialog();
}
update();
update();
for(Window w:windows) {
for(Layout l:w.layouts) {
for(Item i:l.items) {
i.updateToGlobalVariables();
}
}
}
}
/**
* Parses the given file line by line, expecting each xml-tag to be in his own single line
......
......@@ -423,7 +423,7 @@ public class Button extends Item implements ActionListener{
else {
bi = down_res.image;
}
if(s.gvars.parseBoolean(visible)==true) g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(vis) g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(selected) {
g.setColor(Color.RED);
g.drawRect((x+x_)*z,(y+y_)*z,bi.getWidth()*z-1,bi.getHeight()*z-1);
......
......@@ -66,6 +66,8 @@ public class Checkbox extends Item implements ActionListener{
ImageResource up1_res, over1_res, down1_res, up2_res, over2_res, down2_res;
ActionEditor action1_ae, action2_ae;
private boolean state_bool = true;
/** Creates a new instance of Checkbox
* @param xmlcode The XML code
......@@ -568,7 +570,7 @@ public class Checkbox extends Item implements ActionListener{
public void draw(Graphics2D g, int x_, int y_, int z) {
if(!created) return;
java.awt.image.BufferedImage bi = null;
if(s.gvars.parseBoolean(state)) {
if(state_bool) {
if(!hovered || ( (over2.equals("none") && !clicked)||(clicked && down2.equals("none")) )) bi = up2_res.image;
else if(!clicked || down2.equals("none")) bi = over2_res.image;
else bi = down2_res.image;
......@@ -578,7 +580,7 @@ public class Checkbox extends Item implements ActionListener{
else if(!clicked || down1.equals("none")) bi = over1_res.image;
else bi = down1_res.image;
}
if(s.gvars.parseBoolean(visible)==true )g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(vis)g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(selected) {
g.setColor(Color.RED);
g.drawRect((x+x_)*z,(y+y_)*z,bi.getWidth()*z-1,bi.getHeight()*z-1);
......@@ -597,4 +599,9 @@ public class Checkbox extends Item implements ActionListener{
public boolean uses(String id_) {
return (up1.equals(id_)||up2.equals(id_)||over1.equals(id_)||over2.equals(id_)||down1.equals(id_)||down2.equals(id_));
}
@Override
public void updateToGlobalVariables() {
vis = s.gvars.parseBoolean(visible);
state_bool = s.gvars.parseBoolean(state);
}
}
......@@ -391,7 +391,7 @@ public class Image extends Item implements ActionListener{
public void draw(Graphics2D g,int x_, int y_, int z) {
if(!created) return;
BufferedImage bi = image_res.image;
if(s.gvars.parseBoolean(visible)==true) g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(vis) g.drawImage(bi,(x+x_)*z,(y+y_)*z,bi.getWidth()*z,bi.getHeight()*z,null);
if(selected) {
g.setColor(Color.RED);
g.drawRect((x+x_)*z,(y+y_)*z,bi.getWidth()*z-1,bi.getHeight()*z-1);
......
......@@ -668,7 +668,7 @@ public class Playtree extends Item implements ActionListener{
Graphics2D g = (Graphics2D)(buffi.getGraphics());
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
if(!created) return;
if(s.gvars.parseBoolean(visible)==true) {
if(vis) {
Font f = s.getFont(font);
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
......
......@@ -66,6 +66,9 @@ public class Slider extends Item implements ActionListener{
Bezier b;
int[] xpos,ypos;
private Point2D.Float sliderPos;
private Point2D.Float[] bezierPoints;
/** Creates a new instance of Slider
* @param xmlcode The XML code
......@@ -176,6 +179,11 @@ public class Slider extends Item implements ActionListener{
ypos[i] = Integer.parseInt(coords[1].replaceAll("\\)","").trim());
}
b = new Bezier(xpos,ypos,Bezier.kCoordsBoth);
sliderPos = b.getPoint(s.gvars.getSliderValue());
bezierPoints = new Point2D.Float[11];
for(float f=0;f<=100;f+=10) {
bezierPoints[(int)(f/10)] = b.getPoint(f/100);
}
}
public void update() {
if(!created) {
......@@ -572,22 +580,26 @@ public class Slider extends Item implements ActionListener{
if(!created) return;
offsetx=x_;
offsety=y_;
boolean vis = s.gvars.parseBoolean(visible);
//boolean vis = s.gvars.parseBoolean(visible);
if(sbg!=null && vis) {
sbg.draw(g,x+x_,y+y_,z);
sbg.setOffset(x+offsetx,y+offsety);
}
java.awt.image.BufferedImage si = up_res.image;
Point2D.Float p = b.getPoint(s.gvars.getSliderValue());
if(vis && si!=null) g.drawImage(si,(int)(p.getX()+x+x_-si.getWidth()/2)*z,(int)(p.getY()+y+y_-si.getHeight()/2)*z,si.getWidth()*z,si.getHeight()*z,null);
if(vis && si!=null) g.drawImage(si,(int)(sliderPos.getX()+x+x_-si.getWidth()/2)*z,(int)(sliderPos.getY()+y+y_-si.getHeight()/2)*z,si.getWidth()*z,si.getHeight()*z,null);
if(selected) {
g.setColor(Color.RED);
for(float f=0f;f<=1f;f=f+0.1f) {
/*for(float f=0f;f<=1f;f=f+0.1f) {
Point2D.Float p1 = b.getPoint(f);
Point2D.Float p2 = b.getPoint(f+0.1f);
g.drawLine((int)(p1.getX()+x+x_)*z,(int)(p1.getY()+y+y_)*z,(int)(p2.getX()+x+x_)*z,(int)(p2.getY()+y+y_)*z);
}*/
for(int i=0;i<=10;i++) {
Point2D.Float p1 = bezierPoints[i];
Point2D.Float p2 = bezierPoints[i+1];
g.drawLine((int)(p1.getX()+x+x_)*z,(int)(p1.getY()+y+y_)*z,(int)(p2.getX()+x+x_)*z,(int)(p2.getY()+y+y_)*z);
}
g.setColor(Color.YELLOW);
g.setColor(Color.ORANGE);
for(int i=0;i<xpos.length;i++) {
g.fillOval((xpos[i]+x+x_-1)*z,(ypos[i]+y+y_-1)*z,3,3);
}
......
......@@ -56,8 +56,10 @@ public class SliderBackground extends Item implements ActionListener{
BufferedImage bi = null;
String bitmap_str = "";
Slider sl;
private float sliderVal = 0.5f;
/** Creates a new instance of SliderBackground
* @param xmlcode The XML code
* @param s_ The parent skin
......@@ -279,10 +281,9 @@ public class SliderBackground extends Item implements ActionListener{
bi = image_res.image;
if(bi==null) return;
int fwidth = (bi.getWidth()-padhoriz*(nbhoriz-1))/nbhoriz;
int fheight = (bi.getHeight()-padvert*(nbvert-1))/nbvert;
float f = s.gvars.getSliderValue();
int fheight = (bi.getHeight()-padvert*(nbvert-1))/nbvert;
int fields = nbhoriz*nbvert;
int n = (int)(fields*f);
int n = (int)(fields*sliderVal);
int fypos = n/nbhoriz-1;
if (fypos<0) fypos=0;
int fxpos = n%nbhoriz;
......@@ -307,4 +308,8 @@ public class SliderBackground extends Item implements ActionListener{
public boolean uses(String id_) {
return (image.equals(id_));
}
@Override
public void updateToGlobalVariables() {
sliderVal = s.gvars.getSliderValue();
}
}
......@@ -421,7 +421,7 @@ public class Text extends Item implements ActionListener{
f = new Font(Font.SANS_SERIF,Font.PLAIN,12);
}
}
if(s.gvars.parseBoolean(visible)==true) {
if(vis) {
BufferedImage bi;
String ptext = s.gvars.parseString(text);
if(width==0) {
......
......@@ -352,7 +352,7 @@ public class Video extends Item implements ActionListener{
if(!created) return;
g.setColor(Color.BLACK);
if(s.gvars.parseBoolean(visible)==true) g.fillRect((x+x_)*z,(y+y_)*z,width*z,height*z);
if(vis) g.fillRect((x+x_)*z,(y+y_)*z,width*z,height*z);
if(selected) {
g.setColor(Color.RED);
g.drawRect((x+x_)*z,(y+y_)*z,width*z-1,height*z-1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment