Author: remi
Date: 2008-07-31 12:51:29 +0200 (Thu, 31 Jul 2008)
New Revision: 1433

Modified:
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
   
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
Log:
* added copy and past block functions

Modified: 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
===================================================================
--- 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
      2008-07-30 14:35:16 UTC (rev 1432)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
      2008-07-31 10:51:29 UTC (rev 1433)
@@ -2,6 +2,7 @@
 
 import java.net.URLEncoder;
 import java.util.Hashtable;
+import java.util.Iterator;
 
 /**
  * 
@@ -22,6 +23,7 @@
                        LEDS_BLINK_CANVAS.put("cmd", "leds_blink");
                        LEDS_BLINK_CANVAS.put("count", 1.0);
                        LEDS_BLINK_CANVAS.put("speed", 1);
+                       LEDS_BLINK_CANVAS.put("duration", 0.0);
                }
        private static String[] ledsBlinkTmc(Hashtable<String,Object> struct)
        {
@@ -568,4 +570,65 @@
                        return null;
                }
        }
+       
+       /**
+        * 
+        * @param struct
+        * @return
+        */
+       public static Hashtable<String,Object> 
copyBlockStruct(Hashtable<String,Object> struct)
+       {
+               Hashtable<String,Object> result = new 
Hashtable<String,Object>();
+               String key;
+               Iterator<String> it = (Iterator<String>)struct.keys();
+
+               while (it.hasNext())
+               {
+                       key = (String)it.next();
+                       result.put(key, struct.get(key));
+               }
+               
+               return result;
+       }
+       
+       /**
+        * 
+        * @param rowIdx
+        * @return
+        */
+       public static Hashtable<String,Object> getDefaultBlock(int rowIdx)
+       {
+               Hashtable<String,Object> result;
+               
+               if (rowIdx == 0)
+               {
+                       result = copyBlockStruct(LEDS_BLINK_CANVAS);
+               }
+               else if (rowIdx == 1)
+               {
+                       result = copyBlockStruct(EYES_ON_CANVAS);
+               }
+               else if (rowIdx == 2)
+               {
+                       result = copyBlockStruct(FLIPPERS_ON_CANVAS);
+               }
+               else if (rowIdx == 3)
+               {
+                       result = copyBlockStruct(SPINNING_LEFT_CANVAS);
+               }
+               else if (rowIdx == 4)
+               {
+                       result = copyBlockStruct(PLAY_FLASH_CANVAS);
+               }
+               else if (rowIdx == 5)
+               {
+                       result = copyBlockStruct(PLAY_TTS_CANVAS);
+               }
+               else
+               {
+                       result = copyBlockStruct(LEDS_BLINK_CANVAS);
+               }
+               
+               return result;
+       }
 }

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-07-30 14:35:16 UTC (rev 1432)
+++ 
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/visual/ATTBlockViewer.java
      2008-07-31 10:51:29 UTC (rev 1433)
@@ -75,6 +75,8 @@
        private ATTBlock focusedBlock;
        private int focusedRowIndex;
        private boolean draggingBlock;
+       private ATTBlock blockCopied;
+       private int rowCopied;
        
        private int zoomFactor;
        
@@ -155,6 +157,9 @@
                focusedRowIndex = -1;
                draggingBlock = false;
                blockContainer0.setFocused(true);
+               /* Block to copy */
+               blockCopied = null;
+               rowCopied = -1;
                /* Zoom init */
                zoomFactor = -1;
                /* Event handlers */
@@ -1076,6 +1081,7 @@
                resBlock.setLength(timeLength);
                recalcFullTime();
                setFocusedBlock(resBlock);
+               this.repaint();
                return resBlock;
        }
        
@@ -1102,6 +1108,7 @@
                                        {
                                                
blockContainers[i].deleteBlock(j);
                                                recalcFullTime();
+                                               this.repaint();
                                        }
                                        
                                        return;
@@ -1319,4 +1326,38 @@
                
                sendSimpleCmd(String.format("macro/play?macro=%s", macro));
        }
+       
+       /**
+        * 
+        */
+       public void copyBlock()
+       {
+               blockCopied = focusedBlock;
+               rowCopied = focusedRowIndex;
+       }
+       
+       /**
+        * 
+        * @param timeBegin
+        * @return
+        */
+       public ATTBlock pastBlock(double timeBegin)
+       {
+               if (rowCopied == -1)
+               {
+                       return null;
+               }
+               else if (rowCopied != focusedRowIndex)
+               {
+                       return null;
+               }
+               
+               if (blockCopied == null)
+               {
+                       return null;
+               }
+               
+               return createBlock(rowCopied, blockCopied.getFunctionParams(), 
+                               timeBegin, blockCopied.getLength());
+       }
 }


-------------------------------------------------------------------------
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