[DEV] rework enums

This commit is contained in:
Edouard DUPIN 2021-04-13 23:01:40 +02:00
parent d263376329
commit aa71e26ba8
10 changed files with 438 additions and 384 deletions

View File

@ -37,7 +37,7 @@ public class Gale {
* @param _argv Standard argv
* @return normal error int for the application error management
*/
public static int run(final Application application, final String[] arg) {
public static int run(final GaleApplication application, final String[] arg) {
init();
//etk::init(_argc, _argv);
Context context = null;

View File

@ -11,7 +11,7 @@ import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
public class Application {
public class GaleApplication {
private boolean needRedraw = true;
private String title = "gale";
private Uri iconName = null;
@ -19,7 +19,7 @@ public class Application {
private Orientation orientation = Orientation.screenAuto;
private Vector2f windowsSize = new Vector2f(800, 600);
public Application() {
public GaleApplication() {
Log.verbose("Constructor Gale Application");
}
@ -289,12 +289,16 @@ public class Application {
if (size.x() <= 0 || size.y() <= 0) {
Log.error("Wrong windows size: " + size);
}
Vector2f oldSize = this.windowsSize;
this.windowsSize = size;
final Context context = Gale.getContext();
if (context == null) {
return;
}
context.setSize(size);
if (!context.setSize(size)) {
Log.error("Can not set the size required by the user.");
this.windowsSize = oldSize;
}
}
/**

View File

@ -1,16 +1,16 @@
package org.atriasoft.gale.context;
public enum ClipboardList {
clipboard0, //!< internal clipboard 0
clipboard1, //!< internal clipboard 1
clipboard2, //!< internal clipboard 2
clipboard3, //!< internal clipboard 3
clipboard4, //!< internal clipboard 4
clipboard5, //!< internal clipboard 5
clipboard6, //!< internal clipboard 6
clipboard7, //!< internal clipboard 7
clipboard8, //!< internal clipboard 8
clipboard9, //!< internal clipboard 9
clipboardStd, //!< External clipboard represent the Copy/Cut/Past buffer
clipboardSelection, //!< External or internal clipboard depending on the OS, represent the middle button
CLIPBOARD_0, //!< internal clipboard 0
CLIPBOARD_1, //!< internal clipboard 1
CLIPBOARD_2, //!< internal clipboard 2
CLIPBOARD_3, //!< internal clipboard 3
CLIPBOARD_4, //!< internal clipboard 4
CLIPBOARD_5, //!< internal clipboard 5
CLIPBOARD_6, //!< internal clipboard 6
CLIPBOARD_7, //!< internal clipboard 7
CLIPBOARD_8, //!< internal clipboard 8
CLIPBOARD_9, //!< internal clipboard 9
CLIPBOARD_STD, //!< External clipboard represent the Copy/Cut/Past buffer
CLIPBOARD_SELECTION, //!< External or internal clipboard depending on the OS, represent the middle button
}

View File

@ -6,7 +6,7 @@ import org.atriasoft.etk.Color;
import org.atriasoft.etk.ThreadAbstract;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.gale.Application;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.Fps;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.Orientation;
@ -45,7 +45,7 @@ public abstract class Context {
}
protected ThreadAbstract periodicThread;;
protected Application application; //!< Application handle
protected GaleApplication application; //!< Application handle
protected ApplicationState applicationState = ApplicationState.UNDEFINED; // state of the application
private final CommandLine commandLine = new CommandLine(); //!< Start command line information;
private final ResourceManager resourceManager = new ResourceManager(); //!< global resources Manager
@ -61,7 +61,7 @@ public abstract class Context {
protected boolean fullscreen = false;
protected Vector2f windowsPos; //!< current size of the system
public Context(final Application application, final String[] args) {
public Context(final GaleApplication application, final String[] args) {
// set a basic
this.application = application;
this.applicationState = ApplicationState.CREATE;
@ -109,7 +109,7 @@ public abstract class Context {
Log.info("GALE v:" + Gale.getVersion());
forceOrientation(Orientation.screenAuto);
postAction((context) -> {
final Application appl = context.getApplication();
final GaleApplication appl = context.getApplication();
if (appl == null) {
this.applicationState = ApplicationState.UNDEFINED;
return;
@ -178,7 +178,7 @@ public abstract class Context {
return message;
}
public Application getApplication() {
public GaleApplication getApplication() {
return this.application;
}
@ -278,7 +278,7 @@ public abstract class Context {
*/
public void operatingSystemClipBoardArrive(final ClipboardList clipboardID) {
postAction((context) -> {
final Application appl = context.getApplication();
final GaleApplication appl = context.getApplication();
if (appl != null) {
appl.onClipboardEvent(clipboardID);
}
@ -467,7 +467,7 @@ public abstract class Context {
postAction((context) -> {
Log.debug("Receive MSG : THREADMOVE : " + context.windowsPos + " ==> " + pos);
context.windowsPos = pos;
final Application appl = context.getApplication();
final GaleApplication appl = context.getApplication();
if (appl == null) {
return;
}
@ -496,7 +496,7 @@ public abstract class Context {
Log.debug("Receive MSG : THREADRESIZE : " + context.windowsSize + " ==> " + size);
context.windowsSize = size;
//gale::Dimension::setPixelWindowsSize(context.windowsSize);
final Application tmpAppl = context.getApplication();
final GaleApplication tmpAppl = context.getApplication();
if (tmpAppl != null) {
tmpAppl.onResize(context.windowsSize);
}
@ -523,7 +523,7 @@ public abstract class Context {
public void operatingSystemSetInput(final KeySpecial special, final KeyType type, final KeyStatus status, final int pointerID, final Vector2f pos) {
postAction((context) -> {
final Application appl = context.getApplication();
final GaleApplication appl = context.getApplication();
if (appl == null) {
return;
}
@ -549,7 +549,7 @@ public abstract class Context {
public void operatingSystemsetKeyboard2(final KeySpecial special, final KeyKeyboard type, final KeyStatus state, final Character charValue) {
postAction((context) -> {
final Application appl = context.getApplication();
final GaleApplication appl = context.getApplication();
if (appl == null) {
return;
}
@ -723,8 +723,9 @@ public abstract class Context {
* The application request a change of his current size.
* @param size new Requested size of the windows.
*/
public void setSize(final Vector2f size) {
public boolean setSize(final Vector2f size) {
Log.info("setSize: NOT implemented ...");
return false;
}
/**
@ -809,7 +810,7 @@ class PeriodicThread extends ThreadAbstract {
synchronized (this.context) {
this.context.processEvents();
// call all the application for periodic request (the application manage multiple instance )...
final Application appl = this.context.getApplication();
final GaleApplication appl = this.context.getApplication();
if (appl != null) {
appl.onPeriod(System.currentTimeMillis());
}

View File

@ -30,9 +30,9 @@ import io.scenarium.logger.Logger;
import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.gale.Application;
import org.atriasoft.gale.DisplayManagerDraw;
import org.atriasoft.gale.Fps;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.context.Context;
import org.atriasoft.gale.internal.Log;
import org.atriasoft.gale.key.KeyKeyboard;
@ -67,7 +67,7 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
private static double currentMousePositionX = 0;
private static double currentMousePositionY = 0;
public static Context create(final Application application, final String[] arg) {
public static Context create(final GaleApplication application, final String[] arg) {
// TODO Auto-generated method stub
return new ContextLWJGLAWT(application, arg);
}
@ -101,7 +101,7 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
private final List<Integer> pressedKey = new ArrayList<>();
public ContextLWJGLAWT(final Application application, final String[] args) {
public ContextLWJGLAWT(final GaleApplication application, final String[] args) {
super(application, args);
System.out.println("Hello JOGL !");
initWindows();
@ -202,50 +202,50 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
public void keyEvent(final KeyEvent e, final boolean pressed, final boolean thisIsAReapeateKey) {
//Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
boolean find = true;
KeyKeyboard keyInput = KeyKeyboard.unknow;
KeyKeyboard keyInput = KeyKeyboard.UNKNOWN;
//Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
switch (e.getKeyCode()) {
//case 328: // keypad
case KeyEvent.VK_UP:
keyInput = KeyKeyboard.up;
keyInput = KeyKeyboard.UP;
break;
//case 324: // keypad
case KeyEvent.VK_LEFT:
keyInput = KeyKeyboard.left;
keyInput = KeyKeyboard.LEFT;
break;
//case 326: // keypad
case KeyEvent.VK_RIGHT:
keyInput = KeyKeyboard.right;
keyInput = KeyKeyboard.RIGHT;
break;
//case 323: // keypad
case KeyEvent.VK_DOWN:
keyInput = KeyKeyboard.down;
keyInput = KeyKeyboard.DOWN;
break;
//case 329: // keypad
case KeyEvent.VK_PAGE_UP:
keyInput = KeyKeyboard.pageUp;
keyInput = KeyKeyboard.PAGE_UP;
break;
//case 323: // keypad
case KeyEvent.VK_PAGE_DOWN:
keyInput = KeyKeyboard.pageDown;
keyInput = KeyKeyboard.PAGE_DOWN;
break;
//case 327: // keypad
case KeyEvent.VK_HOME:
keyInput = KeyKeyboard.start;
keyInput = KeyKeyboard.START;
break;
//case 321: // keypad
case KeyEvent.VK_END:
keyInput = KeyKeyboard.end;
keyInput = KeyKeyboard.END;
break;
case KeyEvent.VK_PRINTSCREEN:
keyInput = KeyKeyboard.stopDefil;
keyInput = KeyKeyboard.STOP_DEFIL;
break;
case KeyEvent.VK_PAUSE:
keyInput = KeyKeyboard.wait;
keyInput = KeyKeyboard.WAIT;
break;
//case 320: // keypad
case KeyEvent.VK_INSERT:
keyInput = KeyKeyboard.insert;
keyInput = KeyKeyboard.INSERT;
if (!pressed) {
if (this.guiKeyBoardMode.getInsert()) {
this.guiKeyBoardMode.setInsert(false);
@ -256,117 +256,117 @@ public class ContextLWJGLAWT extends Context implements MouseListener, MouseMoti
break;
//case 84: keyInput = KeyboardCenter; break; // Keypad
case KeyEvent.VK_F1:
keyInput = KeyKeyboard.f1;
keyInput = KeyKeyboard.F1;
break;
case KeyEvent.VK_F2:
keyInput = KeyKeyboard.f2;
keyInput = KeyKeyboard.F2;
break;
case KeyEvent.VK_F3:
keyInput = KeyKeyboard.f3;
keyInput = KeyKeyboard.F3;
break;
case KeyEvent.VK_F4:
keyInput = KeyKeyboard.f4;
keyInput = KeyKeyboard.F4;
break;
case KeyEvent.VK_F5:
keyInput = KeyKeyboard.f5;
keyInput = KeyKeyboard.F5;
break;
case KeyEvent.VK_F6:
keyInput = KeyKeyboard.f6;
keyInput = KeyKeyboard.F6;
break;
case KeyEvent.VK_F7:
keyInput = KeyKeyboard.f7;
keyInput = KeyKeyboard.F7;
break;
case KeyEvent.VK_F8:
keyInput = KeyKeyboard.f8;
keyInput = KeyKeyboard.F8;
break;
case KeyEvent.VK_F9:
keyInput = KeyKeyboard.f9;
keyInput = KeyKeyboard.F9;
break;
case KeyEvent.VK_F10:
keyInput = KeyKeyboard.f10;
keyInput = KeyKeyboard.F10;
break;
case KeyEvent.VK_F11:
keyInput = KeyKeyboard.f11;
keyInput = KeyKeyboard.F11;
break;
case KeyEvent.VK_F12:
keyInput = KeyKeyboard.f12;
keyInput = KeyKeyboard.F12;
break;
case KeyEvent.VK_CAPS_LOCK:
keyInput = KeyKeyboard.capLock;
keyInput = KeyKeyboard.CAP_LOCK;
this.guiKeyBoardMode.setCapsLock(pressed);
break;
case KeyEvent.VK_SHIFT:
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
keyInput = KeyKeyboard.shiftLeft;
keyInput = KeyKeyboard.SHIFT_LEFT;
this.guiKeyBoardMode.setShiftLeft(pressed);
break;
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.shiftLeft;
keyInput = KeyKeyboard.SHIFT_LEFT;
this.guiKeyBoardMode.setShiftRight(pressed);
break;
}
case KeyEvent.VK_CONTROL:
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
keyInput = KeyKeyboard.ctrlLeft;
keyInput = KeyKeyboard.CTRL_LEFT;
this.guiKeyBoardMode.setCtrlLeft(pressed);
break;
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.ctrlRight;
keyInput = KeyKeyboard.CTRL_RIGHT;
this.guiKeyBoardMode.setCtrlRight(pressed);
break;
}
case KeyEvent.VK_META:
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
keyInput = KeyKeyboard.metaLeft;
keyInput = KeyKeyboard.META_LEFT;
this.guiKeyBoardMode.setMetaLeft(pressed);
break;
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
keyInput = KeyKeyboard.metaRight;
keyInput = KeyKeyboard.META_RIGHT;
this.guiKeyBoardMode.setMetaRight(pressed);
break;
}
case KeyEvent.VK_ALT:
keyInput = KeyKeyboard.altLeft;
keyInput = KeyKeyboard.ALT_LEFT;
this.guiKeyBoardMode.setAltLeft(pressed);
break;
case KeyEvent.VK_ALT_GRAPH:
keyInput = KeyKeyboard.altRight;
keyInput = KeyKeyboard.ALT_RIGHT;
this.guiKeyBoardMode.setAltRight(pressed);
break;
case KeyEvent.VK_CONTEXT_MENU:
keyInput = KeyKeyboard.contextMenu;
keyInput = KeyKeyboard.CONTEXT_MENU;
break;
case KeyEvent.VK_NUM_LOCK:
keyInput = KeyKeyboard.numLock;
keyInput = KeyKeyboard.NUM_LOCK;
this.guiKeyBoardMode.setNumLock(pressed);
break;
case KeyEvent.VK_DELETE: // Suppr on keypad
find = false;
if (this.guiKeyBoardMode.getNumLock()) {
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, '.');
} else {
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x7F);
}
break;
case KeyEvent.VK_TAB: // special case for TAB
find = false;
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, (char) 0x09);
break;
default:
find = false;
if (thisIsAReapeateKey) {
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (!pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
}
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.character, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
operatingSystemsetKeyboard(this.guiKeyBoardMode, KeyKeyboard.CHARACTER, (pressed ? KeyStatus.down : KeyStatus.up), thisIsAReapeateKey, e.getKeyChar());
}
if (find) {
if (thisIsAReapeateKey) {

View File

@ -1,50 +1,50 @@
package org.atriasoft.gale.key;
public enum KeyKeyboard {
unknow, //!< Unknown keyboard key
character, //!< Char input is arrived ...
left, //!< Left key <--
right, //!< Right key -->
up, //!< Up key ^
down, //!< Down key \/
pageUp, //!< Page Up key
pageDown, //!< page down key
start, //!< Start key
end, //!< End key
print, //!< print screen key.
stopDefil, //!< Stop display key.
wait, //!< Wait key.
insert, //!< insert key.
f1, //!< F1 key.
f2, //!< F2 key.
f3, //!< F3 key.
f4, //!< F4 key.
f5, //!< F5 key.
f6, //!< F6 key.
f7, //!< F7 key.
f8, //!< F8 key.
f9, //!< F9 key.
f10, //!< F10 key.
f11, //!< F11 key.
f12, //!< F12 key.
capLock, //!< Capital Letter Lock key.
shiftLeft, //!< Shift left key.
shiftRight, //!< Shift right key.
ctrlLeft, //!< Control left key.
ctrlRight, //!< Control right key.
metaLeft, //!< Meta left key (apple key or windows key).
metaRight, //!< Meta right key (apple key or windows key).
altLeft, //!< Alt left key.
altRight, //!< Alt right key.
contextMenu, //!< Contextual menu key.
numLock, //!< Numerical Lock key
UNKNOWN, //!< Unknown keyboard key
CHARACTER, //!< Char input is arrived ...
LEFT, //!< Left key <--
RIGHT, //!< Right key -->
UP, //!< Up key ^
DOWN, //!< Down key \/
PAGE_UP, //!< Page Up key
PAGE_DOWN, //!< page down key
START, //!< Start key
END, //!< End key
PRINT, //!< print screen key.
STOP_DEFIL, //!< Stop display key.
WAIT, //!< Wait key.
INSERT, //!< insert key.
F1, //!< F1 key.
F2, //!< F2 key.
F3, //!< F3 key.
F4, //!< F4 key.
F5, //!< F5 key.
F6, //!< F6 key.
F7, //!< F7 key.
F8, //!< F8 key.
F9, //!< F9 key.
F10, //!< F10 key.
F11, //!< F11 key.
F12, //!< F12 key.
CAP_LOCK, //!< Capital Letter Lock key.
SHIFT_LEFT, //!< Shift left key.
SHIFT_RIGHT, //!< Shift right key.
CTRL_LEFT, //!< Control left key.
CTRL_RIGHT, //!< Control right key.
META_LEFT, //!< Meta left key (apple key or windows key).
META_RIGHT, //!< Meta right key (apple key or windows key).
ALT_LEFT, //!< Alt left key.
ALT_RIGHT, //!< Alt right key.
CONTEXT_MENU, //!< Contextual menu key.
NUM_LOCK, //!< Numerical Lock key
// harware section:
volumeUp, //!< Hardware volume UP key
volumeDown, //!< Hardware volume DOWN key
menu, //!< Hardware Menu key
camera, //!< Hardware Camera key
home, //!< Hardware Home key
power, //!< Hardware Power key
back //!< Hardware Back key
VOLUME_UP, //!< Hardware volume UP key
VOLUME_DOWN, //!< Hardware volume DOWN key
MENU, //!< Hardware Menu key
CAMERA, //!< Hardware Camera key
HOME, //!< Hardware Home key
POWER, //!< Hardware Power key
BACK //!< Hardware Back key
}

View File

@ -12,166 +12,58 @@ public class KeySpecial {
private boolean valueAltRight = false;
private boolean valueNumLock = false;
private boolean valueInsert = false;
/**
* Main ructor
*/
public KeySpecial() {
}
/**
* get the current CapLock Status
* @return The CapLock value
* Get the value with the input moving key.
* @param move Moving key.
* @return true The key is pressed.
* @return false The key is released.
*/
public boolean getCapsLock() {
return valueCapLock;
public boolean get(final KeyKeyboard move) {
switch (move) {
case INSERT:
return getInsert();
case CAP_LOCK:
return getCapsLock();
case SHIFT_LEFT:
return getShiftLeft();
case SHIFT_RIGHT:
return getShiftRight();
case CTRL_LEFT:
return getCtrlLeft();
case CTRL_RIGHT:
return getCtrlRight();
case META_LEFT:
return getMetaLeft();
case META_RIGHT:
return getMetaRight();
case ALT_LEFT:
return getAltLeft();
case ALT_RIGHT:
return getAltRight();
case NUM_LOCK:
return getNumLock();
default:
break;
}
/**
* set the current CapLock Status
* @param value The new CapLock value
*/
public void setCapsLock(boolean value) {
valueCapLock = value;
}
/**
* Get the current Shift key status
* @return The Shift value
*/
public boolean getShift() {
return valueShiftLeft || valueShiftRight;
}
/**
* Get the current Shift left key status
* @return The Shift value
*/
public boolean getShiftLeft() {
return valueShiftLeft;
}
/**
* Get the current Shift right key status
* @return The Shift value
*/
public boolean getShiftRight() {
return valueShiftRight;
}
/**
* Set the current Shift left key status
* @param value The new Shift value
*/
public void setShiftLeft(boolean value) {
valueShiftLeft = value;
}
/**
* Set the current Shift right key status
* @param value The new Shift value
*/
public void setShiftRight(boolean value) {
valueShiftRight = value;
}
/**
* Get the Current Control key status
* @return The Control value
*/
public boolean getCtrl() {
return valueCtrlLeft || valueCtrlRight;
}
/**
* Get the Current Control left key status
* @return The Control value
*/
public boolean getCtrlLeft() {
return valueCtrlLeft;
}
/**
* Get the Current Control right key status
* @return The Control value
*/
public boolean getCtrlRight() {
return valueCtrlRight;
}
/**
* Set the Current Control left key status
* @param value The new Control value
*/
public void setCtrlLeft(boolean value){
valueCtrlLeft = value;
}
/**
* Set the Current Control right key status
* @param value The new Control value
*/
public void setCtrlRight(boolean value) {
valueCtrlRight = value;
}
/**
* Get the current Meta key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMeta() {
return valueMetaLeft || valueMetaRight;
}
/**
* Get the current Meta left key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMetaLeft() {
return valueMetaLeft;
}
/**
* Get the current Meta right key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMetaRight() {
return valueMetaRight;
}
/**
* Set the current Meta left key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...)
*/
public void setMetaLeft(boolean value) {
valueMetaLeft = value;
}
/**
* Set the current Meta right key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...)
*/
public void setMetaRight(boolean value) {
valueMetaRight = value;
return false;
}
/**
* Get the current Alt key status
* @return The Alt value
*/
public boolean getAlt() {
return valueAltLeft || valueAltRight;
}
/**
* Get the current Alt left key status
* @return The Alt value
*/
public boolean getAltLeft() {
return valueAltLeft;
}
/**
* Get the current Alt right key status (alt-gr)
* @return The Alt value
*/
public boolean getAltRight() {
return valueAltRight;
}
/**
* Set the current Alt left key status
* @param value The new Alt value
*/
public void setAltLeft(boolean value) {
valueAltLeft = value;
}
/**
* Set the current Alt right key status (alt-gr)
* @param value The new Alt value
*/
public void setAltRight(boolean value) {
valueAltRight = value;
return this.valueAltLeft || this.valueAltRight;
}
/**
* Get the current Alt-Gr key status
* @return The Alt-gr value (does not exist on MacOs)
@ -179,126 +71,263 @@ public class KeySpecial {
public boolean getAltGr() {
return getAltRight();
}
/**
* Set the current Alt-Gr key status
* @param value The new Alt-gr value (does not exist on MacOs)
* Get the current Alt left key status
* @return The Alt value
*/
public void setAltGr(boolean value) {
setAltRight(value);
public boolean getAltLeft() {
return this.valueAltLeft;
}
/**
* Get the current Ver-num key status
* @return The Numerical Lock value
* Get the current Alt right key status (alt-gr)
* @return The Alt value
*/
public boolean getNumLock() {
return valueNumLock;
public boolean getAltRight() {
return this.valueAltRight;
}
/**
* Set the current Ver-num key status
* @param value The new Numerical Lock value
* get the current CapLock Status
* @return The CapLock value
*/
public void setNumLock(boolean value) {
valueNumLock = value;
public boolean getCapsLock() {
return this.valueCapLock;
}
/**
* Get the Current Control key status
* @return The Control value
*/
public boolean getCtrl() {
return this.valueCtrlLeft || this.valueCtrlRight;
}
/**
* Get the Current Control left key status
* @return The Control value
*/
public boolean getCtrlLeft() {
return this.valueCtrlLeft;
}
/**
* Get the Current Control right key status
* @return The Control value
*/
public boolean getCtrlRight() {
return this.valueCtrlRight;
}
/**
* Get the current Intert key status
* @return The Insert value
*/
public boolean getInsert() {
return valueInsert;
return this.valueInsert;
}
/**
* Get the current Meta key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMeta() {
return this.valueMetaLeft || this.valueMetaRight;
}
/**
* Get the current Meta left key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMetaLeft() {
return this.valueMetaLeft;
}
/**
* Get the current Meta right key status (also named windows or apple key)
* @return The Meta value (name Windows key, apple key, command key ...)
*/
public boolean getMetaRight() {
return this.valueMetaRight;
}
/**
* Get the current Ver-num key status
* @return The Numerical Lock value
*/
public boolean getNumLock() {
return this.valueNumLock;
}
/**
* Get the current Shift key status
* @return The Shift value
*/
public boolean getShift() {
return this.valueShiftLeft || this.valueShiftRight;
}
/**
* Get the current Shift left key status
* @return The Shift value
*/
public boolean getShiftLeft() {
return this.valueShiftLeft;
}
/**
* Get the current Shift right key status
* @return The Shift value
*/
public boolean getShiftRight() {
return this.valueShiftRight;
}
/**
* Set the current Alt-Gr key status
* @param value The new Alt-gr value (does not exist on MacOs)
*/
public void setAltGr(final boolean value) {
setAltRight(value);
}
/**
* Set the current Alt left key status
* @param value The new Alt value
*/
public void setAltLeft(final boolean value) {
this.valueAltLeft = value;
}
/**
* Set the current Alt right key status (alt-gr)
* @param value The new Alt value
*/
public void setAltRight(final boolean value) {
this.valueAltRight = value;
}
/**
* set the current CapLock Status
* @param value The new CapLock value
*/
public void setCapsLock(final boolean value) {
this.valueCapLock = value;
}
/**
* Set the Current Control left key status
* @param value The new Control value
*/
public void setCtrlLeft(final boolean value) {
this.valueCtrlLeft = value;
}
/**
* Set the Current Control right key status
* @param value The new Control value
*/
public void setCtrlRight(final boolean value) {
this.valueCtrlRight = value;
}
/**
* Set the current Intert key status
* @param value The new Insert value
*/
public void setInsert(boolean value) {
valueInsert = value;
public void setInsert(final boolean value) {
this.valueInsert = value;
}
/**
* Set the current Meta left key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...)
*/
public void setMetaLeft(final boolean value) {
this.valueMetaLeft = value;
}
/**
* Set the current Meta right key status (also named windows or apple key)
* @param value The new Meta value (name Windows key, apple key, command key ...)
*/
public void setMetaRight(final boolean value) {
this.valueMetaRight = value;
}
/**
* Set the current Ver-num key status
* @param value The new Numerical Lock value
*/
public void setNumLock(final boolean value) {
this.valueNumLock = value;
}
/**
* Set the current Shift left key status
* @param value The new Shift value
*/
public void setShiftLeft(final boolean value) {
this.valueShiftLeft = value;
}
/**
* Set the current Shift right key status
* @param value The new Shift value
*/
public void setShiftRight(final boolean value) {
this.valueShiftRight = value;
}
@Override
public String toString() {
return "Special [CapLock=" + this.valueCapLock + ", Shift=(" + this.valueShiftLeft + "," + this.valueShiftRight + "), Ctrl=(" + this.valueCtrlLeft + "," + this.valueCtrlRight + "), Meta=("
+ this.valueMetaLeft + "," + this.valueMetaRight + "), Alt=(" + this.valueAltLeft + "," + this.valueAltRight + "), NumLock=" + this.valueNumLock + ", Insert=" + this.valueInsert + "]";
}
/**
* Update the internal value with the input moving key.
* @param move Moving key.
* @param isDown The key is pressed or not.
*/
public void update(KeyKeyboard move, boolean isDown) {
public void update(final KeyKeyboard move, final boolean isDown) {
switch (move) {
case insert:
case INSERT:
setInsert(isDown);
break;
case capLock:
case CAP_LOCK:
setCapsLock(isDown);
break;
case shiftLeft:
case SHIFT_LEFT:
setShiftLeft(isDown);
break;
case shiftRight:
case SHIFT_RIGHT:
setShiftRight(isDown);
break;
case ctrlLeft:
case CTRL_LEFT:
setCtrlLeft(isDown);
break;
case ctrlRight:
case CTRL_RIGHT:
setCtrlRight(isDown);
break;
case metaLeft:
case META_LEFT:
setMetaLeft(isDown);
break;
case metaRight:
case META_RIGHT:
setMetaRight(isDown);
break;
case altLeft:
case ALT_LEFT:
setAltLeft(isDown);
break;
case altRight:
case ALT_RIGHT:
setAltRight(isDown);
break;
case numLock:
case NUM_LOCK:
setNumLock(isDown);
break;
default:
break;
}
}
/**
* Get the value with the input moving key.
* @param move Moving key.
* @return true The key is pressed.
* @return false The key is released.
*/
public boolean get(KeyKeyboard move) {
switch (move) {
case insert:
return getInsert();
case capLock:
return getCapsLock();
case shiftLeft:
return getShiftLeft();
case shiftRight:
return getShiftRight();
case ctrlLeft:
return getCtrlLeft();
case ctrlRight:
return getCtrlRight();
case metaLeft:
return getMetaLeft();
case metaRight:
return getMetaRight();
case altLeft:
return getAltLeft();
case altRight:
return getAltRight();
case numLock:
return getNumLock();
default:
break;
}
return false;
}
@Override
public String toString() {
return "Special [CapLock=" + valueCapLock + ", Shift=(" + valueShiftLeft + ","
+ valueShiftRight + "), Ctrl=(" + valueCtrlLeft + "," + valueCtrlRight
+ "), Meta=(" + valueMetaLeft + "," + valueMetaRight + "), Alt=("
+ valueAltLeft + "," + valueAltRight + "), NumLock=" + valueNumLock
+ ", Insert=" + valueInsert + "]";
}
}

View File

@ -192,6 +192,10 @@ public class ResourceVirtualArrayObject extends Resource {
return this.vaoID;
}
public int getVertexCount() {
return this.vertexCount;
}
public void loadAgainToVAO() {
createVAO();
if (this.indices != null) {
@ -275,16 +279,20 @@ public class ResourceVirtualArrayObject extends Resource {
}
public void render(final RenderMode mode) {
Log.warning("request rendering indices : " + this.vertexCount);
Log.verbose("request rendering indices : " + this.vertexCount);
OpenGL.drawElements(mode, this.vertexCount);
}
public void renderArrays(final RenderMode mode) {
Log.warning("request rendering direct : " + this.vertexCount);
Log.verbose("request rendering direct : " + this.vertexCount);
OpenGL.drawArrays(mode, 0, this.vertexCount);
}
public void setColors(final Object colors) {
public void setColors(final Color[] colors) {
this.colors = colors;
}
public void setColors(final float[] colors) {
this.colors = colors;
}
@ -297,11 +305,19 @@ public class ResourceVirtualArrayObject extends Resource {
this.vertexCount = this.indices.length;
}
public void setNormals(final Object normals) {
public void setNormals(final float[] normals) {
this.normals = normals;
}
public void setPosition(final Object positions) {
public void setNormals(final Vector3f[] normals) {
this.normals = normals;
}
public void setPosition(final float[] positions) {
this.positions = positions;
}
public void setPosition(final Vector3f[] positions) {
this.positions = positions;
}
@ -309,6 +325,10 @@ public class ResourceVirtualArrayObject extends Resource {
this.textureCoordinates = textureCoordinates;
}
public void setTextureCoordinate(final Vector2f[] textureCoordinates) {
this.textureCoordinates = textureCoordinates;
}
public void setVertexCount(final int vertexCount) {
this.vertexCount = vertexCount;
}

View File

@ -5,7 +5,7 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.Application;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.context.Context;
import org.atriasoft.gale.key.KeyKeyboard;
@ -15,7 +15,7 @@ import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
public class Sample1Application extends Application {
public class Sample1Application extends GaleApplication {
//float[] vertices = { 0.2f, 0.1f, 0.0f, 0.3f, 0.4f, 0.0f, 0.1f, 0.4f, 0.0f };
private static final float[] VERTICES = { -0.5f, -0.5f, -1.0f, 0.0f, 0.5f, -1.0f, 0.5f, -0.5f, -1.0f };
private static final float[] COLORS = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, };

View File

@ -5,7 +5,7 @@ import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Matrix4f;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.Application;
import org.atriasoft.gale.GaleApplication;
import org.atriasoft.gale.backend3d.OpenGL;
import org.atriasoft.gale.context.Context;
import org.atriasoft.gale.key.KeyKeyboard;
@ -16,7 +16,7 @@ import org.atriasoft.gale.resource.ResourceProgram;
import org.atriasoft.gale.resource.ResourceTexture;
import org.atriasoft.gale.resource.ResourceVirtualArrayObject;
public class Sample2Application extends Application {
public class Sample2Application extends GaleApplication {
private ResourceProgram oGLprogram;
private int oGLMatrixTransformation;
private int oGLMatrixProjection;