Skip to content

Commit

Permalink
build textinput variant of CAAT, more integration fixes for text input
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilmhansen committed Feb 28, 2012
1 parent 795f4ce commit 1a061ce
Show file tree
Hide file tree
Showing 9 changed files with 3,069 additions and 43 deletions.
59 changes: 59 additions & 0 deletions build/scripts/version.compile.pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ VERSION=`cat version.nfo`
FILE_CAAT="${DST_FILE_NAME}.js"
FILE_CAAT_CSS="${DST_FILE_NAME}-css.js"
FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d.js"
FILE_CAAT_TEXTINPUT="${DST_FILE_NAME}-textinput.js"

echo "Packing ${FILE_CAAT}"
echo -e "/*" > "${FILE_CAAT}"
Expand Down Expand Up @@ -137,6 +138,64 @@ while read LINE; do
cp ${FILE_CAAT_CSS} "$( dirname "$LINE" )"
done < version.distribution


echo "Packing ${FILE_CAAT_TEXTINPUT}"
echo -e "/*" > "${FILE_CAAT_TEXTINPUT}"
cat $LICENSE >> "${FILE_CAAT_TEXTINPUT}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_TEXTINPUT}"
echo -e "Created on:" >> "${FILE_CAAT_TEXTINPUT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_TEXTINPUT}"
echo -e "*/\n\n" >> "${FILE_CAAT_TEXTINPUT}"

more $CAAT_SRC_DIR/modules/TextInput/noVNC_Util.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/TextInput/noVNC_Input.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/CAAT.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/core/class.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/affinetransform2D.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/color.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/rectangle.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/bezier.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/point.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/math/quadtree.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/path/interpolator.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/behaviour/behaviour.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/behaviour/csskeyframehelper.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/core/browserdetect.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/debug.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/actor.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/audio.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/extraActor.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/director.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/mouseevent.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/conpoundimage.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/imagepreloader.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/timer.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/model/scene.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/modules.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircle.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircleManager.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/LocalStorage/LocalStorage.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/ImageUtil/ImageUtil.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/Layout/layout.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/Font/font.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/path/interpolatoractor.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/path/path.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/path/pathactor.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/texture/plasma.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/webgl/ShaderUtil.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/webgl/glu.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/webgl/glTexturePage.js >> "${FILE_CAAT_TEXTINPUT}"
more $CAAT_SRC_DIR/modules/TextInput/TextInput.js >> "${FILE_CAAT_TEXTINPUT}"


# Distribute resulting textinput compiled files
#
echo -e "\nCopying:"
while read LINE; do
echo -e "\tCopying results to ${LINE}"
cp ${FILE_CAAT_TEXTINPUT} ${LINE}
done < version.distribution

# box2d

echo "Packing ${FILE_CAAT_BOX2D}"
Expand Down
71 changes: 69 additions & 2 deletions build/scripts/version.compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ DST_FILE_NAME="${CAAT_DST}";
FILE_CAAT="${DST_FILE_NAME}-min.js"
FILE_CAAT_CSS="${DST_FILE_NAME}-css-min.js"
FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d-min.js"
FILE_CAAT_TEXTINPUT="${DST_FILE_NAME}-textinput.js"


#
# DST_FILE is a file name.
Expand All @@ -30,6 +32,7 @@ FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d-min.js"
echo "" > "${FILE_CAAT}"
echo "" > "${FILE_CAAT_CSS}"
echo "" > "${FILE_CAAT_BOX2D}"
echo "" > "${FILE_CAAT_TEXTINPUT}"

SOURCE_DIR=$CAAT_ROOT_DIR/src

Expand Down Expand Up @@ -90,6 +93,20 @@ echo -e "Created on:" >> "${FILE_CAAT_BOX2D}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}"
echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}"

echo -e "/*" >> "${FILE_CAAT_BOX2D}"
cat $LICENSE >> "${FILE_CAAT_BOX2D}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}"
echo -e "Created on:" >> "${FILE_CAAT_BOX2D}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}"
echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}"

echo -e "/*" >> "${FILE_CAAT_TEXTINPUT}"
cat $LICENSE >> "${FILE_CAAT_TEXTINPUT}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_TEXTINPUT}"
echo -e "Created on:" >> "${FILE_CAAT_TEXTINPUT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_TEXTINPUT}"
echo -e "*/\n\n" >> "${FILE_CAAT_TEXTINPUT}"


