Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated events, event handlers, window class, demo.
- Loading branch information
Showing
49 changed files
with
428 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
backend.core/src/main/java/com/spinyowl/spinygui/backend/core/event/SystemEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
package com.spinyowl.spinygui.backend.core.event; | ||
|
||
import com.spinyowl.spinygui.backend.core.event.handler.SystemEventHandler; | ||
import com.spinyowl.spinygui.backend.core.event.handler.SystemEventHandlers; | ||
|
||
/** | ||
* Marker interface that defines tree of system events. | ||
*/ | ||
public interface SystemEvent { | ||
public abstract class SystemEvent { | ||
|
||
private final SystemEventHandler eventHandler; | ||
|
||
public SystemEvent(SystemEventHandler systemEventHandler) { | ||
this.eventHandler = systemEventHandler; | ||
} | ||
|
||
public SystemEvent() { | ||
this.eventHandler = SystemEventHandlers.getHandler(getClass()); | ||
} | ||
|
||
public SystemEventHandler getEventHandler() { | ||
return eventHandler; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...d.core/src/main/java/com/spinyowl/spinygui/backend/core/event/SystemWindowCloseEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...in/java/com/spinyowl/spinygui/backend/core/event/handler/SystemCursorPosEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.spinyowl.spinygui.backend.core.event.handler; | ||
|
||
import com.spinyowl.spinygui.backend.core.event.SystemCursorPosEvent; | ||
import com.spinyowl.spinygui.core.system.service.ServiceHolder; | ||
|
||
public class SystemCursorPosEventHandler implements SystemEventHandler<SystemCursorPosEvent> { | ||
@Override | ||
public void handle(SystemCursorPosEvent event) { | ||
// ServiceHolder. | ||
|
||
|
||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...e/src/main/java/com/spinyowl/spinygui/backend/core/event/handler/SystemEventHandlers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.spinyowl.spinygui.backend.core.event.handler; | ||
|
||
import com.spinyowl.spinygui.backend.core.event.SystemEvent; | ||
import com.spinyowl.spinygui.backend.core.event.SystemWindowCloseEvent; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public final class SystemEventHandlers { | ||
|
||
public static final SystemEventHandler<SystemWindowCloseEvent> DEFAULT_SYSTEM_WINDOW_CLOSE_EVENT_HANDLER = new SystemWindowCloseEventHandler(); | ||
private static SystemEventHandler<SystemWindowCloseEvent> systemWindowCloseEventHandler = DEFAULT_SYSTEM_WINDOW_CLOSE_EVENT_HANDLER; | ||
|
||
private static Map<Class<? extends SystemEvent>, SystemEventHandler> eventHandlerMap = new ConcurrentHashMap<>(); | ||
|
||
static { | ||
setHandler(SystemWindowCloseEvent.class, systemWindowCloseEventHandler); | ||
} | ||
|
||
private SystemEventHandlers() { | ||
} | ||
|
||
public static <T extends SystemEvent, H extends SystemEventHandler<T>> void setHandler(Class<T> clazz, H handler) { | ||
eventHandlerMap.put(clazz, handler); | ||
} | ||
|
||
public static <T extends SystemEvent> SystemEventHandler<T> getHandler(Class<T> clazz) { | ||
return (SystemEventHandler<T>) eventHandlerMap.get(clazz); | ||
} | ||
|
||
public static SystemEventHandler<SystemWindowCloseEvent> getSystemWindowCloseEventHandler() { | ||
return systemWindowCloseEventHandler; | ||
} | ||
|
||
public static void setSystemWindowCloseEventHandler(SystemEventHandler<SystemWindowCloseEvent> systemWindowCloseEventHandler) { | ||
if (systemWindowCloseEventHandler != null) { | ||
SystemEventHandlers.systemWindowCloseEventHandler = systemWindowCloseEventHandler; | ||
} else { | ||
SystemEventHandlers.systemWindowCloseEventHandler = DEFAULT_SYSTEM_WINDOW_CLOSE_EVENT_HANDLER; | ||
} | ||
setHandler(SystemWindowCloseEvent.class, SystemEventHandlers.systemWindowCloseEventHandler); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...end.core/src/main/java/com/spinyowl/spinygui/backend/core/event/handler/util/SehUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.spinyowl.spinygui.backend.core.event.handler.util; | ||
|
||
import com.spinyowl.spinygui.core.component.base.Component; | ||
import com.spinyowl.spinygui.core.component.base.Container; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class SehUtil { | ||
|
||
private SehUtil() { | ||
} | ||
|
||
/** | ||
* Used to find target component for provided layer and vector. Target means top component which intersected by provided point(vector). | ||
* | ||
* @param container root container to search. | ||
* @param x x point coordinates to search. | ||
* @param y y point coordinates to search. | ||
* @return top component from layer intersected by vector. | ||
*/ | ||
public static Component getTargetComponent(Container container, final float x, final float y) { | ||
Component target = container; | ||
List<Component> childComponents = container.getChildComponents(); | ||
for (Component child : childComponents) { | ||
target = recursiveTargetComponentSearch(child, target, x, y); | ||
} | ||
return target; | ||
} | ||
|
||
/** | ||
* Used to search target component (under point) in component. Target means top component which intersected by provided point(vector). | ||
* | ||
* @param component source component to search target. | ||
* @param target current target. | ||
* @param x x point coordinates to search. | ||
* @param y y point coordinates to search. | ||
* @return the top visible component under point. | ||
*/ | ||
private static Component recursiveTargetComponentSearch(Component component, Component target, final float x, final float y) { | ||
Component newtarget = target; | ||
if (isaTarget(component, x, y)) { | ||
newtarget = component; | ||
List<Component> childComponents = component.getChildComponents(); | ||
for (Component child : childComponents) { | ||
newtarget = recursiveTargetComponentSearch(child, newtarget, x, y); | ||
} | ||
} | ||
return newtarget; | ||
} | ||
|
||
|
||
/** | ||
* Used to search all components (under point) in component. | ||
* | ||
* @param container root container to search. | ||
* @param x x point coordinates to search. | ||
* @param y y point coordinates to search. | ||
* @return all top visible components in layer under point(vector). | ||
*/ | ||
public static List<Component> getTargetComponentList(Container container, final float x, final float y) { | ||
List<Component> targetList = new ArrayList<>(); | ||
recursiveTargetComponentListSearch(container, targetList, x, y); | ||
return targetList; | ||
} | ||
|
||
|
||
/** | ||
* Used to search all components (under point) in component. New located target component will be added to target list. | ||
* | ||
* @param component source component to search target. | ||
* @param targetList current target list. | ||
* @param x x point coordinates to search. | ||
* @param y y point coordinates to search. | ||
*/ | ||
public static void recursiveTargetComponentListSearch(Component component, List<Component> targetList, final float x, final float y) { | ||
if (isaTarget(component, x, y)) { | ||
targetList.add(component); | ||
List<Component> childComponents = component.getChildComponents(); | ||
for (Component child : childComponents) { | ||
recursiveTargetComponentListSearch(child, targetList, x, y); | ||
} | ||
} | ||
} | ||
|
||
private static boolean isaTarget(Component component, float x, float y) { | ||
return component.isVisible() && component.getIntersection().intersects(component, x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.