Changeset 90

Show
Ignore:
Timestamp:
29/12/07 14:28:21 (1 year ago)
Author:
altglass
Message:

SubBitamp? editing improved: preview can be zoomed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README.TXT

    r88 r90  
    44----------------------------------------------------------- 
    550.7.0a - Preview can be saved as image 
     6       - Improved SubBitmap editing 
    670.6.1b - Critical bufix for the Preview Window  
    78       - Bugfix for slider points parsing and XML parsing 
  • trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java

    r87 r90  
    3232 * @author Daniel Dreibrodt 
    3333 */ 
    34 public class SubBitmapEditWindow extends JPanel implements MouseListener, MouseMotionListener, KeyListener, WindowListener{ 
     34public class SubBitmapEditWindow extends JPanel implements ActionListener, MouseListener, MouseMotionListener, KeyListener, WindowListener{ 
    3535   
    3636  public JFrame frame; 
     37  JScrollPane scroll_pane; 
     38  JPanel zoom_panel; 
     39  JButton zoom_more, zoom_less; 
     40  JLabel zoom_label; 
     41  int z_fact = 1; 
    3742  Bitmap b; 
    3843  SubBitmap sb; 
     
    4247  int x1, y1, x2, y2; 
    4348  int x1_org, y1_org, x2_org, y2_org; 
    44   int maxx, maxy
     49  int p_width, p_height
    4550  int drawcount; 
    4651   
     
    5560    y2_org = y2 = sb.y+sb.height; 
    5661    frame = new JFrame("Edit SubBitmap"); 
    57     frame.setLayout(new GridLayout(1,1)); 
    58     frame.add(this); 
    59     maxx = b.image.getWidth(); 
    60     maxy = b.image.getHeight(); 
    61     setMinimumSize(new Dimension(maxx,maxy)); 
    62     setPreferredSize(new Dimension(maxx,maxy));     
     62    frame.setLayout(new BorderLayout()); 
     63    zoom_panel = new JPanel(); 
     64    zoom_panel.setLayout(new FlowLayout()); 
     65    zoom_less = new JButton("-");    
     66    zoom_less.addActionListener(this); 
     67    zoom_panel.add(zoom_less); 
     68    zoom_label = new JLabel("Zoom factor: 1x"); 
     69    zoom_panel.add(zoom_label); 
     70    zoom_more = new JButton("+"); 
     71    zoom_more.addActionListener(this); 
     72    zoom_panel.add(zoom_more); 
     73    zoom_panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);     
     74    frame.add(zoom_panel, BorderLayout.PAGE_START); 
     75    p_width = b.image.getWidth(); 
     76    p_height = b.image.getHeight();     
     77    setPreferredSize(new Dimension(p_width,p_height));   
     78    scroll_pane = new JScrollPane(this);     
     79    scroll_pane.setPreferredSize(new Dimension(p_width+20,p_height+20)); 
     80    frame.add(scroll_pane,BorderLayout.CENTER);      
    6381    frame.pack(); 
    6482    frame.setLocation(sb.frame.getX()+sb.frame.getWidth()+5,sb.frame.getY()); 
    65     frame.setResizable(false); 
     83    frame.setMinimumSize(new Dimension(200,100)); 
    6684    frame.setVisible(true); 
    6785    fu = new FrameUpdater(this,25);     
     
    7593    if(drawcount>=40) drawcount = 0; 
    7694    g.clearRect(0,0,getWidth(),getHeight()); 
    77     g.drawImage(b.image,0,0,frame); 
     95    g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame); 
     96    //g.drawImage(b.image,0,0,frame); 
    7897    g.setColor(Color.RED); 
    7998    int[] x = new int[4]; 
    80     x[0] = x1
    81     x[1] = x2
    82     x[2] = x2
    83     x[3] = x1
     99    x[0] = x1*z_fact
     100    x[1] = x2*z_fact
     101    x[2] = x2*z_fact
     102    x[3] = x1*z_fact
    84103    int[] y = new int[4]; 
    85     y[0] = y1
    86     y[1] = y1
    87     y[2] = y2
    88     y[3] = y2
     104    y[0] = y1*z_fact
     105    y[1] = y1*z_fact
     106    y[2] = y2*z_fact
     107    y[3] = y2*z_fact
    89108    if(drawcount<=20 || starteddragging) 
    90109    g.drawPolygon(x,y,4);     
     
    103122      x2_org = x2; 
    104123      y2_org = y2; 
    105       x2 = x1 = e.getX()
    106       y2 = y1 = e.getY()
     124      x2 = x1 = e.getX()/z_fact
     125      y2 = y1 = e.getY()/z_fact
    107126    }     
    108127    else {       
    109       if(e.getX()>=maxx) x2=maxx
    110       else if(e.getX()<0) x2=0; 
    111       else x2 = e.getX()
    112       if(e.getY()>=maxy) y2=maxy
    113       else if(e.getY()<0) y2=0; 
    114       else y2 = e.getY()
     128      if(e.getX()/z_fact>=p_width) x2=p_width
     129      else if(e.getX()/z_fact<0) x2=0; 
     130      else x2 = e.getX()/z_fact
     131      if(e.getY()/z_fact>=p_height) y2=p_height
     132      else if(e.getY()/z_fact<0) y2=0; 
     133      else y2 = e.getY()/z_fact
    115134    } 
    116135  } 
     
    182201  public void windowDeactivated(WindowEvent e) { 
    183202  } 
     203  public void actionPerformed(ActionEvent e) { 
     204    if(e.getSource().equals(zoom_less)) { 
     205      if(z_fact>1) z_fact--; 
     206      zoom_label.setText("Zoom factor: "+z_fact+"x"); 
     207      setSize(p_width*z_fact, p_height*z_fact); 
     208      setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact)); 
     209    } 
     210    else if(e.getSource().equals(zoom_more)) { 
     211      if(z_fact<16) z_fact++; 
     212      zoom_label.setText("Zoom factor: "+z_fact+"x"); 
     213      setSize(p_width*z_fact, p_height*z_fact); 
     214      setPreferredSize(new Dimension(p_width*z_fact, p_height*z_fact)); 
     215    } 
     216  } 
    184217}