#
# Compile canvas/GL
Expand Down Expand Up @@ -176,7 +193,56 @@ $JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/modules/Font/font.js \
--js "${SOURCE_DIR}"/path/interpolatoractor.js \
--js "${SOURCE_DIR}"/path/path.js \
--js "${SOURCE_DIR}"/path/pathactor.js >> "${FILE_CAAT_CSS}"
--js "${SOURCE_DIR}"/path/pathactor.js \
>> "${FILE_CAAT_CSS}"


#
# Compile TextInput Module
#
echo "Creating CAAT TextInput"
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Util.js \
--js "${SOURCE_DIR}"/modules/TextInput/noVNC_Input.js \
--js "${SOURCE_DIR}"/CAAT.js \
--js "${SOURCE_DIR}"/core/browserdetect.js \
--js "${SOURCE_DIR}"/core/class.js \
--js "${SOURCE_DIR}"/math/affinetransform2D.js \
--js "${SOURCE_DIR}"/math/color.js \
--js "${SOURCE_DIR}"/math/rectangle.js \
--js "${SOURCE_DIR}"/math/bezier.js \
--js "${SOURCE_DIR}"/math/point.js \
--js "${SOURCE_DIR}"/math/quadtree.js \
--js "${SOURCE_DIR}"/path/interpolator.js \
--js "${SOURCE_DIR}"/behaviour/behaviour.js \
--js "${SOURCE_DIR}"/model/debug.js \
--js "${SOURCE_DIR}"/model/actor.js \
--js "${SOURCE_DIR}"/model/audio.js \
--js "${SOURCE_DIR}"/model/extraActor.js \
--js "${SOURCE_DIR}"/model/director.js \
--js "${SOURCE_DIR}"/model/mouseevent.js \
--js "${SOURCE_DIR}"/model/conpoundimage.js \
--js "${SOURCE_DIR}"/model/imagepreloader.js \
--js "${SOURCE_DIR}"/model/timer.js \
--js "${SOURCE_DIR}"/model/scene.js \
--js "${SOURCE_DIR}"/modules/modules.js \
--js "${SOURCE_DIR}"/modules/Layout/layout.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircle.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircleManager.js \
--js "${SOURCE_DIR}"/modules/LocalStorage/LocalStorage.js \
--js "${SOURCE_DIR}"/modules/ImageUtil/ImageUtil.js \
--js "${SOURCE_DIR}"/modules/Font/font.js \
--js "${SOURCE_DIR}"/path/interpolatoractor.js \
--js "${SOURCE_DIR}"/path/path.js \
--js "${SOURCE_DIR}"/path/pathactor.js \
--js "${SOURCE_DIR}"/texture/plasma.js \
--js "${SOURCE_DIR}"/webgl/ShaderUtil.js \
--js "${SOURCE_DIR}"/webgl/glu.js \
--js "${SOURCE_DIR}"/webgl/glTexturePage.js \
--js "${SOURCE_DIR}"/modules/TextInput/TextInput.js \
>> "${FILE_CAAT_TEXTINPUT}"



#
# Distribute resulting compiled files
Expand All @@ -186,7 +252,8 @@ while read LINE; do
echo -e "\tCopying results to ${LINE}"
cp ${FILE_CAAT} ${LINE}
cp ${FILE_CAAT_CSS} ${LINE}
cp ${FILE_CAAT_BOX2D} ${LINE}
cp ${FILE_CAAT_BOX2D} ${LINE}
cp ${FILE_CAAT_TEXTINPUT} ${LINE}
done < version.distribution

./version.compile.pack.sh
Expand Down
17 changes: 14 additions & 3 deletions src/model/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@
this.parent= parent;
return this;
},

getScene : function() {
if ( typeof this.parent ==='undefined' || this.parent === null) {
return null;
}
if (this.parent.name === 'CAAT.Scene') {
return this.parent;
}
return this.parent.getScene();
},

/**
* Set this actor's background image.
* The need of a background image is to kept compatibility with the new CSSDirector class.
Expand Down Expand Up @@ -2065,13 +2076,13 @@
* @param child a CAAT.Actor object instance.
* @return this
*/
addChild : function(child) {
addChild : function(child) {

if ( child.parent!=null ) {
throw('adding to a container an element with parent.');
}

child.parent= this;
child.setParent(this); // For TextArea
this.childrenList.push(child);
child.dirty= true;

Expand Down Expand Up @@ -3119,4 +3130,4 @@
};

extend( CAAT.IMActor, CAAT.ActorContainer, null);
})();
})();
115 changes: 83 additions & 32 deletions src/model/mouseevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,53 @@ CAAT.registerKeyListener= function(f) {
CAAT.keyListeners.push(f);
};



