Merge branch 'master' into add-items

This commit is contained in:
OLEGSHA 2021-12-21 17:12:45 +03:00
commit ce573b51ce
Signed by: OLEGSHA
GPG Key ID: E57A4B08D64AFF7A
3 changed files with 146 additions and 131 deletions

View File

@ -40,7 +40,6 @@ compileJava {
repositories {
mavenCentral()
jcenter()
/*
* Specify Windcorp Maven repository
@ -66,8 +65,8 @@ dependencies {
// Log4j
// A logging library
implementation 'org.apache.logging.log4j:log4j-api:2.16.0'
implementation 'org.apache.logging.log4j:log4j-core:2.16.0'
implementation 'org.apache.logging.log4j:log4j-api:2.17.0'
implementation 'org.apache.logging.log4j:log4j-core:2.17.0'
// JUnit
// A unit-testing library
@ -173,13 +172,20 @@ compileJava.mustRunAfter addNativeDependencies // Make sure runtimeOnly has not
task requestLinuxDependencies {
description 'Adds linux, linux-arm64 and linux-arm32 native libraries to built artifacts.'
doFirst {
project.ext.platforms.addAll(['natives-linux', 'natives-linux-arm64', 'natives-linux-arm32'])
project.ext.platforms.addAll([
'natives-linux',
'natives-linux-arm64',
'natives-linux-arm32'
])
}
}
task requestWindowsDependencies {
description 'Adds windows and windows-x86 native libraries to built artifacts.'
doFirst {
project.ext.platforms.addAll(['natives-windows', 'natives-windows-x86'])
project.ext.platforms.addAll([
'natives-windows',
'natives-windows-x86'
])
}
}
task requestMacOSDependencies {

View File

@ -563,6 +563,10 @@ public class Component extends Named {
inputBus.unregister(listener);
}
protected boolean passInputToChildren(InputEvent e) {
return true;
}
InputBus getInputBus() {
return inputBus;
}

View File

@ -27,6 +27,7 @@ import ru.windcorp.progressia.client.graphics.flat.RenderTarget;
import ru.windcorp.progressia.client.graphics.input.InputEvent;
import ru.windcorp.progressia.client.graphics.input.KeyEvent;
import ru.windcorp.progressia.client.graphics.input.bus.InputBus;
import ru.windcorp.progressia.common.util.LowOverheadCache;
import ru.windcorp.progressia.common.util.StashingStack;
public abstract class GUILayer extends AssembledFlatLayer {
@ -75,9 +76,11 @@ public abstract class GUILayer extends AssembledFlatLayer {
}
/**
* Stack for {@link #handleInput(InputEvent)}.
* Stacks for {@link #handleInput(InputEvent)}.
*/
private StashingStack<EventHandlingFrame> path = new StashingStack<>(64, EventHandlingFrame::new);
private final LowOverheadCache<StashingStack<EventHandlingFrame>> pathCache = new LowOverheadCache<>(
() -> new StashingStack<>(64, EventHandlingFrame::new)
);
/*
* This is essentially a depth-first iteration of the component tree. The
@ -85,10 +88,10 @@ public abstract class GUILayer extends AssembledFlatLayer {
*/
@Override
public void handleInput(InputEvent event) {
StashingStack<EventHandlingFrame> path = pathCache.grab();
if (!path.isEmpty()) {
throw new IllegalStateException(
"path is not empty: " + path + ". Are events being processed concurrently?"
);
throw new IllegalStateException("path is not empty: " + path);
}
path.push().init(root);
@ -101,7 +104,7 @@ public abstract class GUILayer extends AssembledFlatLayer {
Component c = it.next();
if (c.isEnabled()) {
if (c.getChildren().isEmpty()) {
if (c.getChildren().isEmpty() || !c.passInputToChildren(event)) {
c.getInputBus().dispatch(event);
} else {
path.push().init(c);
@ -114,6 +117,8 @@ public abstract class GUILayer extends AssembledFlatLayer {
}
}
pathCache.release(path);
}
private void attemptFocusTransfer(KeyEvent e) {