diff --git a/README.md b/README.md index cf17e18..e6ad368 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,39 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + + +-------- +Project Proposal + +Objective: + - Adding full keyboard support for Snap + - Navigate through snap tools really easily + - Main target: Power users + +-- Basic Functionality + + Categories (Motion, Control, Looks, etc.) + - Navigate by Arrow Keys + - May have to implement a 2d Array to keep track of positioning + + Keys to naviage up and down the list of the category + - ',' = Up + - '.' = Down + + Alt tab => Navigate through tabs (Scripts, Costumes, Sounds) + +-- Advanced Functionality + +- Automatically adding blocks together +- 'n' button to start a new group of blocks + + + - MouseSensorMorph line ~6080 + - gui.js tabTo(tabString) + + + + + + diff --git a/blocks.js b/blocks.js index e56d0ed..1b0751b 100644 --- a/blocks.js +++ b/blocks.js @@ -137,7 +137,7 @@ /*global Array, BlinkerMorph, BouncerMorph, BoxMorph, CircleBoxMorph, Color, ColorPaletteMorph, ColorPickerMorph, CursorMorph, Date, -FrameMorph, Function, GrayPaletteMorph, HandMorph, HandleMorph, +FrameMorph, Function, GrayPaletteMorph, HandleMorph, InspectorMorph, ListMorph, Math, MenuItemMorph, MenuMorph, Morph, MorphicPreferences, MouseSensorMorph, Node, Object, PenMorph, Point, Rectangle, ScrollFrameMorph, ShadowMorph, SliderButtonMorph, @@ -5103,6 +5103,7 @@ ScriptsMorph.prototype.userMenu = function () { // ScriptsMorph user menu features: ScriptsMorph.prototype.cleanUp = function () { + var origin = this.topLeft(), y = this.cleanUpMargin, myself = this; @@ -5125,6 +5126,8 @@ ScriptsMorph.prototype.cleanUp = function () { this.setPosition(this.parent.topLeft()); } this.adjustBounds(); + console.log("CALLing Cleanup"); + console.log(this); }; ScriptsMorph.prototype.exportScriptsPicture = function () { diff --git a/gui.js b/gui.js index 46d47e5..167d979 100644 --- a/gui.js +++ b/gui.js @@ -193,6 +193,35 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.source = 'local'; this.serializer = new SnapSerializer(); + // project additions Tinh Nguyen + this.category_index = 0; + this.current_block_selection = -1; // starts highlighting nothing + + // setting up original colors Tinh Nguyen + this.original_colors = { + 'motion': new Color(74, 108, 212, 1), + 'control': new Color(230, 168, 34, 1), + 'looks': new Color(143,86,227,1), + 'sensing': new Color(4, 148, 220, 1), + 'sound': new Color(207, 74, 217, 1), + 'operators': new Color(150, 150, 150, 1), + 'pen': new Color(0, 161, 120, 1), + 'variables': new Color(243, 118, 29, 1) + }; + + this.no_blocks_index = { + 'motion' : [13, 14, 15, 16, 17, 18], + 'control' : [6, 7], + 'looks': [2, 3, 13 ,14], + 'sensing': [4, 5, 6, 7, 8, 9, 14, 15], + 'sound': [7, 8], + 'operators': [0, 1, 2], + 'pen': [], + 'variables': [0, 5, 16] + }; + + // end project additions + this.globalVariables = new VariableFrame(); this.currentSprite = new SpriteMorph(this.globalVariables); this.sprites = new List([this.currentSprite]); @@ -790,6 +819,9 @@ IDE_Morph.prototype.createCategories = function () { each.refresh(); }); myself.refreshPalette(true); + + //project addition, + this.current_block_selection = -1; }, category[0].toUpperCase().concat(category.slice(1)), // label function () { // query @@ -852,6 +884,8 @@ IDE_Morph.prototype.createCategories = function () { }); fixCategoriesLayout(); this.add(this.categories); + + }; IDE_Morph.prototype.createPalette = function (forSearching) { @@ -6327,7 +6361,8 @@ JukeboxMorph.prototype.step = function () { } }; */ - +// Changing for kicks +// testing branch // Jukebox ops JukeboxMorph.prototype.removeSound = function (idx) { diff --git a/jsassignment/Readme.txt b/jsassignment/Readme.txt new file mode 100644 index 0000000..3dffd0b --- /dev/null +++ b/jsassignment/Readme.txt @@ -0,0 +1 @@ +"s" diff --git a/jsassignment/tinhnguyenHW2.js b/jsassignment/tinhnguyenHW2.js new file mode 100644 index 0000000..9dab940 --- /dev/null +++ b/jsassignment/tinhnguyenHW2.js @@ -0,0 +1,108 @@ +/* + + Homework 2 + + Five Simple JavaScript Exercises: a basic warmup to + JavaScript. + + Written by Kyle Hotchkiss, with questions found on Google + + + In this homework, we are going to have you write some simple + functions in JavaScript. We will provide this base code, + howvever, it is up to you to test your code and make sure that + the functions work correctly. We highly urge that you do you + do your best to complete these practice problems. + +*/ + +max = function(x, y) { +/* + max(x, y) is a funtion that returns the larger of the two + numbers that it is given. +*/ + if(x>y){ + return x; + } + return y; + +}; + +maxOfThree = function(x, y, z) { +/* + maxOfThree(x, y, z) is a funtion that returns the larger of the two + numbers that it is given. +*/ + return max(max(x,y), z); + +}; + +isVowel = function(char) { +/* + isVowel(char) takes in a character and returns + true is the character is a vowel and false + if the character is not. +*/ + var vowels = "aeiou" + if(vowels.search(char) >= 0){ + return true; + } + return false; + +}; + +sum = function(intArray) { +/* + sum(intArray) takes in an int array and returns + the sum of all of the numbers in the array +*/ + +//INSERT CODE HERE + var sum = 0; + for(var i = 0; i < intArray.length; i++){ + sum += intArray[i]; + } + return sum; +}; + + +filterLongWords = function(stringArray, i) { +/* + filterLongWords(stringArray, i) takes in an + Array of strings, and returns an array of strings + that are longer than i characters +*/ + + var a = []; + var count = 0; + for(var b = 0; b < stringArray.length; b++){ + if(stringArray[b].length > i){ + a[count] = stringArray[b]; + count += 1; + } + } + return a; +}; + + +charFreq = function(word) { +/* + charFreq(word) takes in a word and returns the letters + that make up the word, as well as how many times the + letter occured in the word. + For example, the word 'heeeeeeyy' has as character + frequency of h: 1; e: 6; y: 2. + It is up to you how the character frequencies is represented. +*/ + + var map = {}; + for(var i = 0; i < word.length; i++){ + if(word[i] in map){ + map[word[i]] += 1; + } + else{ + map[word[i]] = 1; + } + } + return map; +}; \ No newline at end of file diff --git a/objects.js b/objects.js index 78545a5..ce5f10c 100644 --- a/objects.js +++ b/objects.js @@ -4718,6 +4718,24 @@ StageMorph.prototype.processKeyEvent = function (event, action) { case 40: keyName = 'down arrow'; break; + // project additions Tinh Nguyen + case 9: + if (event.altKey){ + keyName = 'alt tab' + } + break; + // Num 1 + case 49: + keyName = 'scripts 1'; + break; + // Num 2 + case 50: + keyName = 'costumes 2'; + break; + // Num 3 + case 51: + keyName = 'sounds 3'; + break; default: keyName = String.fromCharCode(event.keyCode || event.charCode); if (event.ctrlKey || event.metaKey) { @@ -4732,7 +4750,9 @@ StageMorph.prototype.fireKeyEvent = function (key) { hats = [], procs = [], ide = this.parentThatIsA(IDE_Morph), - myself = this; + myself = this, + index = ide.category_index, + world = this.world(); this.keysPressed[evt] = true; if (evt === 'ctrl enter') { @@ -4761,6 +4781,98 @@ StageMorph.prototype.fireKeyEvent = function (key) { if (evt === 'esc') { return this.fireStopAllEvent(); } + // project additions Tinh Nguyen + if (evt === 'alt tab'){ + ide.category_index = index + 1; + if(ide.category_index === 8){ + ide.category_index = 0; + } + ide.current_block_selection = -1; + ide.categories.children[ide.category_index].action(); + } + if (evt === 'scripts 1'){ + if (ide.currentTab != 'scripts'){ + ide.spriteBar.tabBar.tabTo('scripts'); + ide.currentTab = 'scripts'; + } + } + if (evt === 'costumes 2'){ + if(ide.currentTab != 'costumes'){ + ide.spriteBar.tabBar.tabTo('costumes'); + ide.currentTab = 'costumes'; + } + } + if (evt === 'sounds 3'){ + if (ide.currentTab != 'sounds'){ + ide.spriteBar.tabBar.tabTo('sounds'); + ide.currentTab = 'sounds'; + } + } + if (evt === 'down arrow'){ + + var children = ide.palette.contents.children; + var bad_indexes = ide.no_blocks_index[ide.currentCategory]; + ide.current_block_selection += 1; + + if (ide.current_block_selection >= 0 && ide.current_block_selection < children.length){ + var color = ide.original_colors[ide.currentCategory]; + children[ide.current_block_selection].setColor(new Color(221,255,174,255)); + + if (ide.current_block_selection != 0) { + children[ide.current_block_selection - 1].setColor(color) + } + } + // if its at the end/ we want to just skip + else if(ide.current_block_selection === children.length){ + ide.current_block_selection -= 1; + } + console.log(children[ide.current_block_selection]); + } + if (evt === 'up arrow'){ + var children = ide.palette.contents.children; + ide.current_block_selection -= 1; + var bad_indexes = ide.no_blocks_index[ide.currentCategory]; + + if (ide.current_block_selection >= 0 && ide.current_block_selection < children.length){ + var color = ide.original_colors[ide.currentCategory]; + children[ide.current_block_selection].setColor(new Color(221,255,174,255)); + + if (ide.current_block_selection != -1 ) { + children[ide.current_block_selection + 1].setColor(color) + } + } + else if (ide.current_block_selection === -2){ + ide.current_block_selection = -1; + } + console.log(children[ide.current_block_selection]); + } + if (evt === 'enter'){ + var children = ide.palette.contents.children; + var bad_indexes = ide.no_blocks_index[ide.currentCategory]; + if (bad_indexes.indexOf(ide.current_block_selection) == -1){ + var block = children[ide.current_block_selection]; + var hand = world.hand; + + copied_block = block.fullCopy(); + console.log(copied_block); + hand.grab(copied_block); + hand.drop(); + ide.stage.scripts.parent = copied_block.parent.parent; + ide.stage.scripts.children.push(copied_block); + ide.stage.scripts.cleanUp(); + console.log(ide.stage.scripts); + } + + + + + } + if (evt === 'left arrow'){ + ide.stage.scripts.cleanUp(); + } + + // end project additions + this.children.concat(this).forEach(function (morph) { if (morph instanceof SpriteMorph || morph instanceof StageMorph) { hats = hats.concat(morph.allHatBlocksForKey(evt)); diff --git a/roster.txt b/roster.txt index 9451e23..d10e69f 100644 --- a/roster.txt +++ b/roster.txt @@ -1 +1,2 @@ Spring 2015 Roster +Tinh Nguyen \ No newline at end of file