// Redefinitions of keyboard event to use noVNC code

CAAT.registerKeyListenerIfNeeded= function(f) {
for( var i=0; i<CAAT.keyListeners.length; i++ ) {
if ( f===CAAT.keyListeners[i] ) {
return;
}
}

CAAT.keyListeners.push(f);
};

/**
* Unregister a key events notification function
* @param f {function}
*/
CAAT.unregisterKeyListener= function(f) {
for( var i=0; i<CAAT.windowResizeListeners.length; i++ ) {
if ( f===CAAT.keyListeners[i] ) {
CAAT.keyListeners.splice(i,1);
return;
}
}
};

CAAT.Keys = {
ENTER:13,
BACKSPACE:8,
TAB:9,
SHIFT:16,
CTRL:17,
ALT:18,
ENTER:0xFF0D,
BACKSPACE:0xFF08,
TAB:0xFF09,
SHIFT:0xFFE1,
CTRL:0xFFE3,
ALT:0xFFE9,
PAUSE:19,
CAPSLOCK:20,
ESCAPE:27,
ESCAPE:0xFF1B,
PAGEUP:33,
PAGEDOWN:34,
END:35,
HOME:36,
LEFT:37,
UP:38,
RIGHT:39,
DOWN:40,
INSERT:45,
DELETE:46,
END:0xFF57,
HOME:0xFF50,
LEFT:0xFF51,
UP:0xFF52,
RIGHT:0xFF53,
DOWN:0xFF54,
INSERT:0xFF63,
DELETE:0xFFFF,
0:48,
1:49,
2:50,
Expand Down Expand Up @@ -269,10 +296,10 @@ CAAT.Keys = {
SINGLEQUOTE:222
};

CAAT.SHIFT_KEY= 16;
CAAT.CONTROL_KEY= 17;
CAAT.ALT_KEY= 18;
CAAT.ENTER_KEY= 13;
CAAT.SHIFT_KEY= 0xFFE1;
CAAT.CONTROL_KEY= 0xFFE3;
CAAT.ALT_KEY= 0xFFE9;
CAAT.ENTER_KEY= 0xFF0D;

/**
* Event modifiers.
Expand Down Expand Up @@ -337,13 +364,31 @@ CAAT.GlobalEnableEvents= function __GlobalEnableEvents() {

if ( CAAT.GlobalEventsEnabled ) {
return;
}
}

this.GlobalEventsEnabled= true;

window.addEventListener('keydown',
function(evt) {
var key = (evt.which) ? evt.which : evt.keyCode;
// Setup and activation of NoVNC key events library
keyboard = new Keyboard({'target': MAINDOC,
'onKeyPress': function(keysym, down, evt) {

if (down) {
for( var i=0; i<CAAT.keyListeners.length; i++ ) {
CAAT.keyListeners[i]( new CAAT.KeyEvent(
keysym,
'press',
{
alt: CAAT.KEY_MODIFIERS.alt,
control: CAAT.KEY_MODIFIERS.control,
shift: CAAT.KEY_MODIFIERS.shift
},
evt));
}
}
},
'onKeyDown': function(keysym, down, evt) {

var key = keysym;

if ( key===CAAT.SHIFT_KEY ) {
CAAT.KEY_MODIFIERS.shift= true;
Expand All @@ -365,12 +410,10 @@ CAAT.GlobalEnableEvents= function __GlobalEnableEvents() {
}
}
},
false);
'onKeyUp': function(keysym, down, evt) {

window.addEventListener('keyup',
function(evt) {
var key = keysym;

var key = (evt.which) ? evt.which : evt.keyCode;
if ( key===CAAT.SHIFT_KEY ) {
CAAT.KEY_MODIFIERS.shift= false;
} else if ( key===CAAT.CONTROL_KEY ) {
Expand All @@ -391,20 +434,28 @@ CAAT.GlobalEnableEvents= function __GlobalEnableEvents() {
evt));
}
}
},
false );
}


});

window.addEventListener('resize',
keyboard.grab();




MAINDOC.addEventListener('resize',
function(evt) {
for( var i=0; i<CAAT.windowResizeListeners.length; i++ ) {
CAAT.windowResizeListeners[i].windowResized(
window.innerWidth,
window.innerHeight);
}
},
false);
true);
};


/**
* Polyfill for requestAnimationFrame.
*/
Expand Down Expand Up @@ -524,4 +575,4 @@ CAAT.RegisterDirector= function __CAATGlobal_RegisterDirector(director) {
}, true);
}

})();
})();
Loading

0 comments on commit 1a061ce

Please sign in to comment.