Author: remi
Date: 2008-08-15 19:33:28 +0200 (Fri, 15 Aug 2008)
New Revision: 1504

Added:
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneCmdConf.java
Modified:
   software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
Log:
* visual improvements.
* work on the configuration of the blocks

Added: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneCmdConf.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneCmdConf.java
                         (rev 0)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/GUI/AttituneCmdConf.java
 2008-08-15 17:33:28 UTC (rev 1504)
@@ -0,0 +1,189 @@
+package GUI;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.util.Hashtable;
+
+import javax.swing.*;
+
+import com.tuxisalive.attitunes.*;
+import com.tuxisalive.attitunes.format.*;
+import com.tuxisalive.attitunes.visual.*;
+import com.tuxisalive.attitunes.block.*;
+
+/**
+ * 
+ * @author User
+ *
+ */
+public class AttituneCmdConf
+{      
+       private static JLabel labelCount;
+       private static JLabel labelSpeed;
+       private static JLabel labelNoParameters;
+       private static JLabel labelSoundIndex;
+       private static JLabel labelWaveName;
+       private static JLabel labelText;
+       private static JLabel labelPitch;
+       private static JLabel labelLocutor;
+       
+       static
+       {
+               labelCount = new JLabel("Count :");
+               labelSpeed = new JLabel("Speed :");
+               labelNoParameters = new JLabel("No parameter");
+               labelSoundIndex = new JLabel("Sound index :");
+               labelWaveName = new JLabel("Wave name :");
+               labelText = new JLabel("Text to speak :");
+               labelPitch = new JLabel("Pitch :");
+               labelLocutor = new JLabel("Locutor :");
+       }
+       
+       
+       public static void showBlockConf(ATTBlockViewer attBlockViewer, JPanel 
myPanel, String cmd)
+       {
+               if (cmd.equals("leds_on"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("ledl_on"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("ledr_on"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("leds_off"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("ledl_off"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("ledr_off"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("leds_blink"))
+               {
+                       showBlockLedBlink(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("mouth_on"))
+               {
+                       showBlockMouthOn(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("mouth_open"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("mouth_close"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("eyes_on"))
+               {
+                       showBlockEyesOn(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("eyes_open"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("eyes_close"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("sound_play"))
+               {
+                       showBlockSoundPlay(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("wav_play"))
+               {
+                       showBlockWavPlay(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("spinl_on"))
+               {
+                       showBlockSpinLOn(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("spinr_on"))
+               {
+                       showBlockSpinROn(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("tts_play"))
+               {
+                       showBlockTTS(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("wings_on"))
+               {
+                       showBlockWingsOn(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("wings_up"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else if (cmd.equals("wings_down"))
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+               else
+               {
+                       showBlockNoParam(attBlockViewer, myPanel);
+               }
+       }
+       
+       private static void showBlockLedBlink(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+               myPanel.add(labelSpeed, new GridBagConstraints(1, 1, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockNoParam(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelNoParameters, new GridBagConstraints(1, 0, 1, 
1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new 
Insets(0, 0, 0, 0), 0, 0));
+       }
+       
+       private static void showBlockMouthOn(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockEyesOn(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockWingsOn(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockSoundPlay(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelSoundIndex, new GridBagConstraints(1, 0, 1, 1, 
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new 
Insets(0, 0, 0, 0), 0, 0));
+       }
+       
+       private static void showBlockWavPlay(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelWaveName, new GridBagConstraints(1, 0, 1, 1, 
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new 
Insets(0, 0, 0, 0), 0, 0));
+       }
+       
+       private static void showBlockSpinLOn(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+               myPanel.add(labelSpeed, new GridBagConstraints(1, 1, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockSpinROn(ATTBlockViewer attBlockViewer, 
JPanel myPanel)
+       {
+               myPanel.add(labelCount, new GridBagConstraints(1, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+               myPanel.add(labelSpeed, new GridBagConstraints(1, 1, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+       
+       private static void showBlockTTS(ATTBlockViewer attBlockViewer, JPanel 
myPanel)
+       {
+               myPanel.add(labelLocutor, new GridBagConstraints(1, 0, 1, 1, 
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new 
Insets(0, 0, 0, 0), 0, 0));
+               myPanel.add(labelPitch, new GridBagConstraints(1, 1, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+               myPanel.add(labelText, new GridBagConstraints(1, 2, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
+       }
+}

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java
===================================================================
--- software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java   
2008-08-15 13:25:53 UTC (rev 1503)
+++ software_suite_v2/software/tools/attitunesStudio/trunk/src/MainFrame.java   
2008-08-15 17:33:28 UTC (rev 1504)
@@ -1,11 +1,12 @@
 
 import GUI.*;
 
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
 import java.awt.*;
 import java.util.Hashtable;
 import java.util.List;
@@ -33,9 +34,9 @@
 {
        private static final long serialVersionUID = 724080299924475945L;
        
-       private static final int WINDOW_WIDTH = 644;
-       private static final int WINDOW_HEIGHT_WBP = 380;
-       private static final int WINDOW_HEIGHT_BP = 583;
+       private static final int WINDOW_WIDTH = 646;
+       private static final int WINDOW_HEIGHT_WBP = 375;
+       private static final int WINDOW_HEIGHT_BP = 578;
        
        private GridBagLayout frameLayout;
        
@@ -150,6 +151,7 @@
                        
attBlockViewer.events.register(ATTConfig.EVENT_BLOCK_DRAG_STOPPED, this, 
"onBlockDragStopped"); //$NON-NLS-1$
                        
attBlockViewer.events.register(ATTConfig.EVENT_ATTITUNE_LOADED, this, 
"onAttituneLoaded"); //$NON-NLS-1$
                        
attBlockViewer.events.register(ATTConfig.EVENT_ATTITUNE_SAVED, this, 
"onAttituneSaved"); //$NON-NLS-1$
+                       attBlockViewer.repaint();
                        
                        /* Main viewer commander */
                        jPanelBlock = new JPanel();
@@ -310,7 +312,7 @@
                                jPanelBlockHeadLayout.rowWeights = new double[] 
{0.1};
                                jPanelBlockHeadLayout.rowHeights = new int[] 
{7};
                                jPanelBlockHeadLayout.columnWeights = new 
double[] {0.1, 0.1};
-                               jPanelBlockHeadLayout.columnWidths = new int[] 
{7, 7};
+                               jPanelBlockHeadLayout.columnWidths = new int[] 
{220, 220};
                                
jPanelBlockHead.setLayout(jPanelBlockHeadLayout);
                                {
                                        jPanelCmdName = new JPanel();
@@ -333,6 +335,11 @@
                                                jComboBoxCmdName = new 
JComboBox();
                                                
jPanelCmdName.add(jComboBoxCmdName, new GridBagConstraints(3, 0, 1, 1, 0.0, 
0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 
0, 0), 0, 0));
                                                
jComboBoxCmdName.setModel(jComboBoxCmdNameModel);
+                                               
jComboBoxCmdName.addItemListener(new ItemListener() {
+                                                       public void 
itemStateChanged(ItemEvent evt) {
+                                                               
jComboBoxCmdNameItemStateChanged(evt);
+                                                       }
+                                               });
                                        }
                                }
                                {
@@ -360,12 +367,18 @@
                        
                        {
                                jPanelBlocConf = new JPanel();
+                               GridBagLayout jPanelConfLayout = new 
GridBagLayout();
                                jPanelBlProperties.add(jPanelBlocConf, new 
GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, 
GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                                jPanelBlocConf.setSize(new 
java.awt.Dimension(631, 168));
                                jPanelBlocConf.setMaximumSize(new 
java.awt.Dimension(631, 168));
                                jPanelBlocConf.setMinimumSize(new 
java.awt.Dimension(631, 168));
                                jPanelBlocConf.setPreferredSize(new 
java.awt.Dimension(631, 168));      
                                
jPanelBlocConf.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
+                               jPanelConfLayout.rowWeights = new double[] 
{0.1, 0.1, 0.1, 0.1, 0.1};
+                               jPanelConfLayout.rowHeights = new int[] {7, 7, 
7, 7, 7};
+                               jPanelConfLayout.columnWeights = new double[] 
{0.0, 0.0, 0.0, 0.1, 0.0};
+                               jPanelConfLayout.columnWidths = new int[] {7, 
204, 7, 7, 7};
+                               jPanelBlocConf.setLayout(jPanelConfLayout);
                        }
                        
                        /* Status bar */
@@ -381,14 +394,14 @@
                        
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                        fileChooser.addChoosableFileFilter(new 
AttituneFileFilter());
                        
+                       /* Load the template file */
+                       
attBlockViewer.loadAttitune(ATTConfig.ATT_TEMPLATE_PATH); //$NON-NLS-1$
+                       attBlockViewer.setAttituneIsTemplate(true);
+                       
                        /* Pack the components */
                        pack();
                        attBlockViewer.repaint();
                        
-                       /* Load the template file */
-                       
attBlockViewer.loadAttitune(ATTConfig.ATT_TEMPLATE_PATH); //$NON-NLS-1$
-                       attBlockViewer.setAttituneIsTemplate(true);
-                       
                        /* Splash message under developpement */
                        JOptionPane.showMessageDialog(this, 
                                        ATTMessages.getString("MainFrame.98"), 
@@ -659,16 +672,49 @@
        {       
                if (jPanelBlProperties.isVisible())
                {
+                       this.setVisible(false);
+                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_WBP);
                        jPanelBlProperties.setVisible(false);
-                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_WBP);
+                       this.pack();
+                       this.setVisible(true);
                }
                else
                {
+                       this.setVisible(false);
+                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_BP);
                        jPanelBlProperties.setVisible(true);
-                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_BP);
+                       this.pack();
+                       this.setVisible(true);
                }
        }
        
+       /*
+        * On command choosing
+        */
+       @SuppressWarnings("static-access") //$NON-NLS-1$
+       private void jComboBoxCmdNameItemStateChanged(ItemEvent evt)
+       {
+               if (evt.getStateChange() == evt.SELECTED)
+               {
+                       showBlockConf((String)evt.getItem());
+               }
+       }
+       
+       /*
+        * 
+        */
+       public void showBlockConf(String cmd)
+       {
+               jPanelBlocConf.setVisible(false);
+               jPanelBlocConf.removeAll();
+               if (attBlockViewer.getFocusedBlock() != null)
+               {
+                       AttituneCmdConf.showBlockConf(attBlockViewer, 
jPanelBlocConf, cmd);
+               }
+               jPanelBlocConf.setVisible(true);
+               this.pack();
+       }
+       
        /* 
------------------------------------------------------------------------
         * Blocks viewer events
         * 
--------------------------------------------------------------------- */
@@ -722,6 +768,12 @@
         */
        public void onRowSelected(Integer rowIdx, ATTBlockContainer 
blockContainer)
        {
+               ComboBoxModel cmdModel;
+               
+               cmdModel = new DefaultComboBoxModel();
+               jComboBoxCmdName.setModel(cmdModel);
+               jComboBoxCmdName.setSelectedItem("");
+               showBlockConf("");
        }
        
        /*
@@ -729,11 +781,52 @@
         */
        public void onBlockSelected(ATTBlock block)
        {
+               /* Set the block position in the status bar */
                statusBar.setLabel3(ATTMessages.getString("MainFrame.87") + 
ATTMisc.timeToString(block.getPosition())); //$NON-NLS-1$
+               
+               /* Get the row */
+               int blockRow = block.getBlockType();
+               ComboBoxModel cmdModel;
+               
+               switch (blockRow)
+               {
+               case ATTConfig.BLOCK_TYPE_LEDS:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.LEDS_CMD_TYPES);
+                       break;
+               case ATTConfig.BLOCK_TYPE_EYESMOUTH:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.EYESMOUTH_CMD_TYPES);
+                       break;
+               case ATTConfig.BLOCK_TYPE_WINGS:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.FLIPPERS_CMD_TYPES);
+                       break;
+               case ATTConfig.BLOCK_TYPE_SPIN:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.SPINNING_CMD_TYPES);
+                       break;
+               case ATTConfig.BLOCK_TYPE_WAV:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.WAVSOUND_CMD_TYPES);
+                       break;
+               case ATTConfig.BLOCK_TYPE_TTS:
+                       cmdModel = new 
DefaultComboBoxModel(ATTBlockParams.TTS_CMD_TYPES);
+                       break;
+               default:
+                       cmdModel = new DefaultComboBoxModel();
+               }
+               
+               /* Set the model */
+               jComboBoxCmdName.setModel(cmdModel);
+               
+               /* Select the command in the combobox */
+               String cmd = (String)block.getFunctionParams().get("cmd");
+               jComboBoxCmdName.setSelectedItem(cmd);
+               showBlockConf(cmd);
+               
+               
+               /* Show the properties panel if hidden */
                if (!jPanelBlProperties.isVisible())
                {
+                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_BP);
                        jPanelBlProperties.setVisible(true);
-                       this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT_BP);
+                       this.pack();
                }
        }
        

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java
     2008-08-15 13:25:53 UTC (rev 1503)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/block/ATTBlock.java
     2008-08-15 17:33:28 UTC (rev 1504)
@@ -135,6 +135,15 @@
        
        /**
         * 
+        * @return
+        */
+       public int getBlockType()
+       {
+               return this.blockType;
+       }
+       
+       /**
+        * 
         * @param value
         */
        public void setPosition(double value)

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
      2008-08-15 13:25:53 UTC (rev 1503)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
      2008-08-15 17:33:28 UTC (rev 1504)
@@ -666,7 +666,7 @@
                int yb;
                int ye;
                
-               ye = tlv.top + tlv.height;
+               ye = tlv.top + tlv.height - 1;
                g.setColor(Color.white);
                g.setFont(ruleFont);
                
@@ -842,9 +842,9 @@
                        blockContainer5.drawAll(backBuffer1);
                        /* Draw vertical bars */
                        backBuffer1.setColor(Color.white);
-                       backBuffer1.drawLine(tlv.left, tlv.top - 8, tlv.left, 
this.height);
+                       backBuffer1.drawLine(tlv.left, tlv.top - 8, tlv.left, 
this.height - ATTConfig.TLV_BOTTOM_BORDER - 1);
                        backBuffer1.drawLine(tlv.left + tlv.width, tlv.top - 8, 
-                                       tlv.left + tlv.width, this.height);
+                                       tlv.left + tlv.width, this.height - 
ATTConfig.TLV_BOTTOM_BORDER - 1);
                        /* Current pos bar */
                        drawBars(backBuffer1);
                        


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to