Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public void initWidgets() {
};

WView view = add(theme.view()).expandX().widget();
// Prevents double scrolling for view-in-view scenario
view.maxHeight = window.view.maxHeight - 128;
view.scrollOnlyWhenMouseOver = false;

table = view.add(theme.table()).expandX().widget();

initTable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class WMeteorView extends WView implements MeteorWidget {
@Override
protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) {
if (canScroll && hasScrollBar) {
renderer.quad(handleX(), handleY(), handleWidth(), handleHeight(), theme().scrollbarColor.get(handlePressed, handleMouseOver));
renderer.quad(handleX(), handleY(), handleWidth(), handleHeight(), theme().scrollbarColor.get(focused, handleMouseOver));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ public void moveCells(double deltaX, double deltaY) {

@Override
public boolean isFocused() {
for (Cell<?> cell : cells) if (cell.widget().isFocused()) return true;
if (focused) return true;

for (Cell<?> cell : cells) {
if (cell.widget().isFocused())
return true;
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public abstract class WView extends WVerticalList {
private boolean moveAfterPositionWidgets;

protected boolean handleMouseOver;
protected boolean handlePressed;

@Override
public void init() {
Expand Down Expand Up @@ -77,7 +76,7 @@ protected void onCalculateWidgetPositions() {
@Override
public boolean onMouseClicked(Click click, boolean doubled) {
if (handleMouseOver && click.button() == GLFW_MOUSE_BUTTON_LEFT && !doubled) {
handlePressed = true;
setFocused(true);
return true;
}

Expand All @@ -86,7 +85,7 @@ public boolean onMouseClicked(Click click, boolean doubled) {

@Override
public boolean onMouseReleased(Click click) {
if (handlePressed) handlePressed = false;
if (focused) setFocused(false);

return false;
}
Expand All @@ -104,7 +103,7 @@ public void onMouseMoved(double mouseX, double mouseY, double lastMouseX, double
}
}

if (handlePressed) {
if (focused) {
double preScroll = scroll;
double mouseDelta = mouseY - lastMouseY;

Expand All @@ -123,9 +122,13 @@ public void onMouseMoved(double mouseX, double mouseY, double lastMouseX, double
@Override
public boolean onMouseScrolled(double amount) {
if (!scrollOnlyWhenMouseOver || mouseOver) {
double max = actualHeight - height;

targetScroll -= Math.round(theme.scale(amount * 40));
targetScroll = MathHelper.clamp(targetScroll, 0, actualHeight - height);
return true;
targetScroll = MathHelper.clamp(targetScroll, 0, max);

// Only consume the event if the view actually scrolled, otherwise propagate to parent.
return targetScroll > 0 && targetScroll < max;
}

return false;
Expand Down Expand Up @@ -164,7 +167,13 @@ else if (targetScroll < scroll) {

@Override
protected boolean propagateEvents(WWidget widget) {
return (mouseOver && isWidgetInView(widget)) || widget.isFocused();
if (widget.isFocused()) return true;

// Propagate to any visible view, to allow inputs even when not hovered
if (widget instanceof WView) return isWidgetInView(widget);

// Propagate to any visible widget while the view is hovered
return mouseOver && isWidgetInView(widget);
}

protected double handleWidth() {
Expand Down