Commit 9898fae8 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

SliderBackground Generator can now generate vertical sliders

SliderBackgrounds can now be delete through the normal delete item action
parent 4e1dd22b
......@@ -1570,8 +1570,18 @@ public class Main extends JFrame implements ActionListener, TreeSelectionListene
private void deleteSelectedItem() {
if(getSelectedItem()!=null) {
if(s.getItem(getSelectedItem()).getClass().equals(SliderBackground.class)) {
/* TODO */
Item i = s.getItem(getSelectedItem());
if(i.getClass().equals(SliderBackground.class)) {
Object[] options= {Language.get("CHOICE_YES"),Language.get("CHOICE_NO")};
int n = JOptionPane.showOptionDialog(this,Language.get("DEL_CONFIRM_MSG").replaceAll("%n",getSelectedItem()),Language.get("DEL_CONFIRM_TITLE"),
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]);
if(n==0) {
SliderBackground sbg = (SliderBackground)i;
Slider parentSlider = sbg.getParentSlider();
//TODO make undoable
parentSlider.removeBG();
s.updateItems();
}
} else {
java.util.List<Item> p = s.getParentListOf(getSelectedItem());
if(p!=null) {
......@@ -1579,7 +1589,6 @@ public class Main extends JFrame implements ActionListener, TreeSelectionListene
int n = JOptionPane.showOptionDialog(this,Language.get("DEL_CONFIRM_MSG").replaceAll("%n",getSelectedItem()),Language.get("DEL_CONFIRM_TITLE"),
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]);
if(n==0) {
Item i = s.getItem(getSelectedItem());
ItemDeletionEvent ide = new ItemDeletionEvent(p,i,p.indexOf(i),s);
p.remove(s.getItem(getSelectedItem()));
s.updateItems();
......
This diff is collapsed.
......@@ -149,9 +149,6 @@ public class SliderBGGen extends JFrame implements ActionListener{
card_step1.add(btt_l);
btt_l.setBounds(280,105,100,100);
btt_rb.setEnabled(false);
btt_l.setEnabled(false);
ButtonGroup dir_bg = new ButtonGroup();
dir_bg.add(ltr_rb);
ltr_rb.addActionListener(this);
......@@ -421,8 +418,14 @@ public class SliderBGGen extends JFrame implements ActionListener{
Bitmap b = new Bitmap(s, f);
s.resources.add(b);
sbg.image_tf.setText(b.id);
sbg.nbvert_tf.setText(String.valueOf(sbgb.nbframes));
sbg.nbhoriz_tf.setText("1");
if (sbgb.horizontal) {
sbg.nbvert_tf.setText(String.valueOf(sbgb.nbframes));
sbg.nbhoriz_tf.setText("1");
}
else {
sbg.nbvert_tf.setText("1");
sbg.nbhoriz_tf.setText(String.valueOf(sbgb.nbframes));
}
sbg.padhoriz_tf.setText("0");
sbg.padvert_tf.setText("0");
setVisible(false);
......
......@@ -106,7 +106,7 @@ public class Slider extends Item implements ActionListener{
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("SliderBackground"))
sbg = new SliderBackground(nodes.item(i),s);
sbg = new SliderBackground(nodes.item(i),s,this);
}
up_res = s.getImageResource(up);
......
......@@ -47,13 +47,13 @@ public class SliderBackground extends Item implements ActionListener {
public int nbvert = NBVERT_DEFAULT;
public int padhoriz = PADHORIZ_DEFAULT;
public int padvert = PADVERT_DEFAULT;
JFrame frame;
private JFrame frame;
public JTextField id_tf, image_tf, nbhoriz_tf, nbvert_tf, padhoriz_tf, padvert_tf;
JButton gen_btn, ok_btn, cancel_btn, help_btn;
ImageResource image_res;
BufferedImage bi = null;
String bitmap_str = "";
Slider sl;
private JButton gen_btn, ok_btn, cancel_btn, help_btn;
private ImageResource image_res;
private BufferedImage bi = null;
private String bitmap_str = "";
private Slider parent;
private float sliderVal = 0.5f;
......@@ -65,9 +65,11 @@ public class SliderBackground extends Item implements ActionListener {
* Parses a SliderBackground from a XML node
* @param n The XML node
* @param s_ The parent skin
* @param pr The parent slider
*/
public SliderBackground(Node n, Skin s_) {
public SliderBackground(Node n, Skin s_, Slider pr) {
s = s_;
parent = pr;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t", type).replaceAll("%i", String.valueOf(s.getNewId())));
......@@ -112,7 +114,7 @@ public class SliderBackground extends Item implements ActionListener {
public SliderBackground(Skin s_, Slider sl_) {
s = s_;
sl = sl_;
parent = sl_;
image = "none";
id = Language.get("UNNAMED").replaceAll("%t", type).replaceAll("%i", String.valueOf(s.getNewId()));
showOptions();
......@@ -346,7 +348,7 @@ public class SliderBackground extends Item implements ActionListener {
frame.dispose();
frame = null;
if(!created) {
sl.removeBG();
parent.removeBG();
}
}
}
......@@ -433,4 +435,7 @@ public class SliderBackground extends Item implements ActionListener {
if(image.equals(oldid)) image = newid;
}
public Slider getParentSlider() {
return parent;
}
}
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