diff options
author | Sven Gothel <[email protected]> | 2020-01-16 00:52:24 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-16 00:52:24 +0100 |
commit | a0a2278721a1b0a8c5acc78d4d42b7cd7efeb47d (patch) | |
tree | 723e5640f24e8661cd62628d970179d4b34edb20 /src/newt/classes/jogamp | |
parent | d671b2ab3badbcfdbe0ff57f55ff997ba7bcb060 (diff) |
NEWT.Window: Refine string representation, renamed append(StringBuilder) -> toString(..), added toSimpleString(..)
This also revised commit f56adf14deadd4ee8f434ea1293e27bcafdf2a90 Window API addition of 'append(StringBuilder)',
which has been renamed to 'toString(StringBuilder)' as aligned to out other classes.
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 177 |
1 files changed, 109 insertions, 68 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 78da0e0ad..c92327912 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -60,6 +60,7 @@ import com.jogamp.nativewindow.util.PointImmutable; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.util.RectangleImmutable; +import jogamp.common.os.PlatformPropsImpl; import jogamp.nativewindow.SurfaceScaleUtils; import jogamp.nativewindow.SurfaceUpdatedHelper; @@ -146,6 +147,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms + private static final String COMMA = ", "; + private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; // @@ -335,6 +338,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } protected static StringBuilder appendStateBits(final StringBuilder sb, final int mask, final boolean showChangeFlags) { + sb.append("["); if( showChangeFlags ) { @@ -346,86 +350,95 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } sb.append((0 != ( STATE_MASK_VISIBLE & mask))?"visible":"invisible"); - sb.append(", "); - sb.append((0 != ( STATE_MASK_AUTOPOSITION & mask))?"autopos, ":""); + if( 0 != ( STATE_MASK_AUTOPOSITION & mask) ) { + sb.append(COMMA); + sb.append("autopos"); + } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_PARENTING & mask) ) { sb.append("*"); } sb.append((0 != ( STATE_MASK_CHILDWIN & mask))?"child":"toplevel"); - sb.append(", "); } else if( 0 != ( STATE_MASK_CHILDWIN & mask) ) { + sb.append(COMMA); sb.append("child"); - sb.append(", "); } - sb.append((0 != ( STATE_MASK_FOCUSED & mask))?"focused, ":""); + if( 0 != ( STATE_MASK_FOCUSED & mask) ) { + sb.append(COMMA); + sb.append("focused"); + } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_DECORATION & mask) ) { sb.append("*"); } sb.append((0 != ( STATE_MASK_UNDECORATED & mask))?"undecor":"decor"); - sb.append(", "); } else if( 0 != ( STATE_MASK_UNDECORATED & mask) ) { + sb.append(COMMA); sb.append("undecor"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_ALWAYSONTOP & mask) ) { sb.append("*"); } - sb.append((0 != ( STATE_MASK_ALWAYSONTOP & mask))?"aontop":"!aontop"); - sb.append(", "); + if( 0 == ( STATE_MASK_ALWAYSONTOP & mask) ) { + sb.append("!"); + } + sb.append("aontop"); } else if( 0 != ( STATE_MASK_ALWAYSONTOP & mask) ) { + sb.append(COMMA); sb.append("aontop"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_ALWAYSONBOTTOM & mask) ) { sb.append("*"); } sb.append((0 != ( STATE_MASK_ALWAYSONBOTTOM & mask))?"aonbottom":"!aonbottom"); - sb.append(", "); } else if( 0 != ( STATE_MASK_ALWAYSONBOTTOM & mask) ) { + sb.append(COMMA); sb.append("aonbottom"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_STICKY & mask) ) { sb.append("*"); } sb.append((0 != ( STATE_MASK_STICKY & mask))?"sticky":"unsticky"); - sb.append(", "); } else if( 0 != ( STATE_MASK_STICKY & mask) ) { + sb.append(COMMA); sb.append("sticky"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); sb.append((0 != ( STATE_MASK_REPOSITIONABLE & mask))?"repositionable":"fixed-position"); - sb.append(", "); } else if( 0 != ( STATE_MASK_REPOSITIONABLE & mask) ) { + sb.append(COMMA); sb.append("repositionable"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_RESIZABLE & mask) ) { sb.append("*"); } sb.append((0 != ( STATE_MASK_RESIZABLE & mask))?"resizable":"fixed-size"); - sb.append(", "); } else if( 0 != ( STATE_MASK_RESIZABLE & mask) ) { + sb.append(COMMA); sb.append("resizable"); - sb.append(", "); } if( showChangeFlags ) { + sb.append(COMMA); sb.append("max["); if( 0 != ( CHANGE_MASK_MAXIMIZED_HORZ & mask) ) { sb.append("*"); @@ -442,8 +455,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sb.append("!"); } sb.append("v"); - sb.append("], "); + sb.append("]"); } else if( 0 != ( ( STATE_MASK_MAXIMIZED_HORZ | STATE_MASK_MAXIMIZED_VERT ) & mask) ) { + sb.append(COMMA); sb.append("max["); if( 0 != ( STATE_MASK_MAXIMIZED_HORZ & mask) ) { sb.append("h"); @@ -451,50 +465,51 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 != ( STATE_MASK_MAXIMIZED_VERT & mask) ) { sb.append("v"); } - sb.append("], "); + sb.append("]"); } if( showChangeFlags ) { + sb.append(COMMA); if( 0 != ( CHANGE_MASK_FULLSCREEN & mask) ) { sb.append("*"); } sb.append("fullscreen["); sb.append(0 != ( STATE_MASK_FULLSCREEN & mask)); sb.append((0 != ( STATE_MASK_FULLSCREEN_SPAN & mask))?", span":""); - sb.append("], "); + sb.append("]"); } else if( 0 != ( STATE_MASK_FULLSCREEN & mask) ) { + sb.append(COMMA); sb.append("fullscreen"); - sb.append(", "); } if( showChangeFlags ) { - sb.append("pointer["); - if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) ) { - sb.append("invisible"); - } else { - sb.append("visible"); - } - sb.append(", "); - if( 0 != ( STATE_MASK_POINTERCONFINED & mask) ) { - sb.append("confined"); - } else { - sb.append("free"); - } - sb.append("]"); - } else { - if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) || - 0 != ( STATE_MASK_POINTERCONFINED & mask) ) - { - sb.append("pointer["); - if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) ) { - sb.append("invisible"); - sb.append(", "); - } - if( 0 != ( STATE_MASK_POINTERCONFINED & mask) ) { - sb.append("confined"); - } - sb.append("]"); + sb.append(COMMA); + sb.append("pointer["); + if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) ) { + sb.append("invisible"); + } else { + sb.append("visible"); } + sb.append(COMMA); + if( 0 != ( STATE_MASK_POINTERCONFINED & mask) ) { + sb.append("confined"); + } else { + sb.append("free"); + } + sb.append("]"); + } else if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) || + 0 != ( STATE_MASK_POINTERCONFINED & mask) ) + { + sb.append(COMMA); + sb.append("pointer["); + if( 0 == ( STATE_MASK_POINTERVISIBLE & mask) ) { + sb.append("invisible"); + } + if( 0 != ( STATE_MASK_POINTERCONFINED & mask) ) { + sb.append(COMMA); + sb.append("confined"); + } + sb.append("]"); } sb.append("]"); return sb; @@ -2755,45 +2770,71 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public final StringBuilder append(final StringBuilder sb) { - sb.append(getClass().getName()+"[State "+getStateMaskString()+ - ",\n Reconfig "+getSupportedStateMaskString()+ - ",\n "+screen+ - ",\n window["+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" wu, "+getSurfaceWidth()+"x"+getSurfaceHeight()+" pixel]"+ - ",\n Config "+config+ - ",\n ParentWindow "+parentWindow+ - ",\n ParentWindowHandle "+toHexString(parentWindowHandle)+" ("+(0!=getParentWindowHandle())+")"+ - ",\n WindowHandle "+toHexString(getWindowHandle())+ - ",\n SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+windowLock.isLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+ - ",\n WrappedSurface "+getWrappedSurface()+ - ",\n ChildWindows "+childWindows.size()); - - sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedHelper.size()+" ["); + public final StringBuilder toSimpleString(final StringBuilder sb) { + sb.append(getClass().getSimpleName()).append("[").append("State ").append(getStateMaskString()) + .append("; ").append("Window").append("[").append(getX()).append("/").append(getY()) + .append(" ").append(getWidth()).append("x").append(getHeight()).append(" wu").append(COMMA) + .append(getSurfaceWidth()).append("x").append(getSurfaceHeight()).append(" pixel").append("]") + .append(" handle ").append(toHexString(getWindowHandle())).append(COMMA).append("surfaceHandle ") + .append(toHexString(getSurfaceHandle())).append(COMMA).append("children ").append(childWindows.size()) + .append("; ").append("ParentWindow ").append(parentWindow).append(" (handle ") + .append(toHexString(parentWindowHandle)).append(")") + .append("]"); + return sb; + } + @Override + public final String toSimpleString() { + return toSimpleString(new StringBuilder()).toString(); + } + @Override + public final StringBuilder toString(final StringBuilder sb) { + sb.append(getClass().getName()).append("[").append("State ").append(getStateMaskString()) + .append(COMMA).append("supported ").append(getSupportedStateMaskString()) + .append("; ").append("Window").append("[").append(getX()).append("/").append(getY()) + .append(" ").append(getWidth()).append("x").append(getHeight()).append(" wu").append(COMMA) + .append(getSurfaceWidth()).append("x").append(getSurfaceHeight()).append(" pixel").append("]") + .append(" handle ").append(toHexString(getWindowHandle())).append(COMMA).append("surfaceHandle ") + .append(toHexString(getSurfaceHandle())).append(COMMA).append("children ").append(childWindows.size()) + .append("; ").append("ParentWindow ").append(parentWindow).append(" (handle ") + .append(toHexString(parentWindowHandle)).append(")") + .append(COMMA).append(PlatformPropsImpl.NEWLINE).append(" ").append(screen) + .append(COMMA).append(PlatformPropsImpl.NEWLINE).append(" Config ").append(config) + .append(COMMA).append(PlatformPropsImpl.NEWLINE).append(" WrappedSurface ").append(getWrappedSurface()) + .append(COMMA).append(PlatformPropsImpl.NEWLINE); + + sb.append(" SurfaceUpdatedListeners num ").append(surfaceUpdatedHelper.size()).append(" ["); for (int i = 0; i < surfaceUpdatedHelper.size(); i++ ) { sb.append(surfaceUpdatedHelper.get(i)+", "); } - sb.append("], WindowListeners num "+windowListeners.size()+" ["); + sb.append("]").append(COMMA).append(PlatformPropsImpl.NEWLINE) + .append(" WindowListeners num ").append(windowListeners.size()).append(" ["); for (int i = 0; i < windowListeners.size(); i++ ) { sb.append(windowListeners.get(i)+", "); } - sb.append("], MouseListeners num "+mouseListeners.size()+" ["); + sb.append("]").append(COMMA).append(PlatformPropsImpl.NEWLINE) + .append(" MouseListeners num ").append(mouseListeners.size()).append(" ["); for (int i = 0; i < mouseListeners.size(); i++ ) { sb.append(mouseListeners.get(i)+", "); } - sb.append("], PointerGestures default "+defaultGestureHandlerEnabled+", custom "+pointerGestureHandler.size()+" ["); + sb.append("]").append(COMMA).append(PlatformPropsImpl.NEWLINE) + .append(" PointerGestures default ").append(defaultGestureHandlerEnabled).append(COMMA) + .append("custom ").append(pointerGestureHandler.size()).append(" ["); for (int i = 0; i < pointerGestureHandler.size(); i++ ) { sb.append(pointerGestureHandler.get(i)+", "); } - sb.append("], KeyListeners num "+keyListeners.size()+" ["); + sb.append("]").append(COMMA).append(PlatformPropsImpl.NEWLINE) + .append(" KeyListeners num ").append(keyListeners.size()).append(" ["); for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); } - sb.append("], windowLock "+windowLock+", surfaceLockCount "+surfaceLockCount+"]"); + sb.append("]").append(COMMA).append(PlatformPropsImpl.NEWLINE) + .append(" windowLock ").append(windowLock).append(COMMA).append("surfaceLockCount ").append(surfaceLockCount) + .append("]"); return sb; } @Override public final String toString() { - return append(new StringBuilder()).toString(); + return toString(new StringBuilder()).toString(); } protected final void setWindowHandle(final long handle) { |