//CLOSE BUTTON
// Vector3D a = new Vector3D(-width * 1.2f, height/2f);
Vector3D a = new Vector3D(-width * 1.55f, 0);
a.rotateZ(PApplet.radians(80));
final MTRectangle closeButton = new MTRectangle(x + a.x, y + a.y, buttonWidth, buttonHeight, app);
if (closeButtonImage == null){
closeButtonImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
// "close_32.png"));
// "126182-simple-black-square-icon-alphanumeric-circled-x3_cr.png"));
// "124241-matte-white-square-icon-alphanumeric-circled-x3_cr.png");
"closeButton64.png");
}
closeButton.setTexture(closeButtonImage);
closeButton.setFillColor(new MTColor(255, 255, 255, buttonOpacity));
closeButton.setNoStroke(true);
closeButton.setVisible(false);
this.addChild(closeButton);
//Check if this menu belongs to a window Scene (MTSceneWindow)
//or was added to a normal scene
//-> if its not a windowed scene we dont display the Restore button
if (this.windowedScene){
//RESTORE BUTTON
Vector3D b = new Vector3D(-width * 1.55f, 0);
b.rotateZ(PApplet.radians(10));
final MTRectangle restoreButton = new MTRectangle(x + b.x, y + b.y, buttonWidth, buttonHeight, app);
if (restoreButtonImage == null){
restoreButtonImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
// "window_app_32.png"));
// "126630-simple-black-square-icon-business-document10-sc1_cr.png");
// restoreButton.setFillColor(new MTColor(150, 150, 250, 200));
"restoreButton64.png");
}
restoreButton.setTexture(restoreButtonImage);
restoreButton.setFillColor(new MTColor(255, 255, 255, buttonOpacity));
restoreButton.setNoStroke(true);
restoreButton.setVisible(false);
this.addChild(restoreButton);
menuShape.addGestureListener(DragProcessor.class, new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
DragEvent de = (DragEvent)ge;
switch (de.getId()) {
case MTGestureEvent.GESTURE_DETECTED:
restoreButton.setVisible(true);
closeButton.setVisible(true);
unhighlightButton(closeButton, buttonOpacity);
unhighlightButton(restoreButton, buttonOpacity);
break;
case MTGestureEvent.GESTURE_UPDATED:
//Mouse over effect
if (closeButton.containsPointGlobal(de.getTo())){
highlightButton(closeButton);
}else{
unhighlightButton(closeButton, buttonOpacity);
}
if (restoreButton.containsPointGlobal(de.getTo())){
highlightButton(restoreButton);
}else{
unhighlightButton(restoreButton, buttonOpacity);
}
break;
case MTGestureEvent.GESTURE_ENDED:
unhighlightButton(closeButton, buttonOpacity);
unhighlightButton(restoreButton, buttonOpacity);
InputCursor cursor = de.getDragCursor();
Vector3D restoreButtonIntersection = restoreButton.getIntersectionGlobal(Tools3D.getCameraPickRay(getRenderer(), restoreButton, cursor.getCurrentEvtPosX(), cursor.getCurrentEvtPosY()));
if (restoreButtonIntersection != null){
logger.debug("--> RESTORE!");
MTSceneMenu.this.sceneTexture.restore();
}
Vector3D closeButtonIntersection = closeButton.getIntersectionGlobal(Tools3D.getCameraPickRay(getRenderer(), closeButton, cursor.getCurrentEvtPosX(), cursor.getCurrentEvtPosY()));
if (closeButtonIntersection != null){
// if (app.popScene()){
// app.removeScene(scene); //FIXME wont work if the scene has a transition because we cant remove the still active scene
//// destroy(); //this will be destroyed with the scene
// sceneTexture.destroy(); //destroys also the MTSceneWindow and with it the scene
// logger.debug("--> CLOSE!");
// }
if (sceneTexture.restore()){
// app.removeScene(scene); //FIXME wont work if the scene has a transition because we cant remove the still active scene
// destroy(); //this will be destroyed with the scene
sceneTexture.destroy(); //destroys also the MTSceneWindow and with it the scene
logger.debug("--> CLOSE!");
}
}
restoreButton.setVisible(false);
closeButton.setVisible(false);
break;
default:
break;
}