fix virtual scrollable
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-14 19:11:25 -04:00
parent cb98eac750
commit c136762d16
2 changed files with 22 additions and 12 deletions

View File

@ -1774,6 +1774,7 @@ Chest furniture
Interaction editing debug menu
Fix chest physics&interaction data
Break out collidable template edit into dedicated component
Fix virtual scrollable

View File

@ -16,13 +16,24 @@ import electrosphere.renderer.ui.events.ScrollEvent;
*/
public class VirtualScrollable extends StandardContainerElement implements DrawableElement, ScrollableElement {
//the current amount of scroll applied to this element
/**
* Default scaling applied to scrolling
*/
static final float DEFAULT_SCROLL_SCALE = 5.0f;
/**
* the current amount of scroll applied to this element
*/
double scroll = 0;
//the scrollable callback
/**
* the scrollable callback
*/
ScrollEventCallback callback;
//should we draw this element
/**
* should we draw this element
*/
boolean visible = true;
/**
@ -30,8 +41,8 @@ public class VirtualScrollable extends StandardContainerElement implements Drawa
*/
public VirtualScrollable(int width, int height){
super();
setWidth(width);
setHeight(height);
this.setWidth(width);
this.setHeight(height);
Yoga.YGNodeStyleSetOverflow(this.yogaNode, Yoga.YGOverflowScroll);
}
@ -46,13 +57,13 @@ public class VirtualScrollable extends StandardContainerElement implements Drawa
for(Element child : childList){
if(child instanceof DrawableElement){
DrawableElement drawableChild = (DrawableElement) child;
if(childIsInBounds(drawableChild)){
if(this.childIsInBounds(drawableChild)){
drawableChild.draw(
renderPipelineState,
openGLState,
framebuffer,
framebufferPosX,
framebufferPosY
framebufferPosY - (int)scroll
);
}
}
@ -97,7 +108,7 @@ public class VirtualScrollable extends StandardContainerElement implements Drawa
* @param event The scroll event
*/
private void defaultScrollHandling(ScrollEvent event){
scroll = scroll + event.getScrollAmount();
scroll = scroll + event.getScrollAmount() * DEFAULT_SCROLL_SCALE;
if(scroll > 0){
scroll = 0;
}
@ -111,9 +122,7 @@ public class VirtualScrollable extends StandardContainerElement implements Drawa
if(scroll < - maxScroll){
scroll = -maxScroll;
}
for(Element childElement : this.getChildren()){
childElement.setPositionX((int)(childElement.getAbsoluteX() + scroll));
}
// this.setPositionY((int)scroll);
}
@Override
@ -124,7 +133,7 @@ public class VirtualScrollable extends StandardContainerElement implements Drawa
if(callback != null){
propagate = callback.execute(scrollEvent);
} else {
defaultScrollHandling(scrollEvent);
this.defaultScrollHandling(scrollEvent);
propagate = false;
}
}